public_html/cloud/settings/Controller/UsersController.php
/**
	 * Count all unique users visible for the current admin/subadmin.
	 *
	 * @NoAdminRequired
	 *
	 * @return DataResponse
	 */
Count all unique users visible for the current admin/subadmin.


Count all unique users visible for the current admin / subadmin .
public function stats() {
		$userCount = 0;
		if ($this->isAdmin) {
			$countByBackend = $this->userManager->countUsers();
			if (!empty($countByBackend)) {
				foreach ($countByBackend as $count) {
					$userCount += $count;
				}
			}
		} else {
			$groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser());
			$uniqueUsers = [];
			foreach ($groups as $group) {
				foreach($group->getUsers() as $uid => $displayName) {
					$uniqueUsers[$uid] = true;
				}
			}
			$userCount = count($uniqueUsers);
		}
		return new DataResponse(
			[
				'totalUsers' => $userCount
			]
		);
	}
public function stats ( ) { $ userCount = 0 ; if ( $ this -> isAdmin ) { $ countByBackend = $ this -> userManager -> countUsers ( ) ; if ( ! empty ( $ countByBackend ) ) { foreach ( $ countByBackend as $ count ) { $ userCount += $ count ; } } } else { $ groups = $ this -> groupManager -> getSubAdmin ( ) -> getSubAdminsGroups ( $ this -> userSession -> getUser ( ) ) ; $ uniqueUsers = [ ] ; foreach ( $ groups as $ group ) { foreach ( $ group -> getUsers ( ) as $ uid => $ displayName ) { $ uniqueUsers [ $ uid ] = true ; } } $ userCount = count ( $ uniqueUsers ) ; } return new DataResponse ( [ 'totalUsers' => $ userCount ] ) ; }
Count all unique users visible for the current admin/subadmin.
Count all unique users visible for the current admin / subadmin .