• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Disk\Driver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Bitrix\Disk\Driver的典型用法代码示例。如果您正苦于以下问题:PHP Driver类的具体用法?PHP Driver怎么用?PHP Driver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __construct

 /**
  * Constructor of Externalizer.
  * @param Service\Base $service Service which provides methods for REST.
  * @param \CRestServer $restServer REST server object.
  */
 public function __construct(Service\Base $service, \CRestServer $restServer)
 {
     $this->urlManager = Disk\Driver::getInstance()->getUrlManager();
     $this->host = $this->urlManager->getHostUrl();
     $this->restServer = $restServer;
     $this->service = $service;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:12,代码来源:externalizer.php


示例2: loadData

 private function loadData()
 {
     if (empty($this->arParams['PARAMS']['arUserField'])) {
         return array();
     }
     $userId = $this->getUser()->getId();
     $values = $this->arParams['PARAMS']['arUserField']['VALUE'];
     if (!is_array($this->arParams['PARAMS']['arUserField']['VALUE'])) {
         $values = array($values);
     }
     $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
     $versions = array();
     foreach ($values as $value) {
         $attachedObjectId = (int) $value;
         if ($attachedObjectId <= 0) {
             continue;
         }
         /** @var \Bitrix\Disk\AttachedObject $attachedModel */
         $attachedModel = \Bitrix\Disk\AttachedObject::loadById($attachedObjectId, array('VERSION.OBJECT'));
         if (!$attachedModel) {
             continue;
         }
         $version = $attachedModel->getVersion();
         if (!$version) {
             continue;
         }
         $extension = $version->getExtension();
         $versions[] = array('ID' => $attachedModel->getId(), 'NAME' => $version->getName(), 'CONVERT_EXTENSION' => DocumentHandler::isNeedConvertExtension($extension), 'EDITABLE' => DocumentHandler::isEditable($extension), 'CAN_UPDATE' => $attachedModel->canUpdate($userId), 'FROM_EXTERNAL_SYSTEM' => $version->getObject()->getContentProvider() && $version->getObject()->getCreatedBy() == $userId, 'EXTENSION' => $extension, 'SIZE' => \CFile::formatSize($version->getSize()), 'HISTORY_URL' => $urlManager->getUrlUfController('history', array('attachedId' => $attachedModel->getId())), 'DOWNLOAD_URL' => $urlManager->getUrlUfController('download', array('attachedId' => $attachedModel->getId())), 'COPY_TO_ME_URL' => $urlManager->getUrlUfController('copyTome', array('attachedId' => $attachedModel->getId())), 'VIEW_URL' => $urlManager->getUrlToShowAttachedFileByService($attachedModel->getId(), 'gvdrive'), 'EDIT_URL' => $urlManager->getUrlToStartEditUfFileByService($attachedModel->getId(), 'gdrive'), 'GLOBAL_CONTENT_VERSION' => $version->getGlobalContentVersion(), 'ATTRIBUTES_FOR_VIEWER' => Ui\Viewer::getAttributesByAttachedObject($attachedModel, array('version' => $version->getGlobalContentVersion(), 'canUpdate' => $attachedModel->canUpdate($userId), 'showStorage' => false, 'externalId' => false, 'relativePath' => false)));
     }
     unset($value);
     return $versions;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:32,代码来源:class.php


示例3: getGridData

 private function getGridData($gridId)
 {
     $grid = array('ID' => $gridId);
     $securityContext = $this->storage->getCurrentUserSecurityContext();
     $parameters = array('with' => array('FILE', 'CREATE_USER'), 'filter' => array('IS_EXPIRED' => false, 'OBJECT.STORAGE_ID' => $this->storage->getId(), 'CREATED_BY' => $this->getUser()->getId()));
     $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('OBJECT_ID', 'OBJECT.CREATED_BY'));
     $items = ExternalLink::getModelList($parameters);
     Collection::sortByColumn($items, array('CREATE_TIME' => array(SORT_NUMERIC, SORT_ASC)));
     $urlManager = Driver::getInstance()->getUrlManager();
     $rows = array();
     foreach ($items as $externalLink) {
         /** @var ExternalLink $externalLink */
         $exportData = $externalLink->toArray();
         $nameSpecialChars = htmlspecialcharsbx($externalLink->getFile()->getName());
         $createDateText = htmlspecialcharsbx((string) $externalLink->getCreateTime());
         $columnName = "\n\t\t\t\t<table class=\"bx-disk-object-name\"><tr>\n\t\t\t\t\t\t<td style=\"width: 45px;\"><div data-object-id=\"{$externalLink->getId()}\" class=\"draggable bx-file-icon-container-small bx-disk-file-icon\"></div></td>\n\t\t\t\t\t\t<td><a class=\"bx-disk-folder-title\" id=\"disk_obj_{$externalLink->getId()}\" href=\"\" data-bx-dateModify=\"{$createDateText}\">{$nameSpecialChars}</a></td>\n\t\t\t\t</tr></table>\n\t\t\t";
         $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $externalLink->getCreatedBy()));
         $rows[] = array('data' => $exportData, 'columns' => array('CREATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'UPDATE_TIME' => formatDate('x', $externalLink->getCreateTime()->getTimestamp(), time() + CTimeZone::getOffset()), 'NAME' => $columnName, 'FORMATTED_SIZE' => CFile::formatSize($externalLink->getFile()->getSize()), 'CREATE_USER' => "\n\t\t\t\t\t\t<div class=\"bx-disk-user-link\"><a target='_blank' href=\"{$createdByLink}\" id=\"\">" . htmlspecialcharsbx($externalLink->getCreateUser()->getFormattedName()) . "</a></div>\n\t\t\t\t\t"), 'actions' => array(array("PSEUDO_NAME" => "download", "DEFAULT" => true, "ICONCLASS" => "download", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DOWNLOAD'), "ONCLICK" => "jsUtils.Redirect(arguments, '" . $urlManager->getUrlForDownloadFile($externalLink->getFile()) . "')"), array("PSEUDO_NAME" => "disable_external_link", "ICONCLASS" => "disable_external_link", "TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK'), "SHORT_TEXT" => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_ACT_DISABLE_EXTERNAL_LINK_SHORT'), "ONCLICK" => "BX.Disk['ExternalLinkListClass_{$this->getComponentId()}'].disableExternalLink({$externalLink->getId()}, {$externalLink->getObjectId()})")));
     }
     unset($externalLink);
     $grid['MODE'] = 'list';
     $grid['HEADERS'] = array(array('id' => 'ID', 'name' => 'ID', 'default' => false, 'show_checkbox' => true), array('id' => 'NAME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_NAME'), 'default' => true), array('id' => 'CREATE_TIME', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_TIME'), 'default' => true), array('id' => 'CREATE_USER', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_CREATE_USER'), 'default' => false), array('id' => 'FORMATTED_SIZE', 'name' => Loc::getMessage('DISK_EXTERNAL_LINK_LIST_COLUMN_FORMATTED_SIZE'), 'default' => true));
     $grid['ROWS'] = $rows;
     $grid['ROWS_COUNT'] = count($rows);
     $grid['FOOTER'] = array();
     return $grid;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:27,代码来源:class.php


示例4: AddBlogPost

 public static function AddBlogPost($arFields)
 {
     if (!is_array($_POST)) {
         $_POST = array();
     }
     $_POST = array_merge($_POST, array("apply" => "Y", "decode" => "N"), $arFields);
     $strPathToPost = COption::GetOptionString("socialnetwork", "userblogpost_page", false, SITE_ID);
     $strPathToSmile = COption::GetOptionString("socialnetwork", "smile_page", false, SITE_ID);
     $BlogGroupID = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, SITE_ID);
     $arBlogComponentParams = array("IS_REST" => "Y", "ID" => "new", "PATH_TO_POST" => $strPathToPost, "PATH_TO_SMILE" => $strPathToSmile, "GROUP_ID" => $BlogGroupID, "USER_ID" => $GLOBALS["USER"]->GetID(), "USE_SOCNET" => "Y", "MICROBLOG" => "Y");
     ob_start();
     $result = $GLOBALS["APPLICATION"]->IncludeComponent("bitrix:socialnetwork.blog.post.edit", "", $arBlogComponentParams, false, array("HIDE_ICONS" => "Y"));
     ob_end_clean();
     if (!$result) {
         throw new Exception('Error');
     } else {
         if (isset($arFields["FILES"]) && \Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk') && ($storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($GLOBALS["USER"]->GetID())) && ($folder = $storage->getFolderForUploadedFiles($GLOBALS["USER"]->GetID()))) {
             // upload to storage
             $arResultFile = array();
             foreach ($arFields["FILES"] as $tmp) {
                 $arFile = CRestUtil::saveFile($tmp);
                 if (is_array($arFile)) {
                     $file = $folder->uploadFile($arFile, array('NAME' => $arFile["name"], 'CREATED_BY' => $GLOBALS["USER"]->GetID()), array(), true);
                     if ($file) {
                         $arResultFile[] = \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX . $file->getId();
                     }
                 }
             }
             if (!empty($arResultFile)) {
                 CBlogPost::Update($result, array("HAS_PROPS" => "Y", "UF_BLOG_POST_FILE" => $arResultFile));
             }
         }
         return $result;
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:35,代码来源:rest.php


示例5: needProxyToDiskByDocType

 private static function needProxyToDiskByDocType($documentType)
 {
     if (!(\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk'))) {
         return false;
     }
     if (empty($documentType)) {
         return false;
     }
     $storage = null;
     if (substr($documentType, 0, 7) == 'STORAGE') {
         $storageId = (int) substr($documentType, 8);
         if ($storageId) {
             $storage = \Bitrix\Disk\Storage::loadById($storageId);
         }
         if ($storage) {
             return $storage;
         }
     }
     list(, $iblockId, $typeLib, $entityId) = explode('_', $documentType);
     if ($typeLib == 'user') {
         $storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($entityId);
     } elseif ($typeLib == 'group') {
         $storage = \Bitrix\Disk\Driver::getInstance()->getStorageByGroupId($entityId);
     } else {
         return false;
     }
     return $storage;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:28,代码来源:iblocksocnetbizproc.php


示例6: uploadFile

 protected static function uploadFile($name, $content, array $parameters = array())
 {
     static::includeDisk();
     $storage = Driver::getInstance()->getStorageByUserId($parameters['USER_ID']);
     if (!$storage) {
         throw new RestException("Could not find storage for user '" . $parameters['USER_ID'] . "'.", RestException::ERROR_NOT_FOUND);
     }
     $folder = $storage->getFolderForUploadedFiles();
     if (!$folder) {
         return false;
     }
     $securityContext = $storage->getCurrentUserSecurityContext();
     if (!$folder->canAdd($securityContext)) {
         throw new AccessException();
     }
     $fileData = \CRestUtil::saveFile($content);
     if (!$fileData) {
         throw new RestException('Could not save file');
     }
     $file = $folder->uploadFile($fileData, array('NAME' => $name, 'CREATED_BY' => $parameters['USER_ID']), array(), true);
     if (!$file) {
         //$folder->getErrors();
         throw new RestException("Could not upload file to the storage");
     }
     return $file->getId();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:26,代码来源:attachment.php


示例7: getDocument

 public static function getDocument($documentId)
 {
     $documentId = (int) $documentId;
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $file = File::loadById($documentId);
     if (!$file) {
         return null;
     }
     $ufFields = Driver::getInstance()->getUserFieldManager()->getFieldsForObject($file);
     $ufFileRow = array();
     if (!empty($ufFields)) {
         foreach ($ufFields as $fieldKey => $fieldData) {
             $ufFileRow[$fieldKey] = $fieldData['VALUE'];
             $ufFileRow[$fieldData['XML_ID']] = $fieldData['VALUE'];
         }
     }
     $fileRow = File::getList(array('with' => array('CREATE_USER', 'UPDATE_USER', 'DELETE_USER'), 'filter' => array('ID' => $documentId)))->fetch();
     if (!$fileRow) {
         return null;
     }
     if (empty($fileRow["CODE"])) {
         $fileRow["CODE"] = Loc::getMessage("DISK_BZ_D_NAME_NOT_CODE");
     }
     return array_merge(array("ID" => $fileRow["ID"], "CREATE_TIME" => $fileRow["CREATE_TIME"], "CREATED_BY" => $fileRow["CREATED_BY"], "CREATED_BY_PRINTABLE" => $fileRow['CREATE_USERREF_NAME'] . ' ' . $fileRow['CREATE_USERREF_LAST_NAME'], "UPDATE_TIME" => $fileRow["UPDATE_TIME"], "UPDATED_BY" => $fileRow["UPDATED_BY"], "UPDATED_BY_PRINTABLE" => $fileRow['UPDATE_USERREF_NAME'] . ' ' . $fileRow['UPDATE_USERREF_LAST_NAME'], "DELETE_TIME" => $fileRow["DELETE_TIME"], "DELETED_BY" => $fileRow["DELETED_BY"], "DELETED_BY_PRINTABLE" => $fileRow['DELETE_USERREF_NAME'] . ' ' . $fileRow['DELETE_USERREF_LAST_NAME'], "STORAGE_ID" => $fileRow["STORAGE_ID"], "NAME" => $fileRow["NAME"], "SIZE" => $fileRow["SIZE"], "CODE" => $fileRow["CODE"], "TIMESTAMP_X" => $fileRow["UPDATE_TIME"], "MODIFIED_BY" => $fileRow["CREATED_BY"], "MODIFIED_BY_PRINTABLE" => $fileRow['UPDATE_USERREF_NAME'] . ' ' . $fileRow['UPDATE_USERREF_LAST_NAME'], "DATE_CREATE" => $fileRow["CREATE_TIME"], "FILE_SIZE" => $fileRow["SIZE"]), $ufFileRow);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:27,代码来源:bizprocdocumentcompatible.php


示例8: __wd_get_root_section

 function __wd_get_root_section($IBLOCK_ID, $object, $object_id)
 {
     $result = CIBlockWebdavSocnet::GetSectionID($IBLOCK_ID, $object, $object_id);
     if (intval($result) > 0) {
         return $result;
     } else {
         __wd_check_uf_use_bp_property($arParams["IBLOCK_ID"]);
         $arFields = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N");
         if ($object == "user") {
             $dbUser = CUser::GetByID($object_id);
             $arUser = $dbUser->Fetch();
             $arFields["NAME"] = trim($arUser['LAST_NAME'] . " " . $arUser['FIRST_NAME']);
             $arFields["NAME"] = trim(!empty($arFields["NAME"]) ? $arFields["NAME"] : $arUser['LOGIN']);
             $arFields['CREATED_BY'] = $arUser['ID'];
             $arFields['MODIFIED_BY'] = $arUser['ID'];
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $arTasks = CWebDavIblock::GetTasks();
                 $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'U' . $object_id, 'TASK_ID' => $arTasks['X']));
             }
         } else {
             /*		$res = CSocNetGroup::GetByID($arResult["VARIABLES"]["group_id"]);
             				if (!$res)
             				{
             					$arParams["ERROR_MESSAGE"] = GetMessage("SONET_GROUP_NOT_EXISTS");
             					return 0;
             				} */
             $arFields["SOCNET_GROUP_ID"] = $object_id;
             //$arGroup = CSocNetGroup::GetByID($object_id);
             $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $object_id;
             $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $object_id), false, false, array("ID", "SITE_ID", "NAME"));
             if ($arGroup = $dbGroup->Fetch()) {
                 $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"];
             }
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $arTasks = CWebDavIblock::GetTasks();
                 $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_A', 'TASK_ID' => $arTasks['X']), 'n1' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_E', 'TASK_ID' => $arTasks['W']), 'n2' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_K', 'TASK_ID' => $arTasks['W']));
             }
         }
         if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) {
             \Bitrix\Disk\Driver::getInstance()->addGroupStorage($arFields["SOCNET_GROUP_ID"]);
         }
         $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"];
         $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $IBLOCK_ID . "_SECTION", $arFields);
         $bs = new CIBlockSection();
         $sectionID = $bs->Add($arFields);
         if (!$sectionID) {
             $arParams["ERROR_MESSAGE"] = $bs->LAST_ERROR;
             return 0;
         }
         WDClearComponentCache(array("webdav.element.edit", "webdav.element.hist", "webdav.element.upload", "webdav.element.view", "webdav.menu", "webdav.section.edit", "webdav.section.list"));
         return true;
         /*
         	if ($ob->workflow == 'bizproc')
         	{
         		__wd_create_default_bp_user_and_groups($arBizProcParameters);
         	}
         */
     }
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:59,代码来源:webdav_settings.php


示例9: preloadOperationsForChildren

 public function preloadOperationsForChildren($parentObjectId)
 {
     $rightsManager = Driver::getInstance()->getRightsManager();
     foreach ($rightsManager->getUserOperationsForChildren($parentObjectId, $this->userId) as $objectId => $operations) {
         $this->operationsCache[$objectId] = $operations;
     }
     unset($operations);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:8,代码来源:disksecuritycontext.php


示例10: buildByAttachedObject

 /**
  * @param AttachedObject $attachedObject
  * @return static
  * @throws \Bitrix\Main\SystemException
  */
 public static function buildByAttachedObject(AttachedObject $attachedObject)
 {
     /** @var Entry $cloudImport */
     $cloudImport = $attachedObject->getObject()->getLastCloudImportEntry();
     $documentHandler = Driver::getInstance()->getDocumentHandlersManager()->getHandlerByCode($cloudImport->getService());
     if (!$documentHandler) {
         return null;
     }
     return new static($documentHandler);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:15,代码来源:importmanager.php


示例11: getTasks

 /**
  * Returns tasks by module Disk.
  * @return array
  */
 protected function getTasks()
 {
     $rightsManager = Driver::getInstance()->getRightsManager();
     $tasks = array($rightsManager->getTaskById($rightsManager->getTaskIdByName($rightsManager::TASK_FULL)), $rightsManager->getTaskById($rightsManager->getTaskIdByName($rightsManager::TASK_EDIT)), $rightsManager->getTaskById($rightsManager->getTaskIdByName($rightsManager::TASK_READ)));
     foreach ($tasks as &$task) {
         $task = array_intersect_key($task, array('ID' => true, 'NAME' => true, 'TITLE' => true));
     }
     unset($task);
     return $tasks;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:14,代码来源:rights.php


示例12: onRestAppDelete

 /**
  * Deletes application storage.
  * @param array $fields Fields describes application.
  * @return void
  */
 public static function onRestAppDelete(array $fields)
 {
     if (empty($fields['APP_ID']) || empty($fields['CLEAN'])) {
         return;
     }
     $storage = Driver::getInstance()->getStorageByRestApp($fields['APP_ID']);
     if (!$storage) {
         return;
     }
     $storage->delete(SystemUser::SYSTEM_USER_ID);
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:16,代码来源:restmanager.php


示例13: processActionDefault

 protected function processActionDefault()
 {
     $validPassword = true;
     if ($this->externalLink->hasPassword()) {
         $validPassword = $this->checkPassword();
     }
     $file = $this->externalLink->getFile();
     $downloadToken = Random::getString(12);
     $this->storeDownloadToken($file, $downloadToken);
     $this->arResult = array('FILE' => array('ID' => $file->getId(), 'IS_IMAGE' => TypeFile::isImage($file->getName()), 'ICON_CLASS' => Icon::getIconClassByObject($file), 'UPDATE_TIME' => $file->getUpdateTime(), 'NAME' => $file->getName(), 'SIZE' => $file->getSize(), 'DOWNLOAD_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlExternalLink(array('hash' => $this->externalLink->getHash(), 'action' => 'download', 'token' => $downloadToken)), 'SHOW_PREVIEW_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlExternalLink(array('hash' => $this->externalLink->getHash(), 'action' => 'showPreview', 'token' => $downloadToken)), 'SHOW_FILE_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlExternalLink(array('hash' => $this->externalLink->getHash(), 'action' => 'showFile', 'token' => $downloadToken)), 'VIEW_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getShortUrlExternalLink(array('hash' => $this->externalLink->getHash(), 'action' => 'default'), true), 'VIEW_FULL_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlExternalLink(array('hash' => $this->externalLink->getHash(), 'action' => 'default'))), 'PROTECTED_BY_PASSWORD' => $this->externalLink->hasPassword(), 'VALID_PASSWORD' => $validPassword);
     $this->includeComponentTemplate();
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:12,代码来源:class.php


示例14: add

 /**
  * Adds row to entity table, fills error collection and builds model.
  * @param array           $data Data.
  * @param ErrorCollection $errorCollection Error collection.
  * @return \Bitrix\Disk\Internals\Model|static|null
  * @throws \Bitrix\Main\NotImplementedException
  * @internal
  */
 public static function add(array $data, ErrorCollection $errorCollection)
 {
     $result = FileTable::add($data);
     if (!$result->isSuccess()) {
         $errorCollection->addFromResult($result);
         return null;
     }
     $file = static::buildFromResult($result);
     if ($file && $file->getCreatedBy()) {
         $driver = Driver::getInstance();
         $driver->getRecentlyUsedManager()->push($file->getCreatedBy(), $file->getId());
     }
     return $file;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:22,代码来源:filelink.php


示例15: processActionGenerateExternalLink

 protected function processActionGenerateExternalLink()
 {
     /** @var File $file */
     list($file, $extLink) = $this->getFileAndExternalLink();
     if (!$extLink) {
         $extLink = $file->addExternalLink(array('CREATED_BY' => $this->getUser()->getId(), 'TYPE' => ExternalLinkTable::TYPE_MANUAL));
     }
     if (!$extLink) {
         $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_FILE_VIEW_ERROR_COULD_NOT_CREATE_FIND_EXT_LINK'), self::ERROR_COULD_NOT_CREATE_FIND_EXT_LINK));
         $this->errorCollection->add($file->getErrors());
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse(array('hash' => $extLink->getHash(), 'link' => Driver::getInstance()->getUrlManager()->getShortUrlExternalLink(array('hash' => $extLink->getHash(), 'action' => 'default'), true)));
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:14,代码来源:ajax.php


示例16: processActionCommit

 /**
  * For UF and work with local editors we have special scenario:
  * If user don't have permission for update file,
  * we have to attach new file to entity by posting comment with
  * alternative version.
  */
 protected function processActionCommit()
 {
     $userId = $this->getUser()->getId();
     if ($this->attachedModel->canUpdate($userId)) {
         parent::processActionCommit();
         return;
     }
     $this->checkRequiredFilesParams(array('file'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $userStorage = Driver::getInstance()->getStorageByUserId($userId);
     if (!$userStorage) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_STORAGE'), self::ERROR_COULD_NOT_FIND_STORAGE)));
         $this->sendJsonErrorResponse();
     }
     $folder = $userStorage->getFolderForCreatedFiles();
     if (!$folder) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_FOLDER_FOR_CREATED_FILES'), self::ERROR_COULD_NOT_FIND_FOLDER_FOR_CREATED_FILES)));
         $this->sendJsonErrorResponse();
     }
     if (!$folder->canAdd($folder->getStorage()->getCurrentUserSecurityContext())) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_BAD_RIGHTS'), self::ERROR_BAD_RIGHTS)));
         $this->sendJsonErrorResponse();
     }
     //todo fix Cherezov. Ban encoding 1251
     $fileArray = $this->request->getFile('file');
     $fileArray['name'] = $this->file->getName();
     $newFile = $folder->uploadFile($fileArray, array('NAME' => $this->file->getName(), 'CREATED_BY' => $userId), array(), true);
     if (!$newFile) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_COULD_NOT_CREATE_FILE'), self::ERROR_COULD_NOT_CREATE_FILE)));
         $this->errorCollection->add($folder->getErrors());
         $this->sendJsonErrorResponse();
     }
     $valueFileUf = FileUserType::NEW_FILE_PREFIX . $newFile->getId();
     /** @var User $createUser */
     $createUser = User::loadById($userId);
     if (!$createUser) {
         $this->sendJsonErrorResponse();
     }
     $text = Loc::getMessage('DISK_UF_LOCAL_DOC_CONTROLLER_UPLOAD_NEW_VERSION_IN_COMMENT_M');
     if ($createUser->getPersonalGender() == 'F') {
         $text = Loc::getMessage('DISK_UF_LOCAL_DOC_CONTROLLER_UPLOAD_NEW_VERSION_IN_COMMENT_F');
     }
     if ($this->attachedModel->getAllowAutoComment()) {
         $this->attachedModel->getConnector()->addComment($userId, array('text' => $text, 'fileId' => $valueFileUf));
     }
     $this->sendJsonSuccessResponse();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:55,代码来源:localdocumentcontroller.php


示例17: getFileData

 public static function getFileData($fileNodeId, $parameters = array())
 {
     if (!is_array($parameters)) {
         $parameters = array();
     }
     $result = array('ATTACHMENT_ID' => $fileNodeId);
     if (!isset($parameters['SERVER']) || !$parameters['SERVER'] instanceof \CRestServer) {
         return $result;
     }
     if (!Loader::includeModule('disk')) {
         return $result;
     }
     $fileNodeId = intval($fileNodeId);
     if (!$fileNodeId) {
         return $result;
     }
     $result['DOWNLOAD_URL'] = Driver::getInstance()->getUrlManager()->getUrlUfController('download', array('attachedId' => $fileNodeId, 'auth' => $parameters['SERVER']->getAuth()));
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:19,代码来源:disk.php


示例18: getList

 /**
  * Returns list of storages.
  * @param array $filter Filter.
  * @param array $order  Order.
  * @return Disk\Storage[]|null
  */
 protected function getList(array $filter = array(), array $order = array())
 {
     $securityContext = $this->getSecurityContextByUser($this->userId);
     $internalizer = new Disk\Rest\Internalizer(new Entity\Storage(), $this);
     $parameters = array_merge(array('with' => array('ROOT_OBJECT'), 'filter' => array_merge(array('=ROOT_OBJECT.PARENT_ID' => null, '=MODULE_ID' => Disk\Driver::INTERNAL_MODULE_ID, '=RIGHTS_CHECK' => true), $internalizer->cleanFilter($filter)), 'runtime' => array(new ExpressionField('RIGHTS_CHECK', 'CASE WHEN ' . $securityContext->getSqlExpressionForList('%1$s', '%2$s') . ' THEN 1 ELSE 0 END', array('ROOT_OBJECT.ID', 'ROOT_OBJECT.CREATED_BY'), array('data_type' => 'boolean'))), 'order' => $order), Disk\Rest\RestManager::getNavData($this->start));
     $parameters = Disk\Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('ROOT_OBJECT.ID', 'ROOT_OBJECT.CREATED_BY'));
     $storages = Disk\Storage::getModelList($parameters);
     if ($storages === null) {
         $this->errorCollection->addOne(new Error('Could not load list of storages.'));
         return null;
     }
     foreach ($storages as $key => $storage) {
         if (!$storage->getProxyType() instanceof Disk\ProxyType\Common && !$storage->getProxyType() instanceof Disk\ProxyType\Group && !$storage->getProxyType() instanceof Disk\ProxyType\User) {
             unset($storages[$key]);
         }
     }
     unset($storage);
     return $storages;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:25,代码来源:storage.php


示例19: beforeLogFormat

 /**
  * Called before record transformed for log writing.
  *
  * @param array &$record Database record.
  *
  * @return void
  */
 public function beforeLogFormat(array &$record)
 {
     global $USER;
     if ($record["PARAM_NAME"] !== "FILE_ID" || $record["PARAM_VALUE"] <= 0) {
         return;
     }
     if (!\Bitrix\Main\Loader::includeModule('disk')) {
         AddMessage2Log('MessageParamHandler::beforeLogFormat: failed to load disk module.');
         return;
     }
     if (!is_object($USER) || $USER->GetID() < 0) {
         AddMessage2Log('MessageParamHandler::beforeLogFormat: no user provided.');
         return;
     }
     /** @var \Bitrix\Disk\File $file */
     $fileId = $record["PARAM_VALUE"];
     $userId = $USER->GetID();
     $file = \Bitrix\Disk\File::loadById($fileId);
     if (!$file) {
         AddMessage2Log('MessageParamHandler::beforeLogFormat: file (' . $fileId . ') not found for user (' . $userId . ').');
         return;
     }
     $externalLink = $file->addExternalLink(array('CREATED_BY' => $userId, 'TYPE' => \Bitrix\Disk\Internals\ExternalLinkTable::TYPE_MANUAL));
     if (!$externalLink) {
         AddMessage2Log('MessageParamHandler::beforeLogFormat: failed to get external link for file (' . $fileId . ').');
         AddMessage2Log($file->getErrors());
         return;
     }
     $url = \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlExternalLink(array('hash' => $externalLink->getHash(), 'action' => 'default'), true);
     $fileName = $file->getName();
     $fileSize = $file->getSize();
     $attach = new \CIMMessageParamAttach(null, \CIMMessageParamAttach::CHAT);
     $attach->AddFiles(array(array("NAME" => $fileName, "LINK" => $url, "SIZE" => $fileSize)));
     $record["PARAM_NAME"] = 'ATTACH';
     $record["PARAM_VALUE"] = 1;
     $record["PARAM_JSON"] = $attach->GetJSON();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:44,代码来源:messageparamhandler.php


示例20: decline

 /**
  * @param      $declinedBy
  * @param bool $withDeletingObject
  * @return bool
  */
 public function decline($declinedBy, $withDeletingObject = true)
 {
     $this->errorCollection->clear();
     if ($this->isDeclined()) {
         return true;
     }
     if ($withDeletingObject && ($this->isToUser() || $this->isToGroup() || $this->isToDepartmentChild())) {
         $linkModel = $this->getLinkObject();
         if ($linkModel instanceof FolderLink) {
             $linkModel->deleteTree($declinedBy);
         } elseif ($linkModel instanceof FileLink) {
             $linkModel->deleteWithoutSharing($declinedBy);
         }
     }
     $success = $this->update(array('LINK_OBJECT_ID' => null, 'LINK_STORAGE_ID' => null, 'STATUS' => SharingTable::STATUS_IS_DECLINED));
     if (!$success) {
         return false;
     }
     foreach ($this->getChildren() as $childSharing) {
         $childSharing->decline($declinedBy, $withDeletingObject);
     }
     unset($childSharing);
     if (!$this->getRealObject()) {
         return true;
     }
     if ($this->isToUser() || $this->isToGroup() || $this->isToDepartmentParent()) {
         $rightsManager = Driver::getInstance()->getRightsManager();
         $rightsManager->deleteByDomain($this->getRealObject(), $rightsManager->getSharingDomain($this->id));
     }
     if ($this->isToUser() && !$this->isToDepartmentChild() && self::CODE_USER . $declinedBy == $this->toEntity && $this->fromEntity != $this->toEntity) {
         $isFolder = $this->getRealObject() instanceof Folder;
         $message = Loc::getMessage($isFolder ? 'DISK_SHARING_MODEL_TEXT_SELF_DISCONNECT' : 'DISK_SHARING_MODEL_TEXT_SELF_DISCONNECT_FILE', array('#NAME#' => $this->getRealObject()->getName(), '#USERNAME#' => User::loadById($declinedBy)->getFormattedName()));
         list($subTag, $tag) = $this->getNotifyTags();
         Driver::getInstance()->sendNotify($this->createdBy, array('FROM_USER_ID' => $declinedBy, 'NOTIFY_EVENT' => 'sharing', 'NOTIFY_TAG' => $tag, 'NOTIFY_MESSAGE' => $message, 'NOTIFY_MESSAGE_OUT' => strip_tags($message)));
     }
     return true;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:42,代码来源:sharing.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Highloadblock\HighloadBlockTable类代码示例发布时间:2022-05-23
下一篇:
PHP Currency\CurrencyManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap