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


PHP IGroupManager::isInGroup方法代碼示例

本文整理匯總了PHP中OCP\IGroupManager::isInGroup方法的典型用法代碼示例。如果您正苦於以下問題:PHP IGroupManager::isInGroup方法的具體用法?PHP IGroupManager::isInGroup怎麽用?PHP IGroupManager::isInGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCP\IGroupManager的用法示例。


在下文中一共展示了IGroupManager::isInGroup方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: readLegacyConfig

 /**
  * Read legacy config data
  *
  * @return array list of mount configs
  */
 protected function readLegacyConfig()
 {
     // read global config
     $data = parent::readLegacyConfig();
     $userId = $this->getUser()->getUID();
     // don't use array_filter() with ARRAY_FILTER_USE_KEY, it's PHP 5.6+
     if (isset($data[\OC_Mount_Config::MOUNT_TYPE_USER])) {
         $newData = [];
         foreach ($data[\OC_Mount_Config::MOUNT_TYPE_USER] as $key => $value) {
             if (strtolower($key) === strtolower($userId) || $key === 'all') {
                 $newData[$key] = $value;
             }
         }
         $data[\OC_Mount_Config::MOUNT_TYPE_USER] = $newData;
     }
     if (isset($data[\OC_Mount_Config::MOUNT_TYPE_GROUP])) {
         $newData = [];
         foreach ($data[\OC_Mount_Config::MOUNT_TYPE_GROUP] as $key => $value) {
             if ($this->groupManager->isInGroup($userId, $key)) {
                 $newData[$key] = $value;
             }
         }
         $data[\OC_Mount_Config::MOUNT_TYPE_GROUP] = $newData;
     }
     return $data;
 }
開發者ID:unrealbato,項目名稱:core,代碼行數:31,代碼來源:userglobalstoragesservice.php

示例2: readLegacyConfig

 /**
  * Read legacy config data
  *
  * @return array list of mount configs
  */
 protected function readLegacyConfig()
 {
     // read global config
     $data = parent::readLegacyConfig();
     $userId = $this->getUser()->getUID();
     if (isset($data[\OC_Mount_Config::MOUNT_TYPE_USER])) {
         $data[\OC_Mount_Config::MOUNT_TYPE_USER] = array_filter($data[\OC_Mount_Config::MOUNT_TYPE_USER], function ($key) use($userId) {
             return strtolower($key) === strtolower($userId) || $key === 'all';
         }, ARRAY_FILTER_USE_KEY);
     }
     if (isset($data[\OC_Mount_Config::MOUNT_TYPE_GROUP])) {
         $data[\OC_Mount_Config::MOUNT_TYPE_GROUP] = array_filter($data[\OC_Mount_Config::MOUNT_TYPE_GROUP], function ($key) use($userId) {
             return $this->groupManager->isInGroup($userId, $key);
         }, ARRAY_FILTER_USE_KEY);
     }
     return $data;
 }
開發者ID:GrumpyCrouton,項目名稱:core,代碼行數:22,代碼來源:userglobalstoragesservice.php

示例3: isMember

 /**
  * @param string $gid
  * @param string $uid
  * @return bool
  */
 protected function isMember($gid, $uid)
 {
     if (isset($this->memberships[$gid][$uid])) {
         return $this->memberships[$gid][$uid];
     }
     $isMember = $this->groupManager->isInGroup($uid, $gid);
     if (!isset($this->memberships[$gid])) {
         $this->memberships[$gid] = [];
     }
     $this->memberships[$gid][$uid] = $isMember;
     return $isMember;
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:17,代碼來源:OldGroupMembershipShares.php

示例4: removeFromGroup

 /**
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function removeFromGroup($parameters)
 {
     // Check if user is logged in
     $user = $this->userSession->getUser();
     if ($user === null) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
     }
     $group = !empty($parameters['_delete']['groupid']) ? $parameters['_delete']['groupid'] : null;
     if (is_null($group)) {
         return new OC_OCS_Result(null, 101);
     }
     // If they're not an admin, check they are a subadmin of the group in question
     if (!$this->groupManager->isInGroup($user->getUID(), 'admin') && !OC_SubAdmin::isSubAdminofGroup($user->getUID(), $group)) {
         return new OC_OCS_Result(null, 104);
     }
     // Check they aren't removing themselves from 'admin' or their 'subadmin; group
     if ($parameters['userid'] === $user->getUID()) {
         if ($this->groupManager->isInGroup($user->getUID(), 'admin')) {
             if ($group === 'admin') {
                 return new OC_OCS_Result(null, 105, 'Cannot remove yourself from the admin group');
             }
         } else {
             // Not an admin, check they are not removing themself from their subadmin group
             if (in_array($group, OC_SubAdmin::getSubAdminsGroups($user->getUID()))) {
                 return new OC_OCS_Result(null, 105, 'Cannot remove yourself from this group as you are a SubAdmin');
             }
         }
     }
     // Check if the group exists
     if (!$this->groupManager->groupExists($group)) {
         return new OC_OCS_Result(null, 102);
     }
     // Check if the user exists
     if (!$this->userManager->userExists($parameters['userid'])) {
         return new OC_OCS_Result(null, 103);
     }
     // Remove user from group
     $this->groupManager->get($group)->removeUser($this->userManager->get($parameters['userid']));
     return new OC_OCS_Result(null, 100);
 }
開發者ID:jincreator,項目名稱:core,代碼行數:44,代碼來源:users.php


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