示例#1
13
 /**
  * Returns the list of pair for mapping.
  * Key is field in DataManager, value is object property.
  * @return array
  */
 public static function getMapAttributes()
 {
     static $shelve = null;
     if ($shelve !== null) {
         return $shelve;
     }
     $shelve = array_merge(parent::getMapAttributes(), array('HAS_SUBFOLDERS' => 'hasSubFolders'));
     return $shelve;
 }
示例#2
0
 protected function calculateCrumb(BaseObject $object)
 {
     $parentId = $object->getParentId();
     if (!$parentId) {
         $this->crumbsByObjectId[$object->getId()] = array($object->getName());
         return $this->crumbsByObjectId[$object->getId()];
     }
     if (isset($this->crumbsByObjectId[$parentId])) {
         $this->crumbsByObjectId[$object->getId()] = $this->crumbsByObjectId[$parentId];
         $this->crumbsByObjectId[$object->getId()][] = $object->getName();
         return $this->crumbsByObjectId[$object->getId()];
     }
     $storage = $object->getStorage();
     $fake = Driver::getInstance()->getFakeSecurityContext();
     $this->crumbsByObjectId[$object->getId()] = array();
     foreach ($object->getParents($fake, array('select' => array('ID', 'NAME', 'TYPE')), SORT_DESC) as $parent) {
         if ($parent->getId() == $storage->getRootObjectId()) {
             continue;
         }
         $this->crumbsByObjectId[$object->getId()][] = $parent->getName();
     }
     unset($parent);
     $this->crumbsByObjectId[$parentId] = $this->crumbsByObjectId[$object->getId()];
     $this->crumbsByObjectId[$object->getId()][] = $object->getName();
     return $this->crumbsByObjectId[$object->getId()];
 }
示例#3
0
 protected function processActionMoveTo()
 {
     if (!$this->checkRequiredPostParams(array('objectId', 'targetObjectId'))) {
         $this->sendJsonErrorResponse();
     }
     /** @var \Bitrix\Disk\File|\Bitrix\Disk\Folder $object */
     $object = BaseObject::loadById((int) $this->request->getPost('objectId'), array('STORAGE'));
     if (!$object) {
         $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_BREADCRUMBS_TREE_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT));
         $this->sendJsonErrorResponse();
     }
     $securityContext = $object->getStorage()->getCurrentUserSecurityContext();
     if (!$object->canRead($securityContext)) {
         $this->sendJsonAccessDeniedResponse();
     }
     /** @var \Bitrix\Disk\Folder $targetObject */
     $targetObject = Folder::loadById((int) $this->request->getPost('targetObjectId'), array('STORAGE'));
     if (!$targetObject) {
         $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_BREADCRUMBS_TREE_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT));
         $this->sendJsonErrorResponse();
     }
     if (!$object->canMove($securityContext, $targetObject)) {
         $this->sendJsonAccessDeniedResponse();
     }
     if (!$object->moveTo($targetObject, $this->getUser()->getId(), true)) {
         $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_BREADCRUMBS_TREE_ERROR_COULD_NOT_MOVE_OBJECT'), self::ERROR_COULD_NOT_MOVE_OBJECT));
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse(array('id' => $object->getId(), 'name' => $object->getName()));
 }
示例#4
0
 /**
  * @return File|null
  */
 public function getObject()
 {
     if (!$this->objectId) {
         return null;
     }
     if (isset($this->object) && $this->objectId == $this->object->getId()) {
         return $this->object;
     }
     $this->object = File::loadById($this->objectId);
     return $this->object;
 }
示例#5
0
 public static function getIconClassByObject(BaseObject $object, $appendSharedClass = false)
 {
     $class = '';
     if ($object instanceof Folder) {
         $class = 'bx-disk-folder-icon';
     } elseif ($object instanceof File) {
         $class = 'bx-disk-file-icon';
         $ext = strtolower($object->getExtension());
         if (isset(self::$possibleIconClasses[$ext])) {
             $class .= ' ' . self::$possibleIconClasses[$ext];
         } elseif (TypeFile::isImage($object)) {
             $class .= ' ' . self::$possibleIconClasses['img'];
         } elseif (TypeFile::isVideo($object)) {
             $class .= ' ' . self::$possibleIconClasses['vid'];
         }
     }
     if ($object->isLink()) {
         $class .= ' icon-shared shared icon-shared_2';
     } elseif ($appendSharedClass) {
         $class .= ' icon-shared shared icon-shared_1 icon-shared_2';
     }
     return $class;
 }
示例#6
0
 protected function processActionShowObjectInGrid()
 {
     if (!$this->checkRequiredGetParams(array('objectId'))) {
         $this->sendJsonErrorResponse();
     }
     /** @var Folder|File $object */
     $object = BaseObject::loadById((int) $this->request->getQuery('objectId'), array('STORAGE'));
     if (!$object) {
         $this->errorCollection->addOne(new Error('Could not find file or folder', self::ERROR_COULD_NOT_FIND_FILE));
         $this->sendJsonErrorResponse();
     }
     $storage = $object->getStorage();
     $securityContext = $storage->getCurrentUserSecurityContext();
     if (!$object->canRead($securityContext)) {
         $this->errorCollection->addOne(new Error('Could not find file or folder', self::ERROR_COULD_NOT_READ_FILE));
         $this->sendJsonErrorResponse();
     }
     $gridOptions = new Internals\Grid\FolderListOptions($storage);
     $pageSize = $gridOptions->getPageSize();
     $parameters = array('select' => array('ID'), 'filter' => array('PARENT_ID' => $object->getParentId(), 'DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE), 'order' => $gridOptions->getOrderForOrm(), 'limit' => $pageSize);
     $countQuery = new Query(ObjectTable::getEntity());
     $countQuery->addSelect(new ExpressionField('CNT', 'COUNT(1)'));
     $countQuery->setFilter($parameters['filter']);
     $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
     $totalCount = $totalCount['CNT'];
     $pageCount = ceil($totalCount / $pageSize);
     $driver = Driver::getInstance();
     $finalPage = null;
     for ($pageNumber = 1; $pageNumber <= $pageCount; $pageNumber++) {
         $fullParameters = $driver->getRightsManager()->addRightsCheck($securityContext, $parameters, array('ID', 'CREATED_BY'));
         $fullParameters['offset'] = $pageSize * ($pageNumber - 1);
         $query = ObjectTable::getList($fullParameters);
         while ($row = $query->fetch()) {
             if ($row['ID'] == $object->getId()) {
                 $finalPage = $pageNumber;
                 break;
             }
         }
         if ($finalPage !== null) {
             break;
         }
     }
     $finalPage = $finalPage ?: 1;
     $command = $this->request->getQuery('cmd') ?: '';
     if ($command) {
         $command = '!' . $command;
     }
     LocalRedirect($driver->getUrlManager()->getPathInListing($object) . "?&pageNumber={$finalPage}#hl-" . $object->getId() . $command);
 }
示例#7
0
 private function processGridActions($gridId)
 {
     $postAction = 'action_button_' . $gridId;
     if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST[$postAction]) && check_bitrix_sessid()) {
         $userId = $this->getUser()->getID();
         if ($_POST[$postAction] == 'restore') {
             if (empty($_POST['ID'])) {
                 return;
             }
             foreach ($_POST['ID'] as $targetId) {
                 /** @var Folder|File $object */
                 $object = BaseObject::loadById($targetId);
                 if (!$object) {
                     continue;
                 }
                 if (!$object->canRestore($object->getStorage()->getCurrentUserSecurityContext())) {
                     continue;
                 }
                 $object->restore($userId);
             }
         } elseif ($_POST[$postAction] == 'delete' || $_POST[$postAction] == 'destroy') {
             if (empty($_POST['ID'])) {
                 return;
             }
             foreach ($_POST['ID'] as $targetId) {
                 /** @var Folder|File $object */
                 $object = BaseObject::loadById($targetId);
                 if (!$object) {
                     continue;
                 }
                 if (!$object->canDelete($object->getStorage()->getCurrentUserSecurityContext())) {
                     continue;
                 }
                 if ($object instanceof Folder) {
                     $object->deleteTree($userId);
                 } else {
                     $object->delete($userId);
                 }
             }
         }
     }
 }
示例#8
0
 /**
  * Gets data attributes by object (folder or file) to viewer.
  * @param File|Folder|BaseObject $object Target object.
  * @param array                  $additionalParams Additional parameters 'relativePath', 'externalId', 'canUpdate', 'showStorage'.
  * @return string
  */
 public static function getAttributesByObject(BaseObject $object, array $additionalParams = array())
 {
     $urlManager = Driver::getInstance()->getUrlManager();
     $name = $object->getName();
     $dateTime = $object->getUpdateTime();
     if ($object instanceof Folder) {
         $user = $object->getCreateUser();
         $dataAttributesForViewer = 'data-bx-viewer="folder" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="" ' . 'data-bx-owner="' . htmlspecialcharsbx($user ? $user->getFormattedName() : '') . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
         return $dataAttributesForViewer;
     }
     if (!$object instanceof File) {
         return '';
     }
     if (DocumentHandler::isEditable($object->getExtension())) {
         $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowFileByService($object->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="' . (DocumentHandler::isNeedConvertExtension($object->getExtension()) ? '1' : '') . '" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($object->getSize())) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     } elseif (Viewer::isViewable($object->getExtension())) {
         $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowFileByService($object->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="0" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($object->getSize())) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     } elseif (TypeFile::isImage($object)) {
         $dataAttributesForViewer = 'data-bx-viewer="image" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     } else {
         $user = $object->getCreateUser();
         $dataAttributesForViewer = 'data-bx-viewer="unknown" ' . 'data-bx-src="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-owner="' . htmlspecialcharsbx($user ? $user->getFormattedName() : '') . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($object->getSize())) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     }
     $dataAttributesForViewer .= " bx-attach-file-id=\"{$object->getId()}\"" . " data-bx-version=\"\"" . " data-bx-history=\"\"" . " data-bx-historyPage=\"\"";
     if (!empty($additionalParams['relativePath'])) {
         $dataAttributesForViewer .= ' data-bx-relativePath="' . htmlspecialcharsbx($additionalParams['relativePath'] . '/' . $name) . '" ';
     }
     if (!empty($additionalParams['externalId'])) {
         $dataAttributesForViewer .= ' data-bx-externalId="' . htmlspecialcharsbx($additionalParams['externalId']) . '" ';
     }
     if (!empty($additionalParams['canUpdate'])) {
         $dataAttributesForViewer .= ' data-bx-edit="' . $urlManager->getUrlForStartEditFile($object->getId(), 'gdrive') . '" ';
     }
     if (!empty($additionalParams['showStorage'])) {
         $dataAttributesForViewer .= ' data-bx-storage="' . htmlspecialcharsbx($object->getParent()->getName()) . '" ';
     }
     return $dataAttributesForViewer;
 }
示例#9
0
 private function fillChildren()
 {
     if ($this->object instanceof File) {
         return;
     }
     $specificRightsByObjectId = array($this->object->getId() => $this->specificRights);
     //store all rights on object (all inherited rights)
     $inheritedRightsByObjectId = array($this->object->getId() => $this->getParentRights());
     $childrenRights = Driver::getInstance()->getRightsManager()->getDescendantsRights($this->object->getId());
     if (!$childrenRights) {
         SimpleRightTable::fillDescendants($this->object->getId());
         return;
     }
     //store all specific rights on object
     foreach ($childrenRights as $right) {
         if (!isset($specificRightsByObjectId[$right['OBJECT_ID']])) {
             $specificRightsByObjectId[$right['OBJECT_ID']] = array();
         }
         $specificRightsByObjectId[$right['OBJECT_ID']][] = $right;
     }
     unset($right, $childrenRights);
     $simpleRightsByObjectId = array($this->object->getId() => $this->simpleRights);
     $query = ObjectTable::getDescendants($this->object->getId(), array('select' => array('ID', 'PARENT_ID')));
     while ($object = $query->fetch()) {
         //specific rights on object
         if (!isset($specificRightsByObjectId[$object['ID']])) {
             $specificRightsByObjectId[$object['ID']] = array();
         }
         if (!isset($inheritedRightsByObjectId[$object['ID']])) {
             $inheritedRightsByObjectId[$object['ID']] = array();
         }
         if (!isset($simpleRightsByObjectId[$object['PARENT_ID']])) {
             $simpleRightsByObjectId[$object['PARENT_ID']] = array();
         }
         if (isset($inheritedRightsByObjectId[$object['PARENT_ID']])) {
             $inheritedRightsByObjectId[$object['ID']] = array_merge($inheritedRightsByObjectId[$object['PARENT_ID']], $specificRightsByObjectId[$object['PARENT_ID']] ?: array());
         } else {
             $inheritedRightsByObjectId[$object['PARENT_ID']] = array();
         }
         $simpleRightsByObjectId[$object['ID']] = $this->uniqualizeSimpleRights($this->getNewSimpleRight($specificRightsByObjectId[$object['ID']], $inheritedRightsByObjectId[$object['ID']], $simpleRightsByObjectId[$object['PARENT_ID']]));
         $items = array();
         foreach ($simpleRightsByObjectId[$object['ID']] as $right) {
             $items[] = array('OBJECT_ID' => $object['ID'], 'ACCESS_CODE' => $right['ACCESS_CODE']);
         }
         unset($right);
         SimpleRightTable::insertBatch($items);
     }
     unset($object);
 }
示例#10
0
 private static function getDetailUrl(BaseObject $object)
 {
     $detailUrl = '';
     $urlManager = Driver::getInstance()->getUrlManager();
     if ($object instanceof File) {
         $detailUrl = $urlManager->getUrlFocusController('openFileDetail', array('fileId' => $object->getId()));
     } elseif ($object instanceof Folder) {
         $detailUrl = $urlManager->getUrlFocusController('openFolderList', array('folderId' => $object->getId()));
     }
     return $detailUrl;
 }
示例#11
0
 /**
  * @param BaseObject $object
  * @return string
  */
 private function getUfEntityName(BaseObject $object)
 {
     if ($object instanceof File) {
         return 'DISK_FILE_' . $object->getStorageId();
     }
     return 'DISK_FOLDER_' . $object->getStorageId();
 }
示例#12
0
 public static function addAfterMove(BaseObject $object, array $subscribersLostAccess, $updatedBy, ErrorCollection $errorCollection)
 {
     $items = array();
     $dateTime = new DateTime();
     $isFolder = $object instanceof Folder;
     foreach ($subscribersLostAccess as $storageId => $userId) {
         $items[] = array('STORAGE_ID' => $storageId, 'OBJECT_ID' => $object->getId(), 'TYPE' => $isFolder ? ObjectTable::TYPE_FOLDER : ObjectTable::TYPE_FILE, 'USER_ID' => $updatedBy, 'CREATE_TIME' => $dateTime);
     }
     unset($storageId, $userId);
     DeletedLogTable::insertBatch($items);
     if ($isFolder) {
         Driver::getInstance()->cleanCacheTreeBitrixDisk(array_keys($subscribersLostAccess));
     }
     Driver::getInstance()->sendChangeStatus($subscribersLostAccess);
 }
示例#13
0
 protected function getBizProcData(BaseObject $object, SecurityContext $securityContext, array $actions, array $columnsBizProc, array $bizprocIcon, array $exportData)
 {
     $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($object->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($object->getId())));
     $listBpTemplates = array();
     foreach ($this->arParams['TEMPLATE_BIZPROC'] as $idTemplate => $valueTemplate) {
         $url = CComponentEngine::MakePathFromTemplate($valueTemplate['URL'], array("ELEMENT_ID" => $object->getId()));
         $listBpTemplates[] = array("ICONCLASS" => "", "TEXT" => $valueTemplate['NAME'], "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "');");
     }
     if ($object->canStartBizProc($securityContext) && !empty($listBpTemplates)) {
         $actions[] = array("ICONCLASS" => "bizproc_start", "TEXT" => Loc::getMessage("DISK_FOLDER_LIST_ACT_START_BIZPROC"), "MENU" => $listBpTemplates);
     }
     $webdavFileId = $object->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']));
             }
         }
     }
     foreach ($documentData as $nameModuleId => $data) {
         $temporary[$nameModuleId] = CBPDocument::getDocumentStates($data['DOCUMENT_TYPE'], $data['DOCUMENT_ID']);
     }
     if (isset($temporary['OLD_FILE'])) {
         $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV'], $temporary['OLD_FILE']);
     } else {
         $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV']);
     }
     foreach ($documentStates as $key => $documentState) {
         if (empty($documentState['ID'])) {
             unset($documentStates[$key]);
         }
     }
     $columnsBizProc['BIZPROC'] = "";
     $bizprocIcon['BIZPROC'] = "";
     if (!empty($documentStates)) {
         if (count($documentStates) == 1) {
             $documentState = reset($documentStates);
             if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) {
                 $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]);
                 $columnsBizProc["BIZPROC"] = '<div class="bizproc-item-title">' . htmlspecialcharsbx($documentState["TEMPLATE_NAME"]) . ': ' . '<span class="bizproc-item-title bizproc-state-title" style="">' . '<a href="' . $exportData["OPEN_URL"] . '#tab-bp">' . (strlen($documentState["STATE_TITLE"]) > 0 ? htmlspecialcharsbx($documentState["STATE_TITLE"]) : htmlspecialcharsbx($documentState["STATE_NAME"])) . '</a>' . '</span>' . '</div>';
                 $columnsBizProc['BIZPROC'] = str_replace("'", "\"", $columnsBizProc['BIZPROC']);
                 $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . (!(strlen($documentState["ID"]) <= 0 || strlen($documentState["WORKFLOW_STATUS"]) <= 0) ? 'bizproc-status-' . (empty($tasksWorkflow) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc["BIZPROC"]) . "\")'></div>";
                 if (!empty($tasksWorkflow)) {
                     $tmp = array();
                     foreach ($tasksWorkflow as $val) {
                         $url = CComponentEngine::makePathFromTemplate($this->arParams["PATH_TO_DISK_TASK"], array("ID" => $val["ID"]));
                         $url .= "?back_url=" . urlencode($this->getApplication()->getCurPageParam());
                         $tmp[] = '<a href="' . $url . '">' . $val["NAME"] . '</a>';
                     }
                     $columnsBizProc["BIZPROC"] .= '<div class="bizproc-tasks">' . implode(", ", $tmp) . '</div>';
                     return array($actions, $columnsBizProc, $bizprocIcon);
                 }
                 return array($actions, $columnsBizProc, $bizprocIcon);
             }
             return array($actions, $columnsBizProc, $bizprocIcon);
         } else {
             $tasks = array();
             $inprogress = false;
             foreach ($documentStates as $key => $documentState) {
                 if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) {
                     $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]);
                     if (!$inprogress) {
                         $inprogress = strlen($documentState['ID']) > 0 && strlen($documentState['WORKFLOW_STATUS']) > 0;
                     }
                     if (!empty($tasksWorkflow)) {
                         foreach ($tasksWorkflow as $val) {
                             $tasks[] = $val;
                         }
                     }
                 }
             }
             $columnsBizProc["BIZPROC"] = '<span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC") . ': <a href="' . $exportData["OPEN_URL"] . '#tab-bp" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TITLE") . '">' . count($documentStates) . '</a></span>' . (!empty($tasks) ? '<br /><span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS") . ': <a href="' . $this->arParams["PATH_TO_DISK_TASK_LIST"] . '" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS_TITLE") . '">' . count($tasks) . '</a></span>' : '');
             $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . ($inprogress ? ' bizproc-status-' . (empty($tasks) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc['BIZPROC']) . "\")'></div>";
             return array($actions, $columnsBizProc, $bizprocIcon);
         }
     }
     return array($actions, $columnsBizProc, $bizprocIcon);
 }
示例#14
0
 private function appendSubscribersBySharings(BaseObject $object, array $alreadySubscribers)
 {
     foreach ($object->getSharingsAsReal() as $sharing) {
         if (!$sharing->isToUser()) {
             //todo true? I'm right? to skip another
             continue;
         }
         $linkObject = $sharing->getLinkObject();
         if ($linkObject) {
             $alreadySubscribers[$linkObject->getStorageId()] = substr($sharing->getToEntity(), 1);
             foreach ($this->collectSubscribers($linkObject) as $storageId => $userId) {
                 $alreadySubscribers[$storageId] = $userId;
             }
             unset($storageId, $userId);
         }
     }
     unset($sharing);
     return $alreadySubscribers;
 }
示例#15
0
 /**
  * Works with nodes which have negative rights.
  *
  * We have to get all negative nodes in subtree and order by DEPTH_LEVEL ASC.
  * Then we go from each negative node up and calculate opportunity to read this object by ACCESS_CODE.
  * If we have positive right on different TASK_ID in subtree, then we can't delete simple rights from subtree.
  * If we don't have positive right on different TASK_ID in subtree, then we delete simple rights from subtree
  * before we find another positive rights with same ACCESS_CODE.
  *
  * @return $this
  * @throws \Bitrix\Main\ArgumentOutOfRangeException
  */
 private function workWithNegativeNodes()
 {
     $negativeNodes = $this->connection->query("\n\t\t\tSELECT\n\t\t\t\tr.ACCESS_CODE, r.TASK_ID,\n\t\t\t\tr.OBJECT_ID, p.DEPTH_LEVEL\n\t\t\tFROM b_disk_right r\n\t\t\t\tINNER JOIN b_disk_object_path p ON p.OBJECT_ID = r.OBJECT_ID\n\t\t\tWHERE\n\t\t\t\tp.PARENT_ID = {$this->objectId} AND r.NEGATIVE = 1\n\t\t")->fetchAll();
     $rightsManager = Driver::getInstance()->getRightsManager();
     Collection::sortByColumn($negativeNodes, array('DEPTH_LEVEL' => SORT_ASC));
     foreach ($negativeNodes as $negativeNode) {
         $nodeObject = BaseObject::buildFromArray(array('ID' => $negativeNode['OBJECT_ID'], 'TYPE' => ObjectTable::TYPE_FOLDER));
         $runClean = true;
         foreach ($rightsManager->getAllListNormalizeRights($nodeObject) as $right) {
             if ($right['ACCESS_CODE'] !== $negativeNode['ACCESS_CODE']) {
                 continue;
             }
             //the right goes from parent
             if (!empty($right['NEGATIVE']) && $right['OBJECT_ID'] != $negativeNode['OBJECT_ID'] && $right['TASK_ID'] == $negativeNode['TASK_ID']) {
                 $runClean = false;
                 break;
             }
             if (!empty($right['NEGATIVE'])) {
                 continue;
             }
             if ($rightsManager->containsOperationInTask($rightsManager::OP_READ, $right['TASK_ID'])) {
                 $runClean = false;
                 break;
             }
         }
         unset($right);
         if (!$runClean) {
             //the node and all sub-elements inherit OP_READ from another positive right.
             continue;
         }
         $this->deleteSimpleRightFromSubTree($negativeNode['OBJECT_ID'], $negativeNode['ACCESS_CODE']);
     }
     unset($negativeNode);
     return $this;
 }
示例#16
0
 private function getParentRights()
 {
     if ($this->parentRights !== null) {
         return $this->parentRights;
     }
     $this->parentRights = Driver::getInstance()->getRightsManager()->getParentsRights($this->object->getId());
     Collection::sortByColumn($this->parentRights, array('DEPTH_LEVEL' => SORT_DESC));
     return $this->parentRights;
 }
示例#17
0
 /**
  * Returns the list attributes which is connected with another models.
  * @return array
  */
 public static function getMapReferenceAttributes()
 {
     $userClassName = User::className();
     $fields = User::getFieldsForSelect();
     return array('CREATE_USER' => array('class' => $userClassName, 'select' => $fields), 'UPDATE_USER' => array('class' => $userClassName, 'select' => $fields), 'DELETE_USER' => array('class' => $userClassName, 'select' => $fields), 'REAL_OBJECT' => BaseObject::className(), 'STORAGE' => Storage::className());
 }
示例#18
0
 /**
  * @param $path
  * @param File|Folder|Object $object
  * @return CDavResource
  */
 protected function getResourceByObject($path, BaseObject $object)
 {
     $isFolder = $object instanceof Folder;
     $resource = new CDavResource($path . ($isFolder && substr($path, -1, 1) != "/" ? "/" : ""));
     $resource->AddProperty('name', $object->getName());
     if ($object instanceof File) {
         $resource->AddProperty('getcontentlength', $object->getSize());
     }
     $resource->AddProperty('creationdate', $object->getCreateTime()->getTimestamp());
     $resource->AddProperty('getlastmodified', $object->getUpdateTime()->getTimestamp());
     $resource->AddProperty('iscollection', $isFolder ? '1' : '0');
     if ($isFolder) {
         $resource->AddProperty('resourcetype', array('collection', ''));
         $resource->AddProperty('getcontenttype', 'httpd/unix-directory');
     } else {
         $resource->AddProperty('getcontenttype', '');
         $resource->AddProperty('isreadonly', '');
         $resource->AddProperty('ishidden', '');
         $resource->AddProperty('resourcetype', '');
     }
     $resource->AddProperty("supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>");
     return $resource;
 }
示例#19
0
 /**
  * Returns the list of pair for mapping.
  * Key is field in DataManager, value is object property.
  * @return array
  */
 public static function getMapAttributes()
 {
     static $shelve = null;
     if ($shelve !== null) {
         return $shelve;
     }
     $shelve = array_merge(parent::getMapAttributes(), array('ID' => 'id', 'NAME' => 'name', 'CODE' => 'code', 'STORAGE_ID' => 'storageId', 'STORAGE' => 'storage', 'TYPE' => 'type', 'REAL_OBJECT_ID' => 'realObjectId', 'REAL_OBJECT' => 'realObject', 'PARENT_ID' => 'parentId', 'DELETED_TYPE' => 'deletedType', 'TYPE_FILE' => 'typeFile', 'GLOBAL_CONTENT_VERSION' => 'globalContentVersion', 'FILE_ID' => 'fileId', 'SIZE' => 'size', 'EXTERNAL_HASH' => 'externalHash', 'CREATE_TIME' => 'createTime', 'UPDATE_TIME' => 'updateTime', 'DELETE_TIME' => 'deleteTime', 'CREATED_BY' => 'createdBy', 'CREATE_USER' => 'createUser', 'UPDATED_BY' => 'updatedBy', 'UPDATE_USER' => 'updateUser', 'DELETED_BY' => 'deletedBy', 'DELETE_USER' => 'deleteUser'));
     return $shelve;
 }
示例#20
0
 protected function processActionDelete()
 {
     $this->checkRequiredPostParams(array('objectId'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     /** @var Folder|File $object */
     $object = BaseObject::loadById((int) $this->request->getPost('objectId'), array('STORAGE'));
     if (!$object) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FOLDER_LIST_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT)));
         $this->sendJsonErrorResponse();
     }
     if (!$object->canDelete($object->getStorage()->getCurrentUserSecurityContext())) {
         $this->sendJsonAccessDeniedResponse();
     }
     if ($object instanceof Folder) {
         if (!$object->deleteTree($this->getUser()->getId())) {
             $this->errorCollection->add($object->getErrors());
             $this->sendJsonErrorResponse();
         }
         $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('DISK_FOLDER_ACTION_MESSAGE_FOLDER_DELETED')));
     }
     if (!$object->delete($this->getUser()->getId())) {
         $this->errorCollection->add($object->getErrors());
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('DISK_FOLDER_ACTION_MESSAGE_FILE_DELETED')));
 }
示例#21
0
 private function getBreadcrumbs(BaseObject $object)
 {
     $parentId = $object->isLink() ? $object->getParentId() : $object->getRealObject()->getParentId();
     $realId = $object->isLink() ? $object->getId() : $object->getRealObject()->getId();
     if (isset($this->cacheBreadcrumbs[$parentId])) {
         if ($object instanceof File) {
             return $this->cacheBreadcrumbs[$parentId] . '/' . $object->getName();
         }
         $this->cacheBreadcrumbs[$realId] = $this->cacheBreadcrumbs[$parentId] . '/' . $object->getName();
         if ($object->isLink()) {
             $this->cacheBreadcrumbs[$object->getRealObject()->getId()] = $this->cacheBreadcrumbs[$realId];
         }
     } else {
         if ($parentId == $this->storage->getRootObjectId()) {
             $this->cacheBreadcrumbs[$realId] = '/' . $object->getName();
             if ($object->isLink()) {
                 if (!$object->getRealObject()) {
                     return null;
                 }
                 $this->cacheBreadcrumbs[$object->getRealObject()->getId()] = $this->cacheBreadcrumbs[$realId];
             }
             return $this->cacheBreadcrumbs[$realId];
         }
         $path = '';
         $parents = ObjectTable::getAncestors($realId, array('select' => array('ID', 'NAME', 'TYPE', 'CODE')));
         while ($parent = $parents->fetch()) {
             if ($parent['CODE'] == Folder::CODE_FOR_UPLOADED_FILES) {
                 //todo hack. CODE_FOR_UPLOADED_FILES
                 return null;
             }
             if ($this->storage->getRootObjectId() == $parent['ID']) {
                 continue;
             }
             $path .= '/' . $parent['NAME'];
             if (!isset($this->cacheBreadcrumbs[$parent['ID']])) {
                 $this->cacheBreadcrumbs[$parent['ID']] = $path;
             }
         }
         if (isset($this->cacheBreadcrumbs[$parentId])) {
             $this->cacheBreadcrumbs[$realId] = $this->cacheBreadcrumbs[$parentId];
             if ($object->isLink()) {
                 $this->cacheBreadcrumbs[$object->getRealObject()->getId()] = $this->cacheBreadcrumbs[$realId];
             }
         } else {
             $this->cacheBreadcrumbs[$realId] = null;
         }
     }
     return $this->cacheBreadcrumbs[$realId];
 }
示例#22
0
 /**
  * Gets path to list where file or folder.
  * @param BaseObject $object Target file or folder.
  * @return string
  */
 public function getPathInListing(BaseObject $object)
 {
     if ($object->getStorage()->getRootObjectId() == $object->getId()) {
         return $object->getStorage()->getProxyType()->getBaseUrlFolderList();
     }
     $crumbs = implode('/', CrumbStorage::getInstance()->getByObject($object));
     if ($crumbs) {
         $crumbs .= '/';
     }
     return $object->getStorage()->getProxyType()->getBaseUrlFolderList() . $crumbs;
 }
示例#23
0
 /**
  * Getting id for module search.
  * @param BaseObject $object
  * @return string
  */
 private static function getItemId(BaseObject $object)
 {
     if ($object instanceof File) {
         return 'FILE_' . $object->getId();
     }
     return 'FOLDER_' . $object->getId();
 }
示例#24
0
 public static function getMapReferenceAttributes()
 {
     return array('OBJECT' => BaseObject::className(), 'VERSION' => Version::className(), 'TMP_FILE' => TmpFile::className(), 'USER' => array('class' => User::className(), 'select' => User::getFieldsForSelect()));
 }
示例#25
0
 /**
  * @return array
  */
 public static function getMapReferenceAttributes()
 {
     $storageClassName = Storage::className();
     $objectClassName = BaseObject::className();
     return array('PARENT' => static::className(), 'LINK_OBJECT' => $objectClassName, 'REAL_OBJECT' => $objectClassName, 'LINK_STORAGE' => $storageClassName, 'REAL_STORAGE' => $storageClassName, 'CREATE_USER' => array('class' => User::className(), 'select' => User::getFieldsForSelect()));
 }
示例#26
0
 /**
  * @param $path
  * @param File|Folder|Object $object
  * @return CDavResource
  */
 protected function getResourceByObject($path, BaseObject $object)
 {
     $isFolder = $object instanceof Folder;
     $resource = new CDavResource($path . ($isFolder && substr($path, -1, 1) != "/" ? "/" : ""));
     $resource->AddProperty('name', $object->getName());
     if ($object instanceof File) {
         $resource->AddProperty('getcontentlength', $object->getSize());
     }
     $resource->AddProperty('creationdate', $object->getCreateTime()->getTimestamp());
     $resource->AddProperty('getlastmodified', $object->getUpdateTime()->getTimestamp());
     $resource->AddProperty('iscollection', $isFolder ? '1' : '0');
     $resource->AddProperty('Win32CreationTime', $object->getCreateTime()->getTimestamp(), "urn:schemas-microsoft-com:");
     $resource->AddProperty('Win32LastModifiedTime', $object->getUpdateTime()->getTimestamp(), "urn:schemas-microsoft-com:");
     if ($isFolder) {
         $resource->AddProperty('resourcetype', array('collection', ''));
         $resource->AddProperty('getcontenttype', 'httpd/unix-directory');
     } else {
         $resource->AddProperty('getcontenttype', '');
         $resource->AddProperty('isreadonly', '');
         $resource->AddProperty('ishidden', '');
         $resource->AddProperty('resourcetype', '');
     }
     $resource->AddProperty("supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>");
     /*
       <D:response xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
      	<D:href>/docs/shared/%D0%97%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B8</D:href>
      	 <D:propstat>
      	  <D:prop>
      	   <D:resourcetype><D:collection/></D:resourcetype>
      	   <D:getcontenttype>httpd/unix-directory</D:getcontenttype>
      	   <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:37:25Z</D:creationdate>
      	   <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:37:25 GMT</D:getlastmodified>
      	   <D:iscollection/>
      	   <D:supportedlock><D:lockentry>
      						<D:lockscope><D:exclusive/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry>
      					<D:lockentry>
      						<D:lockscope><D:shared/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry></D:supportedlock>
      	 </D:prop>
      	 <D:status>HTTP/1.1 200 OK</D:status>
      	</D:propstat>
       </D:response>
     
     
       <D:response xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
      	<D:href>/docs/shared/%D0%90%D0%BD%D0%BA%D0%B5%D1%82%D0%B0.docx</D:href>
      	 <D:propstat>
      	  <D:prop>
      	   <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:26:30Z</D:creationdate>
      	   <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:26:31 GMT</D:getlastmodified>
      	   <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:26:30Z</D:creationdate>
      	   <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:26:31 GMT</D:getlastmodified>
      	   <D:getcontenttype/>
      	   <D:getcontentlength>86838</D:getcontentlength>
      	   <D:isreadonly>false</D:isreadonly>
      	   <D:ishidden>false</D:ishidden>
      	   <D:iscollection>0</D:iscollection>
      	   <D:resourcetype/>
      	   <D:supportedlock><D:lockentry>
      						<D:lockscope><D:exclusive/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry>
      					<D:lockentry>
      						<D:lockscope><D:shared/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry></D:supportedlock>
      	 </D:prop>
      	 <D:status>HTTP/1.1 200 OK</D:status>
      	</D:propstat>
       </D:response>
     */
     return $resource;
 }