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


PHP CFile::viewByUser方法代码示例

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


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

示例1: sendFile

 /**
  * @param $file
  * @return boolean
  */
 public function sendFile($file)
 {
     /** @var File $file */
     $file = File::loadById($file['extra']['id']);
     if (!$file->canRead($this->storage->getCurrentUserSecurityContext())) {
         throw new CWebDavAccessDeniedException();
     }
     return CFile::viewByUser($file->getFile(), array("force_download" => true));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:13,代码来源:diskstorage.php

示例2: download

 /**
  * Sends file content.
  *
  * The method is invoked by \CRestUtil::METHOD_DOWNLOAD.
  *
  * @param int $id Id of file.
  * @throws AccessException
  * @throws RestException
  * @return void
  */
 protected function download($id)
 {
     /** @var Disk\File $file */
     $file = $this->get($id);
     $fileData = $file->getFile();
     if (!$fileData) {
         throw new RestException('Could not get content of file');
     }
     \CFile::viewByUser($fileData, array('force_download' => true, 'cache_time' => 0, 'attachment_name' => $file->getName()));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:20,代码来源:file.php

示例3: writeFileToResponse

 public static function writeFileToResponse($fileID)
 {
     if (!Loader::includeModule('disk')) {
         return;
     }
     $file = File::loadById($fileID);
     if (!$file) {
         return;
     }
     $fileData = $file->getFile();
     if (!$fileData) {
         return;
     }
     \CFile::viewByUser($fileData, array('force_download' => true, 'cache_time' => 0, 'attachment_name' => $file->getName()));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:15,代码来源:diskmanager.php

示例4: processActionDownload

 protected function processActionDownload($showFile = false, $runResize = false)
 {
     if ($this->externalLink->hasPassword() && !$this->checkPassword()) {
         $this->showAccessDenied();
         return false;
     }
     $file = $this->externalLink->getFile();
     if (!$file) {
         $this->includeComponentTemplate('error');
         return false;
     }
     if (!$this->externalLink->isAutomatic() && !$this->checkDownloadToken($file, $this->request->getQuery('token'))) {
         $this->includeComponentTemplate('error');
         return false;
     }
     $this->externalLink->incrementDownloadCount();
     if ($this->externalLink->isSpecificVersion()) {
         $version = $file->getVersion($this->externalLink->getVersionId());
         if (!$version) {
             $this->includeComponentTemplate('error');
             return false;
         }
         $fileData = $version->getFile();
     } else {
         $fileData = $file->getFile();
     }
     if (!$fileData) {
         $this->includeComponentTemplate('error');
         return false;
     }
     if ($runResize && TypeFile::isImage($fileData['ORIGINAL_NAME'])) {
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $tmpFile = \CFile::resizeImageGet($fileData, array("width" => 255, "height" => 255), BX_RESIZE_IMAGE_EXACT, true, false, true);
         $fileData["FILE_SIZE"] = $tmpFile["size"];
         $fileData["SRC"] = $tmpFile["src"];
     }
     CFile::viewByUser($fileData, array('force_download' => !$showFile, 'attachment_name' => $file->getName()));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:38,代码来源:class.php

示例5: processActionDownloadFile

 protected function processActionDownloadFile()
 {
     $this->checkRequiredGetParams(array('attachedId'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $fileModel = null;
     list($type, $realValue) = FileUserType::detectType($this->request->getQuery('attachedId'));
     if ($type == FileUserType::TYPE_NEW_OBJECT) {
         /** @var File $fileModel */
         $fileModel = File::loadById((int) $realValue, array('STORAGE'));
         if (!$fileModel) {
             $this->errorCollection->add(array(new Error("Could not find file")));
             $this->sendJsonErrorResponse();
         }
         if (!$fileModel->canRead($fileModel->getStorage()->getCurrentUserSecurityContext())) {
             $this->errorCollection->add(array(new Error("Bad permission. Could not read this file")));
             $this->sendJsonErrorResponse();
         }
         $fileName = $fileModel->getName();
         $fileData = $fileModel->getFile();
         if (!$fileData) {
             $this->end();
         }
         $cacheTime = 0;
         $width = $this->request->getQuery('width');
         $height = $this->request->getQuery('height');
         if (TypeFile::isImage($fileData["ORIGINAL_NAME"]) && ($width > 0 || $height > 0)) {
             $signature = $this->request->getQuery('signature');
             if (!$signature) {
                 $this->sendJsonInvalidSignResponse('Empty signature');
             }
             if (!ParameterSigner::validateImageSignature($signature, $fileModel->getId(), $width, $height)) {
                 $this->sendJsonInvalidSignResponse('Invalid signature');
             }
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             $tmpFile = \CFile::resizeImageGet($fileData, array("width" => $width, "height" => $height), $this->request->getQuery('exact') == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true);
             $fileData["FILE_SIZE"] = $tmpFile["size"];
             $fileData["SRC"] = $tmpFile["src"];
             $cacheTime = 86400;
         }
         \CFile::viewByUser($fileData, array("force_download" => false, "cache_time" => $cacheTime, 'attachment_name' => $fileName));
     } else {
         $this->errorCollection->add(array(new Error('Could not find attached object')));
         $this->sendJsonErrorResponse();
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:47,代码来源:controller.php

示例6: elseif

     $componentPage = "section_edit_simple";
 } elseif ($componentPage == "element_upload" && isset($_REQUEST["use_light_view"]) && strToUpper($_REQUEST["use_light_view"]) == "Y") {
     $componentPage = "element_upload_simple";
 } elseif ($componentPage == "sections") {
     $arResult["VARIABLES"]["PATH"] = $ob->_path;
     if (!empty($ob->_path)) {
         $ob->IsDir(array('check_permissions' => false));
         if ($ob->arParams["not_found"]) {
             $ob->SetStatus('404 not found');
         } elseif (!empty($ob->arParams['file_name'])) {
             if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) {
                 /** @var \Bitrix\Disk\File $diskFile */
                 $diskFile = \Bitrix\Disk\File::load(array('XML_ID' => $ob->arParams['element_array']['ID']), array('STORAGE'));
                 if ($diskFile && $diskFile->getStorage()) {
                     if ($diskFile->canRead($diskFile->getStorage()->getCurrentUserSecurityContext())) {
                         CFile::viewByUser($diskFile->getFile(), array("force_download" => false));
                     }
                 }
             }
             $APPLICATION->RestartBuffer();
             $ob->base_GET();
             die;
         }
         if (!empty($needToRedirectPageUrl)) {
             LocalRedirect($needToRedirectPageUrl);
         }
         $arResult["VARIABLES"]["SECTION_ID"] = $ob->arParams["item_id"];
     }
 }
 if ($componentPage == "sections" && strpos($_SERVER["REQUEST_URI"], "dialog=Y") !== false) {
     $componentPage = "sections_dialog";
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例7: processActionDownloadVersion

 protected function processActionDownloadVersion()
 {
     $this->version = $this->file->getVersion($this->versionId);
     if (!$this->version) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOWNLOAD_CONTROLLER_ERROR_COULD_NOT_FIND_VERSION'), self::ERROR_COULD_NOT_FIND_VERSION)));
         $this->sendJsonErrorResponse();
     }
     $fileData = $this->version->getFile();
     \CFile::viewByUser($fileData, array("force_download" => false, 'cache_time' => 0, 'attachment_name' => $this->file->getName()));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:10,代码来源:downloadcontroller.php

示例8: sendFile

 /**
  * @param $file
  * @throws AccessDeniedException
  * @return bool|void
  */
 public function sendFile($file)
 {
     /** @var File $file */
     $file = File::loadById($file['extra']['id']);
     if (!$file->canRead($this->storage->getCurrentUserSecurityContext())) {
         throw new AccessDeniedException();
     }
     /** @noinspection PhpUndefinedClassInspection */
     /** @noinspection PhpVoidFunctionResultUsedInspection */
     return \CFile::viewByUser($file->getFile(), array("force_download" => true));
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:16,代码来源:diskstorage.php

示例9: array

}
if (empty($_REQUEST['objectId'])) {
    return;
}
/** @var File $file */
$file = File::loadById((int) $_REQUEST['objectId'], array('STORAGE'));
if (!$file) {
    return;
}
$securityContext = $file->getStorage()->getCurrentUserSecurityContext();
if (!$file->canRead($securityContext)) {
    return;
}
if (!empty($_GET['download'])) {
    $fileData = $file->getFile();
    \CFile::viewByUser($fileData, array("force_download" => false, 'attachment_name' => $file->getName()));
}
if (CFile::isImage($file->getName())) {
    $icon = 'img.png';
} else {
    $icons = array('pdf' => 'pdf.png', 'doc' => 'doc.png', 'docx' => 'doc.png', 'ppt' => 'ppt.png', 'pptx' => 'ppt.png', 'rar' => 'rar.png', 'xls' => 'xls.png', 'xlsx' => 'xls.png', 'zip' => 'zip.png');
    $ext = strtolower(getFileExtension($file->getName()));
    $icon = isset($icons[$ext]) ? $icons[$ext] : 'blank.png';
}
$arResult['NAME'] = $file->getName();
$arResult['SIZE'] = $file->getSize();
$arResult['CREATE_TIME'] = $file->getCreateTime();
$arResult['DATE_CREATE'] = $file->getUpdateTime();
$arResult['ICON'] = $this->getPath() . '/images/' . $icon;
$arResult['DESCRIPTION'] = '';
$arResult['URL'] = SITE_DIR . "mobile/disk/{$file->getId()}/download" . '/' . mobileDiskPrepareForJson($file->getName());
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php


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