Exemple #1
0
 public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0)
 {
     if ($gid !== self::GroupName) {
         return array();
     }
     return \OC_User::getUsers($search, $limit, $offset);
 }
Exemple #2
0
 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']);
 }
 /**
  * Update all charts for all users
  */
 public function updateChartsForUsers()
 {
     $users = \OC_User::getUsers();
     foreach ($users as $userName) {
         $this->updateChartsForUser($userName);
     }
 }
 /**
  * Update the user storage, called from command
  */
 public function updateUserStorage()
 {
     $users = \OC_User::getUsers();
     foreach($users as $userName)
     {
         $this->updateUserStorageByUser($userName);
     }
 }
 /**
  * @return User[]
  */
 public function allUsers()
 {
     $users = [];
     $systemUsers = \OC_User::getUsers();
     foreach ($systemUsers as $uid) {
         $users[] = User::named($uid);
     }
     return $users;
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Exemple #8
0
 /**
  * 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;
 }
Exemple #9
0
}
</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;
<?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;
Exemple #11
0
 // 				}
 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++;
Exemple #12
0
 /**
  * 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;
     }
     if (!($info = self::getExportInfo($exportdata))) {
         return json_encode(array('success' => false));
     }
     // Add the export info json to the export zip
     self::$content->addFromString($info, 'export_info.json');
     if (!self::$content->finish()) {
         return json_encode(array('success' => false));
     }
     return json_encode(array('success' => true, 'data' => self::$zippath));
 }
Exemple #13
0
 * 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);
Exemple #14
0
        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())));
Exemple #15
0
 /**
  * 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;
 }
Exemple #16
0
 /**
  * Get a list of all users
  * @param string $search search pattern
  * @param int|null $limit
  * @param int|null $offset
  * @return array an array of all uids
  */
 public static function getUsers($search = '', $limit = null, $offset = null)
 {
     return \OC_User::getUsers($search, $limit, $offset);
 }
Exemple #17
0
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
require_once '../../lib/base.php';
OC_JSON::callCheck();
OC_JSON::checkSubAdminUser();
if (isset($_GET['offset'])) {
    $offset = $_GET['offset'];
} else {
    $offset = 0;
}
$users = array();
if (OC_Group::inGroup(OC_User::getUser(), 'admin')) {
    $batch = OC_User::getUsers('', 10, $offset);
    foreach ($batch as $user) {
        $users[] = array('name' => $user, 'groups' => join(', ', OC_Group::getUserGroups($user)), 'subadmin' => join(', ', OC_SubAdmin::getSubAdminsGroups($user)), 'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
    }
} else {
    $groups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
    $batch = OC_Group::usersInGroups($groups, '', 10, $offset);
    foreach ($batch as $user) {
        $users[] = array('name' => $user, 'groups' => join(', ', OC_Group::getUserGroups($user)), 'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
    }
}
OC_JSON::success(array('data' => $users));
 * get_disk_usage
 * Created on: May 28, 2013 2:27:56 PM
 * 
 * Copyright 2013 EnginSoft S.p.A.
 * All rights reserved
 */
if (!OC_User::isLoggedIn()) {
    exit;
}
include_once 'neurocloud/lib/common.php';
$table = "homes";
if (isset($_GET["table"])) {
    $table = $_GET["table"];
}
// get the active jobs for all users
foreach (OC_User::getUsers() as $user) {
    if ($table === "homes") {
        $usage = get_disk_usage($user);
        $userquota = OC_Preferences::getValue($user, 'files', 'quota', OC_Appconfig::getValue('files', 'default_quota', '???'));
        if ($usage) {
            ?>
<tr>
                <td><?php 
            echo $user;
            ?>
</td>
                <td><?php 
            echo $usage;
            ?>
</td>
                <td><?php 
/**
 * Copyright (c) 2011, Robin Appelman <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
require_once '../lib/base.php';
OC_Util::checkAdminUser();
// We have some javascript foo!
OC_Util::addScript('settings', 'users');
OC_Util::addScript('core', 'multiselect');
OC_Util::addStyle('settings', 'settings');
OC_App::setActiveNavigationEntry('core_users');
$users = array();
$groups = array();
foreach (OC_User::getUsers() as $i) {
    $users[] = array("name" => $i, "groups" => join(", ", OC_Group::getUserGroups($i)), 'quota' => OC_Preferences::getValue($i, 'files', 'quota', 'default'));
}
foreach (OC_Group::getGroups() 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);
foreach ($quotaPreset as &$preset) {
    $preset = trim($preset);
}
$defaultQuota = OC_Appconfig::getValue('files', 'default_quota', 'none');
$tmpl = new OC_Template("settings", "users", "user");
$tmpl->assign("users", $users);
$tmpl->assign("groups", $groups);
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('files_sharing');
$users = array();
$groups = array();
$self = OCP\USER::getUser();
$users[] = "<optgroup label='Users'>";
$groups[] = "<optgroup label='Groups'>";
if (OCP\Config::getAppValue('files_sharing', 'allowSharingWithEveryone', 'no') == 'yes') {
    $allGroups = OC_Group::getGroups();
    foreach ($allGroups as $group) {
        $groups[] = "<option value='" . $group . "(group)'>" . $group . " (group) </option>";
    }
    $allUsers = OC_User::getUsers();
    foreach ($allUsers as $user) {
        if ($user != $self) {
            $users[] = "<option value='" . $user . "'>" . $user . "</option>";
        }
    }
} else {
    $userGroups = OC_Group::getUserGroups($self);
    foreach ($userGroups as $group) {
        $groupUsers = OC_Group::usersInGroup($group);
        $userCount = 0;
        foreach ($groupUsers as $user) {
            if ($user != $self) {
                $users[] = "<option value='" . $user . "'>" . $user . "</option>";
                $userCount++;
            }
        }
Exemple #21
0
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
set_time_limit(0);
//scanning can take ages
\OCP\JSON::checkLoggedIn();
\OCP\JSON::callCheck();
\OC::$server->getSession()->close();
$force = (isset($_GET['force']) and $_GET['force'] === 'true');
$dir = isset($_GET['dir']) ? (string) $_GET['dir'] : '';
if (isset($_GET['users'])) {
    \OCP\JSON::checkAdminUser();
    if ($_GET['users'] === 'all') {
        $users = OC_User::getUsers();
    } else {
        $users = json_decode($_GET['users']);
    }
} else {
    $users = array(OC_User::getUser());
}
$eventSource = \OC::$server->createEventSource();
$listener = new ScanListener($eventSource);
foreach ($users as $user) {
    $eventSource->send('user', $user);
    $scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection());
    $scanner->listen('\\OC\\Files\\Utils\\Scanner', 'scanFile', array($listener, 'file'));
    $scanner->listen('\\OC\\Files\\Utils\\Scanner', 'scanFolder', array($listener, 'folder'));
    try {
        if ($force) {
	public static function getRooms() {
		$grooms = array();
		$urooms = array();
		$userId = OC_User::getUser();
		$ordering = array();
		// add groups the user contains if more than the user himself is in the room
		foreach (OC_Group::getUserGroups($userId) as $group) {
			if ( count(OC_Group::usersInGroup($group)) > 1 ) {
				$grooms["group:".$group] = array( "type" => "group", "name" => $group );
				/*if ( UC_ROOM_ONLY_MSGS ) { // TODO: option: maybe private msgs only to users in same rooms ?					
				} */
			}
		}
		// if no group exist create default; NEW in 0.2: no default room!
		//if ( empty($grooms) )
		//	$grooms["group:default"] = array( "type" => "group", "name" => "default" );

		// add all other users
		if ( UC_SINGLE_USER_MSG == true ) {
			foreach (OC_User::getUsers() as $user) {
				if ( $userId != $user ) {
					$urooms["user:"******"type" => "user", "name" => $user );
				}
			}
		}
		$rooms = $grooms + $urooms; 
		return $rooms;
	}	
Exemple #23
0
 /**
  * Return all users from the current system
  *
  * @return array
  */
 public function getSystemUsers()
 {
     return \OC_User::getUsers();
 }
Exemple #24
0
 /**
  * returns a list of users
  */
 public static function getUsers($parameters)
 {
     return OC_User::getUsers();
 }