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


PHP IUserSession::getUser方法代码示例

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


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

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

示例2: load

 /**
  * Create a new \OCP\ITags instance and load tags from db.
  *
  * @see \OCP\ITags
  * @param string $type The type identifier e.g. 'contact' or 'event'.
  * @param array $defaultTags An array of default tags to be used if none are stored.
  * @param boolean $includeShared Whether to include tags for items shared with this user by others.
  * @param string $userId user for which to retrieve the tags, defaults to the currently
  * logged in user
  * @return \OCP\ITags
  */
 public function load($type, $defaultTags = array(), $includeShared = false, $userId = null)
 {
     if (is_null($userId)) {
         $userId = $this->userSession->getUser()->getUId();
     }
     return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:18,代码来源:tagmanager.php

示例3: index

 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @return TemplateResponse
  */
 public function index()
 {
     $userId = $this->userSession->getUser()->getUID();
     $appVersion = $this->config->getAppValue($this->appName, 'installed_version');
     $defaultView = $this->config->getUserValue($userId, $this->appName, 'currentView', 'month');
     return new TemplateResponse('calendar', 'main', ['appVersion' => $appVersion, 'defaultView' => $defaultView]);
 }
开发者ID:dominicrico,项目名称:calendar-rework,代码行数:13,代码来源:viewcontroller.php

示例4: updatePrivateKeyPassword

 /**
  * @NoAdminRequired
  * @UseSession
  *
  * @param string $oldPassword
  * @param string $newPassword
  * @return DataResponse
  */
 public function updatePrivateKeyPassword($oldPassword, $newPassword)
 {
     $result = false;
     $uid = $this->userSession->getUser()->getUID();
     $errorMessage = $this->l->t('Could not update the private key password.');
     //check if password is correct
     $passwordCorrect = $this->userManager->checkPassword($uid, $newPassword);
     if ($passwordCorrect !== false) {
         $encryptedKey = $this->keyManager->getPrivateKey($uid);
         $decryptedKey = $this->crypt->decryptPrivateKey($encryptedKey, $oldPassword);
         if ($decryptedKey) {
             $encryptedKey = $this->crypt->symmetricEncryptFileContent($decryptedKey, $newPassword);
             $header = $this->crypt->generateHeader();
             if ($encryptedKey) {
                 $this->keyManager->setPrivateKey($uid, $header . $encryptedKey);
                 $this->session->setPrivateKey($decryptedKey);
                 $result = true;
             }
         } else {
             $errorMessage = $this->l->t('The old password was not correct, please try again.');
         }
     } else {
         $errorMessage = $this->l->t('The current log-in password was not correct, please try again.');
     }
     if ($result === true) {
         $this->session->setStatus(Session::INIT_SUCCESSFUL);
         return new DataResponse(['message' => (string) $this->l->t('Private key password successfully updated.')]);
     } else {
         return new DataResponse(['message' => (string) $errorMessage], Http::STATUS_BAD_REQUEST);
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:39,代码来源:settingscontroller.php

示例5: getUser

 /**
  * @return IUser|null
  */
 protected function getUser()
 {
     if ($this->user) {
         return $this->user;
     }
     return $this->userSession->getUser();
 }
开发者ID:evanjt,项目名称:core,代码行数:10,代码来源:usertrait.php

示例6: getGroup

 /**
  * returns an array of users in the group specified
  *
  * @param array $parameters
  * @return OC_OCS_Result
  */
 public function getGroup($parameters)
 {
     // Check if user is logged in
     $user = $this->userSession->getUser();
     if ($user === null) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED);
     }
     $groupId = $parameters['groupid'];
     // Check the group exists
     if (!$this->groupManager->groupExists($groupId)) {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_NOT_FOUND, 'The requested group could not be found');
     }
     $isSubadminOfGroup = false;
     $group = $this->groupManager->get($groupId);
     if ($group !== null) {
         $isSubadminOfGroup = $this->groupManager->getSubAdmin()->isSubAdminofGroup($user, $group);
     }
     // Check subadmin has access to this group
     if ($this->groupManager->isAdmin($user->getUID()) || $isSubadminOfGroup) {
         $users = $this->groupManager->get($groupId)->getUsers();
         $users = array_map(function ($user) {
             /** @var IUser $user */
             return $user->getUID();
         }, $users);
         $users = array_values($users);
         return new OC_OCS_Result(['users' => $users]);
     } else {
         return new OC_OCS_Result(null, \OCP\API::RESPOND_UNAUTHORISED, 'User does not have access to specified group');
     }
 }
开发者ID:kenwi,项目名称:core,代码行数:36,代码来源:groups.php

示例7: isAdmin

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

示例8: index

 /**
  * @NoAdminRequired
  *
  * @param string $pattern
  * @param bool $filterGroups
  * @return DataResponse
  */
 public function index($pattern = '', $filterGroups = false)
 {
     $groupPattern = $filterGroups ? $pattern : '';
     $groupsInfo = new \OC\Group\MetaData($this->userSession->getUser()->getUID(), $this->isAdmin, $this->groupManager);
     $groupsInfo->setSorting($groupsInfo::SORT_USERCOUNT);
     list($adminGroups, $groups) = $groupsInfo->get($groupPattern, $pattern);
     return new DataResponse(array('data' => array('adminGroups' => $adminGroups, 'groups' => $groups)));
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:15,代码来源:groupscontroller.php

示例9: getFilesByTag

 /**
  * Updates the tags of the specified file path.
  * The passed tags are absolute, which means they will
  * replace the actual tag selection.
  *
  * @param array $tagName tag name to filter by
  * @return FileInfo[] list of matching files
  * @throws \Exception if the tag does not exist
  */
 public function getFilesByTag($tagName)
 {
     $nodes = $this->homeFolder->searchByTag($tagName, $this->userSession->getUser()->getUId());
     foreach ($nodes as &$node) {
         $node = $node->getFileInfo();
     }
     return $nodes;
 }
开发者ID:riso,项目名称:owncloud-core,代码行数:17,代码来源:tagservice.php

示例10: manipulateStorageConfig

 protected function manipulateStorageConfig(StorageConfig $storage)
 {
     /** @var AuthMechanism */
     $authMechanism = $storage->getAuthMechanism();
     $authMechanism->manipulateStorageConfig($storage, $this->userSession->getUser());
     /** @var Backend */
     $backend = $storage->getBackend();
     $backend->manipulateStorageConfig($storage, $this->userSession->getUser());
 }
开发者ID:Juraganet,项目名称:core,代码行数:9,代码来源:userglobalstoragescontroller.php

示例11: logout

 /**
  * @NoAdminRequired
  * @UseSession
  *
  * @return RedirectResponse
  */
 public function logout()
 {
     $loginToken = $this->request->getCookie('oc_token');
     if (!is_null($loginToken)) {
         $this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);
     }
     $this->userSession->logout();
     return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:15,代码来源:LoginController.php

示例12: getView

 /**
  * get a config value
  *
  * @return JSONResponse
  *
  * @NoAdminRequired
  */
 public function getView()
 {
     $userId = $this->userSession->getUser()->getUID();
     $app = $this->appName;
     try {
         $view = $this->config->getUserValue($userId, $app, 'currentView', 'month');
     } catch (\Exception $e) {
         return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR);
     }
     return new JSONResponse(['value' => $view]);
 }
开发者ID:dominicrico,项目名称:calendar-rework,代码行数:18,代码来源:settingscontroller.php

示例13: load

 /**
  * Create a new \OCP\ITags instance and load tags from db.
  *
  * @see \OCP\ITags
  * @param string $type The type identifier e.g. 'contact' or 'event'.
  * @param array $defaultTags An array of default tags to be used if none are stored.
  * @param boolean $includeShared Whether to include tags for items shared with this user by others.
  * @param string $userId user for which to retrieve the tags, defaults to the currently
  * logged in user
  * @return \OCP\ITags
  */
 public function load($type, $defaultTags = array(), $includeShared = false, $userId = null)
 {
     if (is_null($userId)) {
         $user = $this->userSession->getUser();
         if ($user === null) {
             // nothing we can do without a user
             return null;
         }
         $userId = $this->userSession->getUser()->getUId();
     }
     return new Tags($this->mapper, $userId, $type, $defaultTags, $includeShared);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:23,代码来源:tagmanager.php

示例14: initCollections

 /**
  * initializes the collection. At this point of time, we need the logged in
  * user. Since it is not the case when the instance is created, we cannot
  * have this in the constructor.
  *
  * @throws NotAuthenticated
  */
 protected function initCollections()
 {
     if (!empty($this->entityTypeCollections)) {
         return;
     }
     $user = $this->userSession->getUser();
     if (is_null($user)) {
         throw new NotAuthenticated();
     }
     $userFolder = $this->rootFolder->getUserFolder($user->getUID());
     $this->entityTypeCollections['files'] = new EntityTypeCollection('files', $this->commentsManager, $userFolder, $this->userManager, $this->logger);
 }
开发者ID:matt407,项目名称:core,代码行数:19,代码来源:rootcollection.php

示例15: impersonate

 /**
  * become another user
  * @param string $userid
  * @UseSession
  * @return JSONResponse
  */
 public function impersonate($userid)
 {
     $oldUserId = $this->userSession->getUser()->getUID();
     $this->logger->warning("User {$oldUserId} trying to impersonate user {$userid}", ['app' => 'impersonate']);
     $user = $this->userManager->get($userid);
     if ($user === null) {
         return new JSONResponse("No user found for {$userid}", Http::STATUS_NOT_FOUND);
     } else {
         $this->logger->warning("changing to user {$userid}", ['app' => 'impersonate']);
         $this->userSession->setUser($user);
     }
     return new JSONResponse();
 }
开发者ID:AARNet,项目名称:impersonate,代码行数:19,代码来源:settingscontroller.php


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