本文整理汇总了PHP中OCP\IUserManager::getBackends方法的典型用法代码示例。如果您正苦于以下问题:PHP IUserManager::getBackends方法的具体用法?PHP IUserManager::getBackends怎么用?PHP IUserManager::getBackends使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\IUserManager
的用法示例。
在下文中一共展示了IUserManager::getBackends方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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');
}
示例3: index
/**
* @NoAdminRequired
*
* @param int $offset
* @param int $limit
* @param string $gid GID to filter for
* @param string $pattern Pattern to search for in the username
* @param string $backend Backend to filter for (class-name)
* @return DataResponse
*
* TODO: Tidy up and write unit tests - code is mainly static method calls
*/
public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '')
{
// FIXME: The JS sends the group '_everyone' instead of no GID for the "all users" group.
if ($gid === '_everyone') {
$gid = '';
}
// Remove backends
if (!empty($backend)) {
$activeBackends = $this->userManager->getBackends();
$this->userManager->clearBackends();
foreach ($activeBackends as $singleActiveBackend) {
if ($backend === get_class($singleActiveBackend)) {
$this->userManager->registerBackend($singleActiveBackend);
break;
}
}
}
$users = [];
if ($this->isAdmin) {
if ($gid !== '') {
$batch = $this->getUsersForUID($this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset));
} else {
$batch = $this->userManager->search($pattern, $limit, $offset);
}
foreach ($batch as $user) {
$users[] = $this->formatUserForIndex($user);
}
} else {
$subAdminOfGroups = $this->groupManager->getSubAdmin()->getSubAdminsGroups($this->userSession->getUser());
// New class returns IGroup[] so convert back
$gids = [];
foreach ($subAdminOfGroups as $group) {
$gids[] = $group->getGID();
}
$subAdminOfGroups = $gids;
// Set the $gid parameter to an empty value if the subadmin has no rights to access a specific group
if ($gid !== '' && !in_array($gid, $subAdminOfGroups)) {
$gid = '';
}
// Batch all groups the user is subadmin of when a group is specified
$batch = [];
if ($gid === '') {
foreach ($subAdminOfGroups as $group) {
$groupUsers = $this->groupManager->displayNamesInGroup($group, $pattern, $limit, $offset);
foreach ($groupUsers as $uid => $displayName) {
$batch[$uid] = $displayName;
}
}
} else {
$batch = $this->groupManager->displayNamesInGroup($gid, $pattern, $limit, $offset);
}
$batch = $this->getUsersForUID($batch);
foreach ($batch as $user) {
// Only add the groups, this user is a subadmin of
$userGroups = array_values(array_intersect($this->groupManager->getUserGroupIds($user), $subAdminOfGroups));
$users[] = $this->formatUserForIndex($user, $userGroups);
}
}
return new DataResponse($users);
}
示例4: createKeyPairs
/**
* create key-pair for every user
*/
protected function createKeyPairs()
{
$this->output->writeln("\n");
$progress = new ProgressBar($this->output);
$progress->setFormat(" %message% \n [%bar%]");
$progress->start();
foreach ($this->userManager->getBackends() as $backend) {
$limit = 500;
$offset = 0;
do {
$users = $backend->getUsers('', $limit, $offset);
foreach ($users as $user) {
if ($this->keyManager->userHasKeys($user) === false) {
$progress->setMessage('Create key-pair for ' . $user);
$progress->advance();
$this->setupUserFS($user);
$password = $this->generateOneTimePassword($user);
$this->userSetup->setupUser($user, $password);
} else {
// users which already have a key-pair will be stored with a
// empty password and filtered out later
$this->userPasswords[$user] = '';
}
}
$offset += $limit;
} while (count($users) >= $limit);
}
$progress->setMessage('Key-pair created for all users');
$progress->finish();
}
示例5: index
/**
* @NoAdminRequired
*
* @param int $offset
* @param int $limit
* @param string $gid GID to filter for
* @param string $pattern Pattern to search for in the username
* @param string $backend Backend to filter for (class-name)
* @return DataResponse
*
* TODO: Tidy up and write unit tests - code is mainly static method calls
*/
public function index($offset = 0, $limit = 10, $gid = '', $pattern = '', $backend = '')
{
// FIXME: The JS sends the group '_everyone' instead of no GID for the "all users" group.
if ($gid === '_everyone') {
$gid = '';
}
// Remove backends
if (!empty($backend)) {
$activeBackends = $this->userManager->getBackends();
$this->userManager->clearBackends();
foreach ($activeBackends as $singleActiveBackend) {
if ($backend === get_class($singleActiveBackend)) {
$this->userManager->registerBackend($singleActiveBackend);
break;
}
}
}
//$users = ($gid !== '') ? Data::readGroupUsers($gid) : Data::readAllUsers();
$users = \OCP\User::getDisplayNames();
ksort($users, SORT_NATURAL | SORT_FLAG_CASE);
//file_put_contents('123.txt',print_r($users,true));
$users = array_diff($users, array(User::getUser()));
$users = array_slice($users, 0);
return new DataResponse(array('data' => $users, 'status' => 'success'));
}
示例6: encryptAllUserFilesWithMasterKey
/**
* encrypt all user files with the master key
*
* @param ProgressBar $progress
*/
protected function encryptAllUserFilesWithMasterKey(ProgressBar $progress)
{
$userNo = 1;
foreach ($this->userManager->getBackends() as $backend) {
$limit = 500;
$offset = 0;
do {
$users = $backend->getUsers('', $limit, $offset);
foreach ($users as $user) {
$userCount = "{$user} ({$userNo})";
$this->encryptUsersFiles($user, $progress, $userCount);
$userNo++;
}
$offset += $limit;
} while (count($users) >= $limit);
}
}
示例7: decryptAllUsersFiles
/**
* iterate over all user and encrypt their files
* @param string $user which users files should be decrypted, default = all users
*/
protected function decryptAllUsersFiles($user = '')
{
$this->output->writeln("\n");
$userList = [];
if (empty($user)) {
$fetchUsersProgress = new ProgressBar($this->output);
$fetchUsersProgress->setFormat(" %message% \n [%bar%]");
$fetchUsersProgress->start();
$fetchUsersProgress->setMessage("Fetch list of users...");
$fetchUsersProgress->advance();
foreach ($this->userManager->getBackends() as $backend) {
$limit = 500;
$offset = 0;
do {
$users = $backend->getUsers('', $limit, $offset);
foreach ($users as $user) {
$userList[] = $user;
}
$offset += $limit;
$fetchUsersProgress->advance();
} while (count($users) >= $limit);
$fetchUsersProgress->setMessage("Fetch list of users... finished");
$fetchUsersProgress->finish();
}
} else {
$userList[] = $user;
}
$this->output->writeln("\n\n");
$progress = new ProgressBar($this->output);
$progress->setFormat(" %message% \n [%bar%]");
$progress->start();
$progress->setMessage("starting to decrypt files...");
$progress->advance();
$numberOfUsers = count($userList);
$userNo = 1;
foreach ($userList as $uid) {
$userCount = "{$uid} ({$userNo} of {$numberOfUsers})";
$this->decryptUsersFiles($uid, $progress, $userCount);
$userNo++;
}
$progress->setMessage("starting to decrypt files... finished");
$progress->finish();
$this->output->writeln("\n\n");
}
示例8: moveUserKeys
/**
* iterate over each user and move the keys to the new storage
*
* @param string $oldRoot
* @param string $newRoot
* @param OutputInterface $output
*/
protected function moveUserKeys($oldRoot, $newRoot, OutputInterface $output)
{
$progress = new ProgressBar($output);
$progress->start();
foreach ($this->userManager->getBackends() as $backend) {
$limit = 500;
$offset = 0;
do {
$users = $backend->getUsers('', $limit, $offset);
foreach ($users as $user) {
$progress->advance();
$this->setupUserFS($user);
$this->moveUserEncryptionFolder($user, $oldRoot, $newRoot);
}
$offset += $limit;
} while (count($users) >= $limit);
}
$progress->finish();
}