当前位置: 首页>>代码示例>>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;未经允许,请勿转载。