本文整理汇总了PHP中OCP\IUserSession类的典型用法代码示例。如果您正苦于以下问题:PHP IUserSession类的具体用法?PHP IUserSession怎么用?PHP IUserSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IUserSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param ILogger $logger
* @param IUserSession $userSession
* @param IConfig $config
*/
public function __construct(ILogger $logger, IUserSession $userSession, IConfig $config)
{
$this->logger = $logger;
$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser() : false;
$this->config = $config;
$this->supportedKeyFormats = ['hash', 'password'];
}
示例2: testTagManagerWithoutUserReturnsNull
public function testTagManagerWithoutUserReturnsNull()
{
$this->userSession = $this->getMock('\\OCP\\IUserSession');
$this->userSession->expects($this->any())->method('getUser')->will($this->returnValue(null));
$this->tagMgr = new OC\TagManager($this->tagMapper, $this->userSession);
$this->assertNull($this->tagMgr->load($this->objectType));
}
示例3: __construct
/**
* @param ILogger $logger
* @param IUserSession $userSession
* @param Crypt $crypt
* @param KeyManager $keyManager
*/
public function __construct(ILogger $logger, IUserSession $userSession, Crypt $crypt, KeyManager $keyManager)
{
$this->logger = $logger;
$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : false;
$this->crypt = $crypt;
$this->keyManager = $keyManager;
}
示例4: __construct
/**
* constructor of the controller
*
* @param string $appName
* @param IRequest $request
* @param ILogger $logger
* @param IUserSession $userSession
* @param CurrentUserSettings $userSettings
*/
public function __construct($appName, IRequest $request, ILogger $logger, IUserSession $userSession, CurrentUserSettings $userSettings)
{
parent::__construct($appName, $request);
$this->logger = $logger;
$this->user = $userSession->getUser();
$this->userSettings = $userSettings;
}
示例5: __construct
/**
* Util constructor.
*
* @param View $files
* @param Crypt $crypt
* @param ILogger $logger
* @param IUserSession $userSession
* @param IConfig $config
*/
public function __construct(View $files, Crypt $crypt, ILogger $logger, IUserSession $userSession, IConfig $config)
{
$this->files = $files;
$this->crypt = $crypt;
$this->logger = $logger;
$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser() : false;
$this->config = $config;
}
示例6: __construct
/**
* @param ILogger $logger
* @param IUserSession $userSession
* @param IConfig $config
* @param IL10N $l
*/
public function __construct(ILogger $logger, IUserSession $userSession, IConfig $config, IL10N $l)
{
$this->logger = $logger;
$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : '"no user given"';
$this->config = $config;
$this->l = $l;
$this->supportedKeyFormats = ['hash', 'password'];
}
示例7: __construct
/**
* @param \Sabre\DAV\Tree $tree tree
* @param IUserSession $userSession user session
* @param \OCP\Files\Folder $userFolder user home folder
* @param \OCP\Share\IManager $shareManager share manager
*/
public function __construct(\Sabre\DAV\Tree $tree, IUserSession $userSession, \OCP\Files\Folder $userFolder, \OCP\Share\IManager $shareManager)
{
$this->tree = $tree;
$this->shareManager = $shareManager;
$this->userFolder = $userFolder;
$this->userId = $userSession->getUser()->getUID();
$this->cachedShareTypes = [];
}
示例8: getCurrentUser
/**
* @param IUserSession $session
* @return string
*/
protected function getCurrentUser(IUserSession $session)
{
$user = $session->getUser();
if ($user instanceof IUser) {
$user = $user->getUID();
}
return (string) $user;
}
示例9: __construct
public function __construct($AppName, IRequest $request, IUserSession $session, IConfig $settings)
{
parent::__construct($AppName, $request);
$this->request = $request;
$this->current_user = $session->getUser()->getUID();
$this->content = array();
$this->settings = $settings;
$this->app = $AppName;
}
示例10: 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;
}
}
示例11: 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);
}
}
示例12: 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');
}
}
示例13: getUser
/**
* @return IUser|null
*/
protected function getUser()
{
if ($this->user) {
return $this->user;
}
return $this->userSession->getUser();
}
示例14: 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);
}
示例15: 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]);
}