From b2ca595509a1c14eb28768e4eed99a3ba6eba46a Mon Sep 17 00:00:00 2001 From: raghunayyar Date: Tue, 28 Jan 2014 14:07:42 +0530 Subject: Add GroupList Ajax to Users. --- settings/ajax/grouplist.php | 75 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 settings/ajax/grouplist.php (limited to 'settings/ajax') diff --git a/settings/ajax/grouplist.php b/settings/ajax/grouplist.php new file mode 100644 index 00000000000..99acf50c764 --- /dev/null +++ b/settings/ajax/grouplist.php @@ -0,0 +1,75 @@ +. + * + */ + +// This file is repsonsible for the Ajax Request for Group list +// Outputs are Names of Groups and IDs of users which are a part of them + +OC_JSON::checkSubAdminUser(); + +$users = array(); +$groupname = array(); +$useringroup = array(); +$userUid = OC_User::getUser(); +$isAdmin = OC_User::isAdminUser($userUid); + +if (isset($_GET['offset'])) { + $offset = $_GET['offset']; +} else { + $offset = 0; +} +if (isset($_GET['limit'])) { + $limit = $_GET['limit']; +} else { + $limit = 10; +} + +if ($isAdmin) { + $groups = OC_Group::getGroups(); + $batch = OC_User::getDisplayNames('', $limit, $offset); + foreach ($batch as $user) { + $users['users'][] = array( 'user' => $user ); + } +} +else { + $groups = OC_SubAdmin::getSubAdminsGroups($userUid); + $batch = OC_Group::usersInGroups($groups, '', $limit, $offset); + foreach ($batch as $user) { + $users['users'][] = array( 'user' => $user ); + } +} + +// convert them to the needed format +foreach( $groups as $gid ) { + $groupname[] = array( + 'id' => str_replace(' ','', $gid ), + 'name' => $gid, + 'useringroup' => OC_Group::usersInGroup($gid, '', $limit, $offset), + 'isAdmin' => !OC_User::isAdminUser($gid), + ); +} + +OCP\JSON::success(array('result' => $groupname )); + +?> \ No newline at end of file -- cgit v1.2.3 From b506388b75c8454ef54ce05fa0d98db854c10faf Mon Sep 17 00:00:00 2001 From: raghunayyar Date: Tue, 28 Jan 2014 21:36:48 +0530 Subject: Reverts last commit, implements user in group count. --- settings/ajax/grouplist.php | 75 -------------------------------------------- settings/css/settings.css | 1 + settings/routes.php | 2 -- settings/templates/users.php | 5 ++- settings/users.php | 21 +++++++++++-- 5 files changed, 23 insertions(+), 81 deletions(-) delete mode 100644 settings/ajax/grouplist.php (limited to 'settings/ajax') diff --git a/settings/ajax/grouplist.php b/settings/ajax/grouplist.php deleted file mode 100644 index 99acf50c764..00000000000 --- a/settings/ajax/grouplist.php +++ /dev/null @@ -1,75 +0,0 @@ -. - * - */ - -// This file is repsonsible for the Ajax Request for Group list -// Outputs are Names of Groups and IDs of users which are a part of them - -OC_JSON::checkSubAdminUser(); - -$users = array(); -$groupname = array(); -$useringroup = array(); -$userUid = OC_User::getUser(); -$isAdmin = OC_User::isAdminUser($userUid); - -if (isset($_GET['offset'])) { - $offset = $_GET['offset']; -} else { - $offset = 0; -} -if (isset($_GET['limit'])) { - $limit = $_GET['limit']; -} else { - $limit = 10; -} - -if ($isAdmin) { - $groups = OC_Group::getGroups(); - $batch = OC_User::getDisplayNames('', $limit, $offset); - foreach ($batch as $user) { - $users['users'][] = array( 'user' => $user ); - } -} -else { - $groups = OC_SubAdmin::getSubAdminsGroups($userUid); - $batch = OC_Group::usersInGroups($groups, '', $limit, $offset); - foreach ($batch as $user) { - $users['users'][] = array( 'user' => $user ); - } -} - -// convert them to the needed format -foreach( $groups as $gid ) { - $groupname[] = array( - 'id' => str_replace(' ','', $gid ), - 'name' => $gid, - 'useringroup' => OC_Group::usersInGroup($gid, '', $limit, $offset), - 'isAdmin' => !OC_User::isAdminUser($gid), - ); -} - -OCP\JSON::success(array('result' => $groupname )); - -?> \ No newline at end of file diff --git a/settings/css/settings.css b/settings/css/settings.css index 37cd1b6f132..39290308cbe 100644 --- a/settings/css/settings.css +++ b/settings/css/settings.css @@ -51,6 +51,7 @@ table.nostyle label { margin-right: 2em; } table.nostyle td { padding: 0.2em 0; } /* USERS */ +.usercount { float: right; margin:6px;} form { display:inline; } table.grid th { height:2em; color:#999; } table.grid th, table.grid td { border-bottom:1px solid #ddd; padding:0 .5em; padding-left:.8em; text-align:left; font-weight:normal; } diff --git a/settings/routes.php b/settings/routes.php index 77a10f68d6f..0e0f293b9be 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -25,8 +25,6 @@ $this->create('settings_admin', '/settings/admin') // users $this->create('settings_ajax_userlist', '/settings/ajax/userlist') ->actionInclude('settings/ajax/userlist.php'); -$this->create('settings_ajax_grouplist', '/settings/ajax/grouplist') - ->actionInclude('settings/ajax/grouplist.php'); $this->create('settings_ajax_createuser', '/settings/ajax/createuser.php') ->actionInclude('settings/ajax/createuser.php'); $this->create('settings_ajax_removeuser', '/settings/ajax/removeuser.php') diff --git a/settings/templates/users.php b/settings/templates/users.php index 83b54543b02..a56c7229c1a 100644 --- a/settings/templates/users.php +++ b/settings/templates/users.php @@ -29,7 +29,10 @@ $_['subadmingroups'] = array_flip($items);
  • - + + + +
  • diff --git a/settings/users.php b/settings/users.php index f09d0e90d3c..31a54b05c02 100644 --- a/settings/users.php +++ b/settings/users.php @@ -18,6 +18,17 @@ OC_App::setActiveNavigationEntry( 'core_users' ); $users = array(); $groups = array(); +if (isset($_GET['offset'])) { + $offset = $_GET['offset']; +} else { + $offset = 0; +} +if (isset($_GET['limit'])) { + $limit = $_GET['limit']; +} else { + $limit = 10; +} + $isadmin = OC_User::isAdminUser(OC_User::getUser()); $recoveryAdminEnabled = OC_App::isEnabled('files_encryption') && OC_Appconfig::getValue( 'files_encryption', 'recoveryAdminEnabled' ); @@ -65,9 +76,13 @@ foreach($accessibleusers as $uid => $displayName) { ); } -foreach( $accessiblegroups as $i ) { - // Do some more work here soon - $groups[] = array( "name" => $i ); +foreach( $accessiblegroups as $gid ) { + $groups[] = array( + 'id' => str_replace(' ','', $gid ), + 'name' => $gid, + 'useringroup' => OC_Group::usersInGroup($gid, '', $limit, $offset), + 'isAdmin' => !OC_User::isAdminUser($gid), + ); } $tmpl = new OC_Template( "settings", "users", "user" ); -- cgit v1.2.3 From ce46cd3680979019de59e48654771f3061076e7b Mon Sep 17 00:00:00 2001 From: raghunayyar Date: Tue, 28 Jan 2014 22:32:51 +0530 Subject: Implements Group Creation from Sidebar --- settings/ajax/creategroup.php | 4 ++-- settings/js/users.js | 41 +++++++++++++++++++++++++++++++++++++++++ settings/templates/users.php | 9 ++++++--- 3 files changed, 49 insertions(+), 5 deletions(-) (limited to 'settings/ajax') 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);