Implements Group Creation from Sidebar
This commit is contained in:
parent
b506388b75
commit
ce46cd3680
|
@ -7,7 +7,7 @@ $groupname = $_POST["groupname"];
|
|||
|
||||
// Does the group exist?
|
||||
if( in_array( $groupname, OC_Group::getGroups())) {
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Group already exists") )));
|
||||
OC_JSON::error(array("data" => array( "message" => 'Group already exists' )));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -16,5 +16,5 @@ if( OC_Group::createGroup( $groupname )) {
|
|||
OC_JSON::success(array("data" => array( "groupname" => $groupname )));
|
||||
}
|
||||
else{
|
||||
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to add group") )));
|
||||
OC_JSON::error(array("data" => array( "message" => 'Unable to add group' )));
|
||||
}
|
||||
|
|
|
@ -530,6 +530,47 @@ $(document).ready(function () {
|
|||
}
|
||||
);
|
||||
});
|
||||
$('#newgroup').submit(function (event) {
|
||||
event.preventDefault();
|
||||
var groupname = $('#newgroupname').val();
|
||||
if ($.trim(groupname) === '') {
|
||||
OC.dialogs.alert(
|
||||
t('settings', 'A valid groupname must be provided'),
|
||||
t('settings', 'Error creating group'));
|
||||
return false;
|
||||
}
|
||||
$.post(
|
||||
OC.filePath('settings', 'ajax', 'creategroup.php'),
|
||||
{
|
||||
groupname : groupname
|
||||
},
|
||||
function (result) {
|
||||
if (result.status !== 'success') {
|
||||
OC.dialogs.alert(result.data.message,
|
||||
t('settings', 'Error creating group'));
|
||||
} else {
|
||||
if (result.data.groupname) {
|
||||
var addedGroups = result.data.groupname;
|
||||
UserList.availableGroups = $.unique($.merge(UserList.availableGroups, addedGroups));
|
||||
}
|
||||
if (result.data.homeExists){
|
||||
OC.Notification.hide();
|
||||
OC.Notification.show(t('settings', 'Warning: Home directory for user "{group}" already exists', {group: result.data.groupname}));
|
||||
if (UserList.notificationTimeout){
|
||||
window.clearTimeout(UserList.notificationTimeout);
|
||||
}
|
||||
UserList.notificationTimeout = window.setTimeout(
|
||||
function(){
|
||||
OC.Notification.hide();
|
||||
UserList.notificationTimeout = null;
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
// Handle undo notifications
|
||||
OC.Notification.hide();
|
||||
$('#notification').on('click', '.undo', function () {
|
||||
|
|
|
@ -19,8 +19,10 @@ $_['subadmingroups'] = array_flip($items);
|
|||
<ul>
|
||||
<!-- Add new group -->
|
||||
<li>
|
||||
<input type="text" placeholder="<?php p($l->t('Group')); ?>..." />
|
||||
<button><?php p($l->t('Add')); ?></button>
|
||||
<form id="newgroup">
|
||||
<input type="text" id="newgroupname" placeholder="<?php p($l->t('Group')); ?>..." />
|
||||
<input type="submit" value="<?php p($l->t('Create'))?>" />
|
||||
</form>
|
||||
</li>
|
||||
<!-- Everyone -->
|
||||
<li>
|
||||
|
@ -89,7 +91,8 @@ $_['subadmingroups'] = array_flip($items);
|
|||
<?php foreach($_["groups"] as $group): ?>
|
||||
<option value="<?php p($group['name']);?>"><?php p($group['name']);?></option>
|
||||
<?php endforeach;?>
|
||||
</select> <input type="submit" value="<?php p($l->t('Create'))?>" />
|
||||
</select>
|
||||
<input type="submit" value="<?php p($l->t('Create'))?>" />
|
||||
</form>
|
||||
<?php if((bool)$_['recoveryAdminEnabled']): ?>
|
||||
<div class="recoveryPassword">
|
||||
|
|
Loading…
Reference in New Issue