本文整理匯總了PHP中OC_Util::setupFS方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Util::setupFS方法的具體用法?PHP OC_Util::setupFS怎麽用?PHP OC_Util::setupFS使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OC_Util
的用法示例。
在下文中一共展示了OC_Util::setupFS方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeController
/**
* This runs all the security checks before a method call. The
* security checks are determined by inspecting the controller method
* annotations
* @param string/Controller $controller the controllername or string
* @param string $methodName the name of the method
* @throws AmpacheException when a security check fails
*/
public function beforeController($controller, $methodName)
{
// get annotations from comments
$annotationReader = new MethodAnnotationReader($controller, $methodName);
$this->isAmpacheCall = $annotationReader->hasAnnotation('AmpacheAPI');
// don't try to authenticate for the handshake request
if ($this->isAmpacheCall && $this->request['action'] !== 'handshake') {
$token = $this->request['auth'];
if ($token !== null && $token !== '') {
$user = $this->mapper->find($token);
if ($user !== false && array_key_exists('user_id', $user)) {
// setup the filesystem for the user - actual login isn't really needed
\OC_Util::setupFS($user['user_id']);
$this->ampacheUser->setUserId($user['user_id']);
return;
}
} else {
// for ping action without token the version information is provided
if ($this->request['action'] === 'ping') {
return;
}
}
throw new AmpacheException('Invalid Login', 401);
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$input->getOption('debug')) {
$this->scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
$output->writeln("Scanning <info>{$path}</info>");
});
}
$inputPath = $input->getOption('path');
$path = false;
if ($inputPath) {
$path = '/' . trim($inputPath, '/');
list(, $user, ) = explode('/', $path, 3);
$users = array($user);
} else {
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
\OC_Util::tearDownFS();
\OC_Util::setupFS($user);
$output->writeln("Start scan for <info>{$user}</info>");
$this->scanner->rescan($user, true, $path ? $path : $this->resolveUserFolder($user), $input->getOption('debug'), $output);
}
}
示例3: 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());
}
}
}
示例4: updateAvatar
/**
* @brief reads jpegPhoto and set is as avatar if available
* @param $uid string ownCloud user name
* @param $dn string the user's LDAP DN
* @return void
*/
private function updateAvatar($uid, $dn)
{
$hasLoggedIn = \OCP\Config::getUserValue($uid, 'user_ldap', 'firstLoginAccomplished', 0);
$lastChecked = \OCP\Config::getUserValue($uid, 'user_ldap', 'lastJpegPhotoLookup', 0);
if ($hasLoggedIn !== '1' || time() - intval($lastChecked) < 86400) {
//update only once a day
return;
}
$avatarImage = $this->getAvatarImage($uid, $dn);
if ($avatarImage === false) {
//not set, nothing left to do;
return;
}
$image = new \OCP\Image();
$image->loadFromBase64(base64_encode($avatarImage));
if (!$image->valid()) {
\OCP\Util::writeLog('user_ldap', 'jpegPhoto data invalid for ' . $dn, \OCP\Util::ERROR);
return;
}
//make sure it is a square and not bigger than 128x128
$size = min(array($image->width(), $image->height(), 128));
if (!$image->centerCrop($size)) {
\OCP\Util::writeLog('user_ldap', 'croping image for avatar failed for ' . $dn, \OCP\Util::ERROR);
return;
}
if (!\OC\Files\Filesystem::$loaded) {
\OC_Util::setupFS($uid);
}
$avatarManager = \OC::$server->getAvatarManager();
$avatar = $avatarManager->getAvatar($uid);
$avatar->set($image);
}
示例5: getByShareToken
public static function getByShareToken($token)
{
$linkItem = \OCP\Share::getShareByToken($token);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
// seems to be a valid share
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
$fileOwner = $rootLinkItem['uid_owner'];
} else {
throw new \Exception('This file was probably unshared');
}
if (!isset($rootLinkItem['path']) && isset($rootLinkItem['file_target'])) {
$rootLinkItem['path'] = 'files/' . $rootLinkItem['file_target'];
}
$file = new File($rootLinkItem['file_source'], array($rootLinkItem));
if (isset($rootLinkItem['uid_owner'])) {
\OC_Util::tearDownFS();
\OC_Util::setupFS($rootLinkItem['uid_owner']);
$file->setOwner($rootLinkItem['uid_owner']);
$file->setPath('/files' . \OC\Files\Filesystem::getPath($linkItem['file_source']));
}
if (isset($linkItem['share_with']) && !empty($linkItem['share_with'])) {
$file->setPasswordProtected(true);
}
return $file;
}
示例6: authenticate
public function authenticate(Sabre_DAV_Server $server, $realm)
{
$config = array("tokenInfoEndpoint" => $this->tokenInfoEndpoint, "throwException" => TRUE, "resourceServerRealm" => $realm);
$authorizationHeader = $server->httpRequest->getHeader('Authorization');
// Apache could prefix environment variables with REDIRECT_ when urls
// are passed through mod_rewrite
if (!$authorizationHeader) {
$authorizationHeader = $server->httpRequest->getRawServerValue('REDIRECT_HTTP_AUTHORIZATION');
}
try {
$resourceServer = new RemoteResourceServer($config);
$resourceServer->verifyAuthorizationHeader($authorizationHeader);
if ($this->useResourceOwnerId) {
// when using the user_id
$this->currentUser = $resourceServer->getResourceOwnerId();
} else {
// when using a (SAML) attribute
$attributes = $resourceServer->getAttributes();
$this->currentUser = $attributes[$this->userIdAttributeName][0];
}
OC_Util::setupFS($this->currentUser);
return true;
} catch (RemoteResourceServerException $e) {
$server->httpResponse->setHeader('WWW-Authenticate', $e->getAuthenticateHeader());
// FIXME: do we need to set the status here explicitly, or does the
// Exception below take care of this?
$server->httpResponse->sendStatus($e->getResponseCode());
if ("403" === $e->getResponseCode()) {
throw new Sabre_DAV_Exception_Forbidden($e->getDescription());
} else {
throw new Sabre_DAV_Exception_NotAuthenticated($e->getDescription());
}
}
}
示例7: tearDown
protected function tearDown()
{
\OC_User::setIncognitoMode(false);
// Set old user
\OC_User::setUserId($this->oldUser);
\OC_Util::setupFS($this->oldUser);
parent::tearDown();
}
示例8: setUp
public function setUp()
{
parent::setUp();
$this->userId = $this->getUniqueID();
$this->createUser($this->userId, 'pass');
$this->registerMount($this->userId, new Temporary(), '/' . $this->userId . '/files/');
\OC_Util::setupFS($this->userId);
$this->view = new View();
$this->root = new Root(Filesystem::getMountManager(), $this->view, \OC::$server->getUserManager()->get($this->userId));
}
示例9: authenticate
/**
* Override function here. We want to cache authentication cookies
* in the syncing client to avoid HTTP-401 roundtrips.
* If the sync client supplies the cookies, then OC_User::isLoggedIn()
* will return true and we can see this WebDAV request as already authenticated,
* even if there are no HTTP Basic Auth headers.
* In other case, just fallback to the parent implementation.
*
* @return bool
*/
public function authenticate(Sabre_DAV_Server $server, $realm)
{
if (OC_User::handleApacheAuth() || OC_User::isLoggedIn()) {
$user = OC_User::getUser();
OC_Util::setupFS($user);
$this->currentUser = $user;
return true;
}
return parent::authenticate($server, $realm);
}
示例10: setUp
function setUp()
{
$this->username = OC_Util::generateRandomBytes(20);
OC_User::createUser($this->username, OC_Util::generateRandomBytes(20));
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($this->username);
$this->user = \OC::$server->getUserManager()->get($this->username);
$this->certificateManager = new CertificateManager($this->user);
}
示例11: generateUser
/**
* Generates a test user and sets up their file system
* @return string the test users id
*/
public function generateUser()
{
$username = uniqid();
\OC_User::createUser($username, 'password');
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($username);
$this->users[] = $username;
return $username;
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->username = $this->getUniqueID('', 20);
OC_User::createUser($this->username, $this->getUniqueID('', 20));
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($this->username);
$this->certificateManager = new CertificateManager($this->username, new \OC\Files\View());
}
示例13: setupFS
/**
* Act on behalf on trash item owner
* @param string $user
* @return boolean
*/
protected function setupFS($user)
{
\OC_Util::tearDownFS();
\OC_Util::setupFS($user);
// Check if this user has a versions directory
$view = new \OC\Files\View('/' . $user);
if (!$view->is_dir('/files_versions')) {
return false;
}
return true;
}
示例14: handle
public function handle()
{
$userManager = \OC::$server->getUserManager();
if (!$userManager->userExists($this->user)) {
// User has been deleted already
return;
}
\OC_Util::setupFS($this->user);
Storage::expire($this->fileName, $this->versionsSize, $this->neededSpace);
\OC_Util::tearDownFS();
}
示例15: tearDown
protected function tearDown()
{
\OC_Util::tearDownFS();
\OC_User::setUserId('');
Filesystem::tearDown();
\OC_User::deleteUser($this->user);
\OC_User::setIncognitoMode(false);
\OC::$server->getSession()->set('public_link_authenticated', '');
// Set old user
\OC_User::setUserId($this->oldUser);
\OC_Util::setupFS($this->oldUser);
}