コード例 #1
0
ファイル: util.php プロジェクト: omusico/isle-web-framework
 /**
  * @brief Can be set up
  * @param string $user
  * @return boolean
  * @description configure the initial filesystem based on the configuration
  */
 public static function setupFS($user = '')
 {
     //setting up the filesystem twice can only lead to trouble
     if (self::$fsSetup) {
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // load all filesystem apps before, so no setup-hook gets lost
     if (!isset($RUNTIME_NOAPPS) || !$RUNTIME_NOAPPS) {
         OC_App::loadApps(array('filesystem'));
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     \OC\Files\Filesystem::initMounts();
     if (!self::$rootMounted) {
         \OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Local', array('datadir' => $configDataDirectory), '/');
         self::$rootMounted = true;
     }
     //if we aren't logged in, there is no use to set up the filesystem
     if ($user != "") {
         \OC\Files\Filesystem::addStorageWrapper(function ($mountPoint, $storage) {
             // set up quota for home storages, even for other users
             // which can happen when using sharing
             if ($storage instanceof \OC\Files\Storage\Home) {
                 $user = $storage->getUser()->getUID();
                 $quota = OC_Util::getUserQuota($user);
                 if ($quota !== \OC\Files\SPACE_UNLIMITED) {
                     return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota));
                 }
             }
             return $storage;
         });
         $userDir = '/' . $user . '/files';
         $userRoot = OC_User::getHome($user);
         $userDirectory = $userRoot . '/files';
         if (!is_dir($userDirectory)) {
             mkdir($userDirectory, 0755, true);
             OC_Util::copySkeleton($userDirectory);
         }
         //jail the user into his "home" directory
         \OC\Files\Filesystem::init($user, $userDir);
         $fileOperationProxy = new OC_FileProxy_FileOperations();
         OC_FileProxy::register($fileOperationProxy);
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
     }
     return true;
 }
コード例 #2
0
ファイル: util.php プロジェクト: pinoniq/core
 /**
  * Can be set up
  *
  * @param string $user
  * @return boolean
  * @description configure the initial filesystem based on the configuration
  */
 public static function setupFS($user = '')
 {
     //setting up the filesystem twice can only lead to trouble
     if (self::$fsSetup) {
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // load all filesystem apps before, so no setup-hook gets lost
     OC_App::loadApps(array('filesystem'));
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     //check if we are using an object storage
     $objectStore = OC_Config::getValue('objectstore');
     if (isset($objectStore)) {
         self::initObjectStoreRootFS($objectStore);
     } else {
         self::initLocalStorageRootFS();
     }
     if ($user != '' && !OCP\User::userExists($user)) {
         return false;
     }
     //if we aren't logged in, there is no use to set up the filesystem
     if ($user != "") {
         \OC\Files\Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) {
             // set up quota for home storages, even for other users
             // which can happen when using sharing
             /**
              * @var \OC\Files\Storage\Storage $storage
              */
             if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Home') || $storage->instanceOfStorage('\\OC\\Files\\ObjectStore\\HomeObjectStoreStorage')) {
                 if (is_object($storage->getUser())) {
                     $user = $storage->getUser()->getUID();
                     $quota = OC_Util::getUserQuota($user);
                     if ($quota !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
                         return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota, 'root' => 'files'));
                     }
                 }
             }
             return $storage;
         });
         // copy skeleton for local storage only
         if (!isset($objectStore)) {
             $userRoot = OC_User::getHome($user);
             $userDirectory = $userRoot . '/files';
             if (!is_dir($userDirectory)) {
                 mkdir($userDirectory, 0755, true);
                 OC_Util::copySkeleton($userDirectory);
             }
         }
         $userDir = '/' . $user . '/files';
         //jail the user into his "home" directory
         \OC\Files\Filesystem::init($user, $userDir);
         $fileOperationProxy = new OC_FileProxy_FileOperations();
         OC_FileProxy::register($fileOperationProxy);
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
     }
     return true;
 }
コード例 #3
0
ファイル: server.php プロジェクト: spielhoelle/owncloud
 /**
  * Returns a view to ownCloud's files folder
  *
  * @param string $userId user ID
  * @return \OCP\Files\Folder
  */
 public function getUserFolder($userId = null)
 {
     if ($userId === null) {
         $user = $this->getUserSession()->getUser();
         if (!$user) {
             return null;
         }
         $userId = $user->getUID();
     } else {
         $user = $this->getUserManager()->get($userId);
     }
     \OC\Files\Filesystem::initMountPoints($userId);
     $dir = '/' . $userId;
     $root = $this->getRootFolder();
     $folder = null;
     if (!$root->nodeExists($dir)) {
         $folder = $root->newFolder($dir);
     } else {
         $folder = $root->get($dir);
     }
     $dir = '/files';
     if (!$folder->nodeExists($dir)) {
         $folder = $folder->newFolder($dir);
         \OC_Util::copySkeleton($user, $folder);
     } else {
         $folder = $folder->get($dir);
     }
     return $folder;
 }
コード例 #4
0
ファイル: server.php プロジェクト: Romua1d/core
 /**
  * Returns a view to ownCloud's files folder
  *
  * @param string $userId user ID
  * @return \OCP\Files\Folder
  */
 function getUserFolder($userId = null)
 {
     if ($userId === null) {
         $user = $this->getUserSession()->getUser();
         if (!$user) {
             return null;
         }
         $userId = $user->getUID();
     } else {
         $user = $this->getUserManager()->get($userId);
     }
     $dir = '/' . $userId;
     $root = $this->getRootFolder();
     $folder = null;
     if (!$root->nodeExists($dir)) {
         $folder = $root->newFolder($dir);
     } else {
         $folder = $root->get($dir);
     }
     $dir = '/files';
     if (!$folder->nodeExists($dir)) {
         $folder = $folder->newFolder($dir);
         if (\OCP\App::isEnabled('files_encryption')) {
             // disable encryption proxy to prevent recursive calls
             $proxyStatus = \OC_FileProxy::$enabled;
             \OC_FileProxy::$enabled = false;
         }
         \OC_Util::copySkeleton($user, $folder);
         if (\OCP\App::isEnabled('files_encryption')) {
             // re-enable proxy - our work is done
             \OC_FileProxy::$enabled = $proxyStatus;
         }
     } else {
         $folder = $folder->get($dir);
     }
     return $folder;
 }
コード例 #5
0
ファイル: root.php プロジェクト: evanjt/core
 /**
  * Returns a view to user's files folder
  *
  * @param String $userId user ID
  * @return \OCP\Files\Folder
  */
 public function getUserFolder($userId)
 {
     \OC\Files\Filesystem::initMountPoints($userId);
     $dir = '/' . $userId;
     $folder = null;
     if (!$this->nodeExists($dir)) {
         $folder = $this->newFolder($dir);
     } else {
         $folder = $this->get($dir);
     }
     $dir = '/files';
     if (!$folder->nodeExists($dir)) {
         $folder = $folder->newFolder($dir);
         \OC_Util::copySkeleton($userId, $folder);
     } else {
         $folder = $folder->get($dir);
     }
     return $folder;
 }
コード例 #6
0
ファイル: Root.php プロジェクト: rchicoli/owncloud-core
 /**
  * Returns a view to user's files folder
  *
  * @param String $userId user ID
  * @return \OCP\Files\Folder
  */
 public function getUserFolder($userId)
 {
     \OC\Files\Filesystem::initMountPoints($userId);
     $dir = '/' . $userId;
     $folder = null;
     try {
         $folder = $this->get($dir);
     } catch (NotFoundException $e) {
         $folder = $this->newFolder($dir);
     }
     $dir = '/files';
     try {
         $folder = $folder->get($dir);
     } catch (NotFoundException $e) {
         $folder = $folder->newFolder($dir);
         \OC_Util::copySkeleton($userId, $folder);
     }
     return $folder;
 }