diff options
Diffstat (limited to 'settings')
-rw-r--r-- | settings/ajax/geteveryonecount.php | 49 | ||||
-rw-r--r-- | settings/js/users/groups.js | 11 | ||||
-rw-r--r-- | settings/routes.php | 2 | ||||
-rw-r--r-- | settings/templates/users/part.grouplist.php | 6 | ||||
-rw-r--r-- | settings/users.php | 35 |
5 files changed, 82 insertions, 21 deletions
diff --git a/settings/ajax/geteveryonecount.php b/settings/ajax/geteveryonecount.php new file mode 100644 index 00000000000..54fbd6e2fbd --- /dev/null +++ b/settings/ajax/geteveryonecount.php @@ -0,0 +1,49 @@ +<?php +/** + * ownCloud + * + * @author Clark Tomlinson + * @copyright 2014 Clark Tomlinson <clark@owncloud.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +OC_JSON::callCheck(); +OC_JSON::checkSubAdminUser(); + +$userCount = 0; + +$currentUser = \OC::$server->getUserSession()->getLoginName(); + +if (!OC_User::isAdminUser($currentUser)) { + $groups = OC_SubAdmin::getSubAdminsGroups($currentUser); + + foreach ($groups as $group) { + $userCount += count(OC_Group::usersInGroup($group)); + + } +} else { + + $userCountArray = \OC::$server->getUserManager()->countUsers(); + + if (!empty($userCountArray)) { + foreach ($userCountArray as $classname => $usercount) { + $userCount += $usercount; + } + } +} + + +OC_JSON::success(array('count' => $userCount)); diff --git a/settings/js/users/groups.js b/settings/js/users/groups.js index 258b6aa7efd..081842734f0 100644 --- a/settings/js/users/groups.js +++ b/settings/js/users/groups.js @@ -251,12 +251,23 @@ GroupList = { getElementGID: function (element) { return ($(element).closest('li').data('gid') || '').toString(); + }, + getEveryoneCount: function () { + $.ajax({ + type: "GET", + dataType: "json", + url: OC.generateUrl('/settings/ajax/geteveryonecount') + }).success(function (data) { + $('#everyonegroup').data('usercount', data.count); + $('#everyonecount').text(data.count); + }); } }; $(document).ready( function () { $userGroupList = $('#usergrouplist'); GroupList.initDeleteHandling(); + GroupList.getEveryoneCount(); // Display or hide of Create Group List Element $('#newgroup-form').hide(); diff --git a/settings/routes.php b/settings/routes.php index 1c8ad1b3fe8..d98497ee617 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -27,6 +27,8 @@ $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_everyonecount', '/settings/ajax/geteveryonecount') + ->actionInclude('settings/ajax/geteveryonecount.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/part.grouplist.php b/settings/templates/users/part.grouplist.php index 255f2a6cf45..5b516bc0e16 100644 --- a/settings/templates/users/part.grouplist.php +++ b/settings/templates/users/part.grouplist.php @@ -12,15 +12,15 @@ </form> </li> <!-- Everyone --> - <li data-gid="_everyone" data-usercount="<?php p($_["usercount"]); ?>" class="isgroup"> + <li id="everyonegroup" data-gid="_everyone" data-usercount="" class="isgroup"> <a href="#"> <span class="groupname"> <?php p($l->t('Everyone')); ?> </span> </a> <span class="utils"> - <span class="usercount"> - <?php p($_["usercount"]); ?> + <span class="usercount" id="everyonecount"> + </span> </span> </li> diff --git a/settings/users.php b/settings/users.php index bc6c2ea7e7c..94dda43c523 100644 --- a/settings/users.php +++ b/settings/users.php @@ -60,13 +60,13 @@ $defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false // load users and quota foreach($accessibleUsers as $uid => $displayName) { - $quota=OC_Preferences::getValue($uid, 'files', 'quota', 'default'); - $isQuotaUserDefined=array_search($quota, $quotaPreset)===false - && array_search($quota, array('none', 'default'))===false; + $quota = OC_Preferences::getValue($uid, 'files', 'quota', 'default'); + $isQuotaUserDefined = array_search($quota, $quotaPreset) === false + && array_search($quota, array('none', 'default')) === false; $name = $displayName; - if ( $displayName !== $uid ) { - $name = $name . ' ('.$uid.')'; + if ($displayName !== $uid) { + $name = $name . ' (' . $uid . ')'; } $user = $userManager->get($uid); @@ -82,17 +82,16 @@ foreach($accessibleUsers as $uid => $displayName) { ); } -$tmpl = new OC_Template( "settings", "users/main", "user" ); -$tmpl->assign( 'users', $users ); -$tmpl->assign( 'groups', $groups ); -$tmpl->assign( 'adminGroup', $adminGroup ); -$tmpl->assign( 'isAdmin', (int) $isAdmin); -$tmpl->assign( 'subadmins', $subadmins); -$tmpl->assign('usercount', count($users)); -$tmpl->assign( 'numofgroups', count($groups) + count($adminGroup)); -$tmpl->assign( 'quota_preset', $quotaPreset); -$tmpl->assign( 'default_quota', $defaultQuota); -$tmpl->assign( 'defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined); -$tmpl->assign( 'recoveryAdminEnabled', $recoveryAdminEnabled); -$tmpl->assign( 'enableAvatars', \OC_Config::getValue('enable_avatars', true)); +$tmpl = new OC_Template("settings", "users/main", "user"); +$tmpl->assign('users', $users); +$tmpl->assign('groups', $groups); +$tmpl->assign('adminGroup', $adminGroup); +$tmpl->assign('isAdmin', (int)$isAdmin); +$tmpl->assign('subadmins', $subadmins); +$tmpl->assign('numofgroups', count($groups) + count($adminGroup)); +$tmpl->assign('quota_preset', $quotaPreset); +$tmpl->assign('default_quota', $defaultQuota); +$tmpl->assign('defaultQuotaIsUserDefined', $defaultQuotaIsUserDefined); +$tmpl->assign('recoveryAdminEnabled', $recoveryAdminEnabled); +$tmpl->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true)); $tmpl->printPage(); |