當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OC_Util::setupFS方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:hjimmy,項目名稱:owncloud,代碼行數:33,代碼來源:ampachemiddleware.php

示例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);
     }
 }
開發者ID:DevelopIdeas,項目名稱:music,代碼行數:30,代碼來源:scan.php

示例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());
         }
     }
 }
開發者ID:DOM-Digital-Online-Media,項目名稱:apps,代碼行數:27,代碼來源:OC_Connector_Sabre_OAuth.php

示例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);
 }
開發者ID:CDN-Sparks,項目名稱:owncloud,代碼行數:38,代碼來源:user_ldap.php

示例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;
 }
開發者ID:omusico,項目名稱:isle-web-framework,代碼行數:25,代碼來源:file.php

示例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());
         }
     }
 }
開發者ID:netcon-source,項目名稱:apps,代碼行數:34,代碼來源:oauth.php

示例7: tearDown

 protected function tearDown()
 {
     \OC_User::setIncognitoMode(false);
     // Set old user
     \OC_User::setUserId($this->oldUser);
     \OC_Util::setupFS($this->oldUser);
     parent::tearDown();
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:8,代碼來源:PublicAuthTest.php

示例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));
 }
開發者ID:DaubaKao,項目名稱:owncloud-core,代碼行數:10,代碼來源:hookconnector.php

示例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);
 }
開發者ID:omusico,項目名稱:isle-web-framework,代碼行數:20,代碼來源:auth.php

示例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);
 }
開發者ID:Combustible,項目名稱:core,代碼行數:11,代碼來源:certificatemanager.php

示例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;
 }
開發者ID:olucao,項目名稱:owncloud-core,代碼行數:15,代碼來源:migrate.php

示例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());
 }
開發者ID:heldernl,項目名稱:owncloud8-extended,代碼行數:11,代碼來源:certificatemanager.php

示例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;
 }
開發者ID:stweil,項目名稱:owncloud-core,代碼行數:16,代碼來源:expireversions.php

示例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();
 }
開發者ID:enoch85,項目名稱:owncloud-testserver,代碼行數:11,代碼來源:expire.php

示例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);
 }
開發者ID:heldernl,項目名稱:owncloud8-extended,代碼行數:12,代碼來源:sharecontroller.php


注:本文中的OC_Util::setupFS方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。