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


PHP IUserManager::get方法代码示例

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


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

示例1: format

 /**
  * @param IEvent $event
  * @param string $parameter The parameter to be formatted
  * @param bool $allowHtml   Should HTML be used to format the parameter?
  * @param bool $verbose     Should paths, names, etc be shortened or full length
  * @return string The formatted parameter
  */
 public function format(IEvent $event, $parameter, $allowHtml, $verbose = false)
 {
     // If the username is empty, the action has been performed by a remote
     // user, or via a public share. We don't know the username in that case
     if ($parameter === '') {
         if ($allowHtml === null) {
             return '<user display-name="' . Util::sanitizeHTML($this->l->t('"remote user"')) . '">' . Util::sanitizeHTML('') . '</user>';
         }
         if ($allowHtml) {
             return '<strong>' . $this->l->t('"remote user"') . '</strong>';
         } else {
             return $this->l->t('"remote user"');
         }
     }
     $user = $this->manager->get($parameter);
     $displayName = $user ? $user->getDisplayName() : $parameter;
     $parameter = Util::sanitizeHTML($parameter);
     if ($allowHtml === null) {
         return '<user display-name="' . Util::sanitizeHTML($displayName) . '">' . Util::sanitizeHTML($parameter) . '</user>';
     }
     if ($allowHtml) {
         $avatarPlaceholder = '';
         if ($this->config->getSystemValue('enable_avatars', true)) {
             $avatarPlaceholder = '<div class="avatar" data-user="' . $parameter . '"></div>';
         }
         return $avatarPlaceholder . '<strong>' . Util::sanitizeHTML($displayName) . '</strong>';
     } else {
         return $displayName;
     }
 }
开发者ID:ynott,项目名称:activity,代码行数:37,代码来源:userformatter.php

示例2: getAvatar

 /**
  * return a user specific instance of \OCP\IAvatar
  * @see \OCP\IAvatar
  * @param string $user the ownCloud user id
  * @return \OCP\IAvatar
  * @throws \Exception In case the username is potentially dangerous
  */
 public function getAvatar($userId)
 {
     $user = $this->userManager->get($userId);
     if (is_null($user)) {
         throw new \Exception('user does not exist');
     }
     return new Avatar($this->rootFolder->getUserFolder($userId)->getParent(), $this->l, $user);
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:15,代码来源:avatarmanager.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $user = $this->userManager->get($input->getArgument('uid'));
     if (is_null($user)) {
         $output->writeln('<error>User does not exist</error>');
         return;
     }
     $user->setEnabled(false);
     $output->writeln('<info>The specified user is disabled</info>');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:10,代码来源:Disable.php

示例4: format

 /**
  * @param IEvent $event
  * @param string $parameter The parameter to be formatted
  * @return string The formatted parameter
  */
 public function format(IEvent $event, $parameter)
 {
     // If the username is empty, the action has been performed by a remote
     // user, or via a public share. We don't know the username in that case
     if ($parameter === '') {
         return '<user display-name="' . Util::sanitizeHTML($this->l->t('"remote user"')) . '">' . Util::sanitizeHTML('') . '</user>';
     }
     $user = $this->manager->get($parameter);
     $displayName = $user ? $user->getDisplayName() : $parameter;
     $parameter = Util::sanitizeHTML($parameter);
     return '<user display-name="' . Util::sanitizeHTML($displayName) . '">' . Util::sanitizeHTML($parameter) . '</user>';
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:17,代码来源:UserFormatter.php

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

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $user = $this->userManager->get($input->getArgument('uid'));
     if (is_null($user)) {
         $output->writeln('<error>User does not exist</error>');
         return;
     }
     if ($user->delete()) {
         $output->writeln('<info>The specified user was deleted</info>');
         return;
     }
     $output->writeln('<error>The specified user could not be deleted. Please check the logs.</error>');
 }
开发者ID:alfrescoo,项目名称:core,代码行数:13,代码来源:delete.php

示例7: getDisplayNames

 /**
  * Lookup user display names
  *
  * @NoAdminRequired
  *
  * @param array $users
  *
  * @return JSONResponse
  */
 public function getDisplayNames($users)
 {
     $result = array();
     foreach ($users as $user) {
         $userObject = $this->userManager->get($user);
         if (is_object($userObject)) {
             $result[$user] = $userObject->getDisplayName();
         } else {
             $result[$user] = $user;
         }
     }
     $json = array('users' => $result, 'status' => 'success');
     return new JSONResponse($json);
 }
开发者ID:evanjt,项目名称:core,代码行数:23,代码来源:usercontroller.php

示例8: 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)
 {
     list($prefix, $name) = explode('/', $path);
     $user = $this->userManager->get($name);
     if ($prefix === 'principals' && !is_null($user)) {
         $principal = ['uri' => 'principals/' . $user->getUID(), '{DAV:}displayname' => $user->getUID()];
         $email = $this->config->getUserValue($user->getUID(), 'settings', 'email');
         if ($email) {
             $principal['{http://sabredav.org/ns}email-address'] = $email;
         }
         return $principal;
     }
     return null;
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:22,代码来源:principal.php

示例9: formatShare

 /**
  * Convert an IShare to an array for OCS output
  *
  * @param \OCP\Share\IShare $share
  * @return array
  * @throws NotFoundException In case the node can't be resolved.
  */
 protected function formatShare(\OCP\Share\IShare $share)
 {
     $sharedBy = $this->userManager->get($share->getSharedBy());
     $shareOwner = $this->userManager->get($share->getShareOwner());
     $result = ['id' => $share->getId(), 'share_type' => $share->getShareType(), 'uid_owner' => $share->getSharedBy(), 'displayname_owner' => $sharedBy !== null ? $sharedBy->getDisplayName() : $share->getSharedBy(), 'permissions' => $share->getPermissions(), 'stime' => $share->getShareTime()->getTimestamp(), 'parent' => null, 'expiration' => null, 'token' => null, 'uid_file_owner' => $share->getShareOwner(), 'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner()];
     $node = $share->getNode();
     $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner())->getRelativePath($node->getPath());
     if ($node instanceof \OCP\Files\Folder) {
         $result['item_type'] = 'folder';
     } else {
         $result['item_type'] = 'file';
     }
     $result['storage_id'] = $node->getStorage()->getId();
     $result['storage'] = $node->getStorage()->getCache()->getNumericStorageId();
     $result['item_source'] = $node->getId();
     $result['file_source'] = $node->getId();
     $result['file_parent'] = $node->getParent()->getId();
     $result['file_target'] = $share->getTarget();
     if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
         $sharedWith = $this->userManager->get($share->getSharedWith());
         $result['share_with'] = $share->getSharedWith();
         $result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
     } else {
         if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
             $result['share_with'] = $share->getSharedWith();
             $result['share_with_displayname'] = $share->getSharedWith();
         } else {
             if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
                 $result['share_with'] = $share->getPassword();
                 $result['share_with_displayname'] = $share->getPassword();
                 $result['token'] = $share->getToken();
                 $result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);
                 $expiration = $share->getExpirationDate();
                 if ($expiration !== null) {
                     $result['expiration'] = $expiration->format('Y-m-d 00:00:00');
                 }
             } else {
                 if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
                     $result['share_with'] = $share->getSharedWith();
                     $result['share_with_displayname'] = $share->getSharedWith();
                     $result['token'] = $share->getToken();
                 }
             }
         }
     }
     $result['mail_send'] = $share->getMailSend() ? 1 : 0;
     return $result;
 }
开发者ID:gvde,项目名称:core,代码行数:55,代码来源:share20ocs.php

示例10: sendEmail

 /**
  * @param string $user
  * @throws \Exception
  */
 protected function sendEmail($user)
 {
     if (!$this->userManager->userExists($user)) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please make sure your username is correct.'));
     }
     $userObject = $this->userManager->get($user);
     $email = $userObject->getEMailAddress();
     if (empty($email)) {
         throw new \Exception($this->l10n->t('Could not send reset email because there is no email address for this username. Please contact your administrator.'));
     }
     $token = $this->secureRandom->generate(21, ISecureRandom::CHAR_DIGITS . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER);
     $this->config->setUserValue($user, 'owncloud', 'lostpassword', $this->timeFactory->getTime() . ':' . $token);
     $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', array('userId' => $user, 'token' => $token));
     $tmpl = new \OC_Template('core/lostpassword', 'email');
     $tmpl->assign('link', $link);
     $msg = $tmpl->fetchPage();
     try {
         $message = $this->mailer->createMessage();
         $message->setTo([$email => $user]);
         $message->setSubject($this->l10n->t('%s password reset', [$this->defaults->getName()]));
         $message->setPlainBody($msg);
         $message->setFrom([$this->from => $this->defaults->getName()]);
         $this->mailer->send($message);
     } catch (\Exception $e) {
         throw new \Exception($this->l10n->t('Couldn\'t send reset email. Please contact your administrator.'));
     }
 }
开发者ID:ErikPel,项目名称:core,代码行数:31,代码来源:lostcontroller.php

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

示例12: prepareUserParam

 /**
  * Prepares a user name parameter for usage
  *
  * Add an avatar to usernames
  *
  * @param string $param
  * @param bool $highlightParams
  * @return string
  */
 protected function prepareUserParam($param, $highlightParams)
 {
     // If the username is empty, the action has been performed by a remote
     // user, or via a public share. We don't know the username in that case
     if ($param === '') {
         if ($highlightParams) {
             return '<strong>' . $this->l->t('"remote user"') . '</strong>';
         } else {
             return $this->l->t('"remote user"');
         }
     }
     $user = $this->userManager->get($param);
     $displayName = $user ? $user->getDisplayName() : $param;
     $param = Util::sanitizeHTML($param);
     $displayName = Util::sanitizeHTML($displayName);
     if ($highlightParams) {
         $avatarPlaceholder = '';
         if ($this->config->getSystemValue('enable_avatars', true)) {
             $avatarPlaceholder = '<div class="avatar" data-user="' . $param . '"></div>';
         }
         return $avatarPlaceholder . '<strong>' . $displayName . '</strong>';
     } else {
         return $displayName;
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:34,代码来源:parameterhelper.php

示例13: sendEmailToUser

 /**
  * Send a notification to one user
  *
  * @param string $userName Username of the recipient
  * @param string $email Email address of the recipient
  * @param string $lang Selected language of the recipient
  * @param string $timezone Selected timezone of the recipient
  * @param int $maxTime
  */
 public function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime)
 {
     $user = $this->userManager->get($userName);
     if (!$user instanceof IUser) {
         return;
     }
     list($mailData, $skippedCount) = $this->getItemsForUser($userName, $maxTime);
     $l = $this->getLanguage($lang);
     $this->dataHelper->setUser($userName);
     $this->dataHelper->setL10n($l);
     $activityList = array();
     foreach ($mailData as $activity) {
         $relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($activity['amq_timestamp'], 'long', 'medium', new \DateTimeZone($timezone), $l);
         $activityList[] = array($this->dataHelper->translation($activity['amq_appid'], $activity['amq_subject'], $this->dataHelper->getParameters($activity['amq_subjectparams'])), $relativeDateTime);
     }
     $alttext = new Template('activity', 'email.notification', '');
     $alttext->assign('username', $user->getDisplayName());
     $alttext->assign('activities', $activityList);
     $alttext->assign('skippedCount', $skippedCount);
     $alttext->assign('owncloud_installation', $this->urlGenerator->getAbsoluteURL('/'));
     $alttext->assign('overwriteL10N', $l);
     $emailText = $alttext->fetchPage();
     $message = $this->mailer->createMessage();
     $message->setTo([$email => $user->getDisplayName()]);
     $message->setSubject((string) $l->t('Activity notification'));
     $message->setPlainBody($emailText);
     $message->setFrom([$this->getSenderData('email') => $this->getSenderData('name')]);
     $this->mailer->send($message);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:38,代码来源:mailqueuehandler.php

示例14: getAvatar

	/**
	 * @NoAdminRequired
	 *
	 * @param string $userId
	 * @param int $size
	 * @return DataResponse|DataDisplayResponse
	 */
	public function getAvatar($userId, $size) {
		if ($size > 2048) {
			$size = 2048;
		} elseif ($size <= 0) {
			$size = 64;
		}

		$avatar = $this->avatarManager->getAvatar($userId);
		$image = $avatar->get($size);

		if ($image instanceof \OCP\IImage) {
			$resp = new DataDisplayResponse($image->data(),
				Http::STATUS_OK,
				['Content-Type' => $image->mimeType()]);
			$resp->setETag(crc32($image->data()));
		} else {
			$user = $this->userManager->get($userId);
			$userName = $user ? $user->getDisplayName() : '';
			$resp = new DataResponse([
				'data' => [
					'displayname' => $userName,
				],
			]);
		}

		$resp->addHeader('Pragma', 'public');
		$resp->cacheFor(0);
		$resp->setLastModified(new \DateTime('now', new \DateTimeZone('GMT')));

		return $resp;
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:38,代码来源:avatarcontroller.php

示例15: loginWithCookie

 /**
  * perform login using the magic cookie (remember login)
  *
  * @param string $uid the username
  * @param string $currentToken
  * @return bool
  */
 public function loginWithCookie($uid, $currentToken)
 {
     $this->session->regenerateId();
     $this->manager->emit('\\OC\\User', 'preRememberedLogin', array($uid));
     $user = $this->manager->get($uid);
     if (is_null($user)) {
         // user does not exist
         return false;
     }
     // get stored tokens
     $tokens = OC::$server->getConfig()->getUserKeys($uid, 'login_token');
     // test cookies token against stored tokens
     if (!in_array($currentToken, $tokens, true)) {
         return false;
     }
     // replace successfully used token with a new one
     OC::$server->getConfig()->deleteUserValue($uid, 'login_token', $currentToken);
     $newToken = OC::$server->getSecureRandom()->generate(32);
     OC::$server->getConfig()->setUserValue($uid, 'login_token', $newToken, time());
     $this->setMagicInCookie($user->getUID(), $newToken);
     //login
     $this->setUser($user);
     $this->manager->emit('\\OC\\User', 'postRememberedLogin', array($user));
     return true;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:32,代码来源:Session.php


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