本文整理汇总了PHP中OC\User\Manager类的典型用法代码示例。如果您正苦于以下问题:PHP Manager类的具体用法?PHP Manager怎么用?PHP Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Manager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$username = $input->getArgument('user');
/** @var $user \OC\User\User */
$user = $this->userManager->get($username);
if (is_null($user)) {
$output->writeln("<error>There is no user called " . $username . "</error>");
return 1;
}
if ($input->isInteractive()) {
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
$dialog = $this->getHelperSet()->get('dialog');
$password = $dialog->askHiddenResponse($output, '<question>Enter a new password: </question>', false);
$confirm = $dialog->askHiddenResponse($output, '<question>Confirm the new password: </question>', false);
if ($password === $confirm) {
$success = $user->setPassword($password);
if ($success) {
$output->writeln("<info>Successfully reset password for " . $username . "</info>");
} else {
$output->writeln("<error>Error while resetting password!</error>");
return 1;
}
} else {
$output->writeln("<error>Passwords did not match!</error>");
return 1;
}
} else {
$output->writeln("<error>Interactive input is needed for entering a new password!</error>");
return 1;
}
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:31,代码来源:resetpassword.php
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getOption('path');
if ($path) {
$path = '/' . trim($path, '/');
list(, $user, ) = explode('/', $path, 3);
$users = array($user);
} else {
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
}
$quiet = $input->getOption('quiet');
if (count($users) === 0) {
$output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
return;
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
if ($this->userManager->userExists($user)) {
$this->scanFiles($user, $path, $quiet, $output);
} else {
$output->writeln("<error>Unknown user {$user}</error>");
}
}
}
开发者ID:ninjasilicon,项目名称:core,代码行数:30,代码来源:scan.php
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$wasSuccessful = $this->userManager->get($input->getArgument('uid'))->delete();
if ($wasSuccessful === true) {
$output->writeln('The specified user was deleted');
return;
}
$output->writeln('<error>The specified could not be deleted. Please check the logs.</error>');
}
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:9,代码来源:delete.php
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$uid = $input->getArgument('uid');
$user = $this->userManager->get($uid);
if (is_null($user)) {
$output->writeln("<error>Invalid UID</error>");
return;
}
$this->manager->enableTwoFactorAuthentication($user);
$output->writeln("Two-factor authentication enabled for user {$uid}");
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:11,代码来源:Enable.php
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
$this->scanFiles($user, $output);
}
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:14,代码来源:scan.php
示例6: displayNamesInGroup
/**
* get a list of all display names in a group
* @param string $gid
* @param string $search
* @param int $limit
* @param int $offset
* @return array an array of display names (value) and user ids (key)
*/
public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0)
{
$group = $this->get($gid);
if (is_null($group)) {
return array();
}
// only user backends have the capability to do a complex search for users
$groupUsers = $group->searchUsers('', $limit, $offset);
$search = trim($search);
if (!empty($search)) {
//TODO: for OC 7 earliest: user backend should get a method to check selected users against a pattern
$filteredUsers = $this->userManager->search($search);
$testUsers = true;
} else {
$filteredUsers = array();
$testUsers = false;
}
$matchingUsers = array();
foreach ($groupUsers as $user) {
if (!$testUsers || isset($filteredUsers[$user->getUID()])) {
$matchingUsers[$user->getUID()] = $user->getDisplayName();
}
}
return $matchingUsers;
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:33,代码来源:manager.php
示例7: updateCard
public function updateCard($addressBookId, $uid)
{
/**
* @param \Sabre\VObject\Component\VCard $vCard
* @param \OC\User\User $user
*/
$user = $this->userManager->get($uid);
$userId = $user->getUID();
$cardId = md5($userId) . ".vcf";
$card = $this->cardDavBackend->getCard($addressBookId, $cardId);
if (!$card) {
$this->insertCard($addressBookId, $uid);
} else {
$vCard = Reader::read($card['carddata']);
$needsUpdate = $this->converterUser->updateCard($vCard, $user);
if ($needsUpdate) {
$groups = \OC::$server->getGroupManager()->getUserGroups($user);
if ($groups) {
foreach ($groups as $groupName => $groupInfo) {
$vCard->add(new Text($vCard, 'CATEGORIES', $groupName));
}
}
$this->cardDavBackend->updateCard($addressBookId, $cardId, $vCard->serialize());
// $this->cardDavBackend->deleteCard($addressBookId, $cardId);
// $this->insertCard($addressBookId, $uid);
}
}
}
开发者ID:raceface2nd,项目名称:owncollab,代码行数:28,代码来源:projectbook.php
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
if (count($users) === 0) {
$output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>");
return;
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
$this->scanFiles($user, $output);
}
}
开发者ID:Combustible,项目名称:core,代码行数:18,代码来源:scan.php
示例9: getUserGroups
/**
* Get all groups a user belongs to
* @param string $uid Name of the user
* @return array an array of group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
*/
public static function getUserGroups($uid)
{
$user = self::$userManager->get($uid);
if ($user) {
return self::getManager()->getUserGroupIds($user);
} else {
return array();
}
}
开发者ID:olucao,项目名称:owncloud-core,代码行数:17,代码来源:group.php
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
\OC_App::loadApps('authentication');
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
if ($this->userManager->userExists($user)) {
$this->scanFiles($user, $output);
} else {
$output->writeln("<error>Unknown user {$user}</error>");
}
}
}
开发者ID:hjimmy,项目名称:owncloud,代码行数:19,代码来源:scan.php
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$username = $input->getArgument('user');
/** @var $user \OC\User\User */
$user = $this->userManager->get($username);
if (is_null($user)) {
$output->writeln("<error>There is no user called " . $username . "</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');
if (\OCP\App::isEnabled('files_encryption')) {
$output->writeln('<error>Warning: Resetting the password when using encryption will result in data loss!</error>');
if (!$dialog->askConfirmation($output, '<question>Do you want to continue?</question>', true)) {
return 1;
}
}
$password = $dialog->askHiddenResponse($output, '<question>Enter a new password: </question>', false);
$confirm = $dialog->askHiddenResponse($output, '<question>Confirm the new 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 new password!</error>");
return 1;
}
$success = $user->setPassword($password);
if ($success) {
$output->writeln("<info>Successfully reset password for " . $username . "</info>");
} else {
$output->writeln("<error>Error while resetting password!</error>");
return 1;
}
}
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:42,代码来源:resetpassword.php
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$scanner = $this->container['Scanner'];
$scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
$output->writeln("Scanning <info>{$path}</info>");
});
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
\OC_Util::tearDownFS();
\OC_Util::setupFS($user);
$output->writeln("Start scan for <info>{$user}</info>");
$scanner->rescan($user, true);
}
}
开发者ID:hjimmy,项目名称:owncloud,代码行数:21,代码来源:scan.php
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$inputPath = $input->getOption('path');
if ($inputPath) {
$inputPath = '/' . trim($inputPath, '/');
list(, $user, ) = explode('/', $inputPath, 3);
$users = array($user);
} else {
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
}
if (count($users) === 0) {
$output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
return;
}
# no messaging level option means: no full printout but statistics
# $quiet means no print at all
# $verbose means full printout including statistics
# -q -v full stat
# 0 0 no yes
# 0 1 yes yes
# 1 -- no no (quiet overrules verbose)
$verbose = $input->getOption('verbose');
$quiet = $input->getOption('quiet');
# restrict the verbosity level to VERBOSITY_VERBOSE
if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
if ($quiet) {
$verbose = false;
}
$this->initTools();
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
$path = $inputPath ? $inputPath : '/' . $user;
if ($this->userManager->userExists($user)) {
# full: printout data if $verbose was set
$this->scanFiles($user, $path, $verbose, $output);
} else {
$output->writeln("<error>Unknown user {$user}</error>");
}
}
# stat: printout statistics if $quiet was not set
if (!$quiet) {
$this->presentStats($output);
}
}
开发者ID:kenwi,项目名称:core,代码行数:52,代码来源:scan.php
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// perform system reorganization
$migration = new Migration($this->config, $this->view, $this->connection, $this->logger);
$users = $input->getArgument('user_id');
if (!empty($users)) {
foreach ($users as $user) {
if ($this->userManager->userExists($user)) {
$output->writeln("Migrating keys <info>{$user}</info>");
$migration->reorganizeFolderStructureForUser($user);
} else {
$output->writeln("<error>Unknown user {$user}</error>");
}
}
} else {
$output->writeln("Reorganize system folder structure");
$migration->reorganizeSystemFolderStructure();
$migration->updateDB();
foreach ($this->userManager->getBackends() as $backend) {
$name = get_class($backend);
if ($backend instanceof IUserBackend) {
$name = $backend->getBackendName();
}
$output->writeln("Migrating keys for users on backend <info>{$name}</info>");
$limit = 500;
$offset = 0;
do {
$users = $backend->getUsers('', $limit, $offset);
foreach ($users as $user) {
$output->writeln(" <info>{$user}</info>");
$migration->reorganizeFolderStructureForUser($user);
}
$offset += $limit;
} while (count($users) >= $limit);
}
}
$migration->finalCleanUp();
}
开发者ID:kenwi,项目名称:core,代码行数:38,代码来源:migratekeys.php
示例15: generateToken
/**
* Generate a new access token clients can authenticate with
*
* @PublicPage
* @NoCSRFRequired
*
* @param string $user
* @param string $password
* @param string $name the name of the client
* @return JSONResponse
*/
public function generateToken($user, $password, $name = 'unknown client')
{
if (is_null($user) || is_null($password)) {
$response = new JSONResponse();
$response->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY);
return $response;
}
$loginName = $user;
$user = $this->userManager->checkPassword($loginName, $password);
if ($user === false) {
$response = new JSONResponse();
$response->setStatus(Http::STATUS_UNAUTHORIZED);
return $response;
}
if ($this->twoFactorAuthManager->isTwoFactorAuthenticated($user)) {
$resp = new JSONResponse();
$resp->setStatus(Http::STATUS_UNAUTHORIZED);
return $resp;
}
$token = $this->secureRandom->generate(128);
$this->tokenProvider->generateToken($token, $user->getUID(), $loginName, $password, $name, IToken::PERMANENT_TOKEN);
return ['token' => $token];
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:34,代码来源:TokenController.php
示例16: getVerifiedUsers
/**
* returns all the Users from an array that really exists
* @param string[] $userIds an array containing user IDs
* @return \OC\User\User[] an Array with the userId as Key and \OC\User\User as value
*/
private function getVerifiedUsers($userIds)
{
if (!is_array($userIds)) {
return array();
}
$users = array();
foreach ($userIds as $userId) {
$user = $this->userManager->get($userId);
if (!is_null($user)) {
$users[$userId] = $user;
}
}
return $users;
}
开发者ID:loulancn,项目名称:core,代码行数:19,代码来源:group.php
示例17: getUserGroups
/**
* @brief Get all groups a user belongs to
* @param string $uid Name of the user
* @return array with group names
*
* This function fetches all groups a user belongs to. It does not check
* if the user exists at all.
*/
public static function getUserGroups($uid)
{
$user = self::$userManager->get($uid);
if ($user) {
$groups = self::getManager()->getUserGroups($user);
$groupIds = array();
foreach ($groups as $group) {
$groupIds[] = $group->getGID();
}
return $groupIds;
} else {
return array();
}
}
开发者ID:hjimmy,项目名称:owncloud,代码行数:22,代码来源:group.php
示例18: isExcluded
/**
* check if it is a path which is excluded by ownCloud from encryption
*
* @param string $path
* @return boolean
*/
public function isExcluded($path)
{
$normalizedPath = \OC\Files\Filesystem::normalizePath($path);
$root = explode('/', $normalizedPath, 4);
if (count($root) > 1) {
//detect system wide folders
if (in_array($root[1], $this->excludedPaths)) {
return true;
}
// detect user specific folders
if ($this->userManager->userExists($root[1]) && in_array($root[2], $this->excludedPaths)) {
return true;
}
}
return false;
}
开发者ID:samj1912,项目名称:repo,代码行数:22,代码来源:util.php
示例19: getPath
/**
* @param string $token
* @return string Resolved file path of the token
* @throws \Exception In case share could not get properly resolved
*/
private function getPath($token)
{
$linkItem = Share::getShareByToken($token, false);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
// seems to be a valid share
$rootLinkItem = Share::resolveReShare($linkItem);
if (isset($rootLinkItem['uid_owner'])) {
if (!$this->userManager->userExists($rootLinkItem['uid_owner'])) {
throw new \Exception('Owner of the share does not exist anymore');
}
OC_Util::tearDownFS();
OC_Util::setupFS($rootLinkItem['uid_owner']);
$path = Filesystem::getPath($linkItem['file_source']);
if (!empty($path) && Filesystem::isReadable($path)) {
return $path;
}
}
}
throw new \Exception('No file found belonging to file.');
}
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:25,代码来源:sharecontroller.php
示例20: isExcluded
/**
* check if it is a path which is excluded by ownCloud from encryption
*
* @param string $path
* @return boolean
*/
public function isExcluded($path)
{
$normalizedPath = Filesystem::normalizePath($path);
$root = explode('/', $normalizedPath, 4);
if (count($root) > 1) {
// detect alternative key storage root
$rootDir = $this->getKeyStorageRoot();
if ($rootDir !== '' && 0 === strpos(Filesystem::normalizePath($path), Filesystem::normalizePath($rootDir))) {
return true;
}
//detect system wide folders
if (in_array($root[1], $this->excludedPaths)) {
return true;
}
// detect user specific folders
if ($this->userManager->userExists($root[1]) && in_array($root[2], $this->excludedPaths)) {
return true;
}
}
return false;
}
开发者ID:loulancn,项目名称:core,代码行数:27,代码来源:util.php
注:本文中的OC\User\Manager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论