當前位置: 首頁>>代碼示例>>PHP>>正文


PHP IGroupManager::search方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:rosarion,項目名稱:core,代碼行數:28,代碼來源:groupstest.php

示例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;
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:23,代碼來源:GroupPrincipalBackend.php

示例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]);
 }
開發者ID:rosarion,項目名稱:core,代碼行數:14,代碼來源:groups.php

示例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()]]);
         }
     }
 }
開發者ID:rosarion,項目名稱:core,代碼行數:38,代碼來源:sharees.php

示例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]);
 }
開發者ID:kenwi,項目名稱:core,代碼行數:24,代碼來源:groups.php

示例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;
     }
 }
開發者ID:rchicoli,項目名稱:owncloud-core,代碼行數:19,代碼來源:MetaData.php

示例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;
     }
 }
開發者ID:adolfo2103,項目名稱:hcloudfilem,代碼行數:26,代碼來源:metadata.php


注:本文中的OCP\IGroupManager::search方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。