Using countUsers method to return true count of users
This commit is contained in:
parent
033b0361ed
commit
6a56e03d48
|
@ -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));
|
|
@ -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();
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -88,11 +88,10 @@ $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->assign('enableAvatars', \OC::$server->getConfig()->getSystemValue('enable_avatars', true));
|
||||
$tmpl->printPage();
|
||||
|
|
Loading…
Reference in New Issue