protected function checkUpdatePermissions()
 {
     $securityContext = $this->file->getStorage()->getCurrentUserSecurityContext();
     if (!$this->file->canUpdate($securityContext)) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_BAD_RIGHTS'), self::ERROR_BAD_RIGHTS)));
         $this->sendJsonErrorResponse();
     }
 }
Example #2
0
 protected function processActionDefault()
 {
     $gridId = 'file_version_list';
     $securityContext = $this->storage->getCurrentUserSecurityContext();
     $urlManager = Driver::getInstance()->getUrlManager();
     $this->getApplication()->setTitle($this->storage->getProxyType()->getTitleForCurrentUser());
     $breadcrumbs = $this->getBreadcrumbs();
     $externalLinkData = array();
     $externalLink = $this->getExternalLink();
     if ($externalLink) {
         $externalLinkData = array('LINK' => Driver::getInstance()->getUrlManager()->getShortUrlExternalLink(array('hash' => $externalLink->getHash(), 'action' => 'default'), true));
     }
     $createdByLink = \CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_USER'], array("user_id" => $this->file->getCreatedBy()));
     $canUpdate = $this->file->canUpdate($securityContext);
     $viewFile = CComponentEngine::makePathFromTemplate($this->arParams['PATH_TO_FILE_VIEW'], array('FILE_ID' => $this->file->getId(), 'FILE_PATH' => $this->arParams['RELATIVE_PATH']));
     $this->arResult = array('VERSION_GRID' => array(), 'STORAGE' => $this->storage, 'USE_IN_ENTITIES' => false, 'ENTITIES' => array(), 'SHOW_USER_FIELDS' => false, 'USER_FIELDS' => array(), 'TOOLBAR' => array('BUTTONS' => array(array('TEXT' => Loc::getMessage('DISK_FILE_VIEW_GO_BACK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FILE_VIEW_GO_BACK_TITLE'), 'LINK' => end($breadcrumbs), 'ICON' => 'back'), array('TEXT' => Loc::getMessage('DISK_FILE_VIEW_COPY_LINK_TEXT'), 'TITLE' => Loc::getMessage('DISK_FILE_VIEW_COPY_LINK_TITLE'), 'LINK' => "javascript:BX.Disk['FileViewClass_{$this->getComponentId()}'].getInternalLink();", 'ICON' => 'copy-link'))), 'EXTERNAL_LINK' => $externalLinkData, 'FILE' => array('ID' => $this->file->getId(), 'IS_IMAGE' => TypeFile::isImage($this->file->getName()), 'CREATE_USER' => array('LINK' => $createdByLink, 'NAME' => $this->file->getCreateUser()->getFormattedName(), 'AVA' => $this->file->getCreateUser()->getAvatarSrc(21, 21)), 'VIEWER_ATTRIBUTES' => Ui\Viewer::getAttributesByObject($this->file, array('canUpdate' => $canUpdate)), 'UPDATE_TIME' => $this->file->getUpdateTime(), 'ICON_CLASS' => Icon::getIconClassByObject($this->file), 'NAME' => $this->file->getName(), 'SIZE' => $this->file->getSize(), 'IS_LINK' => $this->file->isLink(), 'FOLDER_LIST_WEBDAV' => rtrim(end($breadcrumbs), '/') . '/' . $this->file->getName(), 'DOWNLOAD_URL' => $urlManager->getUrlForDownloadFile($this->file), 'SHOW_PREVIEW_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlForShowFile($this->file, array('exact' => 'Y', 'width' => 255, 'height' => 255)), 'SHOW_FILE_URL' => \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlForShowFile($this->file)), 'CAN_UPDATE' => $canUpdate, 'CAN_DELETE' => $this->file->canDelete($securityContext), 'PATH_TO_FILE_VIEW' => $viewFile);
     $attachedObjects = $this->file->getAttachedObjects();
     if ($attachedObjects) {
         $userId = $this->getUser()->getId();
         $this->arResult['USE_IN_ENTITIES'] = true;
         Uf\Connector::setPathToUser($this->arParams['PATH_TO_USER']);
         Uf\Connector::setPathToGroup($this->arParams['PATH_TO_GROUP']);
         foreach ($attachedObjects as $attachedObject) {
             $connector = $attachedObject->getConnector();
             if (!$connector->canRead($userId)) {
                 continue;
             }
             $dataToShow = $connector->getDataToShow();
             if ($dataToShow) {
                 $this->arResult['ENTITIES'][] = $dataToShow;
             }
         }
         unset($attachedObject);
     }
     $userFieldsObject = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager()->getFieldsForObject($this->file);
     foreach ($userFieldsObject as $field) {
         if ($field['VALUE'] !== false) {
             $this->arResult['SHOW_USER_FIELDS'] = true;
             $this->arResult['USER_FIELDS'] = $userFieldsObject;
             break;
         }
     }
     unset($field);
     $this->arParams['STATUS_BIZPROC'] = $this->storage->isEnabledBizProc() && Loader::includeModule("bizproc");
     if ($this->arParams['STATUS_BIZPROC']) {
         $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($this->file->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($this->file->getId())));
         $webdavFileId = $this->file->getXmlId();
         if (!empty($webdavFileId)) {
             if (Loader::includeModule("iblock")) {
                 if ($this->storage->getProxyType() instanceof ProxyType\Group) {
                     $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch();
                     $entity = 'CIBlockDocumentWebdavSocnet';
                 } else {
                     $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch();
                     $entity = 'CIBlockDocumentWebdav';
                 }
                 if (!empty($iblock)) {
                     $documentData['OLD_FILE'] = array('DOCUMENT_TYPE' => array('webdav', $entity, "iblock_" . $iblock['IBLOCK_ID']), 'DOCUMENT_ID' => array('webdav', $entity, $iblock['ID']));
                 }
             }
         }
         $this->getAutoloadTemplateBizProc($documentData);
         if ($this->request->isPost() && intval($this->request->getPost('bizproc_index')) > 0) {
             $this->showBizProc($documentData);
         }
     }
     $this->includeComponentTemplate();
 }