本文整理汇总了PHP中OCP\IUserManager::searchDisplayName方法的典型用法代码示例。如果您正苦于以下问题:PHP IUserManager::searchDisplayName方法的具体用法?PHP IUserManager::searchDisplayName怎么用?PHP IUserManager::searchDisplayName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IUserManager
的用法示例。
在下文中一共展示了IUserManager::searchDisplayName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* @param string $pattern which should match within the $searchProperties
* @param array $searchProperties defines the properties within the query pattern should match
* @param array $options - for future use. One should always have options!
* @return array an array of contacts which are arrays of key-value-pairs
*/
public function search($pattern, $searchProperties, $options)
{
$users = array();
if ($pattern == '') {
// Fetch all contacts
$users = $this->userManager->search('');
} else {
foreach ($searchProperties as $property) {
$result = array();
if ($property === 'FN') {
$result = $this->userManager->searchDisplayName($pattern);
} else {
if ($property === 'id') {
$result = $this->userManager->search($pattern);
}
}
if (is_array($result)) {
$users = array_merge($users, $result);
}
}
}
$contacts = array();
foreach ($users as $user) {
$contact = array("id" => $user->getUID(), "FN" => $user->getDisplayname(), "EMAIL" => array(), "IMPP" => array("x-owncloud-handle:" . $user->getUID()));
$contacts[] = $contact;
}
return $contacts;
}
示例2: getUsers
/**
* @param string $search
*/
protected function getUsers($search)
{
$this->result['users'] = $this->result['exact']['users'] = $users = [];
$userGroups = [];
if ($this->shareWithGroupOnly) {
// Search in all the groups this user is part of
$userGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
foreach ($userGroups as $userGroup) {
$usersTmp = $this->groupManager->displayNamesInGroup($userGroup, $search, $this->limit, $this->offset);
foreach ($usersTmp as $uid => $userDisplayName) {
$users[$uid] = $userDisplayName;
}
}
} else {
// Search in all users
$usersTmp = $this->userManager->searchDisplayName($search, $this->limit, $this->offset);
foreach ($usersTmp as $user) {
$users[$user->getUID()] = $user->getDisplayName();
}
}
if (!$this->shareeEnumeration || sizeof($users) < $this->limit) {
$this->reachedEndFor[] = 'users';
}
$foundUserById = false;
foreach ($users as $uid => $userDisplayName) {
if (strtolower($uid) === $search || strtolower($userDisplayName) === $search) {
if (strtolower($uid) === $search) {
$foundUserById = true;
}
$this->result['exact']['users'][] = ['label' => $userDisplayName, 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => $uid]];
} else {
$this->result['users'][] = ['label' => $userDisplayName, 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => $uid]];
}
}
if ($this->offset === 0 && !$foundUserById) {
// On page one we try if the search result has a direct hit on the
// user id and if so, we add that to the exact match list
$user = $this->userManager->get($search);
if ($user instanceof IUser) {
$addUser = true;
if ($this->shareWithGroupOnly) {
// Only add, if we have a common group
$commonGroups = array_intersect($userGroups, $this->groupManager->getUserGroupIds($user));
$addUser = !empty($commonGroups);
}
if ($addUser) {
array_push($this->result['exact']['users'], ['label' => $user->getDisplayName(), 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => $user->getUID()]]);
}
}
}
if (!$this->shareeEnumeration) {
$this->result['users'] = [];
}
}