コード例 #1
0
ファイル: iblock.php プロジェクト: mrdeadmouse/u136006
 function GetNavChain($options = array(), $for_url = false)
 {
     static $nav_chain = array();
     $bReturn = strtoupper($for_url) === "ARRAY" ? "ARRAY" : ($for_url === true ? "URL" : "SITE");
     if (empty($options) && isset($this->arParams["dir_array"])) {
         // === to deal with 0 at the root of IB
         $options["section_id"] = intval($this->arParams["dir_array"]["ID"]);
     } elseif (isset($options['section_id'])) {
         $options['section_id'] = intval($options['section_id']);
     }
     //mixin iblock id for symlinksection
     $dataCache = $options;
     $dataCache['IBLOCK_ID'] = $this->IBLOCK_ID;
     $dataCache['ROOT_SECTION_ID'] = empty($this->arRootSection['ID']) ? 0 : $this->arRootSection['ID'];
     $id = md5(serialize($dataCache));
     if (!array_key_exists($id, $nav_chain)) {
         if ($this->CACHE_OBJ && $this->CACHE_OBJ->InitCache($this->CACHE_TIME, $id, $this->CACHE_PATH . "nav_chain")) {
             $nav_chain[$id] = $this->CACHE_OBJ->GetVars();
         } else {
             $options['check_permissions'] = false;
             $arObject = $this->GetObject($options);
             $nav_chain[$id] = array("URL" => array(), "SITE" => array(), "ARRAY" => array());
             if ($arObject["not_found"] == false && intVal($arObject["item_id"]) > 0) {
                 $arFile = array();
                 $section_id = $arObject["item_id"];
                 if ($arObject["is_file"]) {
                     $arFile = $arObject["element_array"];
                     $section_id = $arFile["IBLOCK_SECTION_ID"];
                     $sectionData = $this->getSectionDataForLinkAnalyze($arFile['IBLOCK_SECTION_ID'], array('ID' => $arFile['IBLOCK_SECTION_ID'], 'IBLOCK_ID' => $arObject['element_array']['IBLOCK_ID']));
                 } else {
                     $sectionData = $this->getSectionDataForLinkAnalyze($arObject["item_id"], array('ID' => $arObject["item_id"], 'IBLOCK_ID' => empty($arObject['dir_array']['IBLOCK_ID']) ? $this->IBLOCK_ID : $arObject['dir_array']['IBLOCK_ID']));
                 }
                 //simple detect link
                 list($contextType, $contextEntityId) = $this->getContextData();
                 $isSymlink = !$this->_symlinkMode && CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData);
                 if ($isSymlink) {
                     $symlinkSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData);
                 }
                 if ($this->_symlinkMode) {
                     $bRootFounded = empty($this->_symlinkRealRootSectionData) ? true : false;
                     foreach (CWebDavSymlinkHelper::getNavChain($this->_symlinkSectionData['IBLOCK_ID'], $this->_symlinkSectionData['ID']) as $res) {
                         $this->MetaNames($res);
                         if (!$bRootFounded && $res["ID"] == $this->_symlinkRealRootSectionData["ID"]) {
                             $bRootFounded = true;
                             continue;
                         }
                         if (!$bRootFounded) {
                             continue;
                         }
                         $url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
                         $nav_chain[$id]["URL"][] = $url;
                         $nav_chain[$id]["SITE"][] = $res["NAME"];
                         $nav_chain[$id]["ARRAY"][] = $res + array("URL" => $url);
                     }
                 }
                 $iblockId = $this->IBLOCK_ID;
                 $sectionId = $section_id;
                 if ($isSymlink) {
                     $iblockId = $symlinkSectionData['IBLOCK_ID'];
                     $sectionId = $symlinkSectionData['ID'];
                 }
                 $bRootFounded = empty($this->arRootSection) ? true : false;
                 foreach (CWebDavSymlinkHelper::getNavChain($iblockId, $sectionId) as $res) {
                     $this->MetaNames($res);
                     if (!$bRootFounded && $res["ID"] == $this->arRootSection["ID"]) {
                         $bRootFounded = true;
                         continue;
                     }
                     if (!$bRootFounded) {
                         continue;
                     }
                     $url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
                     $nav_chain[$id]["URL"][] = $url;
                     $nav_chain[$id]["SITE"][] = $res["NAME"];
                     $nav_chain[$id]["ARRAY"][] = $res + array("URL" => $url);
                 }
                 if ($isSymlink) {
                     $bRootFounded = empty($symlinkSectionData[self::UF_LINK_SECTION_ID]) ? true : false;
                     foreach (CWebDavSymlinkHelper::getNavChain($symlinkSectionData[self::UF_LINK_IBLOCK_ID], $section_id) as $res) {
                         $this->MetaNames($res);
                         if (!$bRootFounded && $res["ID"] == $symlinkSectionData[self::UF_LINK_SECTION_ID]) {
                             $bRootFounded = true;
                             continue;
                         }
                         if (!$bRootFounded) {
                             continue;
                         }
                         $url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
                         $nav_chain[$id]["URL"][] = $url;
                         $nav_chain[$id]["SITE"][] = $res["NAME"];
                         $nav_chain[$id]["ARRAY"][] = $res + array("URL" => $url);
                     }
                 }
                 if (!empty($arFile)) {
                     $url = $this->_uencode($res["NAME"], array("utf8" => "Y", "convert" => "full"));
                     $nav_chain[$id]["URL"][] = $url;
                     $nav_chain[$id]["SITE"][] = $arFile["NAME"];
                     $nav_chain[$id]["ARRAY"][] = $arFile + array("URL" => $url);
                 }
             }
             if ($this->CACHE_OBJ) {
                 $this->CACHE_OBJ->StartDataCache($this->CACHE_TIME, $id, $this->CACHE_PATH . "_nav_chain");
                 $this->CACHE_OBJ->EndDataCache($nav_chain[$id]);
             }
         }
     }
     $res = $nav_chain[$id][$bReturn];
     return is_array($res) ? $res : array();
 }
コード例 #2
0
 public function processActionDelete(array $params)
 {
     $this->enableIgnoreQuotaError();
     $this->checkRequiredParams($params, array('id', 'version', 'extra', 'storageExtra', 'storageId'));
     //isDirectory
     $id = $params['id'];
     $version = $params['version'];
     $isDirectory = (bool) $params['isDirectory'];
     $lastVersion = null;
     $isDirectory = (bool) $isDirectory;
     $storage = $this->getStorageObject($params['storageExtra'], $params['storageId']);
     $extra = $storage->parseElementExtra($params['extra']);
     $element = $isDirectory ? $storage->getDirectory($id, $extra) : $storage->getFile($id, $extra);
     //todo check invite, if file under symlink
     if ($element && $extra['inSymlink']) {
         $chain = CWebDavSymlinkHelper::getNavChain($element['extra']['iblockId'], $element['extra']['sectionId']);
         $sectionIds = array();
         foreach ($chain as $item) {
             $sectionIds[] = $item['ID'];
         }
         unset($item, $chain);
         //has current user invite on this section?
         $query = \Bitrix\Webdav\FolderInviteTable::getList(array('select' => array('ID'), 'filter' => array('INVITE_USER_ID' => $this->getUser()->getId(), 'IS_APPROVED' => true, 'IS_DELETED' => false, 'SECTION_ID' => $sectionIds)));
         $row = $query->fetch();
         if (!isset($row['ID'])) {
             return $this->sendResponse(array('status' => static::STATUS_NOT_FOUND, 'message' => 'Link detached'));
         }
     }
     if ($element) {
         if ($storage::compareVersion($element['version'], $version) > 0) {
             $element['status'] = static::STATUS_OLD_VERSION;
             return $this->sendResponse($element);
         }
         $lastVersion = $isDirectory ? $storage->deleteDirectory($element) : $storage->deleteFile($element);
     } else {
         $lastVersion = $storage->getVersionDelete(array('id' => $id, 'version' => $version, 'isDirectory' => $isDirectory, 'extra' => $extra));
     }
     if ((bool) $lastVersion) {
         CWebDavTools::runEvent($isDirectory ? static::ON_AFTER_DISK_FOLDER_DELETE : static::ON_AFTER_DISK_FILE_DELETE, array($element['extra']['id'], $element));
         return $this->sendSuccess(array('version' => $this->convertToExternalVersion((string) $lastVersion)));
     }
     return $this->sendResponse(array('status' => static::STATUS_NOT_FOUND));
 }