当前位置: 首页>>代码示例>>PHP>>正文


PHP IGroupManager::getSubAdmin方法代码示例

本文整理汇总了PHP中OCP\IGroupManager::getSubAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP IGroupManager::getSubAdmin方法的具体用法?PHP IGroupManager::getSubAdmin怎么用?PHP IGroupManager::getSubAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\IGroupManager的用法示例。


在下文中一共展示了IGroupManager::getSubAdmin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setMailAddress

 /**
  * Set the mail address of a user
  *
  * @NoAdminRequired
  * @NoSubadminRequired
  *
  * @param string $id
  * @param string $mailAddress
  * @return DataResponse
  */
 public function setMailAddress($id, $mailAddress)
 {
     $userId = $this->userSession->getUser()->getUID();
     $user = $this->userManager->get($id);
     if ($userId !== $id && !$this->isAdmin && !$this->groupManager->getSubAdmin()->isUserAccessible($this->userSession->getUser(), $user)) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Forbidden'))), Http::STATUS_FORBIDDEN);
     }
     if ($mailAddress !== '' && !$this->mailer->validateMailAddress($mailAddress)) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Invalid mail address'))), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     if (!$user) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Invalid user'))), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     // this is the only permission a backend provides and is also used
     // for the permission of setting a email address
     if (!$user->canChangeDisplayName()) {
         return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Unable to change mail address'))), Http::STATUS_FORBIDDEN);
     }
     // delete user value if email address is empty
     if ($mailAddress === '') {
         $this->config->deleteUserValue($id, 'settings', 'email');
     } else {
         $this->config->setUserValue($id, 'settings', 'email', $mailAddress);
     }
     return new DataResponse(array('status' => 'success', 'data' => array('username' => $id, 'mailAddress' => $mailAddress, 'message' => (string) $this->l10n->t('Email saved'))), Http::STATUS_OK);
 }
开发者ID:phongtnit,项目名称:core,代码行数:36,代码来源:userscontroller.php

示例2: 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

示例3: setDisplayName

 /**
  * Set the displayName of a user
  *
  * @NoAdminRequired
  * @NoSubadminRequired
  *
  * @param string $username
  * @param string $displayName
  * @return DataResponse
  */
 public function setDisplayName($username, $displayName)
 {
     $currentUser = $this->userSession->getUser();
     if ($username === null) {
         $username = $currentUser->getUID();
     }
     $user = $this->userManager->get($username);
     if ($user === null || !$user->canChangeDisplayName() || !$this->groupManager->isAdmin($currentUser->getUID()) && !$this->groupManager->getSubAdmin()->isUserAccessible($currentUser, $user) && $currentUser !== $user) {
         return new DataResponse(['status' => 'error', 'data' => ['message' => $this->l10n->t('Authentication error')]]);
     }
     if ($user->setDisplayName($displayName)) {
         return new DataResponse(['status' => 'success', 'data' => ['message' => $this->l10n->t('Your full name has been changed.'), 'username' => $username, 'displayName' => $displayName]]);
     } else {
         return new DataResponse(['status' => 'error', 'data' => ['message' => $this->l10n->t('Unable to change full name'), 'displayName' => $user->getDisplayName()]]);
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:26,代码来源:userscontroller.php

示例4: getSubAdminsOfGroup

 /**
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function getSubAdminsOfGroup($parameters)
 {
     $group = $parameters['groupid'];
     // Check group exists
     $targetGroup = $this->groupManager->get($group);
     if ($targetGroup === null) {
         return new OC_OCS_Result(null, 101, 'Group does not exist');
     }
     $subadmins = $this->groupManager->getSubAdmin()->getGroupsSubAdmins($targetGroup);
     // New class returns IUser[] so convert back
     $uids = [];
     foreach ($subadmins as $user) {
         $uids[] = $user->getUID();
     }
     return new OC_OCS_Result($uids);
 }
开发者ID:kenwi,项目名称:core,代码行数:20,代码来源:groups.php

示例5: getUserSubAdminGroups

 /**
  * Get the groups a user is a subadmin of
  *
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function getUserSubAdminGroups($parameters)
 {
     $user = $this->userManager->get($parameters['userid']);
     // Check if the user exists
     if ($user === null) {
         return new OC_OCS_Result(null, 101, 'User does not exist');
     }
     // Get the subadmin groups
     $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($user);
     foreach ($groups as $key => $group) {
         $groups[$key] = $group->getGID();
     }
     if (!$groups) {
         return new OC_OCS_Result(null, 102, 'Unknown error occurred');
     } else {
         return new OC_OCS_Result($groups);
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:24,代码来源:users.php

示例6: stats

 /**
  * Count all unique users visible for the current admin/subadmin.
  *
  * @NoAdminRequired
  *
  * @return DataResponse
  */
 public function stats()
 {
     $userCount = 0;
     if ($this->isAdmin) {
         $countByBackend = $this->userManager->countUsers();
         if (!empty($countByBackend)) {
             foreach ($countByBackend as $count) {
                 $userCount += $count;
             }
         }
     } else {
         $groups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser());
         $uniqueUsers = [];
         foreach ($groups as $group) {
             foreach ($group->getUsers() as $uid => $displayName) {
                 $uniqueUsers[$uid] = true;
             }
         }
         $userCount = count($uniqueUsers);
     }
     return new DataResponse(['totalUsers' => $userCount]);
 }
开发者ID:rajeshpillai,项目名称:core,代码行数:29,代码来源:userscontroller.php

示例7: testGetSubAdminsOfGroup

 public function testGetSubAdminsOfGroup()
 {
     $user1 = $this->generateUsers();
     $user2 = $this->generateUsers();
     $this->userSession->setUser($user1);
     $this->groupManager->get('admin')->addUser($user1);
     $group1 = $this->groupManager->createGroup($this->getUniqueID());
     $this->groupManager->getSubAdmin()->createSubAdmin($user2, $group1);
     $result = $this->api->getSubAdminsOfGroup(['groupid' => $group1->getGID()]);
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertTrue($result->succeeded());
     $data = $result->getData();
     $this->assertEquals($user2->getUID(), reset($data));
     $group1->delete();
     $user1 = $this->generateUsers();
     $this->userSession->setUser($user1);
     $this->groupManager->get('admin')->addUser($user1);
     $result = $this->api->getSubAdminsOfGroup(['groupid' => $this->getUniqueID()]);
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertFalse($result->succeeded());
     $this->assertEquals(101, $result->getStatusCode());
 }
开发者ID:rajeshpillai,项目名称:core,代码行数:22,代码来源:groupstest.php


注:本文中的OCP\IGroupManager::getSubAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。