aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraghunayyar <me@iraghu.com>2014-01-28 22:32:51 +0530
committerArthur Schiwon <blizzz@owncloud.com>2014-06-02 12:52:52 +0200
commitce46cd3680979019de59e48654771f3061076e7b (patch)
tree7e3baaf52980152792d723a6a22cdc9635749dc3
parentb506388b75c8454ef54ce05fa0d98db854c10faf (diff)
downloadnextcloud-server-ce46cd3680979019de59e48654771f3061076e7b.tar.gz
nextcloud-server-ce46cd3680979019de59e48654771f3061076e7b.zip
Implements Group Creation from Sidebar
-rw-r--r--settings/ajax/creategroup.php4
-rw-r--r--settings/js/users.js41
-rw-r--r--settings/templates/users.php9
3 files changed, 49 insertions, 5 deletions
diff --git a/settings/ajax/creategroup.php b/settings/ajax/creategroup.php
index 0a79527c219..bd878dc1c0a 100644
--- a/settings/ajax/creategroup.php
+++ b/settings/ajax/creategroup.php
@@ -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' )));
}
diff --git a/settings/js/users.js b/settings/js/users.js
index eef3c237277..7b06d961b1a 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -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 () {
diff --git a/settings/templates/users.php b/settings/templates/users.php
index a56c7229c1a..83ac79365b6 100644
--- a/settings/templates/users.php
+++ b/settings/templates/users.php
@@ -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">