本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}