Refactor settings saving
This commit is contained in:
parent
a10109f570
commit
8786d92276
|
|
@ -60,21 +60,25 @@ class SettingsController extends Controller {
|
|||
$this->config->deleteAppValue($this->appName, 'registered_user_group');
|
||||
return new DataResponse(array(
|
||||
'data' => array(
|
||||
'message' => (string) $this->l10n->t('Your settings have been updated.'),
|
||||
'message' => (string) $this->l10n->t('Saved'),
|
||||
),
|
||||
'status' => 'success'
|
||||
|
||||
));
|
||||
} else if ( in_array($registered_user_group, $group_id_list) ) {
|
||||
$this->config->setAppValue($this->appName, 'registered_user_group', $registered_user_group);
|
||||
return new DataResponse(array(
|
||||
'data' => array(
|
||||
'message' => (string) $this->l10n->t('Your settings have been updated.'),
|
||||
'message' => (string) $this->l10n->t('Saved'),
|
||||
),
|
||||
'status' => 'success'
|
||||
));
|
||||
} else {
|
||||
return new DataResponse(array(
|
||||
'data' => array(
|
||||
'message' => (string) $this->l10n->t('No such group'),
|
||||
),
|
||||
'status' => 'error'
|
||||
), Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,23 @@
|
|||
$(document).ready(function() {
|
||||
function saveSettings() {
|
||||
var post = $('#registration').serialize();
|
||||
$.post(OC.generateUrl('/apps/registration/settings'), post);
|
||||
}
|
||||
function saveSettings() {
|
||||
OC.msg.startSaving('#registration_settings_msg');
|
||||
$.ajax({
|
||||
url: OC.generateUrl('/apps/registration/settings'),
|
||||
type: 'POST',
|
||||
data: $('#registration_settings_form').serialize(),
|
||||
success: function(data){
|
||||
OC.msg.finishedSaving('#registration_settings_msg', data);
|
||||
},
|
||||
error: function(data){
|
||||
OC.msg.finishedError('#registration_settings_msg', data.responseJSON.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#registered_user_group').change(saveSettings);
|
||||
$('#allowed_domains').change(saveSettings);
|
||||
$('#registration').keypress(function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
$('#registration_settings_form').change(saveSettings);
|
||||
$('#registration').keypress(function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
script('registration', 'settings');
|
||||
?>
|
||||
<form id="registration" class="section">
|
||||
<h2><?php p($l->t('Registration')); ?></h2>
|
||||
<form id="registration_settings_form" class="section">
|
||||
<h2><?php p($l->t('Registration')); ?></h2><span id="registration_settings_msg" class="msg"></span>
|
||||
<p>
|
||||
<label for="registered_user_group"><?php p($l->t('Default group that all registered users belong')); ?></label>
|
||||
<select id="registered_user_group" name="registered_user_group">
|
||||
|
|
@ -20,8 +20,7 @@ foreach ( $_['groups'] as $group ) {
|
|||
<input type="text" id="allowed_domains" name="allowed_domains" value=<?php p($_['allowed']);?>>
|
||||
</p>
|
||||
<p>
|
||||
<em><?php p($l->t('Enter a semicolon-separated list of allowed domains. Example: owncloud.com;github.com'));?>
|
||||
</em>
|
||||
<em><?php p($l->t('Enter a semicolon-separated list of allowed domains. Example: owncloud.com;github.com'));?></em>
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue