当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::getOwner方法代码示例

本文整理汇总了PHP中OC\Files\Filesystem::getOwner方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getOwner方法的具体用法?PHP Filesystem::getOwner怎么用?PHP Filesystem::getOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::getOwner方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUidAndFilename

 /**
  * get the UID of the owner of the file and the path to the file relative to
  * owners files folder
  *
  * @param string $filename
  * @return array
  * @throws \OC\User\NoUserException
  */
 public static function getUidAndFilename($filename)
 {
     $uid = Filesystem::getOwner($filename);
     $userManager = \OC::$server->getUserManager();
     // if the user with the UID doesn't exists, e.g. because the UID points
     // to a remote user with a federated cloud ID we use the current logged-in
     // user. We need a valid local user to create the versions
     if (!$userManager->userExists($uid)) {
         $uid = User::getUser();
     }
     Filesystem::initMountPoints($uid);
     if ($uid != User::getUser()) {
         $info = Filesystem::getFileInfo($filename);
         $ownerView = new View('/' . $uid . '/files');
         try {
             $filename = $ownerView->getPath($info['fileid']);
             // make sure that the file name doesn't end with a trailing slash
             // can for example happen single files shared across servers
             $filename = rtrim($filename, '/');
         } catch (NotFoundException $e) {
             $filename = null;
         }
     }
     return [$uid, $filename];
 }
开发者ID:gvde,项目名称:core,代码行数:33,代码来源:storage.php

示例2: correctFolders

 /**
  * Correct the parent folders' ETags for all users shared the file at $target
  *
  * @param string $target
  */
 public static function correctFolders($target)
 {
     $uid = \OCP\User::getUser();
     $uidOwner = \OC\Files\Filesystem::getOwner($target);
     $info = \OC\Files\Filesystem::getFileInfo($target);
     // Correct Shared folders of other users shared with
     $users = \OCP\Share::getUsersItemShared('file', $info['fileid'], $uidOwner, true);
     if (!empty($users)) {
         while (!empty($users)) {
             $reshareUsers = array();
             foreach ($users as $user) {
                 if ($user !== $uidOwner) {
                     $etag = \OC\Files\Filesystem::getETag('');
                     \OCP\Config::setUserValue($user, 'files_sharing', 'etag', $etag);
                     // Look for reshares
                     $reshareUsers = array_merge($reshareUsers, \OCP\Share::getUsersItemShared('file', $info['fileid'], $user, true));
                 }
             }
             $users = $reshareUsers;
         }
         // Correct folders of shared file owner
         $target = substr($target, 8);
         if ($uidOwner !== $uid && ($source = \OC_Share_Backend_File::getSource($target))) {
             \OC\Files\Filesystem::initMountPoints($uidOwner);
             $source = '/' . $uidOwner . '/' . $source['path'];
             \OC\Files\Cache\Updater::correctFolder($source, $info['mtime']);
         }
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:34,代码来源:updater.php

示例3: getUidAndFilename

 public static function getUidAndFilename($filename)
 {
     $uid = \OC\Files\Filesystem::getOwner($filename);
     \OC\Files\Filesystem::initMountPoints($uid);
     if ($uid != \OCP\User::getUser()) {
         $info = \OC\Files\Filesystem::getFileInfo($filename);
         $ownerView = new \OC\Files\View('/' . $uid . '/files');
         $filename = $ownerView->getPath($info['fileid']);
     }
     return array($uid, $filename);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:11,代码来源:versions.php

示例4: getUidAndFilename

 /**
  * @param string $filename
  * @return array
  * @throws \OC\User\NoUserException
  */
 public static function getUidAndFilename($filename)
 {
     $uid = \OC\Files\Filesystem::getOwner($filename);
     \OC\Files\Filesystem::initMountPoints($uid);
     if ($uid != \OCP\User::getUser()) {
         $info = \OC\Files\Filesystem::getFileInfo($filename);
         $ownerView = new \OC\Files\View('/' . $uid . '/files');
         try {
             $filename = $ownerView->getPath($info['fileid']);
         } catch (NotFoundException $e) {
             $filename = null;
         }
     }
     return [$uid, $filename];
 }
开发者ID:DanielTosello,项目名称:owncloud,代码行数:20,代码来源:storage.php

示例5: update

 /**
  * update keyfiles and share keys recursively
  *
  * @param int $fileSource file source id
  */
 private function update($fileSource)
 {
     $path = \OC\Files\Filesystem::getPath($fileSource);
     $info = \OC\Files\Filesystem::getFileInfo($path);
     $owner = \OC\Files\Filesystem::getOwner($path);
     $view = new \OC\Files\View('/' . $owner . '/files');
     $ownerPath = $view->getPath($info->getId());
     $absPath = '/' . $owner . '/files' . $ownerPath;
     $mount = $this->mountManager->find($path);
     $mountPoint = $mount->getMountPoint();
     // if a folder was shared, get a list of all (sub-)folders
     if ($this->view->is_dir($absPath)) {
         $allFiles = $this->util->getAllFiles($absPath, $mountPoint);
     } else {
         $allFiles = array($absPath);
     }
     $encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
     foreach ($allFiles as $path) {
         $usersSharing = $this->file->getAccessList($path);
         $encryptionModule->update($path, $this->uid, $usersSharing);
     }
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:27,代码来源:update.php

示例6: getUidAndFilename

 /**
  * get the UID of the owner of the file and the path to the file relative to
  * owners files folder
  *
  * @param string $filename
  * @return array
  * @throws \OC\User\NoUserException
  */
 public static function getUidAndFilename($filename)
 {
     $uid = Filesystem::getOwner($filename);
     $userManager = \OC::$server->getUserManager();
     // if the user with the UID doesn't exists, e.g. because the UID points
     // to a remote user with a federated cloud ID we use the current logged-in
     // user. We need a valid local user to move the file to the right trash bin
     if (!$userManager->userExists($uid)) {
         $uid = User::getUser();
     }
     Filesystem::initMountPoints($uid);
     if ($uid != User::getUser()) {
         $info = Filesystem::getFileInfo($filename);
         $ownerView = new View('/' . $uid . '/files');
         try {
             $filename = $ownerView->getPath($info['fileid']);
         } catch (NotFoundException $e) {
             $filename = null;
         }
     }
     return [$uid, $filename];
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:30,代码来源:Trashbin.php

示例7: correctFolders

 /**
  * Correct the parent folders' ETags for all users shared the file at $target
  *
  * @param string $target
  */
 public static function correctFolders($target)
 {
     $uid = \OCP\User::getUser();
     $uidOwner = \OC\Files\Filesystem::getOwner($target);
     $info = \OC\Files\Filesystem::getFileInfo($target);
     $checkedUser = array($uidOwner);
     // Correct Shared folders of other users shared with
     $users = \OCP\Share::getUsersItemShared('file', $info['fileid'], $uidOwner, true);
     if (!empty($users)) {
         while (!empty($users)) {
             $reshareUsers = array();
             foreach ($users as $user) {
                 if (!in_array($user, $checkedUser)) {
                     $etag = \OC\Files\Filesystem::getETag('');
                     \OCP\Config::setUserValue($user, 'files_sharing', 'etag', $etag);
                     // Look for reshares
                     $reshareUsers = array_merge($reshareUsers, \OCP\Share::getUsersItemShared('file', $info['fileid'], $user, true));
                     $checkedUser[] = $user;
                 }
             }
             $users = $reshareUsers;
         }
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:29,代码来源:updater.php

示例8: file_delete

 /**
  * @brief Store the delete hook events
  * @param array $params The hook params
  */
 public static function file_delete($params)
 {
     $link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($params['path'])));
     $subject = '%s deleted';
     Data::send('files', $subject, substr($params['path'], 1), '', array(), $params['path'], $link, \OCP\User::getUser(), 2);
     if (substr($params['path'], 0, 8) == '/Shared/') {
         $uidOwner = \OC\Files\Filesystem::getOwner($params['path']);
         $realfile = substr($params['path'], 7);
         $link = \OCP\Util::linkToAbsolute('files', 'index.php', array('dir' => dirname($realfile)));
         $subject = '%s deleted by %s';
         Data::send('files', $subject, array($realfile, \OCP\User::getUser()), '', array(), $realfile, $link, $uidOwner, 7, Data::PRIORITY_HIGH);
     }
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:17,代码来源:hooks.php

示例9: getSharesFromItem

 public static function getSharesFromItem($target)
 {
     $result = array();
     $owner = \OC\Files\Filesystem::getOwner($target);
     \OC\Files\Filesystem::initMountPoints($owner);
     $info = \OC\Files\Filesystem::getFileInfo($target);
     $ownerView = new \OC\Files\View('/' . $owner . '/files');
     if ($owner != \OCP\User::getUser()) {
         $path = $ownerView->getPath($info['fileid']);
     } else {
         $path = $target;
     }
     $ids = array();
     while ($path !== dirname($path)) {
         $info = $ownerView->getFileInfo($path);
         if ($info instanceof \OC\Files\FileInfo) {
             $ids[] = $info['fileid'];
         } else {
             \OCP\Util::writeLog('sharing', 'No fileinfo available for: ' . $path, \OCP\Util::WARN);
         }
         $path = dirname($path);
     }
     if (!empty($ids)) {
         $idList = array_chunk($ids, 99, true);
         foreach ($idList as $subList) {
             $statement = "SELECT `share_with`, `share_type`, `file_target` FROM `*PREFIX*share` WHERE `file_source` IN (" . implode(',', $subList) . ") AND `share_type` IN (0, 1, 2)";
             $query = \OCP\DB::prepare($statement);
             $r = $query->execute();
             $result = array_merge($result, $r->fetchAll());
         }
     }
     return $result;
 }
开发者ID:kenwi,项目名称:core,代码行数:33,代码来源:helper.php

示例10: getSourcePathAndOwner

 /**
  * Return the source
  *
  * @param string $path
  * @return array
  */
 protected function getSourcePathAndOwner($path)
 {
     $uidOwner = Filesystem::getOwner($path);
     if ($uidOwner !== $this->currentUser) {
         Filesystem::initMountPoints($uidOwner);
         $info = Filesystem::getFileInfo($path);
         if ($info !== false) {
             $ownerView = new View('/' . $uidOwner . '/files');
             $path = $ownerView->getPath((int) $info['fileid']);
         }
     }
     return array($path, $uidOwner);
 }
开发者ID:AARNet,项目名称:activity,代码行数:19,代码来源:fileshooks.php

示例11: getOwnerPath

 /**
  * get owner and path relative to data/<owner>/files
  *
  * @param string $path path to file for current user
  * @return array ['owner' => $owner, 'path' => $path]
  * @throw \InvalidArgumentException
  */
 protected function getOwnerPath($path)
 {
     $info = Filesystem::getFileInfo($path);
     $owner = Filesystem::getOwner($path);
     $view = new View('/' . $owner . '/files');
     $path = $view->getPath($info->getId());
     if ($path === null) {
         throw new \InvalidArgumentException('No file found for ' . $info->getId());
     }
     return array($owner, $path);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:18,代码来源:Update.php

示例12: getUidAndFilename

	/**
	 * get file owner and path
	 * @param string $filename
	 * @return string[] with the owner's uid and the owner's path
	 */
	private static function getUidAndFilename($filename) {

		$uid = \OC\Files\Filesystem::getOwner($filename);
		\OC\Files\Filesystem::initMountPoints($uid);

		$filename = (strpos($filename, '/') !== 0) ? '/' . $filename : $filename;
		if ($uid != \OCP\User::getUser()) {
			$info = \OC\Files\Filesystem::getFileInfo($filename);
			if (!$info) {
				return array($uid, '/files' . $filename);
			}
			$ownerView = new \OC\Files\View('/' . $uid . '/files');
			$filename = $ownerView->getPath($info['fileid']);
		}
		return array($uid, '/files' . $filename);
	}
开发者ID:ArcherSys,项目名称:ArcherSysOSCloud7,代码行数:21,代码来源:updater.php

示例13: getSourcePathAndOwner

 /**
  * Return the source
  *
  * @param string $path
  * @return array
  */
 public static function getSourcePathAndOwner($path)
 {
     $uidOwner = \OC\Files\Filesystem::getOwner($path);
     if ($uidOwner != \OCP\User::getUser()) {
         \OC\Files\Filesystem::initMountPoints($uidOwner);
         $info = \OC\Files\Filesystem::getFileInfo($path);
         $ownerView = new \OC\Files\View('/' . $uidOwner . '/files');
         $path = $ownerView->getPath($info['fileid']);
     }
     return array($path, $uidOwner);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:17,代码来源:hooks.php

示例14: setSharedFileKeyfiles

 /**
  * @brief Encrypt keyfile to multiple users
  * @param Session $session
  * @param array $users list of users which should be able to access the file
  * @param string $filePath path of the file to be shared
  * @return bool
  */
 public function setSharedFileKeyfiles(Session $session, array $users, $filePath)
 {
     // Make sure users are capable of sharing
     $filteredUids = $this->filterShareReadyUsers($users);
     // If we're attempting to share to unready users
     if (!empty($filteredUids['unready'])) {
         \OCP\Util::writeLog('Encryption library', 'Sharing to these user(s) failed as they are unready for encryption:"' . print_r($filteredUids['unready'], 1), \OCP\Util::WARN);
         return false;
     }
     // Get public keys for each user, ready for generating sharekeys
     $userPubKeys = Keymanager::getPublicKeys($this->view, $filteredUids['ready']);
     // Note proxy status then disable it
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     // Get the current users's private key for decrypting existing keyfile
     $privateKey = $session->getPrivateKey();
     $fileOwner = \OC\Files\Filesystem::getOwner($filePath);
     // Decrypt keyfile
     $plainKeyfile = $this->decryptKeyfile($filePath, $privateKey);
     // Re-enc keyfile to (additional) sharekeys
     $multiEncKey = Crypt::multiKeyEncrypt($plainKeyfile, $userPubKeys);
     // Save the recrypted key to it's owner's keyfiles directory
     // Save new sharekeys to all necessary user directory
     if (!Keymanager::setFileKey($this->view, $this, $filePath, $multiEncKey['data']) || !Keymanager::setShareKeys($this->view, $this, $filePath, $multiEncKey['keys'])) {
         \OCP\Util::writeLog('Encryption library', 'Keyfiles could not be saved for users sharing ' . $filePath, \OCP\Util::ERROR);
         return false;
     }
     // Return proxy to original status
     \OC_FileProxy::$enabled = $proxyStatus;
     return true;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:38,代码来源:util.php

示例15: shareFiles

 /**
  * Share selected files with selected users
  */
 public function shareFiles()
 {
     $this->prepareUsersForShare();
     $files = array();
     foreach ($this->files as $id) {
         $files[] = $file = $this->files->getById($id)[0];
         $fileOwner = \OC\Files\Filesystem::getOwner($file['path']);
         $sharetype = $file['mimetype'] == 2 ? 'folder' : 'file';
         $sharedWith = \OCP\Share::getUsersItemShared($sharetype, $file['fileid'], $fileOwner, false, true);
         foreach ($this->subscriberToShare as $userid) {
             if (isset($file['fileid']) && is_array($file) && !in_array($userid, $sharedWith) && !($userid == $this->author) && ($fileOwner == $this->author || $file['permissions'] >= 16)) {
                 \OCP\Share::shareItem($sharetype, $file['fileid'], \OCP\Share::SHARE_TYPE_USER, $userid, 1);
             }
         }
     }
     $this->forSend['messagedata']['attachlinks'] = Helper::makeAttachLinks($this->files, $files);
 }
开发者ID:bogolubov,项目名称:owncollab_talks-1,代码行数:20,代码来源:answers.php


注:本文中的OC\Files\Filesystem::getOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。