本文整理汇总了PHP中OC_User类的典型用法代码示例。如果您正苦于以下问题:PHP OC_User类的具体用法?PHP OC_User怎么用?PHP OC_User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
$u = new OC_User();
foreach ($this->users as $user) {
$u->deleteUser($user);
}
foreach ($this->tmpfiles as $file) {
\OC_Helper::rmdirr($file);
}
}
示例2: authenticate
public function authenticate(Sabre_DAV_Server $server, $realm)
{
$config = array("introspectionEndpoint" => $this->introspectionEndpoint, "realm" => $realm);
try {
$resourceServer = new RemoteResourceServer($config);
$tokenIntrospection = $resourceServer->verifyRequest(apache_request_headers(), $_GET);
$this->currentUser = $tokenIntrospection->getSub();
OC_User::setUserid($this->currentUser);
OC_Util::setupFS($this->currentUser);
return true;
} catch (RemoteResourceServerException $e) {
switch ($e->getMessage()) {
case "insufficient_entitlement":
case "insufficient_scope":
$server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
throw new Sabre_DAV_Exception_Forbidden($e->getDescription());
case "invalid_request":
throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
case "invalid_token":
case "no_token":
$server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
case "internal_server_error":
throw new Sabre_DAV_Exception($e->getDescription());
}
}
}
示例3: __construct
public function __construct($AppName, IRequest $Request, $CurrentUID, IL10N $L10N)
{
parent::__construct($AppName, $Request);
$this->CurrentUID = $CurrentUID;
$this->L10N = $L10N;
if (strcmp(Config::getSystemValue('dbtype'), 'pgsql') == 0) {
$this->DbType = 1;
}
$this->CanCheckForUpdate = Tools::CanCheckForUpdate();
$this->Settings = new Settings();
$this->Settings->SetKey('WhichDownloader');
$this->WhichDownloader = $this->Settings->GetValue();
$this->WhichDownloader = is_null($this->WhichDownloader) ? 'ARIA2' : $this->WhichDownloader;
$this->Settings->SetKey('AllowProtocolHTTP');
$this->AllowProtocolHTTP = $this->Settings->GetValue();
$this->AllowProtocolHTTP = is_null($this->AllowProtocolHTTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolHTTP, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolFTP');
$this->AllowProtocolFTP = $this->Settings->GetValue();
$this->AllowProtocolFTP = is_null($this->AllowProtocolFTP) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolFTP, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolYT');
$this->AllowProtocolYT = $this->Settings->GetValue();
$this->AllowProtocolYT = is_null($this->AllowProtocolYT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolYT, 'Y') == 0;
$this->Settings->SetKey('AllowProtocolBT');
$this->AllowProtocolBT = $this->Settings->GetValue();
$this->AllowProtocolBT = is_null($this->AllowProtocolBT) || \OC_User::isAdminUser($this->CurrentUID) ? true : strcmp($this->AllowProtocolBT, 'Y') == 0;
}
示例4: register
public function register()
{
$loginRecord = function ($user) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:login success", Util::INFO);
};
$logoutRecord = function () {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('core', "user:" . User::getDisplayName() . " role:" . $this->UserRole . " action:logout success", Util::INFO);
};
$createRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:creates " . $node->getName() . " success", Util::INFO);
};
$deleteRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:deletes " . $node->getName() . " success", Util::INFO);
};
$renameRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:renames " . $node->getName() . " success", Util::INFO);
};
$touchRecord = function ($node) {
$UserRole = \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), "settings", "role", "undefined");
Util::writeLog('activity', "user:" . User::getDisplayName() . " role:" . $UserRole . " action:touches " . $node->getName() . " success", Util::INFO);
};
Util::connectHook('OCP\\Share', 'post_shared', 'OCA\\Activity_Logging\\UserHooks', 'share');
$this->userManager->listen('\\OC\\User', 'postLogin', $loginRecord);
$this->userManager->listen('\\OC\\User', 'logout', $logoutRecord);
$this->UserFolder->listen('\\OC\\Files', 'postCreate', $createRecord);
$this->UserFolder->listen('\\OC\\Files', 'postDelete', $deleteRecord);
$this->UserFolder->listen('\\OC\\Files', 'postRename', $renameRecord);
}
示例5: testBasic
function testBasic()
{
$uid = uniqid();
$this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
OC_User::setUserId($uid);
$calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEquals(count($all), 1);
$this->assertEquals($all[0]['id'], $calId1);
$this->assertEquals($all[0]['displayname'], 'test');
$this->assertEquals($all[0]['uri'], 'test');
$this->assertEquals($uid, $all[0]['userid']);
$calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$this->assertNotEquals($calId1, $calId2);
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEquals(count($all), 2);
$this->assertEquals($all[1]['id'], $calId2);
$this->assertEquals($all[1]['displayname'], 'test');
$this->assertEquals($all[1]['uri'], 'test1');
//$cal1=OC_Calendar_Calendar::find($calId1);
//$this->assertEquals($cal1,$all[0]);
OC_Calendar_Calendar::deleteCalendar($calId1);
OC_Calendar_Calendar::deleteCalendar($calId2);
$this->assertEquals(OC_Calendar_Calendar::allCalendars($uid), array());
}
示例6: tearDownAfterClass
public static function tearDownAfterClass()
{
// cleanup test user
\OC_User::deleteUser(self::TEST_ENCRYPTION_TRASHBIN_USER1);
\OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
parent::tearDownAfterClass();
}
示例7: usersInGroup
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0)
{
if ($gid !== self::GroupName) {
return array();
}
return \OC_User::getUsers($search, $limit, $offset);
}
示例8: getUserLang
/**
* Gets the language of the user, including anonymous
*
* @return The user language
*/
public static function getUserLang()
{
$config = \OC::$server->getConfig();
$lang = \OC_L10N::findLanguage();
$userLang = $config->getUserValue(\OC_User::getUser(), 'core', 'lang', $lang);
return $userLang;
}
示例9: setUp
protected function setUp()
{
parent::setUp();
if (!getenv('RUN_OBJECTSTORE_TESTS')) {
$this->markTestSkipped('objectstore tests are unreliable in some environments');
}
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// create users
$users = array('test');
foreach ($users as $userName) {
$user = \OC::$server->getUserManager()->get($userName);
if ($user !== null) {
$user->delete();
}
\OC::$server->getUserManager()->createUser($userName, $userName);
}
// main test user
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('test');
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
$this->objectStorage = new ObjectStoreToTest($config['arguments']);
$config['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($config);
}
示例10: updateChartsForUsers
/**
* Update all charts for all users
*/
public function updateChartsForUsers()
{
$users = \OC_User::getUsers();
foreach ($users as $userName) {
$this->updateChartsForUser($userName);
}
}
示例11: validateUserPass
/**
* Validates a username and password
*
* This method should return true or false depending on if login
* succeeded.
*
* @param string $username
* @param string $password
*
* @return bool
*/
protected function validateUserPass($username, $password)
{
$linkItem = \OCP\Share::getShareByToken($username, false);
\OC_User::setIncognitoMode(true);
$this->share = $linkItem;
if (!$linkItem) {
return false;
}
// check if the share is password protected
if (isset($linkItem['share_with'])) {
if ($linkItem['share_type'] == \OCP\Share::SHARE_TYPE_LINK) {
// Check Password
$forcePortable = CRYPT_BLOWFISH != 1;
$hasher = new \PasswordHash(8, $forcePortable);
if (!$hasher->CheckPassword($password . $this->config->getSystemValue('passwordsalt', ''), $linkItem['share_with'])) {
return false;
} else {
return true;
}
} else {
return false;
}
} else {
return true;
}
}
示例12: __construct
public function __construct($global = false)
{
$this->prefix = OC_Util::getInstanceId() . '/';
if (!$global) {
$this->prefix .= OC_User::getUser() . '/';
}
}
示例13: __construct
/**
* @brief Constructor.
* @param $app The application identifier e.g. 'contacts' or 'calendar'.
* @param $user The user whos data the object will operate on. This
* parameter should normally be omitted but to make an app able to
* update categories for all users it is made possible to provide it.
* @param $defcategories An array of default categories to be used if none is stored.
*/
public function __construct($app, $user = null, $defcategories = array())
{
$this->app = $app;
$this->user = is_null($user) ? OC_User::getUser() : $user;
$categories = trim(OC_Preferences::getValue($this->user, $app, self::PREF_CATEGORIES_LABEL, ''));
$this->categories = $categories != '' ? unserialize($categories) : $defcategories;
}
示例14: tearDown
protected function tearDown()
{
$result = \OC_User::deleteUser(self::$user);
$this->assertTrue($result);
$this->logout();
parent::tearDown();
}
示例15: testGet
/**
* @dataProvider getData
*/
public function testGet($user, $start, $count, $expected)
{
$_GET['start'] = $start;
$_GET['count'] = $count;
\OC_User::setUserId($user);
$sessionUser = \OC::$server->getUserSession()->getUser();
$this->assertInstanceOf('OCP\\IUser', $sessionUser);
$this->assertEquals($user, $sessionUser->getUID());
$activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
$activityManager->registerExtension(function () {
return new Extension(\OCP\Util::getL10N('activity', 'en'), $this->getMock('\\OCP\\IURLGenerator'));
});
$this->overwriteService('ActivityManager', $activityManager);
$result = \OCA\Activity\Api::get(array('_route' => 'get_cloud_activity'));
$this->restoreService('ActivityManager');
$this->assertEquals(100, $result->getStatusCode());
$data = $result->getData();
$this->assertEquals(sizeof($expected), sizeof($data));
while (!empty($expected)) {
$assertExpected = array_shift($expected);
$assertData = array_shift($data);
foreach ($assertExpected as $key => $value) {
$this->assertArrayHasKey($key, $assertData);
if ($value !== null) {
$this->assertEquals($value, $assertData[$key]);
}
}
}
}