コード例 #1
0
ファイル: crumbstorage.php プロジェクト: DarneoStudio/bitrix
 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()];
 }
コード例 #2
0
ファイル: sharing.php プロジェクト: mrdeadmouse/u136006
 /**
  * @return BaseObject
  */
 public function getRealObject()
 {
     if (!$this->realObjectId) {
         return null;
     }
     if (isset($this->realObject) && $this->realObjectId === $this->realObject->getId()) {
         return $this->realObject;
     }
     $this->realObject = BaseObject::loadById($this->realObjectId);
     return $this->realObject;
 }
コード例 #3
0
ファイル: version.php プロジェクト: mrdeadmouse/u136006
 /**
  * @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;
 }
コード例 #4
0
ファイル: viewer.php プロジェクト: DarneoStudio/bitrix
 /**
  * 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;
 }
コード例 #5
0
ファイル: deletedlog.php プロジェクト: DarneoStudio/bitrix
 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);
 }
コード例 #6
0
ファイル: indexmanager.php プロジェクト: mrdeadmouse/u136006
 /**
  * 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();
 }
コード例 #7
0
ファイル: class.php プロジェクト: mrdeadmouse/u136006
 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);
 }
コード例 #8
0
ファイル: diskstorage.php プロジェクト: DarneoStudio/bitrix
 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];
 }
コード例 #9
0
ファイル: indexmanager.php プロジェクト: DarneoStudio/bitrix
 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;
 }
コード例 #10
0
ファイル: entry.php プロジェクト: DarneoStudio/bitrix
 public function linkObject(BaseObject $object)
 {
     $update = $this->update(array('OBJECT_ID' => $object->getId()));
     if ($update) {
         $this->setAttributes(array('OBJECT' => $object));
     }
     return $update;
 }
コード例 #11
0
ファイル: urlmanager.php プロジェクト: mrdeadmouse/u136006
 /**
  * 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;
 }
コード例 #12
0
ファイル: rightsmanager.php プロジェクト: DarneoStudio/bitrix
 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);
 }
コード例 #13
0
ファイル: rightsmanager.php プロジェクト: DarneoStudio/bitrix
 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;
 }