本文整理汇总了PHP中OCP\IUserManager类的典型用法代码示例。如果您正苦于以下问题:PHP IUserManager类的具体用法?PHP IUserManager怎么用?PHP IUserManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IUserManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: search
/**
* @param string $pattern which should match within the $searchProperties
* @param array $searchProperties defines the properties within the query pattern should match
* @param array $options - for future use. One should always have options!
* @return array an array of contacts which are arrays of key-value-pairs
*/
public function search($pattern, $searchProperties, $options)
{
$users = array();
if ($pattern == '') {
// Fetch all contacts
$users = $this->userManager->search('');
} else {
foreach ($searchProperties as $property) {
$result = array();
if ($property === 'FN') {
$result = $this->userManager->searchDisplayName($pattern);
} else {
if ($property === 'id') {
$result = $this->userManager->search($pattern);
}
}
if (is_array($result)) {
$users = array_merge($users, $result);
}
}
}
$contacts = array();
foreach ($users as $user) {
$contact = array("id" => $user->getUID(), "FN" => $user->getDisplayname(), "EMAIL" => array(), "IMPP" => array("x-owncloud-handle:" . $user->getUID()));
$contacts[] = $contact;
}
return $contacts;
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:34,代码来源:localaddressbook.php
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->sourceUser = $input->getArgument('source-user');
$this->destinationUser = $input->getArgument('destination-user');
if (!$this->userManager->userExists($this->sourceUser)) {
$output->writeln("<error>Unknown source user {$this->sourceUser}</error>");
return;
}
if (!$this->userManager->userExists($this->destinationUser)) {
$output->writeln("<error>Unknown destination user {$this->destinationUser}</error>");
return;
}
// target user has to be ready
if (!\OC::$server->getEncryptionManager()->isReadyForUser($this->destinationUser)) {
$output->writeln("<error>The target user is not ready to accept files. The user has at least to be logged in once.</error>");
return;
}
$date = date('c');
$this->finalTarget = "{$this->destinationUser}/files/transferred from {$this->sourceUser} on {$date}";
// setup filesystem
Filesystem::initMountPoints($this->sourceUser);
Filesystem::initMountPoints($this->destinationUser);
// analyse source folder
$this->analyse($output);
// collect all the shares
$this->collectUsersShares($output);
// transfer the files
$this->transfer($output);
// restore the shares
$this->restoreShares($output);
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:31,代码来源:TransferOwnership.php
示例3: 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
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->sourceUser = $input->getArgument('source-user');
$this->destinationUser = $input->getArgument('destination-user');
if (!$this->userManager->userExists($this->sourceUser)) {
$output->writeln("<error>Unknown source user {$this->sourceUser}</error>");
return;
}
if (!$this->userManager->userExists($this->destinationUser)) {
$output->writeln("<error>Unknown destination user {$this->destinationUser}</error>");
return;
}
$date = date('c');
$this->finalTarget = "{$this->destinationUser}/files/transferred from {$this->sourceUser} on {$date}";
// setup filesystem
Filesystem::initMountPoints($this->sourceUser);
Filesystem::initMountPoints($this->destinationUser);
// analyse source folder
$this->analyse($output);
// collect all the shares
$this->collectUsersShares($output);
// transfer the files
$this->transfer($output);
// restore the shares
$this->restoreShares($output);
}
开发者ID:ZverAleksey,项目名称:core,代码行数:26,代码来源:transferownership.php
示例5: startMigration
/**
* start migration
*
* @return array
*/
public function startMigration()
{
// allow as long execution on the web server as possible
set_time_limit(0);
try {
$migration = new Migration($this->config, $this->view, $this->connection);
$migration->reorganizeSystemFolderStructure();
$migration->updateDB();
foreach ($this->userManager->getBackends() as $backend) {
$limit = 500;
$offset = 0;
do {
$users = $backend->getUsers('', $limit, $offset);
foreach ($users as $user) {
$migration->reorganizeFolderStructureForUser($user);
}
$offset += $limit;
} while (count($users) >= $limit);
}
$migration->finalCleanUp();
} catch (\Exception $e) {
return array('data' => array('message' => (string) $this->l10n->t('A problem occurred, please check your log files (Error: %s)', [$e->getMessage()])), 'status' => 'error');
}
return array('data' => array('message' => (string) $this->l10n->t('Migration Completed')), 'status' => 'success');
}
开发者ID:africanforest,项目名称:core,代码行数:30,代码来源:encryptioncontroller.php
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$input->getOption('debug')) {
$this->scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
$output->writeln("Scanning <info>{$path}</info>");
});
}
$inputPath = $input->getOption('path');
$path = false;
if ($inputPath) {
$path = '/' . trim($inputPath, '/');
list(, $user, ) = explode('/', $path, 3);
$users = array($user);
} else {
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>");
$this->scanner->rescan($user, true, $path ? $path : $this->resolveUserFolder($user), $input->getOption('debug'), $output);
}
}
开发者ID:DevelopIdeas,项目名称:music,代码行数:30,代码来源:scan.php
示例7: 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
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$users = $input->getArgument('user_id');
if (!empty($users)) {
foreach ($users as $user) {
if ($this->userManager->userExists($user)) {
$output->writeln("Delete versions of <info>{$user}</info>");
$this->deleteVersions($user);
} else {
$output->writeln("<error>Unknown user {$user}</error>");
}
}
} else {
$output->writeln('Delete all versions');
foreach ($this->userManager->getBackends() as $backend) {
$name = get_class($backend);
if ($backend instanceof IUserBackend) {
$name = $backend->getBackendName();
}
$output->writeln("Delete versions 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>");
$this->deleteVersions($user);
}
$offset += $limit;
} while (count($users) >= $limit);
}
}
}
开发者ID:kenwi,项目名称:core,代码行数:33,代码来源:cleanup.php
示例9: 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($user)
{
if (!$this->userManager->userExists($user)) {
throw new \Exception('user does not exist');
}
return new Avatar($this->rootFolder->getUserFolder($user)->getParent(), $this->l);
}
开发者ID:kenwi,项目名称:core,代码行数:14,代码来源:avatarmanager.php
示例10: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$principalBackend = new Principal($this->config, $this->userManager);
$this->backend = new CardDavBackend($this->dbConnection, $principalBackend);
// ensure system addressbook exists
$systemAddressBook = $this->ensureSystemAddressBookExists();
$converter = new Converter();
$output->writeln('Syncing users ...');
$progress = new ProgressBar($output);
$progress->start();
$this->userManager->callForAllUsers(function ($user) use($systemAddressBook, $converter, $progress) {
/** @var IUser $user */
$name = $user->getBackendClassName();
$userId = $user->getUID();
$cardId = "{$name}:{$userId}.vcf";
$card = $this->backend->getCard($systemAddressBook['id'], $cardId);
if ($card === false) {
$vCard = $converter->createCardFromUser($user);
$this->backend->createCard($systemAddressBook['id'], $cardId, $vCard->serialize());
} else {
$vCard = Reader::read($card['carddata']);
if ($converter->updateCard($vCard, $user)) {
$this->backend->updateCard($systemAddressBook['id'], $cardId, $vCard->serialize());
}
}
$progress->advance();
});
$progress->finish();
$output->writeln('');
}
开发者ID:evanjt,项目名称:core,代码行数:34,代码来源:syncsystemaddressbook.php
示例11: testGetAvatarValidUser
public function testGetAvatarValidUser()
{
$this->userManager->expects($this->once())->method('get')->with('validUser')->willReturn(true);
$folder = $this->getMock('\\OCP\\Files\\Folder');
$this->rootFolder->expects($this->once())->method('getUserFolder')->with('validUser')->willReturn($folder);
$folder->expects($this->once())->method('getParent')->will($this->returnSelf());
$this->avatarManager->getAvatar('validUser');
}
开发者ID:farukuzun,项目名称:core-1,代码行数:8,代码来源:avatarmanagertest.php
示例12: testImpersonate
/**
* @dataProvider usersProvider
* @param $query
* @param $uid
*/
public function testImpersonate($query, $uid)
{
$user = $this->getMock('\\OCP\\IUser');
$user->expects($this->once())->method('getUID')->will($this->returnValue($uid));
$this->userManager->expects($this->once())->method('search')->with($query, 1, 0)->will($this->returnValue([$user]));
$this->userSession->expects($this->once())->method('setUser')->with($user);
$this->assertEquals(new JSONResponse(), $this->controller->impersonate($query));
}
开发者ID:AARNet,项目名称:impersonate,代码行数:13,代码来源:settingscontrollertest.php
示例13: 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
示例14: setupFS
/**
* Act on behalf on trash item owner
* @param string $user
* @return boolean
*/
private function setupFS($user)
{
if (!$this->userManager->userExists($user)) {
return false;
}
\OC_Util::tearDownFS();
\OC_Util::setupFS($user);
return true;
}
开发者ID:kenwi,项目名称:core,代码行数:14,代码来源:expireversions.php
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$user = $input->getArgument('user');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <{$user}> in unknown.");
}
$name = $input->getArgument('name');
$this->cardDavBackend->createAddressBook("principals/users/{$user}", $name, []);
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:9,代码来源:createaddressbook.php
示例16: testRunWithUsersAndOffsetAtEndOfUserList
public function testRunWithUsersAndOffsetAtEndOfUserList()
{
$this->config->expects($this->at(0))->method('getAppValue')->with('files', 'cronjob_scan_files', 0)->will($this->returnValue(50));
$this->userManager->expects($this->at(0))->method('search')->with('', 500, 50)->will($this->returnValue([]));
$this->userManager->expects($this->at(1))->method('search')->with('', 500)->will($this->returnValue([]));
$this->config->expects($this->at(1))->method('setAppValue')->with('files', 'cronjob_scan_files', 500);
$this->scanFiles->expects($this->never())->method('runScanner');
$this->invokePrivate($this->scanFiles, 'run', [[]]);
}
开发者ID:gmurayama,项目名称:core,代码行数:9,代码来源:ScanFilesTest.php
示例17: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$user = $input->getArgument('user');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <{$user}> in unknown.");
}
$name = $input->getArgument('name');
$caldav = new CalDavBackend($this->dbConnection);
$caldav->createCalendar("principals/{$user}", $name, []);
}
开发者ID:reverserob,项目名称:core,代码行数:10,代码来源:createcalendar.php
示例18: generateUsers
/**
* Generates a temp user
* @param int $num number of users to generate
* @return IUser[]|Iuser
*/
protected function generateUsers($num = 1)
{
$users = array();
for ($i = 0; $i < $num; $i++) {
$user = $this->userManager->createUser($this->getUniqueID(), 'password');
$this->users[] = $user;
$users[] = $user;
}
return count($users) == 1 ? reset($users) : $users;
}
开发者ID:nem0xff,项目名称:core,代码行数:15,代码来源:testcase.php
示例19: 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
示例20: run
/**
* @inheritdoc
*/
public function run(IOutput $output)
{
$output->startProgress();
$this->userManager->callForAllUsers(function ($user) use($output) {
/** @var IUser $user */
$output->advance(1, $user->getDisplayName());
$this->birthdayService->syncUser($user->getUID());
});
$output->finishProgress();
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:13,代码来源:GenerateBirthdays.php
注:本文中的OCP\IUserManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论