get all display names

This commit is contained in:
Björn Schießle 2013-01-25 11:05:00 +01:00
parent 2fee1208ef
commit 9bb8e05839
4 changed files with 53 additions and 5 deletions

View File

@ -60,6 +60,16 @@ class User {
return \OC_USER::getDisplayName();
}
/**
* @brief Get a list of all display names
* @returns array with all display names and the correspondig uids
*
* Get a list of all display names.
*/
public static function getDisplayNames($search = '', $limit = null, $offset = null) {
return \OC_USER::getDisplayNames($search, $limit, $offset);
}
/**
* @brief Check if the user is logged in
* @returns true/false

View File

@ -457,6 +457,24 @@ class OC_User {
asort($users);
return $users;
}
/**
* @brief Get a list of all users display name
* @returns associative array with all display names and corresponding uids
*
* Get a list of all users.
*/
public static function getDisplayNames($search = '', $limit = null, $offset = null) {
$displayNames = array();
foreach (self::$_usedBackends as $backend) {
$backendDisplayNames = $backend->getDisplayNames($search, $limit, $offset);
if (is_array($backendDisplayNames)) {
$displayNames = array_merge($displayNames, $backendDisplayNames);
}
}
ksort($displayNames);
return $displayNames;
}
/**
* @brief check if a user exists

View File

@ -131,4 +131,19 @@ abstract class OC_User_Backend implements OC_User_Interface {
public function getDisplayName($uid) {
return $uid;
}
/**
* @brief Get a list of all display names
* @returns array with all displayNames and the correspondig uids
*
* Get a list of all display names.
*/
public function getDisplayNames($search = '', $limit = null, $offset = null) {
$displayNames = array();
$users = $this->getUsers($search, $limit, $offset);
foreach ( $users as $user) {
$displayNames[$user] = $user;
}
return $displayNames;
}
}

View File

@ -22,7 +22,7 @@ $isadmin = OC_User::isAdminUser(OC_User::getUser());
if($isadmin) {
$accessiblegroups = OC_Group::getGroups();
$accessibleusers = OC_User::getUsers('', 30);
$accessibleusers = OC_User::getDisplayNames('', 30);
$subadmins = OC_SubAdmin::getAllSubAdmins();
}else{
$accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
@ -42,16 +42,21 @@ $defaultQuota=OC_Appconfig::getValue('files', 'default_quota', 'none');
$defaultQuotaIsUserDefined=array_search($defaultQuota, $quotaPreset)===false && array_search($defaultQuota, array('none', 'default'))===false;
// load users and quota
foreach($accessibleusers as $i) {
foreach($accessibleusers as $displayName => $uid) {
$quota=OC_Preferences::getValue($i, 'files', 'quota', 'default');
$isQuotaUserDefined=array_search($quota, $quotaPreset)===false && array_search($quota, array('none', 'default'))===false;
$name = $displayName;
if ( $displayName != $uid ) {
$name = $name . ' ('.$uid.')';
}
$users[] = array(
"name" => $i,
"groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($i)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
"name" => $name,
"groups" => join( ", ", /*array_intersect(*/OC_Group::getUserGroups($uid)/*, OC_SubAdmin::getSubAdminsGroups(OC_User::getUser()))*/),
'quota'=>$quota,
'isQuotaUserDefined'=>$isQuotaUserDefined,
'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
'subadmin'=>implode(', ', OC_SubAdmin::getSubAdminsGroups($iuid)));
}
foreach( $accessiblegroups as $i ) {