本文整理汇总了PHP中OCP\IGroupManager::search方法的典型用法代码示例。如果您正苦于以下问题:PHP IGroupManager::search方法的具体用法?PHP IGroupManager::search怎么用?PHP IGroupManager::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IGroupManager
的用法示例。
在下文中一共展示了IGroupManager::search方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetGroups
public function testGetGroups()
{
$groups = [];
$id = $this->getUniqueID();
for ($i = 0; $i < 10; $i++) {
$groups[] = $this->groupManager->createGroup($id . '_' . $i);
}
$_GET = [];
$result = $this->api->getGroups([]);
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$this->assertCount(count($this->groupManager->search('')), $result->getData()['groups']);
$this->assertContains('admin', $result->getData()['groups']);
foreach ($groups as $group) {
$this->assertContains($group->getGID(), $result->getData()['groups']);
}
$_GET = ['search' => $id, 'limit' => 5, 'offset' => 2];
$result = $this->api->getGroups([]);
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$this->assertCount(5, $result->getData()['groups']);
foreach (array_splice($groups, 2, 5) as $group) {
$this->assertContains($group->getGID(), $result->getData()['groups']);
}
foreach ($groups as $group) {
$group->delete();
}
}
示例2: getPrincipalsByPrefix
/**
* Returns a list of principals based on a prefix.
*
* This prefix will often contain something like 'principals'. You are only
* expected to return principals that are in this base path.
*
* You are expected to return at least a 'uri' for every user, you can
* return any additional properties if you wish so. Common properties are:
* {DAV:}displayname
*
* @param string $prefixPath
* @return string[]
*/
public function getPrincipalsByPrefix($prefixPath)
{
$principals = [];
if ($prefixPath === self::PRINCIPAL_PREFIX) {
foreach ($this->groupManager->search('') as $user) {
$principals[] = $this->groupToPrincipal($user);
}
}
return $principals;
}
示例3: getGroups
/**
* returns a list of groups
*/
public function getGroups($parameters)
{
$search = !empty($_GET['search']) ? $_GET['search'] : '';
$limit = !empty($_GET['limit']) ? $_GET['limit'] : null;
$offset = !empty($_GET['offset']) ? $_GET['offset'] : null;
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) {
return $group->getGID();
}, $groups);
return new OC_OCS_Result(['groups' => $groups]);
}
示例4: getGroups
/**
* @param string $search
*/
protected function getGroups($search)
{
$this->result['groups'] = $this->result['exact']['groups'] = [];
$groups = $this->groupManager->search($search, $this->limit, $this->offset);
$groups = array_map(function (IGroup $group) {
return $group->getGID();
}, $groups);
if (sizeof($groups) < $this->limit) {
$this->reachedEndFor[] = 'groups';
}
$userGroups = [];
if (!empty($groups) && $this->shareWithGroupOnly) {
// Intersect all the groups that match with the groups this user is a member of
$userGroups = $this->groupManager->getUserGroups($this->userSession->getUser());
$userGroups = array_map(function (IGroup $group) {
return $group->getGID();
}, $userGroups);
$groups = array_intersect($groups, $userGroups);
}
foreach ($groups as $gid) {
if (strtolower($gid) === $search) {
$this->result['exact']['groups'][] = ['label' => $search, 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => $search]];
} else {
$this->result['groups'][] = ['label' => $gid, 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => $gid]];
}
}
if ($this->offset === 0 && empty($this->result['exact']['groups'])) {
// 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
$group = $this->groupManager->get($search);
if ($group instanceof IGroup && (!$this->shareWithGroupOnly || in_array($group->getGID(), $userGroups))) {
array_push($this->result['exact']['groups'], ['label' => $group->getGID(), 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => $group->getGID()]]);
}
}
}
示例5: getGroups
/**
* returns a list of groups
*
* @param array $parameters
* @return OC_OCS_Result
*/
public function getGroups($parameters)
{
$search = $this->request->getParam('search', '');
$limit = $this->request->getParam('limit');
$offset = $this->request->getParam('offset');
if ($limit !== null) {
$limit = (int) $limit;
}
if ($offset !== null) {
$offset = (int) $offset;
}
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) {
/** @var IGroup $group */
return $group->getGID();
}, $groups);
return new OC_OCS_Result(['groups' => $groups]);
}
示例6: getGroups
/**
* returns the available groups
* @param string $search a search string
* @return \OCP\IGroup[]
*/
protected function getGroups($search = '')
{
if ($this->isAdmin) {
return $this->groupManager->search($search);
} else {
$userObject = $this->userSession->getUser();
if ($userObject !== null) {
$groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($userObject);
} else {
$groups = [];
}
return $groups;
}
}
示例7: getGroups
/**
* returns the available groups
* @param string $search a search string
* @return \OC\Group\Group[]
*/
private function getGroups($search = '')
{
if ($this->isAdmin) {
return $this->groupManager->search($search);
} else {
// FIXME: Remove static method call
$groupIds = \OC_SubAdmin::getSubAdminsGroups($this->user);
/* \OC_SubAdmin::getSubAdminsGroups() returns an array of GIDs, but this
* method is expected to return an array with the GIDs as keys and group objects as
* values, so we need to convert this information.
*/
$groups = array();
foreach ($groupIds as $gid) {
$group = $this->groupManager->get($gid);
if (!is_null($group)) {
$groups[$gid] = $group;
}
}
return $groups;
}
}