Using countUsers method to return true count of users

This commit is contained in:
Clark Tomlinson 2014-08-29 11:27:23 -04:00
parent 033b0361ed
commit 6a56e03d48
5 changed files with 82 additions and 21 deletions

View File

@ -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));

View File

@ -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();

View File

@ -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')

View File

@ -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>

View File

@ -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();