• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP OCP\IGroupManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了IGroupManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: isEnabledForUser

 /**
  * Check if an app is enabled for user
  *
  * @param string $appId
  * @param \OCP\IUser $user (optional) if not defined, the currently logged in user will be used
  * @return bool
  */
 public function isEnabledForUser($appId, $user = null)
 {
     if (is_null($user)) {
         $user = $this->userSession->getUser();
     }
     $installedApps = $this->getInstalledApps();
     if (isset($installedApps[$appId])) {
         $enabled = $installedApps[$appId];
         if ($enabled === 'yes') {
             return true;
         } elseif (is_null($user)) {
             return false;
         } else {
             $groupIds = json_decode($enabled);
             $userGroups = $this->groupManager->getUserGroupIds($user);
             foreach ($userGroups as $groupId) {
                 if (array_search($groupId, $groupIds) !== false) {
                     return true;
                 }
             }
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:33,代码来源:appmanager.php


示例3: tearDown

 protected function tearDown()
 {
     foreach ($this->users as $user) {
         $user->delete();
     }
     $this->groupManager->get('admin')->delete();
     parent::tearDown();
 }
开发者ID:nem0xff,项目名称:core,代码行数:8,代码来源:testcase.php


示例4: isAdmin

 /**
  * Returns whether the currently logged in user is an administrator
  *
  * @return bool true if the user is an admin
  */
 private function isAdmin()
 {
     $user = $this->userSession->getUser();
     if ($user !== null) {
         return $this->groupManager->isAdmin($user->getUID());
     }
     return false;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:13,代码来源:SystemTagsByIdCollection.php


示例5: destroy

 /**
  * @param string $id
  * @return DataResponse
  */
 public function destroy($id)
 {
     $group = $this->groupManager->get($id);
     if ($group) {
         if ($group->delete()) {
             return new DataResponse(array('status' => 'success', 'data' => array('groupname' => $id)), Http::STATUS_NO_CONTENT);
         }
     }
     return new DataResponse(array('status' => 'error', 'data' => array('message' => (string) $this->l10n->t('Unable to delete group.'))), Http::STATUS_FORBIDDEN);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:14,代码来源:groupscontroller.php


示例6: readDBConfig

 protected function readDBConfig()
 {
     $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
     $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
     $groups = $this->groupManager->getUserGroupIds($this->getUser());
     if (is_array($groups) && count($groups) !== 0) {
         $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups);
     } else {
         $groupMounts = [];
     }
     return array_merge($userMounts, $groupMounts, $globalMounts);
 }
开发者ID:gmurayama,项目名称:core,代码行数:12,代码来源:userglobalstoragesservice.php


示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $uid = $input->getArgument('uid');
     if ($this->userManager->userExists($uid)) {
         $output->writeln('<error>The user "' . $uid . '" already exists.</error>');
         return 1;
     }
     if ($input->getOption('password-from-env')) {
         $password = getenv('OC_PASS');
         if (!$password) {
             $output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>');
             return 1;
         }
     } elseif ($input->isInteractive()) {
         /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
         $dialog = $this->getHelperSet()->get('dialog');
         $password = $dialog->askHiddenResponse($output, '<question>Enter password: </question>', false);
         $confirm = $dialog->askHiddenResponse($output, '<question>Confirm password: </question>', false);
         if ($password !== $confirm) {
             $output->writeln("<error>Passwords did not match!</error>");
             return 1;
         }
     } else {
         $output->writeln("<error>Interactive input or --password-from-env is needed for entering a password!</error>");
         return 1;
     }
     $user = $this->userManager->createUser($input->getArgument('uid'), $password);
     if ($user instanceof IUser) {
         $output->writeln('<info>The user "' . $user->getUID() . '" was created successfully</info>');
     } else {
         $output->writeln('<error>An error occurred while creating the user</error>');
         return 1;
     }
     if ($input->getOption('display-name')) {
         $user->setDisplayName($input->getOption('display-name'));
         $output->writeln('Display name set to "' . $user->getDisplayName() . '"');
     }
     foreach ($input->getOption('group') as $groupName) {
         $group = $this->groupManager->get($groupName);
         if (!$group) {
             $this->groupManager->createGroup($groupName);
             $group = $this->groupManager->get($groupName);
             $output->writeln('Created group "' . $group->getGID() . '"');
         }
         $group->addUser($user);
         $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:48,代码来源:add.php


示例8: addSubAdmin

 /**
  * Creates a subadmin
  *
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function addSubAdmin($parameters)
 {
     $group = $_POST['groupid'];
     $user = $parameters['userid'];
     // Check if the user exists
     if (!$this->userManager->userExists($user)) {
         return new OC_OCS_Result(null, 101, 'User does not exist');
     }
     // Check if group exists
     if (!$this->groupManager->groupExists($group)) {
         return new OC_OCS_Result(null, 102, 'Group:' . $group . ' does not exist');
     }
     // Check if trying to make subadmin of admin group
     if (strtolower($group) === 'admin') {
         return new OC_OCS_Result(null, 103, 'Cannot create subadmins for admin group');
     }
     // We cannot be subadmin twice
     if (OC_Subadmin::isSubAdminOfGroup($user, $group)) {
         return new OC_OCS_Result(null, 100);
     }
     // Go
     if (OC_Subadmin::createSubAdmin($user, $group)) {
         return new OC_OCS_Result(null, 100);
     } else {
         return new OC_OCS_Result(null, 103, 'Unknown error occured');
     }
 }
开发者ID:jincreator,项目名称:core,代码行数:33,代码来源:users.php


示例9: create

 /**
  * @NoAdminRequired
  *
  * @param string $username
  * @param string $password
  * @param array $groups
  * @param string $email
  * @return DataResponse
  */
 public function create($username, $password, array $groups = array(), $email = '')
 {
     if ($email !== '' && !$this->mail->validateAddress($email)) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mail address')), Http::STATUS_UNPROCESSABLE_ENTITY);
     }
     if (!$this->isAdmin) {
         $userId = $this->userSession->getUser()->getUID();
         if (!empty($groups)) {
             foreach ($groups as $key => $group) {
                 if (!$this->subAdminFactory->isGroupAccessible($userId, $group)) {
                     unset($groups[$key]);
                 }
             }
         }
         if (empty($groups)) {
             $groups = $this->subAdminFactory->getSubAdminsOfGroups($userId);
         }
     }
     if ($this->userManager->userExists($username)) {
         return new DataResponse(array('message' => (string) $this->l10n->t('A user with that name already exists.')), Http::STATUS_CONFLICT);
     }
     try {
         $user = $this->userManager->createUser($username, $password);
     } catch (\Exception $exception) {
         return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
     }
     if ($user instanceof User) {
         if ($groups !== null) {
             foreach ($groups as $groupName) {
                 $group = $this->groupManager->get($groupName);
                 if (empty($group)) {
                     $group = $this->groupManager->createGroup($groupName);
                 }
                 $group->addUser($user);
             }
         }
         /**
          * Send new user mail only if a mail is set
          */
         if ($email !== '') {
             $this->config->setUserValue($username, 'settings', 'email', $email);
             // data for the mail template
             $mailData = array('username' => $username, 'url' => $this->urlGenerator->getAbsoluteURL('/'));
             $mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
             $mailContent = $mail->render();
             $mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
             $plainTextMailContent = $mail->render();
             $subject = $this->l10n->t('Your %s account was created', [$this->defaults->getName()]);
             try {
                 $this->mail->send($email, $username, $subject, $mailContent, $this->fromMailAddress, $this->defaults->getName(), 1, $plainTextMailContent);
             } catch (\Exception $e) {
                 $this->log->error("Can't send new user mail to {$email}: " . $e->getMessage(), array('app' => 'settings'));
             }
         }
         // fetch users groups
         $userGroups = $this->groupManager->getUserGroupIds($user);
         return new DataResponse($this->formatUserForIndex($user, $userGroups), Http::STATUS_CREATED);
     }
     return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:69,代码来源:userscontroller.php


示例10: createTag

 /**
  * Creates a new tag
  *
  * @param string $data JSON encoded string containing the properties of the tag to create
  * @param string $contentType content type of the data
  * @return ISystemTag newly created system tag
  *
  * @throws BadRequest if a field was missing
  * @throws Conflict if a tag with the same properties already exists
  * @throws UnsupportedMediaType if the content type is not supported
  */
 private function createTag($data, $contentType = 'application/json')
 {
     if (explode(';', $contentType)[0] === 'application/json') {
         $data = json_decode($data, true);
     } else {
         throw new UnsupportedMediaType();
     }
     if (!isset($data['name'])) {
         throw new BadRequest('Missing "name" attribute');
     }
     $tagName = $data['name'];
     $userVisible = true;
     $userAssignable = true;
     if (isset($data['userVisible'])) {
         $userVisible = (bool) $data['userVisible'];
     }
     if (isset($data['userAssignable'])) {
         $userAssignable = (bool) $data['userAssignable'];
     }
     if ($userVisible === false || $userAssignable === false) {
         if (!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
             throw new BadRequest('Not sufficient permissions');
         }
     }
     try {
         return $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
     } catch (TagAlreadyExistsException $e) {
         throw new Conflict('Tag already exists', 0, $e);
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:41,代码来源:systemtagplugin.php


示例11: shareFileOrFolderWithGroup

 /**
  * Sharing a file or folder with a group
  *
  * @param string $shareWith
  * @param int $fileSource File ID that is being shared
  * @param string $itemType File type that is being shared (file or folder)
  * @param string $fileTarget File path
  * @param int $shareId The Share ID of this share
  */
 protected function shareFileOrFolderWithGroup($shareWith, $fileSource, $itemType, $fileTarget, $shareId)
 {
     // Members of the new group
     $affectedUsers = array();
     $group = $this->groupManager->get($shareWith);
     if (!$group instanceof \OCP\IGroup) {
         return;
     }
     // User performing the share
     $this->shareNotificationForSharer('shared_group_self', $shareWith, $fileSource, $itemType);
     $this->shareNotificationForOriginalOwners($this->currentUser, 'reshared_group_by', $shareWith, $fileSource, $itemType);
     $usersInGroup = $group->searchUsers('');
     foreach ($usersInGroup as $user) {
         $affectedUsers[$user->getUID()] = $fileTarget;
     }
     // Remove the triggering user, we already managed his notifications
     unset($affectedUsers[$this->currentUser]);
     if (empty($affectedUsers)) {
         return;
     }
     $filteredStreamUsersInGroup = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'stream', Files_Sharing::TYPE_SHARED);
     $filteredEmailUsersInGroup = $this->userSettings->filterUsersBySetting(array_keys($affectedUsers), 'email', Files_Sharing::TYPE_SHARED);
     $affectedUsers = $this->fixPathsForShareExceptions($affectedUsers, $shareId);
     foreach ($affectedUsers as $user => $path) {
         if (empty($filteredStreamUsersInGroup[$user]) && empty($filteredEmailUsersInGroup[$user])) {
             continue;
         }
         $this->addNotificationsForUser($user, 'shared_with_by', array($path, $this->currentUser), $fileSource, $path, $itemType === 'file', !empty($filteredStreamUsersInGroup[$user]), !empty($filteredEmailUsersInGroup[$user]) ? $filteredEmailUsersInGroup[$user] : 0);
     }
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:39,代码来源:fileshooks.php


示例12: 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 {
         $groupNames = $this->subAdminFactory->getSubAdminsOfGroups($this->userSession->getUser()->getUID());
         $uniqueUsers = [];
         foreach ($groupNames as $groupName) {
             $group = $this->groupManager->get($groupName);
             if (!is_null($group)) {
                 foreach ($group->getUsers() as $uid => $displayName) {
                     $uniqueUsers[$uid] = true;
                 }
             }
         }
         $userCount = count($uniqueUsers);
     }
     return new DataResponse(['totalUsers' => $userCount]);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:32,代码来源:userscontroller.php


示例13: event

 /**
  * @param ManagerEvent $event
  */
 public function event(ManagerEvent $event)
 {
     $actor = $this->session->getUser();
     if ($actor instanceof IUser) {
         $actor = $actor->getUID();
     } else {
         $actor = '';
     }
     $activity = $this->activityManager->generateEvent();
     $activity->setApp(Extension::APP_NAME)->setType(Extension::APP_NAME)->setAuthor($actor);
     if ($event->getEvent() === ManagerEvent::EVENT_CREATE) {
         $activity->setSubject(Extension::CREATE_TAG, [$actor, $this->prepareTagAsParameter($event->getTag())]);
     } else {
         if ($event->getEvent() === ManagerEvent::EVENT_UPDATE) {
             $activity->setSubject(Extension::UPDATE_TAG, [$actor, $this->prepareTagAsParameter($event->getTag()), $this->prepareTagAsParameter($event->getTagBefore())]);
         } else {
             if ($event->getEvent() === ManagerEvent::EVENT_DELETE) {
                 $activity->setSubject(Extension::DELETE_TAG, [$actor, $this->prepareTagAsParameter($event->getTag())]);
             } else {
                 return;
             }
         }
     }
     $group = $this->groupManager->get('admin');
     if ($group instanceof IGroup) {
         foreach ($group->getUsers() as $user) {
             $activity->setAffectedUser($user->getUID());
             $this->activityManager->publish($activity);
         }
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:34,代码来源:listener.php


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


示例15: tearDown

 public function tearDown()
 {
     $this->groupManager->removeListener('\\OC\\Group', 'preAddUser', [$this, 'onPreProcessUser']);
     $this->groupManager->removeListener('\\OC\\Group', 'postAddUser', [$this, 'onPostAddUser']);
     $this->groupManager->removeListener('\\OC\\Group', 'preRemoveUser', [$this, 'onPreProcessUser']);
     $this->groupManager->removeListener('\\OC\\Group', 'postRemoveUser', [$this, 'onPostRemoveUser']);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:7,代码来源:grouppropagationmanager.php


示例16: testGetShareByIdGroupShare

 public function testGetShareByIdGroupShare()
 {
     $qb = $this->dbConn->getQueryBuilder();
     $qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(42), 'file_target' => $qb->expr()->literal('myTarget'), 'permissions' => $qb->expr()->literal(13)]);
     $this->assertEquals(1, $qb->execute());
     // Get the id
     $qb = $this->dbConn->getQueryBuilder();
     $cursor = $qb->select('id')->from('share')->setMaxResults(1)->orderBy('id', 'DESC')->execute();
     $id = $cursor->fetch();
     $id = $id['id'];
     $cursor->closeCursor();
     $storage = $this->getMock('OC\\Files\\Storage\\Storage');
     $storage->expects($this->once())->method('getOwner')->willReturn('shareOwner');
     $path = $this->getMock('OCP\\Files\\Folder');
     $path->expects($this->once())->method('getStorage')->wilLReturn($storage);
     $this->userFolder->expects($this->once())->method('getById')->with(42)->willReturn([$path]);
     $sharedWith = $this->getMock('OCP\\IGroup');
     $sharedBy = $this->getMock('OCP\\IUser');
     $shareOwner = $this->getMock('OCP\\IUser');
     $this->userManager->method('get')->will($this->returnValueMap([['sharedBy', $sharedBy], ['shareOwner', $shareOwner]]));
     $this->groupManager->expects($this->once())->method('get')->with('sharedWith')->willReturn($sharedWith);
     $share = $this->provider->getShareById($id);
     $this->assertEquals($id, $share->getId());
     $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
     $this->assertEquals($sharedWith, $share->getSharedWith());
     $this->assertEquals($sharedBy, $share->getSharedBy());
     $this->assertEquals($shareOwner, $share->getShareOwner());
     $this->assertEquals($path, $share->getPath());
     $this->assertEquals(13, $share->getPermissions());
     $this->assertEquals(null, $share->getToken());
     $this->assertEquals(null, $share->getExpirationDate());
     $this->assertEquals('myTarget', $share->getTarget());
 }
开发者ID:reverserob,项目名称:core,代码行数:33,代码来源:defaultshareprovidertest.php


示例17: testIsUserAccessibleAdmin

 public function testIsUserAccessibleAdmin()
 {
     $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
     $this->assertTrue($subAdmin->createSubAdmin($this->users[0], $this->groups[0]));
     $this->groupManager->get('admin')->addUser($this->users[1]);
     $this->assertFalse($subAdmin->isUserAccessible($this->users[0], $this->users[1]));
 }
开发者ID:nem0xff,项目名称:core,代码行数:7,代码来源:subadmin.php


示例18: shareFileOrFolderWithGroup

 /**
  * Sharing a file or folder with a group
  *
  * @param string $shareWith
  * @param int $fileSource File ID that is being shared
  * @param string $itemType File type that is being shared (file or folder)
  * @param string $fileTarget File path
  * @param int $shareId The Share ID of this share
  * @param bool $isSharing True if sharing, false if unsharing
  */
 protected function shareFileOrFolderWithGroup($shareWith, $fileSource, $itemType, $fileTarget, $shareId, $isSharing)
 {
     if ($isSharing) {
         $actionSharer = 'shared_group_self';
         $actionOwner = 'reshared_group_by';
         $actionUser = 'shared_with_by';
     } else {
         $actionSharer = 'unshared_group_self';
         $actionOwner = 'unshared_group_by';
         $actionUser = 'unshared_by';
     }
     // Members of the new group
     $group = $this->groupManager->get($shareWith);
     if (!$group instanceof IGroup) {
         return;
     }
     // User performing the share
     $this->shareNotificationForSharer($actionSharer, $shareWith, $fileSource, $itemType);
     $this->shareNotificationForOriginalOwners($this->currentUser, $actionOwner, $shareWith, $fileSource, $itemType);
     $offset = 0;
     $users = $group->searchUsers('', self::USER_BATCH_SIZE, $offset);
     while (!empty($users)) {
         $this->addNotificationsForGroupUsers($users, $actionUser, $fileSource, $itemType, $fileTarget, $shareId);
         $offset += self::USER_BATCH_SIZE;
         $users = $group->searchUsers('', self::USER_BATCH_SIZE, $offset);
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:37,代码来源:FilesHooks.php


示例19: createShare

 /**
  * Create a share object from an database row
  *
  * @param mixed[] $data
  * @return Share
  */
 private function createShare($data)
 {
     $share = new Share();
     $share->setId((int) $data['id'])->setShareType((int) $data['share_type'])->setPermissions((int) $data['permissions'])->setTarget($data['file_target'])->setShareTime((int) $data['stime'])->setMailSend((bool) $data['mail_send']);
     if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
         $share->setSharedWith($this->userManager->get($data['share_with']));
     } else {
         if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
             $share->setSharedWith($this->groupManager->get($data['share_with']));
         } else {
             if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
                 $share->setPassword($data['share_with']);
                 $share->setToken($data['token']);
             } else {
                 $share->setSharedWith($data['share_with']);
             }
         }
     }
     $share->setSharedBy($this->userManager->get($data['uid_owner']));
     // TODO: getById can return an array. How to handle this properly??
     $folder = $this->rootFolder->getUserFolder($share->getSharedBy()->getUID());
     $path = $folder->getById((int) $data['file_source'])[0];
     $owner = $path->getOwner();
     $share->setShareOwner($owner);
     $path = $this->rootFolder->getUserFolder($owner->getUID())->getById((int) $data['file_source'])[0];
     $share->setPath($path);
     if ($data['expiration'] !== null) {
         $expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']);
         $share->setExpirationDate($expiration);
     }
     return $share;
 }
开发者ID:loulancn,项目名称:core,代码行数:38,代码来源:defaultshareprovider.php


示例20: getPrincipalByPath

 /**
  * Returns a specific principal, specified by it's path.
  * The returned structure should be the exact same as from
  * getPrincipalsByPrefix.
  *
  * @param string $path
  * @return array
  */
 public function getPrincipalByPath($path)
 {
     $elements = explode('/', $path);
     if ($elements[0] !== 'principals') {
         return null;
     }
     if ($elements[1] !== 'groups') {
         return null;
     }
     $name = $elements[2];
     $user = $this->groupManager->get($name);
     if (!is_null($user)) {
         return $this->groupToPrincipal($user);
     }
     return null;
 }
开发者ID:kenwi,项目名称:core,代码行数:24,代码来源:groupprincipalbackend.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP OCP\IL10N类代码示例发布时间:2022-05-23
下一篇:
PHP OCP\IDBConnection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap