本文整理汇总了PHP中OC_User::getUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_User::getUsers方法的具体用法?PHP OC_User::getUsers怎么用?PHP OC_User::getUsers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_User
的用法示例。
在下文中一共展示了OC_User::getUsers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: usersInGroup
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0)
{
if ($gid !== self::GroupName) {
return array();
}
return \OC_User::getUsers($search, $limit, $offset);
}
示例2: testGetUsers
public function testGetUsers()
{
$result = \OCA\provisioning_API\Users::getUsers(array());
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$count = $result->getData();
$count = count($count['users']);
$this->assertEquals(count(\OC_User::getUsers()), $count);
$user = $this->generateUsers();
$_GET['search'] = $user;
$result = \OCA\provisioning_API\Users::getUsers(array());
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$data = $result->getData();
$this->assertEquals($user, reset($data['users']));
// Add several users
$this->generateUsers(10);
$this->resetParams();
$_GET['limit'] = 2;
$result = \OCA\provisioning_API\Users::getUsers(array());
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$count = $result->getData();
$count = count($count['users']);
$this->assertEquals(2, $count);
$this->resetParams();
$_GET['limit'] = 1;
$_GET['offset'] = 1;
$result = \OCA\provisioning_API\Users::getUsers(array());
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$data = $result->getData();
$this->assertEquals(\OC_User::getUsers('', 1, 1), $data['users']);
}
示例3: updateChartsForUsers
/**
* Update all charts for all users
*/
public function updateChartsForUsers()
{
$users = \OC_User::getUsers();
foreach ($users as $userName) {
$this->updateChartsForUser($userName);
}
}
示例4: updateUserStorage
/**
* Update the user storage, called from command
*/
public function updateUserStorage()
{
$users = \OC_User::getUsers();
foreach($users as $userName)
{
$this->updateUserStorageByUser($userName);
}
}
示例5: allUsers
/**
* @return User[]
*/
public function allUsers()
{
$users = [];
$systemUsers = \OC_User::getUsers();
foreach ($systemUsers as $uid) {
$users[] = User::named($uid);
}
return $users;
}
示例6: testUpdateChart
/**
* No asserts, but do check on what calls to expect
* @TODO Fix the \OC_User dependency ( also in chartupdaterservice )
*/
public function testUpdateChart()
{
$users = \OC_User::getUsers();
$this->configService->expects($this->exactly(count($users)))->method('getChartsByUsername')->willReturn(array($this->configMock));
$this->dataProvider->expects($this->exactly(count($users)))->method('getChartUsageForUpdate')->willReturn(array('bogusdata'));
$this->dataProvider->expects($this->exactly(count($users)))->method('save')->with($this->configMock, array('bogusdata'));
$this->chartUpdaterService->updateChartsForUsers();
// Nothing to assert... Just for sake of it...
$this->assertTrue(true);
}
示例7: getPrincipalsByPrefix
/**
* Returns a list of principals based on a prefix.
*
* This prefix will often contain something like 'principals'. You are only
* expected to return principals that are in this base path.
*
* You are expected to return at least a 'uri' for every user, you can
* return any additional properties if you wish so. Common properties are:
* {DAV:}displayname
*
* @param string $prefixPath
* @return array
*/
public function getPrincipalsByPrefix($prefixPath)
{
$principals = array();
if ($prefixPath == 'principals') {
foreach (OC_User::getUsers() as $user) {
$user_uri = 'principals/' . $user;
$principals[] = array('uri' => $user_uri, '{DAV:}displayname' => $user);
}
}
return $principals;
}
示例8: getPrincipalsByPrefix
/**
* Returns a list of principals based on a prefix.
*
* This prefix will often contain something like 'principals'. You are only
* expected to return principals that are in this base path.
*
* You are expected to return at least a 'uri' for every user, you can
* return any additional properties if you wish so. Common properties are:
* {DAV:}displayname
*
* @param string $prefixPath
* @return array
*/
public function getPrincipalsByPrefix($prefixPath)
{
$principals = array();
if ($prefixPath == 'principals') {
foreach (OC_User::getUsers() as $user) {
$user_uri = 'principals/' . $user;
$principal = array('uri' => $user_uri, '{DAV:}displayname' => $user);
$email = \OCP\Config::getUserValue($user, 'settings', 'email');
if ($email) {
$principal['{http://sabredav.org/ns}email-address'] = $email;
}
$principals[] = $principal;
}
}
return $principals;
}
示例9: array
}
</script>
<div class="personalblock">
<strong>Neurocloud users public keys</strong>
<?php
/*
$datadir = OC_Config::getValue("datadirectory");
$files = array();
$dh = opendir($datadir);
while ($file = readdir($dh)) {
$files[] = $file;
}
closedir($dh);
*/
$files = OC_User::getUsers();
?>
<select id="select_user" name="user">
<option value="" label="-- select --">-- select --</option>
<?php
foreach ($files as $file) {
?>
<option value="<?php
echo $file;
?>
" label="<?php
echo $file;
?>
"><?php
echo $file;
示例10: sizeof
<?php
use OC\AllConfig;
$uids = OC_User::getUsers();
$config = \OC::$server->getConfig();
$userValue = $config->getUserValueForUsers('core', 'enabled', $uids);
$max = sizeof($uids);
for ($i = 0; $i < $max; $i++) {
$name = $uids[$i];
$userValue[$name] = $userValue[$name] == 'true' || empty($userValue[$name]) ? true : false;
}
$userValue = json_encode($userValue);
echo $userValue;
示例11: array
// }
if ($sharePolicy == 'groups_only') {
$groups = OC_Group::getUserGroups(OC_User::getUser());
} else {
$groups = OC_Group::getGroups();
}
$count = 0;
$users = array();
$limit = 0;
$offset = 0;
while ($count < 4 && count($users) == $limit) {
$limit = 4 - $count;
if ($sharePolicy == 'groups_only') {
$users = OC_Group::usersInGroups($groups, $_GET['search'], $limit, $offset);
} else {
$users = OC_User::getUsers($_GET['search'], $limit, $offset);
}
$offset += $limit;
foreach ($users as $user) {
if ((!isset($_GET['itemShares']) || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) || !in_array($user, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) && $user != OC_User::getUser()) {
$shareWith[] = array('label' => $user, 'value' => array('shareType' => OCP\Share::SHARE_TYPE_USER, 'shareWith' => $user));
$count++;
}
}
}
$count = 0;
foreach ($groups as $group) {
if ($count < 4) {
if (stripos($group, $_GET['search']) !== false && (!isset($_GET['itemShares']) || !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) || !in_array($group, $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]))) {
$shareWith[] = array('label' => $group . ' (group)', 'value' => array('shareType' => OCP\Share::SHARE_TYPE_GROUP, 'shareWith' => $group));
$count++;
示例12: export
/**
* exports a user, or owncloud instance
* @param string $uid user id of user to export if export type is user, defaults to current
* @param string $type type of export, defualts to user
* @param string $path path to zip output folder
* @return string on error, path to zip on success
*/
public static function export($uid = null, $type = 'user', $path = null)
{
$datadir = OC_Config::getValue('datadirectory');
// Validate export type
$types = array('user', 'instance', 'system', 'userfiles');
if (!in_array($type, $types)) {
OC_Log::write('migration', 'Invalid export type', OC_Log::ERROR);
return json_encode(array('success' => false));
}
self::$exporttype = $type;
// Userid?
if (self::$exporttype == 'user') {
// Check user exists
self::$uid = is_null($uid) ? OC_User::getUser() : $uid;
if (!OC_User::userExists(self::$uid)) {
return json_encode(array('success' => false));
}
}
// Calculate zipname
if (self::$exporttype == 'user') {
$zipname = 'oc_export_' . self::$uid . '_' . date("y-m-d_H-i-s") . '.zip';
} else {
$zipname = 'oc_export_' . self::$exporttype . '_' . date("y-m-d_H-i-s") . '.zip';
}
// Calculate path
if (self::$exporttype == 'user') {
self::$zippath = $datadir . '/' . self::$uid . '/' . $zipname;
} else {
if (!is_null($path)) {
// Validate custom path
if (!file_exists($path) || !is_writeable($path)) {
OC_Log::write('migration', 'Path supplied is invalid.', OC_Log::ERROR);
return json_encode(array('success' => false));
}
self::$zippath = $path . $zipname;
} else {
// Default path
self::$zippath = get_temp_dir() . '/' . $zipname;
}
}
// Create the zip object
if (!self::createZip()) {
return json_encode(array('success' => false));
}
// Do the export
self::findProviders();
$exportdata = array();
switch (self::$exporttype) {
case 'user':
// Connect to the db
self::$dbpath = $datadir . '/' . self::$uid . '/migration.db';
if (!self::connectDB()) {
return json_encode(array('success' => false));
}
self::$content = new OC_Migration_Content(self::$zip, self::$migration_database);
// Export the app info
$exportdata = self::exportAppData();
// Add the data dir to the zip
self::$content->addDir(OC_User::getHome(self::$uid), true, '/');
break;
case 'instance':
self::$content = new OC_Migration_Content(self::$zip);
// Creates a zip that is compatable with the import function
$dbfile = tempnam(get_temp_dir(), "owncloud_export_data_");
OC_DB::getDbStructure($dbfile, 'MDB2_SCHEMA_DUMP_ALL');
// Now add in *dbname* and *dbprefix*
$dbexport = file_get_contents($dbfile);
$dbnamestring = "<database>\n\n <name>" . OC_Config::getValue("dbname", "owncloud");
$dbtableprefixstring = "<table>\n\n <name>" . OC_Config::getValue("dbtableprefix", "oc_");
$dbexport = str_replace($dbnamestring, "<database>\n\n <name>*dbname*", $dbexport);
$dbexport = str_replace($dbtableprefixstring, "<table>\n\n <name>*dbprefix*", $dbexport);
// Add the export to the zip
self::$content->addFromString($dbexport, "dbexport.xml");
// Add user data
foreach (OC_User::getUsers() as $user) {
self::$content->addDir(OC_User::getHome($user), true, "/userdata/");
}
break;
case 'userfiles':
self::$content = new OC_Migration_Content(self::$zip);
// Creates a zip with all of the users files
foreach (OC_User::getUsers() as $user) {
self::$content->addDir(OC_User::getHome($user), true, "/");
}
break;
case 'system':
self::$content = new OC_Migration_Content(self::$zip);
// Creates a zip with the owncloud system files
self::$content->addDir(OC::$SERVERROOT . '/', false, '/');
foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) {
self::$content->addDir(OC::$SERVERROOT . '/' . $dir, true, "/");
}
break;
//.........这里部分代码省略.........
示例13: array
* See the COPYING-README file.
*/
OC_Util::checkSubAdminUser();
OC_App::loadApps();
// We have some javascript foo!
OC_Util::addScript('settings', 'users');
OC_Util::addScript('core', 'multiselect');
OC_Util::addScript('core', 'jquery.inview');
OC_Util::addStyle('settings', 'settings');
OC_App::setActiveNavigationEntry('core_users');
$users = array();
$groups = array();
$isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin') ? true : false;
if ($isadmin) {
$accessiblegroups = OC_Group::getGroups();
$accessibleusers = OC_User::getUsers('', 30);
$subadmins = OC_SubAdmin::getAllSubAdmins();
} else {
$accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
$accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
$subadmins = false;
}
foreach ($accessibleusers as $i) {
$users[] = array("name" => $i, "groups" => join(", ", OC_Group::getUserGroups($i)), 'quota' => OC_Preferences::getValue($i, 'files', 'quota', 'default'), 'subadmin' => implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
}
foreach ($accessiblegroups as $i) {
// Do some more work here soon
$groups[] = array("name" => $i);
}
$quotaPreset = OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB');
$quotaPreset = explode(',', $quotaPreset);
示例14: foreach
foreach ($_POST["groups"] as $group) {
if (OC_SubAdmin::isGroupAccessible(OC_User::getUser(), $group)) {
$groups[] = $group;
}
}
if (count($groups) == 0) {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
}
} else {
$groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
}
}
$username = $_POST["username"];
$password = $_POST["password"];
// Does the group exist?
if (in_array($username, OC_User::getUsers())) {
OC_JSON::error(array("data" => array("message" => "User already exists")));
exit;
}
// Return Success story
try {
OC_User::createUser($username, $password);
foreach ($groups as $i) {
if (!OC_Group::groupExists($i)) {
OC_Group::createGroup($i);
}
OC_Group::addToGroup($username, $i);
}
OC_JSON::success(array("data" => array("username" => $username, "groups" => implode(", ", OC_Group::getUserGroups($username)))));
} catch (Exception $exception) {
OC_JSON::error(array("data" => array("message" => $exception->getMessage())));
示例15: getUsedSpaceOverTime
/**
* Get data to build the line chart about last 7 days used space evolution
*/
public static function getUsedSpaceOverTime($time)
{
$return = array();
if (OC_Group::inGroup(OC_User::getUser(), 'admin')) {
foreach (OC_User::getUsers() as $user) {
if (strcmp($time, 'daily') == 0) {
$return[$user] = self::getDataByUserToLineChart($user);
} else {
$return[$user] = self::getDataByUserToHistoChart($user);
}
}
} else {
if (strcmp($time, 'daily') == 0) {
$return[OC_User::getUser()] = self::getDataByUserToLineChart(OC_User::getUser());
} else {
$return[OC_User::getUser()] = self::getDataByUserToHistoChart(OC_User::getUser());
}
}
return $return;
}