本文整理汇总了PHP中OC_User::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_User::getUser方法的具体用法?PHP OC_User::getUser怎么用?PHP OC_User::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_User
的用法示例。
在下文中一共展示了OC_User::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($global = false)
{
$this->prefix = OC_Util::getInstanceId() . '/';
if (!$global) {
$this->prefix .= OC_User::getUser() . '/';
}
}
示例2: setUp
public function setUp()
{
//clear all proxies and hooks so we can do clean testing
\OC_FileProxy::clearProxies();
\OC_Hook::clear('OC_Filesystem');
//disabled atm
//enable only the encryption hook if needed
//if(OC_App::isEnabled('files_encryption')) {
// OC_FileProxy::register(new OC_FileProxy_Encryption());
//}
//set up temporary storage
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage, array(), '/');
$datadir = str_replace('local::', '', $storage->getId());
$this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
\OC_Config::setValue('cachedirectory', $datadir);
\OC_User::clearBackends();
\OC_User::useBackend(new \OC_User_Dummy());
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
//set up the users dir
$rootView = new \OC\Files\View('');
$rootView->mkdir('/test');
$this->instance = new \OC\Cache\File();
}
示例3: notifyUserDeletion
/**
* Handle user removal from ownCloud
*/
public static function notifyUserDeletion($args)
{
try {
\OCP\DB::beginTransaction();
$query = \OCP\DB::prepare('SELECT `pid`, `title` FROM `*PREFIX*collaboration_project` WHERE `pid` IN
(SELECT DISTINCT(`pid`) FROM `*PREFIX*collaboration_works_on` WHERE `member`=?) AND `completed`=?');
$result = $query->execute(array($args['uid'], false));
$projs = $result->fetchAll();
if (count($projs) != 0) {
$projects = $projs[0]['title'];
$pids = $projs[0]['pid'];
for ($i = 1; $i < count($projs); $i++) {
$projects .= ', ' . $projs[$i]['title'];
$pids .= ' ' . $projs[$i]['pid'];
}
OC_Collaboration_Post::createPost('Member Removed', 'Owncloud member \'' . $args['uid'] . '\' has been removed from owncloud and hence from the project(s) ' . $projects, OC_User::getUser(), NULL, 'Member removal', OC_Collaboration_Project::getMembersWorkingOnProjects(explode(' ', $pids)), true);
}
OC_Collaboration_Project::deleteMemberRole(NULL, $args['uid'], NULL, OC_User::getUser(), true);
OC_Collaboration_Skillset::removeSkillsOfMember($args['uid']);
OC_Collaboration_Post::removePostsByMember($args['uid'], true);
\OCP\DB::commit();
OC_Log::write('collaboration', 'User deletion notification posted.', OCP\Util::INFO);
} catch (\Exception $e) {
OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
return false;
}
}
示例4: __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;
}
示例5: setUp
protected function setUp()
{
$app = new Application();
$this->container = $app->getContainer();
$this->container['AppName'] = 'core';
$this->container['AvatarManager'] = $this->getMockBuilder('OCP\\IAvatarManager')->disableOriginalConstructor()->getMock();
$this->container['Cache'] = $this->getMockBuilder('OC\\Cache\\File')->disableOriginalConstructor()->getMock();
$this->container['L10N'] = $this->getMockBuilder('OCP\\IL10N')->disableOriginalConstructor()->getMock();
$this->container['L10N']->method('t')->will($this->returnArgument(0));
$this->container['UserManager'] = $this->getMockBuilder('OCP\\IUserManager')->disableOriginalConstructor()->getMock();
$this->container['UserSession'] = $this->getMockBuilder('OCP\\IUserSession')->disableOriginalConstructor()->getMock();
$this->container['Request'] = $this->getMockBuilder('OCP\\IRequest')->disableOriginalConstructor()->getMock();
$this->container['UserFolder'] = $this->getMockBuilder('OCP\\Files\\Folder')->disableOriginalConstructor()->getMock();
$this->avatarMock = $this->getMockBuilder('OCP\\IAvatar')->disableOriginalConstructor()->getMock();
$this->userMock = $this->getMockBuilder('OCP\\IUser')->disableOriginalConstructor()->getMock();
$this->avatarController = $this->container['AvatarController'];
// Store current User
$this->oldUser = \OC_User::getUser();
// Create a dummy user
$this->user = $this->getUniqueID('user');
OC::$server->getUserManager()->createUser($this->user, $this->user);
$this->loginAsUser($this->user);
// Configure userMock
$this->userMock->method('getDisplayName')->willReturn($this->user);
$this->userMock->method('getUID')->willReturn($this->user);
$this->container['UserManager']->method('get')->willReturnMap([[$this->user, $this->userMock]]);
$this->container['UserManager']->method('userExists')->willReturnMap([[$this->user, true]]);
$this->container['UserSession']->method('getUser')->willReturn($this->userMock);
}
示例6: 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;
}
示例7: setUp
protected function setUp()
{
parent::setUp();
//clear all proxies and hooks so we can do clean testing
\OC_Hook::clear('OC_Filesystem');
//set up temporary storage
$this->storage = \OC\Files\Filesystem::getStorage('/');
\OC\Files\Filesystem::clearMounts();
$storage = new \OC\Files\Storage\Temporary(array());
\OC\Files\Filesystem::mount($storage, array(), '/');
$datadir = str_replace('local::', '', $storage->getId());
$config = \OC::$server->getConfig();
$this->datadir = $config->getSystemValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
$config->setSystemValue('cachedirectory', $datadir);
\OC_User::clearBackends();
\OC_User::useBackend(new \Test\Util\User\Dummy());
//login
\OC_User::createUser('test', 'test');
$this->user = \OC_User::getUser();
\OC_User::setUserId('test');
//set up the users dir
$this->rootView = new \OC\Files\View('');
$this->rootView->mkdir('/test');
$this->instance = new \OC\Cache\File();
// forces creation of cache folder for subsequent tests
$this->instance->set('hack', 'hack');
}
示例8: setUp
protected function setUp()
{
$app = new Application();
$this->container = $app->getContainer();
$this->container['Config'] = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
$this->container['AppName'] = 'files_sharing';
$this->container['UserSession'] = $this->getMockBuilder('\\OC\\User\\Session')->disableOriginalConstructor()->getMock();
$this->container['URLGenerator'] = $this->getMockBuilder('\\OC\\URLGenerator')->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->container['URLGenerator'];
$this->shareController = $this->container['ShareController'];
// Store current user
$this->oldUser = \OC_User::getUser();
// Create a dummy user
$this->user = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(12, ISecureRandom::CHAR_LOWER);
\OC_User::createUser($this->user, $this->user);
\OC_Util::tearDownFS();
\OC_User::setUserId('');
Filesystem::tearDown();
\OC_User::setUserId($this->user);
\OC_Util::setupFS($this->user);
// Create a dummy shared file
$view = new View('/' . $this->user . '/files');
$view->file_put_contents('file1.txt', 'I am such an awesome shared file!');
$this->token = \OCP\Share::shareItem(Filesystem::getFileInfo('file1.txt')->getType(), Filesystem::getFileInfo('file1.txt')->getId(), \OCP\Share::SHARE_TYPE_LINK, 'IAmPasswordProtected!', 1);
}
示例9: 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);
}
示例10: declineShare
/**
* Decline a remote share
*
* @param array $params contains the shareID 'id' which should be declined
* @return \OC_OCS_Result
*/
public static function declineShare($params)
{
$externalManager = new Manager(\OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), \OC::$server->getHTTPHelper(), \OC_User::getUser());
if ($externalManager->declineShare($params['id'])) {
return new \OC_OCS_Result();
}
return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
}
示例11: getCurrentUser
/**
* Returns information about the currently logged in username.
*
* If nobody is currently logged in, this method should return null.
*
* @return string|null
*/
public function getCurrentUser()
{
$user = OC_User::getUser();
if (!$user) {
return null;
}
return $user;
}
示例12: checkSubAdminUser
/**
* Check if the user is a subadmin, send json error msg if not
*/
public static function checkSubAdminUser()
{
if (!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
$l = OC_L10N::get('lib');
self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error')));
exit;
}
}
示例13: checkSubAdminUser
/**
* Check if the user is a subadmin, send json error msg if not
*/
public static function checkSubAdminUser() {
self::checkLoggedIn();
self::verifyUser();
if(!OC_Group::inGroup(OC_User::getUser(), 'admin') && !OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
$l = OC_L10N::get('lib');
self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
exit();
}
}
示例14: __construct
function __construct()
{
self::$wp_instance = new OC_wordpress();
self::$db_conn = self::$wp_instance->connectdb();
$uid = OC_User::getUser();
if ($uid) {
self::$current_user_blogs = self::$wp_instance->getUserblogsIds($uid);
}
}
示例15: checkAdminUser
/**
* Check if the user is a admin, send json error msg if not
*/
public static function checkAdminUser()
{
self::checkLoggedIn();
if (!OC_Group::inGroup(OC_User::getUser(), 'admin')) {
$l = new OC_L10N('core');
self::error(array('data' => array('message' => $l->t('Authentication error'))));
exit;
}
}