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


PHP View::chroot方法代码示例

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


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

示例1: show

 /**
  * Get the template for a specific activity-event in the activities
  *
  * @param array $activity An array with all the activity data in it
  * @return string
  */
 public function show($activity)
 {
     $tmpl = new Template('activity', 'stream.item');
     $tmpl->assign('formattedDate', $this->dateTimeFormatter->formatDateTime($activity['timestamp']));
     $tmpl->assign('formattedTimestamp', Template::relative_modified_date($activity['timestamp']));
     if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
         // We do not link the subject as we create links for the parameters instead
         $activity['link'] = '';
     }
     $tmpl->assign('event', $activity);
     if ($activity['file']) {
         $this->view->chroot('/' . $activity['affecteduser'] . '/files');
         $exist = $this->view->file_exists($activity['file']);
         $is_dir = $this->view->is_dir($activity['file']);
         $tmpl->assign('previewLink', $this->getPreviewLink($activity['file'], $is_dir));
         // show a preview image if the file still exists
         $mimeType = Files::getMimeType($activity['file']);
         if ($mimeType && !$is_dir && $this->preview->isMimeSupported($mimeType) && $exist) {
             $tmpl->assign('previewImageLink', $this->urlGenerator->linkToRoute('core_ajax_preview', array('file' => $activity['file'], 'x' => 150, 'y' => 150)));
         } else {
             $mimeTypeIcon = Template::mimetype_icon($is_dir ? 'dir' : $mimeType);
             $mimeTypeIcon = substr($mimeTypeIcon, -4) === '.png' ? substr($mimeTypeIcon, 0, -4) . '.svg' : $mimeTypeIcon;
             $tmpl->assign('previewImageLink', $mimeTypeIcon);
             $tmpl->assign('previewLinkIsDir', true);
         }
     }
     return $tmpl->fetchPage();
 }
开发者ID:AARNet,项目名称:activity,代码行数:34,代码来源:display.php

示例2: shareNotificationForOriginalOwners

 /**
  * Add notifications for the owners whose files have been reshared
  *
  * @param string $currentOwner
  * @param string $subject
  * @param string $shareWith
  * @param int $fileSource
  * @param string $itemType
  */
 protected function shareNotificationForOriginalOwners($currentOwner, $subject, $shareWith, $fileSource, $itemType)
 {
     // Get the full path of the current user
     $this->view->chroot('/' . $currentOwner . '/files');
     try {
         $path = $this->view->getPath($fileSource);
     } catch (NotFoundException $e) {
         return;
     }
     /**
      * Get the original owner and his path
      */
     $owner = $this->view->getOwner($path);
     if ($owner !== $currentOwner) {
         $this->reshareNotificationForSharer($owner, $subject, $shareWith, $fileSource, $itemType);
     }
     /**
      * Get the sharee who shared the item with the currentUser
      */
     $this->view->chroot('/' . $currentOwner . '/files');
     $mount = $this->view->getMount($path);
     if (!$mount instanceof IMountPoint) {
         return;
     }
     $storage = $mount->getStorage();
     if (!$storage->instanceOfStorage('OC\\Files\\Storage\\Shared')) {
         return;
     }
     /** @var \OC\Files\Storage\Shared $storage */
     $shareOwner = $storage->getSharedFrom();
     if ($shareOwner === '' || $shareOwner === null || $shareOwner === $owner || $shareOwner === $currentOwner) {
         return;
     }
     $this->reshareNotificationForSharer($shareOwner, $subject, $shareWith, $fileSource, $itemType);
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:44,代码来源:fileshooks.php

示例3: findInfoById

 /**
  * @param string $user
  * @param int $fileId
  * @param string $filePath
  * @return array
  */
 protected function findInfoById($user, $fileId, $filePath)
 {
     $this->view->chroot('/' . $user . '/files');
     $cache = ['path' => $filePath, 'exists' => false, 'is_dir' => false, 'view' => ''];
     $notFound = false;
     try {
         $path = $this->view->getPath($fileId);
         $cache['path'] = $path;
         $cache['is_dir'] = $this->view->is_dir($path);
         $cache['exists'] = true;
     } catch (NotFoundException $e) {
         // The file was not found in the normal view, maybe it is in
         // the trashbin?
         $this->view->chroot('/' . $user . '/files_trashbin');
         try {
             $path = $this->view->getPath($fileId);
             $cache = ['path' => substr($path, strlen('/files')), 'exists' => true, 'is_dir' => $this->view->is_dir($path), 'view' => 'trashbin'];
         } catch (NotFoundException $e) {
             $notFound = true;
         }
     }
     $this->cacheId[$user][$fileId] = $cache;
     if ($notFound) {
         $this->cacheId[$user][$fileId]['path'] = null;
     }
     return $cache;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:33,代码来源:ViewInfoCache.php

示例4: getPreview

 /**
  * @param string $owner
  * @param int $fileId
  * @param string $filePath
  * @return array
  */
 protected function getPreview($owner, $fileId, $filePath)
 {
     $info = $this->infoCache->getInfoById($owner, $fileId, $filePath);
     if (!$info['exists'] || $info['view'] !== '') {
         return $this->getPreviewFromPath($filePath, $info);
     }
     $preview = ['link' => $this->getPreviewLink($info['path'], $info['is_dir'], $info['view']), 'source' => '', 'isMimeTypeIcon' => true];
     // show a preview image if the file still exists
     if ($info['is_dir']) {
         $preview['source'] = $this->getPreviewPathFromMimeType('dir');
     } else {
         $this->view->chroot('/' . $owner . '/files');
         $fileInfo = $this->view->getFileInfo($info['path']);
         if (!$fileInfo instanceof FileInfo) {
             $pathPreview = $this->getPreviewFromPath($filePath, $info);
             $preview['source'] = $pathPreview['source'];
         } else {
             if ($this->preview->isAvailable($fileInfo)) {
                 $preview['isMimeTypeIcon'] = false;
                 $preview['source'] = $this->urlGenerator->linkToRoute('core_ajax_preview', ['file' => $info['path'], 'c' => $this->view->getETag($info['path']), 'x' => 150, 'y' => 150]);
             } else {
                 $preview['source'] = $this->getPreviewPathFromMimeType($fileInfo->getMimetype());
             }
         }
     }
     return $preview;
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:33,代码来源:OCSEndPoint.php

示例5: encryptAll

 /**
  * Encrypt all files in a directory
  * @param string $dirPath the directory whose files will be encrypted
  * @return bool
  * @note Encryption is recursive
  */
 public function encryptAll($dirPath)
 {
     $result = true;
     $found = $this->findEncFiles($dirPath);
     // Disable proxy to prevent file being encrypted twice
     \OC_FileProxy::$enabled = false;
     $versionStatus = \OCP\App::isEnabled('files_versions');
     \OC_App::disable('files_versions');
     $encryptedFiles = array();
     // Encrypt unencrypted files
     foreach ($found['plain'] as $plainFile) {
         //get file info
         $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
         //relative to data/<user>/file
         $relPath = $plainFile['path'];
         //relative to /data
         $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
         // keep timestamp
         $timestamp = $fileInfo['mtime'];
         // Open plain file handle for binary reading
         $plainHandle = $this->view->fopen($rawPath, 'rb');
         // Open enc file handle for binary writing, with same filename as original plain file
         $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
         if (is_resource($encHandle) && is_resource($plainHandle)) {
             // Move plain file to a temporary location
             $size = stream_copy_to_stream($plainHandle, $encHandle);
             fclose($encHandle);
             fclose($plainHandle);
             $fakeRoot = $this->view->getRoot();
             $this->view->chroot('/' . $this->userId . '/files');
             $this->view->rename($relPath . '.part', $relPath);
             // set timestamp
             $this->view->touch($relPath, $timestamp);
             $encSize = $this->view->filesize($relPath);
             $this->view->chroot($fakeRoot);
             // Add the file to the cache
             \OC\Files\Filesystem::putFileInfo($relPath, array('encrypted' => true, 'size' => $encSize, 'unencrypted_size' => $size, 'etag' => $fileInfo['etag']));
             $encryptedFiles[] = $relPath;
         } else {
             \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt ' . $rawPath, \OCP\Util::FATAL);
             $result = false;
         }
     }
     \OC_FileProxy::$enabled = true;
     if ($versionStatus) {
         \OC_App::enable('files_versions');
     }
     $result = $result && $this->encryptVersions($encryptedFiles);
     return $result;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:56,代码来源:util.php

示例6: testFailShareFile

 /**
  * @medium
  */
 function testFailShareFile()
 {
     // login as admin
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1);
     // save file with content
     $cryptedFile = file_put_contents('crypt:///' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename, $this->dataShort);
     // test that data was successfully written
     $this->assertInternalType('int', $cryptedFile);
     // disable encryption proxy to prevent recursive calls
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     // get the file info from previous created file
     $fileInfo = $this->view->getFileInfo('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename);
     // check if we have a valid file info
     $this->assertInstanceOf('\\OC\\Files\\FileInfo', $fileInfo);
     // check if the unencrypted file size is stored
     $this->assertGreaterThan(0, $fileInfo['unencrypted_size']);
     // break users public key
     $this->view->rename(\OCA\Files_Encryption\Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey', \OCA\Files_Encryption\Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup');
     // re-enable the file proxy
     \OC_FileProxy::$enabled = $proxyStatus;
     // share the file
     try {
         \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_ENCRYPTION_SHARE_GROUP1, \OCP\Constants::PERMISSION_ALL);
     } catch (\Exception $e) {
         $this->assertEquals(0, strpos($e->getMessage(), "Following users are not set up for encryption"));
     }
     // login as admin
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1);
     // check if share key for user1 not exists
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey'));
     // disable encryption proxy to prevent recursive calls
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     // break user1 public key
     $this->view->rename(\OCA\Files_Encryption\Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey_backup', \OCA\Files_Encryption\Keymanager::getPublicKeyPath() . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.publicKey');
     // remove share file
     $this->view->unlink('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey');
     // re-enable the file proxy
     \OC_FileProxy::$enabled = $proxyStatus;
     // unshare the file with user1
     \OCP\Share::unshare('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_ENCRYPTION_SHARE_GROUP1);
     // check if share key not exists
     $this->assertFalse($this->view->file_exists('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files_encryption/keys/' . $this->filename . '/' . self::TEST_ENCRYPTION_SHARE_USER3 . '.shareKey'));
     // cleanup
     $this->view->chroot('/' . self::TEST_ENCRYPTION_SHARE_USER1 . '/files/');
     $this->view->unlink($this->filename);
     $this->view->chroot('/');
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:52,代码来源:share.php

示例7: doTestRenameHook

	/**
	 * test rename operation
	 */
	function doTestRenameHook($filename) {
		// check if keys exists
		$this->assertTrue($this->rootView->file_exists(
			'/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/'
			. $filename . '.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));

		$this->assertTrue($this->rootView->file_exists(
			'/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/'
			. $filename . '.key'));

		// make subfolder and sub-subfolder
		$this->rootView->mkdir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder);
		$this->rootView->mkdir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->folder);

		$this->assertTrue($this->rootView->is_dir('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->folder));

		// move the file to the sub-subfolder
		$root = $this->rootView->getRoot();
		$this->rootView->chroot('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/');
		$this->rootView->rename($filename, '/' . $this->folder . '/' . $this->folder . '/' . $filename);
		$this->rootView->chroot($root);

		$this->assertFalse($this->rootView->file_exists('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $filename));
		$this->assertTrue($this->rootView->file_exists('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder . '/' . $this->folder . '/' . $filename));

		// keys should be renamed too
		$this->assertFalse($this->rootView->file_exists(
			'/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/'
			. $filename . '.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));
		$this->assertFalse($this->rootView->file_exists(
			'/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/'
			. $filename . '.key'));

		$this->assertTrue($this->rootView->file_exists(
			'/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/share-keys/' . $this->folder . '/' . $this->folder . '/'
			. $filename . '.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey'));
		$this->assertTrue($this->rootView->file_exists(
			'/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files_encryption/keyfiles/' . $this->folder . '/' . $this->folder . '/'
			. $filename . '.key'));

		// cleanup
		$this->rootView->unlink('/' . self::TEST_ENCRYPTION_HOOKS_USER1 . '/files/' . $this->folder);
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:46,代码来源:hooks.php

示例8: getPreview

 /**
  * @param string $owner
  * @param int $fileId
  * @param string $filePath
  * @return array
  */
 protected function getPreview($owner, $fileId, $filePath)
 {
     $this->view->chroot('/' . $owner . '/files');
     $path = $this->view->getPath($fileId);
     if ($path === null || $path === '' || !$this->view->file_exists($path)) {
         return $this->getPreviewFromPath($filePath);
     }
     $is_dir = $this->view->is_dir($path);
     $preview = ['link' => $this->getPreviewLink($path, $is_dir), 'source' => '', 'isMimeTypeIcon' => true];
     // show a preview image if the file still exists
     if ($is_dir) {
         $preview['source'] = $this->getPreviewPathFromMimeType('dir');
     } else {
         $fileInfo = $this->view->getFileInfo($path);
         if ($this->preview->isAvailable($fileInfo)) {
             $preview['isMimeTypeIcon'] = false;
             $preview['source'] = $this->urlGenerator->linkToRoute('core_ajax_preview', ['file' => $path, 'c' => $this->view->getETag($path), 'x' => 150, 'y' => 150]);
         } else {
             $preview['source'] = $this->getPreviewPathFromMimeType($fileInfo->getMimetype());
         }
     }
     return $preview;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:29,代码来源:activities.php


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