Exemplo n.º 1
0
 function _getIBlockItemsCount($ib, $section = null, $object = false, $object_id = false)
 {
     $arFilter = array("IBLOCK_ID" => intval($ib), "INCLUDE_SUBSECTIONS" => "Y", "CHECK_PERMISSIONS" => "N", "ACTIVE" => "Y");
     if ($section !== null) {
         $arFilter["SECTION_ID"] = intval($section);
     }
     if ($object !== false) {
         if ($object == "user") {
             $arFilter["CREATED_BY"] = $object_id;
         } else {
             $arFilter["SOCNET_GROUP_ID"] = $object_id;
         }
         $arFilter["SECTION_ID"] = 0;
         $dbRes = CIBLockSection::GetList(array(), $arFilter, false);
         // find GROUP/USER SECTION_ID
         if ($dbRes && ($arRes = $dbRes->Fetch())) {
             $arFilter["SECTION_ID"] = $arRes["ID"];
         } else {
             return 0;
         }
     }
     $itemsCount = CIBlockElement::GetList(array(), $arFilter, array(), false);
     // decrement by trash size
     $arParams = array();
     if ($object !== false) {
         $arParams["ROOT_SECTION_ID"] = $arFilter["SECTION_ID"];
         $arParams["ATTRIBUTES"] = $object == "user" ? array('user_id' => $object_id) : array('group_id' => $object_id);
     }
     $ob = new CWebDavIblock($arFilter['IBLOCK_ID'], '', $arParams);
     $arFilter["SECTION_ID"] = array($ob->GetMetaID("TRASH", false), $ob->GetMetaID("DROPPED", false));
     unset($ob);
     $trashAndDroppedItemsCount = CIBlockElement::GetList(array(), $arFilter, array(), false);
     $itemsCount -= $trashAndDroppedItemsCount;
     return $itemsCount;
 }
Exemplo n.º 2
0
 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);
         	}
         */
     }
 }
Exemplo n.º 3
0
 function saveFile(&$name, $arFile, &$arElement)
 {
     $ob = $this->ob;
     $arResult = $this->arResult;
     $arParams = $this->arParams;
     $res = array();
     $name = CWebDavIblock::CorrectName($name);
     $arDocumentStates = !isset($arParams['arDocumentStates']) ? array() : $arParams['arDocumentStates'];
     $bRandom = isset($_REQUEST['random_folder']) && $_REQUEST['random_folder'] == 'Y';
     $bDropped = $bRandom || isset($_REQUEST['dropped']) && $_REQUEST['dropped'] == 'Y';
     if ($bDropped) {
         $arParams['SECTION_ID'] = $ob->GetMetaID("DROPPED");
         //Add (1), (2), etc. if name non unique in traget dir
         $mainPartName = $name;
         $newName = $mainPartName;
         $countNonUnique = 0;
         while (!$ob->CheckUniqueName($newName, $arParams["SECTION_ID"], $res)) {
             $countNonUnique++;
             $newName = strstr($mainPartName, '.', true) . " ({$countNonUnique})" . strstr($mainPartName, '.');
         }
         $name = $newName;
     } elseif (!$ob->CheckUniqueName($name, $arParams["SECTION_ID"], $res)) {
         if ($res["object"] == "section") {
             $arFileError[] = array("id" => "double_name_section", "text" => str_replace("#NAME#", $arFile["name"], GetMessage("WD_ERROR_DOUBLE_NAME_SECTION")));
         } else {
             if ($res["data"]["ID"] == $arResult["ELEMENT"]["WF_PARENT_ELEMENT_ID"]) {
                 $arElement = $arResult["ELEMENT"];
             } else {
                 $arElement = $res["data"];
             }
             if ($ob->workflow == "bizproc") {
                 $docID = $arParams['DOCUMENT_TYPE'];
                 $docID[2] = $res["data"]["ID"];
                 $arDocumentStates = CBPDocument::GetDocumentStates($arParams["DOCUMENT_TYPE"], $docID);
             }
             if ($arParams["USE_WORKFLOW"] == "Y" && intVal($res["data"]["WF_PARENT_ELEMENT_ID"]) > 0) {
                 $arElement["ID"] = $res["data"]["WF_PARENT_ELEMENT_ID"];
             }
             if ($_REQUEST["overview"] != "Y") {
                 if ($name != $arFile["name"]) {
                     $arFileError[] = array("id" => "double_name_element", "text" => str_replace(array("#NAME#", "#TITLE#"), array($arFile["name"], $name), GetMessage("WD_ERROR_DOUBLE_NAME_TITLE")));
                 } else {
                     $arFileError[] = array("id" => "double_name_element", "text" => str_replace("#NAME#", $arFile["name"], GetMessage("WD_ERROR_DOUBLE_NAME_ELEMENT")));
                 }
             } elseif ($arParams["CHECK_CREATOR"] == "Y" && $arElement["CREATED_BY"] != $GLOBALS['USER']->GetId()) {
                 $arFileError[] = array("id" => "double_name_element", "text" => str_replace("#NAME#", $arFile["name"], GetMessage("WD_ERROR_DOUBLE_NAME_ELEMENT_NOT_REWRITE")));
             } elseif ($arParams["USE_WORKFLOW"] == "Y" && ($res["data"]["WF_STATUS_ID"] > 1 && $arResult["WF_STATUSES_PERMISSION"][$res["data"]["WF_STATUS_ID"]] < 2)) {
                 if ($name != $arFile["name"]) {
                     $arFileError[] = array("id" => "double_name_element", "text" => str_replace(array("#NAME#", "#TITLE#"), array($arFile["name"], $name), GetMessage("WD_ERROR_DOUBLE_NAME_TITLE")));
                 } else {
                     $arFileError[] = array("id" => "double_name_element_and_bad_permission", "text" => str_replace("#NAME#", $arFile["name"], GetMessage("WD_ERROR_DOUBLE_NAME_ELEMENT")));
                 }
             }
         }
     }
     if ($arParams['ELEMENT_ID'] > 0 && $arResult['ELEMENT']['FILE_EXTENTION'] != strtolower(strrchr($arFile["name"], '.'))) {
         $arFileError[] = array("id" => "extensions_dont_match", "text" => GetMessage("WD_ERROR_EXTENSIONS_DONT_MATCH"));
     }
     //this is new element
     if (empty($arElement)) {
         if (!$ob->CheckWebRights("PUT", array('arElement' => array('is_dir' => false, 'parent_id' => $arParams["SECTION_ID"]), 'action' => 'create', 'create_element_in_section' => true), false)) {
             $arFileError[] = array("id" => "bad_file", "text" => $ob->LAST_ERROR ? $ob->LAST_ERROR : GetMessage("WD_ERROR_UPLOAD_BAD_FILE"));
         }
     }
     if (empty($arFileError)) {
         $options = array("new" => empty($arElement), 'dropped' => $bDropped, "arFile" => $arFile, "arDocumentStates" => $arDocumentStates, "arUserGroups" => $ob->USER["GROUPS"], "FILE_NAME" => $name, "IBLOCK_ID" => $arParams["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $arParams["SECTION_ID"], "TAGS" => $arFile["TAGS"], "PREVIEW_TEXT" => $arFile["DESCRIPTION"]);
         if (intVal($_POST["WF_STATUS_ID"]) > 0) {
             $options["WF_STATUS_ID"] = $_POST["WF_STATUS_ID"];
         }
         if (!empty($arElement)) {
             $options["ELEMENT_ID"] = $arElement["ID"];
         } else {
             $options["arUserGroups"][] = "Author";
         }
         $options['USER_FIELDS'] = array();
         $GLOBALS['USER_FIELD_MANAGER']->EditFormAddFields($ob->GetUfEntity(), $options['USER_FIELDS']);
         if (!$ob->put_commit($options)) {
             $arFileError[] = array("id" => "error_put", "text" => $ob->LAST_ERROR);
         } else {
             $arElement['ID'] = $options['ELEMENT_ID'];
         }
         $arElement["dropped"] = $bDropped ? "Y" : "N";
     }
     if (empty($arFileError)) {
         $io = CBXVirtualIo::GetInstance();
         $file = $io->GetFile($arFile["tmp_name"]);
         $file->unlink();
         return true;
     }
     return $arFileError;
 }
Exemplo n.º 4
0
 public static function getUFForPostForm($arParams)
 {
     $arFileData = array();
     $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], LANGUAGE_ID);
     $ufCode = $arParams["UF_CODE"];
     if (!empty($arUF[$ufCode]) && !empty($arUF[$ufCode]["VALUE"])) {
         if ($arParams["IS_DISK_OR_WEBDAV_INSTALLED"]) {
             if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::IncludeModule('disk')) {
                 $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager();
                 $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
                 $userFieldManager->loadBatchAttachedObject($arUF[$ufCode]["VALUE"]);
                 foreach ($arUF[$ufCode]["VALUE"] as $attachedId) {
                     $attachedObject = $userFieldManager->getAttachedObjectById($attachedId);
                     if ($attachedObject) {
                         $file = $attachedObject->getObject();
                         $fileName = $file->getName();
                         $fileUrl = $urlManager->getUrlUfController('download', array('attachedId' => $attachedId));
                         $fileUrl = str_replace("/bitrix/tools/disk/uf.php", SITE_DIR . "mobile/ajax.php", $fileUrl);
                         $fileUrl = $fileUrl . (strpos($fileUrl, "?") === false ? "?" : "&") . "mobile_action=disk_uf_view&filename=" . $fileName;
                         if (\Bitrix\Disk\TypeFile::isImage($file) && ($realFile = $file->getFile())) {
                             $previewImageUrl = $urlManager->getUrlUfController('show', array('attachedId' => $attachedId, 'width' => 144, 'height' => 144, 'exact' => 'Y', 'signature' => \Bitrix\Disk\Security\ParameterSigner::getImageSignature($attachedId, 144, 144)));
                         } else {
                             $previewImageUrl = false;
                         }
                         $icon = CMobileHelper::mobileDiskGetIconByFilename($fileName);
                         $iconUrl = CComponentEngine::makePathFromTemplate('/bitrix/components/bitrix/mobile.disk.file.detail/images/' . $icon);
                         $fileFata = array('type' => $file->getExtension(), 'ufCode' => $ufCode, 'id' => $attachedId, 'extension' => $file->getExtension(), 'name' => $fileName, 'url' => $fileUrl, 'iconUrl' => $iconUrl);
                         if ($previewImageUrl) {
                             $fileFata['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                         }
                         $arFileData[] = $fileFata;
                     }
                 }
             } else {
                 $data = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID());
                 if (is_array($data)) {
                     $ibe = new CIBlockElement();
                     $dbWDFile = $ibe->GetList(array(), array('ID' => $arUF[$ufCode]["VALUE"], 'IBLOCK_ID' => $data["IBLOCK_ID"]), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_FILE'));
                     while ($arWDFile = $dbWDFile->Fetch()) {
                         if ($arFile = CFile::GetFileArray($arWDFile["PROPERTY_FILE_VALUE"])) {
                             if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                                 $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true);
                                 $previewImageUrl = $imageResized["src"];
                             } else {
                                 $previewImageUrl = false;
                             }
                             $fileExtension = GetFileExtension($arFile["FILE_NAME"]);
                             $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arWDFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'url' => $arFile["SRC"]);
                             if ($previewImageUrl) {
                                 $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                             }
                             $arFileData[] = $fileData;
                         }
                     }
                 }
             }
         } else {
             $dbRes = CFile::GetList(array(), array("@ID" => implode(",", $arUF[$ufCode]["VALUE"])));
             while ($arFile = $dbRes->GetNext()) {
                 if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                     $imageResized = CFile::ResizeImageGet($arFile["ID"], array("width" => 144, "height" => 144), BX_RESIZE_IMAGE_EXACT, false, true);
                     $previewImageUrl = $imageResized["src"];
                 } else {
                     $previewImageUrl = false;
                 }
                 $fileExtension = GetFileExtension($arFile["FILE_NAME"]);
                 $fileData = array('type' => $fileExtension, 'ufCode' => $ufCode, 'id' => $arFile["ID"], 'extension' => $fileExtension, 'name' => $arFile["FILE_NAME"], 'downloadUrl' => $arFile["SRC"]);
                 if ($previewImageUrl) {
                     $fileData['previewImageUrl'] = CHTTP::URN2URI($previewImageUrl);
                 }
                 $arFileData[] = $fileData;
             }
         }
     }
     return $arFileData;
 }
Exemplo n.º 5
0
     ShowError(GetMessage("IBLOCK_MODULE_NOT_INSTALLED"));
     return;
 }
 if (is_numeric($arParams["IBLOCK_ID"])) {
     $rsIBlock = CIBlock::GetList(array(), array("ACTIVE" => "Y", "ID" => $arParams["IBLOCK_ID"]));
 } else {
     $rsIBlock = CIBlock::GetList(array(), array("ACTIVE" => "Y", "CODE" => $arParams["IBLOCK_ID"]));
 }
 if ($arResult = $rsIBlock->GetNext()) {
     $arResult["USER_HAVE_ACCESS"] = $bUSER_HAVE_ACCESS;
     if (!CModule::IncludeModule("webdav")) {
         $this->AbortResultCache();
         ShowError(GetMessage("WEBDAV_MODULE_NOT_INSTALLED"));
         return;
     }
     $ob = new CWebDavIblock($arResult['ID'], '', array());
     $arFiles = array();
     $arOptions = array('path' => '/', 'depth' => '1');
     $arFilter = array(true);
     $arPropParams = array('PARENT_ID' => null, 'return' => 'nav_result', 'COLUMNS' => array('ACTIVE_FROM', 'PREVIEW_PICTURE'));
     $bGetProperty = count($arParams["PROPERTY_CODE"]) > 0;
     if ($bGetProperty) {
         $arPropParams['COLUMNS'][] = "PROPERTY_*";
     }
     if ($arParams["CHECK_DATES"]) {
         $arFilter["ACTIVE_DATE"] = "Y";
     }
     if ($arParams["PARENT_SECTION"] > 0) {
         $arFilter["SECTION_ID"] = $arParams["PARENT_SECTION"];
         $arPropParams["PARENT_ID"] = $arParams["PARENT_SECTION"];
         if ($arParams["INCLUDE_SUBSECTIONS"]) {
Exemplo n.º 6
0
 function _isDropped($iblockID, $sectionID)
 {
     if (!CModule::IncludeModule('iblock')) {
         return false;
     }
     $droppedName = CWebDavIblock::getDroppedMetaData();
     $droppedName = isset($droppedName['name']) ? $droppedName['name'] : '.Dropped';
     //set to default ".Dropped". It's unbelievable, but...
     $dropped = false;
     $dbChain = CIBlockSection::GetNavChain($iblockID, $sectionID);
     if ($dbChain) {
         if ($arChain = $dbChain->Fetch()) {
             if ($arChain["NAME"] == $droppedName) {
                 $dropped = true;
             } else {
                 if ($arChain = $dbChain->Fetch()) {
                     if ($arChain["NAME"] == $droppedName) {
                         $dropped = true;
                     }
                 }
             }
         }
     }
     return $dropped;
 }
Exemplo n.º 7
0
$page = $arParsedUrl ? $arParsedUrl['path'] : $_SERVER['REQUEST_URI'];
/************** Initial object *************************************/
$arParams["DOCUMENT_TYPE"] = array("webdav", "CIBlockDocumentWebdavSocnet", "iblock_" . $arParams["IBLOCK_ID"] . "_" . $object . "_" . intVal($object == "user" ? $arResult["VARIABLES"]["user_id"] : $arResult["VARIABLES"]["group_id"]));
$arBizProcParameters = array("object" => $object, "owner" => $object == "user" ? $arResult["VARIABLES"]["user_id"] : $arResult["GROUP"]["OWNER_ID"], "moderator" => strtolower($object == "user" ? SONET_RELATIONS_TYPE_NONE : SONET_ROLES_MODERATOR), "path" => $object == "user" ? $arResult["PATH_TO_USER_FILES_WEBDAV_BIZPROC_VIEW"] : $arResult["PATH_TO_GROUP_FILES_WEBDAV_BIZPROC_VIEW"], "document_type" => $ob->wfParams['DOCUMENT_TYPE'][2]);
$user_id_str = intVal($arResult["VARIABLES"]["user_id"]) > 0 ? $arResult["VARIABLES"]["user_id"] : $GLOBALS["USER"]->GetId();
$arBizProcParameters["path"] = str_replace(array("#user_id#", "#group_id#", "#element_id#"), array($user_id_str, $arResult["VARIABLES"]["group_id"], "{=Document:ID}"), $arBizProcParameters["path"]);
/************** Root Section ***************************************/
$arParams["ROOT_SECTION_ID"] = __wd_get_root_section($arParams["IBLOCK_ID"], $object, $object == 'user' ? $arResult["VARIABLES"]["user_id"] : $arResult["VARIABLES"]["group_id"]);
if ($arParams["ROOT_SECTION_ID"] === true) {
    BXClearCache(true, $ob->CACHE_PATH);
    LocalRedirect($APPLICATION->GetCurPageParam("", array("create_lib", "sessid")));
}
if ($object == "user") {
    CIBlockWebdavSocnet::CreateSharedFolder($arParams["IBLOCK_ID"], $arParams["ROOT_SECTION_ID"], $arResult["VARIABLES"]["user_id"]);
}
$arParams["OBJECT"] = $ob = new CWebDavIblock($arParams['IBLOCK_ID'], $arResult['BASE_URL'], $arParams + array("SHORT_PATH_TEMPLATE" => "/" . ($object == "user" ? $arDefaultUrlTemplates404["user_files_short"] : $arDefaultUrlTemplates404["group_files_short"]), "ATTRIBUTES" => $object == "user" ? array('user_id' => $arResult["VARIABLES"]["user_id"]) : array('group_id' => $arResult["VARIABLES"]["group_id"])));
if (!empty($ob->arError)) {
    $e = new CAdminException($ob->arError);
    $GLOBALS["APPLICATION"]->ThrowException($e);
    $res = $GLOBALS["APPLICATION"]->GetException();
    if ($res) {
        ShowError($res->GetString());
        return false;
    }
} elseif ($ob->permission <= "D") {
    ShowError(GetMessage("WD_ACCESS_DENIED"));
    return false;
}
$ob->file_prop = $arParams["NAME_FILE_PROPERTY"];
$ob->replace_symbols = $arParams["REPLACE_SYMBOLS"] == "Y" ? true : false;
$arParams['WORKFLOW'] = $ob->workflow;
Exemplo n.º 8
0
 /**
  * @param $arFilter - array("FORUM_ID" => 241, "TOPIC_ID" => 82383, "APPROVED" => "Y")
  * @param $rights - string(1) (A|R|U|W);
  */
 public static function setWebdavRights($arFilter, $rights)
 {
     if (IsModuleInstalled("webdav")) {
         $arFilter = is_array($arFilter) ? $arFilter : array($arFilter);
         $arFilter[">UF_FORUM_MESSAGE_DOC"] = 0;
         $db_res = CForumMessage::GetList(array("ID" => "ASC"), $arFilter, false, 0, array("SELECT" => array("UF_FORUM_MESSAGE_DOC")));
         $arDocs = array();
         if ($db_res && ($res = $db_res->Fetch())) {
             do {
                 if (!empty($res["UF_FORUM_MESSAGE_DOC"]) && is_array($res["UF_FORUM_MESSAGE_DOC"])) {
                     $arDocs = array_merge($arDocs, $res["UF_FORUM_MESSAGE_DOC"]);
                 }
             } while ($res = $db_res->Fetch());
         }
         if (!empty($arDocs) && CModule::IncludeModule("webdav")) {
             CWebDavIblock::appendRightsOnElements($arDocs, $rights);
         }
     }
 }
Exemplo n.º 9
0
 public function getDownloadedSectionId($iblockId, $parentSectionId, array $additionalData = array())
 {
     $metaData = CWebDavIblock::getDroppedMetaData();
     $sectionId = CWebDavIblock::findMetaSection($metaData['name'], $iblockId, $parentSectionId);
     if (!$sectionId) {
         $sectionId = CWebDavIblock::createMetaSection($metaData['name'], $iblockId, $parentSectionId, $additionalData);
     }
     return $sectionId;
 }
Exemplo n.º 10
0
 protected function recoverExtensionInName(array &$fileData, $mimeType)
 {
     $originalExtension = strtolower(trim(CWebDavIblock::getExtensionByMimeType($mimeType), '.'));
     $newExtension = strtolower(trim(GetFileExtension($fileData['name']), '.'));
     if ($originalExtension != $newExtension) {
         $fileData['name'] = GetFileNameWithoutExtension($fileData['name']) . '.' . $originalExtension;
         return true;
     }
     return false;
 }
Exemplo n.º 11
0
$langFilename = dirname(__FILE__) . '/lang/' . $lng . '/ajax.php';
if (file_exists($langFilename)) {
    __IncludeLang($langFilename);
}
if (CModule::IncludeModule('compression')) {
    CCompress::Disable2048Spaces();
}
session_write_close();
$arParams["USE_AUTH"] = "Y";
$baseURL = $arParams["BASE_URL"];
$arParams["BASE_URL"] = ($APPLICATION->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $baseURL . "/");
$arParams["NOT_SAVE_SUG_FILES"] = true;
if ($arParams["RESOURCE_TYPE"] == "FOLDER") {
    $ob = new CWebDavFile($arParams, $baseURL);
} else {
    $ob = new CWebDavIblock(intval($arParams['IBLOCK_ID']), $baseURL, $arParams);
    if ($requestTupe == "user" && !empty($filesOwnerUserID)) {
        $ob->attributes['user_id'] = $filesOwnerUserID;
    }
}
if ($ob->IsDir()) {
    $arResFiles = array();
    $optionsQ = array('path' => $ob->_path, 'depth' => 1, 'check_permissions' => true);
    $arSelectedFieldsQ = array('NAME', 'FILE_TUPES');
    $filesQ = null;
    $arFilterQ = array();
    $resQ = $ob->PROPFIND($optionsQ, $filesQ, array("FILTER" => $arFilterQ, "COLUMNS" => $arSelectedFieldsQ, "return" => "nav_result", "get_clones" => "Y", 'NON_TRASH_SECTION' => true, 'NON_OLD_DROPPED_SECTION' => true));
    $foldersNum = 0;
    $filesNum = 0;
    if (is_array($resQ) && array_key_exists("NAV_RESULT", $resQ)) {
        while ($arF = $resQ["NAV_RESULT"]->Fetch()) {
Exemplo n.º 12
0
             $children = $folder->getChildren($securityContext, array('filter' => array("ID" => $_SESSION[$varKeyDocs])));
             foreach ($children as $oDiskFile) {
                 $rsFile = CFile::GetByID($oDiskFile->getFileId());
                 if ($arFile = $rsFile->Fetch()) {
                     if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                         $image_resize = CFile::ResizeImageGet($arFile["ID"], array("width" => $arParams["THUMBNAIL_SIZE"], "height" => $arParams["THUMBNAIL_SIZE"]), $arParams["THUMBNAIL_RESIZE_METHOD"] == "EXACT" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, false);
                         $arResult["ELEMENTS"][] = array("id" => $oDiskFile->getID(), "src" => $image_resize["src"], "name" => $arFile["ORIGINAL_NAME"]);
                     } else {
                         $arResult["ELEMENTS"][] = array("id" => $oDiskFile->getID(), "src" => "", "name" => $arFile["ORIGINAL_NAME"]);
                     }
                 }
             }
         }
     }
 } else {
     $data = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID());
     if (is_array($data)) {
         $ibe = new CIBlockElement();
         $dbWDFile = $ibe->GetList(array(), array('ID' => $_SESSION[$varKeyDocs], 'IBLOCK_ID' => $data["IBLOCK_ID"]), false, false, array('ID', 'IBLOCK_ID', 'PROPERTY_FILE'));
         while ($arWDFile = $dbWDFile->Fetch()) {
             $rsFile = CFile::GetByID($arWDFile["PROPERTY_FILE_VALUE"]);
             if ($arFile = $rsFile->Fetch()) {
                 if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                     $image_resize = CFile::ResizeImageGet($arFile["ID"], array("width" => $arParams["THUMBNAIL_SIZE"], "height" => $arParams["THUMBNAIL_SIZE"]), $arParams["THUMBNAIL_RESIZE_METHOD"] == "EXACT" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, false);
                     $arResult["ELEMENTS"][] = array("id" => $arWDFile["ID"], "src" => $image_resize["src"], "name" => $arFile["ORIGINAL_NAME"]);
                 } else {
                     $arResult["ELEMENTS"][] = array("id" => $arWDFile["ID"], "src" => "", "name" => $arFile["ORIGINAL_NAME"]);
                 }
             }
         }
     }
Exemplo n.º 13
0
	function SetUFRights($files, $rights)
	{
		static $arTasks = null;

		if (!CModule::IncludeModule('iblock') || !CModule::IncludeModule('webdav'))
			return;

		if (!is_array($rights) || count($rights) <= 0)
			return false;

		if ($files === null || $files===false)
			return false;
		if (!is_array($files))
			$files = array($files);
			
		$arFiles = array();
		foreach($files as $id)
		{
			$id = intval($id);
			if (intval($id) > 0)
				$arFiles[] = $id;
		}

		if (count($arFiles) <= 0)
			return false;

		if ($arTasks == null)
			$arTasks = CWebDavIblock::GetTasks();

		$arCodes = array();
		foreach($rights as $value)
		{
			if (substr($value, 0, 2) === 'SG')
				$arCodes[] = $value.'_K';
			$arCodes[] = $value;
		}
		$arCodes = array_unique($arCodes);

		$i=0;
		$arViewRights = array();
		$curUserID = 'U'.$GLOBALS['USER']->GetID();
		foreach($arCodes as $right)
		{
			if ($curUserID == $right) // do not override owner's rights
				continue;
			$key = "n".$i++;
			$arViewRights[$key] = array(
				"GROUP_CODE" => $right,
				"TASK_ID" => $arTasks["R"],
			);
		}

		$ibe = new CIBlockElement();
		$dbWDFile = $ibe->GetList(array(), array("ID" => $arFiles, "SHOW_NEW" => "Y"), false, false, array("ID", "NAME", "SECTION_ID", "IBLOCK_ID", "WF_NEW"));
		$iblockIds = array();
		if ($dbWDFile)
		{
			while ($arWDFile = $dbWDFile->Fetch())
			{
				$id = $arWDFile["ID"];

				if ($arWDFile["WF_NEW"] == "Y")
					$ibe->Update($id, array("BP_PUBLISHED" => "Y"));

				if (CIBlock::GetArrayByID($arWDFile['IBLOCK_ID'], "RIGHTS_MODE") === "E")
				{
					$ibRights = CWebDavIblock::_get_ib_rights_object("ELEMENT", $id, $arWDFile["IBLOCK_ID"]);
					$ibRights->SetRights(CWebDavTools::appendRights($ibRights, $arViewRights, $arTasks));
					if(empty($iblockIds[$arWDFile["IBLOCK_ID"]]))
						$iblockIds[$arWDFile["IBLOCK_ID"]] = $arWDFile["IBLOCK_ID"];
				}
			}

			global $CACHE_MANAGER;

			foreach ($iblockIds as $iblockId)
				$CACHE_MANAGER->ClearByTag("iblock_id_".$iblockId);

			unset($iblockId);
		}
	}
Exemplo n.º 14
0
                 $destLogin = $arUser['LOGIN'];
             } else {
                 ShowError(GetMessage("WD_USER_NOT_FOUND"));
                 return 0;
             }
             $_SERVER['HTTP_DESTINATION'] = str_replace($destName, $destLogin, $_SERVER['HTTP_DESTINATION']);
             $arLocalPath[0] = $destLogin;
         }
     }
     $userPerms = CIBlockWebdavSocnet::GetUserMaxPermission('user', $userID, $currentUserID, $arParams['IBLOCK_USER_ID']);
     foreach (array('PERMISSION', 'CHECK_CREATOR') as $propName) {
         $arParams[$propName] = $userPerms[$propName];
     }
     $arParams["DOCUMENT_TYPE"] = array("webdav", "CIBlockDocumentWebdavSocnet", "iblock_" . $arParams['IBLOCK_USER_ID'] . "_user_" . intVal($userID));
     $basementPath = $rootPath . '/' . $arLocalPath[0];
     $obGroup = new CWebDavIblock($arParams['IBLOCK_USER_ID'], $basementPath, $arParams);
     $obGroup->SetRootSection($sectionID);
     $currentPageUrl = str_replace(array('#USER_ID#', '#PATH#'), array($userID, ''), $arParams["USER_FILE_PATH"]);
     MakeDavRedirect($obGroup, $currentPageUrl, $rootPath . '/' . $arLocalPath[0], '/' . implode('/', array_slice($arLocalPath, 1)) . '/', false);
 } else {
     // user list
     $userTree = array();
     $CACHE_ID = SITE_ID . '|' . $requestURL . '|' . $currentUserID . '|' . (CWebDavBase::IsDavHeaders('check_all') ? 'D' : 'W') . '|USERLIST';
     $userCache = new CPHPCache();
     if ($userCache->InitCache($arParams["CACHE_TIME"], $CACHE_ID, $cachePath)) {
         $vars = $userCache->GetVars();
         $userTree = $vars['USER_TREE'];
     } else {
         $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_USER_ID"], "SOCNET_GROUP_ID" => false, "CHECK_PERMISSIONS" => "N", "SECTION_ID" => 0);
         $dbSection = CIBlockSection::GetList(array(), $arFilter);
         while ($arSection = $dbSection->Fetch()) {
Exemplo n.º 15
0
            $arResult['ENTITY_NAME'] = $arIB['NAME'];
            $arResult['ENTITY_PARENTS'][] = $arIB['IBLOCK_SECTION_ID'];
        }
    }
    if (sizeof($arResult['ENTITY_PARENTS']) > 0 && intval($arResult['ENTITY_PARENTS'][0]) > 0) {
        $dbChain = CIBlockSection::GetNavChain($arParams['IBLOCK_ID'], $arResult['ENTITY_PARENTS'][0]);
        if ($dbChain) {
            while ($arChain = $dbChain->Fetch()) {
                $arResult['ENTITY_PARENTS'][] = $arChain['IBLOCK_SECTION_ID'];
            }
        }
    }
}
if ($USER->CanDoOperation('webdav_change_settings') || $obIBlockRights && $obIBlockRights->UserHasRightTo($arParams['IBLOCK_ID'], $arParams['ENTITY_ID'], $checkOP)) {
    $arTasks = CIBlockRights::GetRightsList();
    $arTaskLetters = CWebDavIblock::GetTasks();
    //bad hack. It's not public rights.
    if (isset($arTaskLetters['S'])) {
        unset($arTasks[$arTaskLetters['S']]);
    }
    if (isset($arTaskLetters['T'])) {
        unset($arTasks[$arTaskLetters['T']]);
    }
    $arResult['PERMISSIONS'] = $arTasks;
    if (!$bCreate) {
        $arRightParams = array("count_overwrited" => true);
        if (!empty($arResult['ENTITY_PARENTS'])) {
            $arRightParams['parents'] = $arResult['ENTITY_PARENTS'];
        }
        $arCurrent = $obIBlockRights->GetRights($arRightParams);
        foreach ($arCurrent as $arRightSet) {
Exemplo n.º 16
0
                    $storage = new CWebDavStorageCore();
                    $storage->setStorageId(array('IBLOCK_ID' => $data['IBLOCK_ID'], 'IBLOCK_SECTION_ID' => $data['SECTION_ID']));
                    $filename = $storage->regenerateNameIfNonUnique($wdElement['element_name'], $savedFolderId);
                    $tmpFile = new CWebDavStubTmpFile();
                    if ($_REQUEST['v']) {
                        list($arFileH, $optionsH, $fullpath, $filenameH) = $ob->getHistoryFileData($wdElement['element_array']['ID'], (int) $_REQUEST['v'], $p);
                        $tmpFile->path = $fullpath;
                    } else {
                        $copyTmpFile = CFile::MakeFileArray($wdElement['element_array']['PROPERTY_FILE_VALUE']);
                        $tmpFile->path = $copyTmpFile['tmp_name'];
                    }
                    $response = array();
                    try {
                        $fileData = $storage->addFile($filename, $savedFolderId, $tmpFile);
                        $savedName = CWebDavIblock::getSavedMetaData();
                        $pathToUserLib = str_replace(array('#USER_ID#', '#user_id#'), array($USER->GetID(), $USER->GetID()), CWebDavIblock::LibOptions('lib_paths', true, $data['IBLOCK_ID']));
                        $pathToUserLib = strstr($pathToUserLib, 'files/element', true) . 'files/lib';
                        $pathToUserLib = $pathToUserLib . '/' . $savedName['alias'] . '?result=doc' . $fileData['extra']['id'];
                        $response = array('status' => 'success', 'newId' => $fileData['extra']['id'], 'viewUrl' => $pathToUserLib);
                    } catch (Exception $e) {
                        $response['status'] = 'error';
                        $fileData = array();
                    }
                    CWebDavTools::sendJsonResponse($response);
                }
            }
        }
    }
} elseif (!empty($_REQUEST['downloadHistory']) && !empty($_REQUEST['id'])) {
    $APPLICATION->RestartBuffer();
    $APPLICATION->IncludeComponent('bitrix:webdav.element.history', '', array('webdav' => $ob, 'ajax' => false, 'elementId' => (int) $_REQUEST['id'], 'versionId' => (int) $_REQUEST['v'], 'fileId' => (int) $_REQUEST['f']));
Exemplo n.º 17
0
 $varKey = isset($_REQUEST["post_id"]) && intval($_REQUEST["post_id"]) > 0 ? "MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"]) : "MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId();
 if ($diskEnabled) {
     $storage = \Bitrix\Disk\Driver::getInstance()->getStorageByUserId($GLOBALS["USER"]->GetID());
     if (!$storage) {
         echo CUtil::PhpToJsObject(array('ERROR' => 'NO_DISK_STORAGE'));
         die;
     }
     $folder = $storage->getFolderForUploadedFiles($GLOBALS["USER"]->GetID());
     if (!$folder) {
         echo CUtil::PhpToJsObject(array('ERROR' => 'NO_DISK_FOLDER'));
         die;
     }
 } elseif (CModule::IncludeModule("webdav")) {
     $data = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID());
     if (is_array($data)) {
         $ob = new CWebDavIblock($data["IBLOCK_ID"], "", array("ROOT_SECTION_ID" => $data["SECTION_ID"], "DOCUMENT_TYPE" => array("webdav", 'CIBlockDocumentWebdavSocnet', 'iblock_' . $data['SECTION_ID'] . '_user_' . intval($GLOBALS["USER"]->GetID()))));
     }
     if (!$ob) {
         echo CUtil::PhpToJsObject(array('ERROR' => 'NO_WEBDAV_INIT'));
         die;
     }
 }
 if ($element_id <= 0 || !in_array($element_id, $_SESSION[$varKey])) {
     echo CUtil::PhpToJsObject(array('ERROR' => 'NO_ELEMENT'));
     die;
 }
 if (!isset($_REQUEST["post_id"]) || intval($_REQUEST["post_id"]) <= 0) {
     if ($storage && $folder) {
         $securityContext = $storage->getCurrentUserSecurityContext();
         $children = $folder->getChildren($securityContext, array('filter' => array("ID" => $element_id)));
         foreach ($children as $oDiskFile) {
Exemplo n.º 18
0
    }
}
/************** Path ***********************************************/
$path = $arResult["NAV_CHAIN_PATH"];
$path[] = CWebDavIblock::_uencode($arResult["ELEMENT"]["NAME"], array("utf8" => "Y", "convert" => "allowed"));
$arResult["ELEMENT"]["URL"]["THIS"] = CComponentEngine::MakePathFromTemplate($arParams["SECTIONS_URL"], array("PATH" => implode("/", $path)));
/********************************************************************
				/Data
********************************************************************/
/********************************************************************
				Action
********************************************************************/
if ((!empty($_POST["HISTORY_ID"]) || !empty($_GET["history_id"])) && check_bitrix_sessid()) {
    $arID = !empty($_POST["HISTORY_ID"]) ? $_POST["HISTORY_ID"] : $_GET["history_id"];
    $arID = is_array($arID) ? $arID : array($arID);
    $ob = new CWebDavIblock($arParams['IBLOCK_ID']);
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0 || empty($arResult['VERSIONS'][$ID])) {
            continue;
        }
        $ID = IntVal($ID);
        $d = CIBlockElement::GetByID($ID);
        if ($dr = $d->Fetch()) {
            if ($_REQUEST["action"] == "restore") {
                $DB->StartTransaction();
                if (!CIBlockElement::WF_Restore($ID)) {
                    $DB->Rollback();
                } else {
                    $options = array("element_id" => $arParams["ELEMENT_ID"]);
                    $ob->UNLOCK($options);
                    $DB->Commit();
Exemplo n.º 19
0
 /**
  * Метод проверяет права на выполнение операций над заданным документом. Проверяются операции 0 - просмотр данных рабочего потока, 1 - запуск рабочего потока, 2 - право изменять документ, 3 - право смотреть документ.
  *
  * @param int $operation - операция.
  * @param int $userId - код пользователя, для которого проверяется право на выполнение операции.
  * @param string $documentId - код документа, к которому применяется операция.
  * @param array $arParameters - ассициативный массив вспомогательных параметров. Используется для того, чтобы не рассчитывать заново те вычисляемые значения, которые уже известны на момент вызова метода. Стандартными являются ключи массива DocumentStates - массив состояний рабочих потоков данного документа, WorkflowId - код рабочего потока (если требуется проверить операцию на одном рабочем потоке). Массив может быть дополнен другими произвольными ключами.
  * @return bool
  */
 function CanUserOperateDocument($operation, $userId, $documentId, $arParameters = array())
 {
     $documentId = trim($documentId);
     if (strlen($documentId) <= 0) {
         return false;
     }
     $diskId = self::processGetDiskIdByDocId($documentId);
     if ($diskId !== null) {
         return self::proxyToDisk(__FUNCTION__, array($operation, $userId, $diskId, $arParameters));
     }
     $userId = intval($userId);
     global $USER;
     if ($USER->IsAuthorized() && $USER->GetID() == $userId && CSocNetUser::IsCurrentUserModuleAdmin()) {
         return true;
     }
     if (array_key_exists("IBlockPermission", $arParameters) && false) {
         if ($arParameters["IBlockPermission"] < "R") {
             return false;
         } elseif ($arParameters["IBlockPermission"] >= "W") {
             return true;
         }
     }
     // Если мы оказались здесь, то либо не указан IBlockPermission, либо IBlockPermission == U
     // Если нам явно не сказали, а нам нужно, то узнаем код инфоблока, автора элемента, тип хранилища и владельца хранилища
     if ($documentId > 0 && (!array_key_exists("IBlockId", $arParameters) || !array_key_exists("CreatedBy", $arParameters) || !array_key_exists("OwnerType", $arParameters) || !array_key_exists("OwnerId", $arParameters)) || $operation == CBPWebDavCanUserOperateOperation::ReadDocument) {
         $db_res = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("ID", "IBLOCK_ID", "CREATED_BY", "IBLOCK_SECTION_ID", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID"));
         $arElement = $db_res->Fetch();
         if (!$arElement) {
             return false;
         }
         $arParameters["IBlockId"] = $arElement["IBLOCK_ID"];
         $arParameters["CreatedBy"] = $arElement["CREATED_BY"];
         if (!array_key_exists("OwnerType", $arParameters) || !array_key_exists("OwnerId", $arParameters)) {
             $dbSectionsChain = CIBlockSection::GetNavChain($arElement["IBLOCK_ID"], $arElement["IBLOCK_SECTION_ID"]);
             if ($arSect = $dbSectionsChain->Fetch()) {
                 $arParameters["OwnerType"] = intVal($arSect["SOCNET_GROUP_ID"]) > 0 ? "group" : "user";
                 $arParameters["OwnerId"] = intVal($arSect["SOCNET_GROUP_ID"]) > 0 ? $arSect["SOCNET_GROUP_ID"] : $arSect["CREATED_BY"];
             }
         }
         $arParameters["Published"] = intVal($arElement["WF_STATUS_ID"]) == 1 && intVal($arElement["WF_PARENT_ELEMENT_ID"]) <= 0 ? "Y" : "N";
     } elseif (array_key_exists("DocumentType", $arParameters)) {
         $res = explode("_", is_array($arParameters["DocumentType"]) ? $arParameters["DocumentType"][2] : $arParameters["DocumentType"]);
         if (count($res) != 4) {
             return false;
         }
         $arParameters["IBlockId"] = intval($res[1]);
         $arParameters["OwnerType"] = $res[2];
         $arParameters["OwnerId"] = intval($res[3]);
     }
     // Если нет необходимых параметров, то возвращаем false
     if (!in_array($arParameters["OwnerType"], array("user", "group")) || $arParameters["OwnerId"] <= 0 || $arParameters["IBlockId"] <= 0) {
         return false;
         // Если пользователь является владельцем хранилища, то возвращаем true
     } elseif ($arParameters["OwnerType"] == "user" && $arParameters["OwnerId"] == $userId) {
         return true;
     }
     // Если нам явно не сказали, то узнаем права пользователя на инфоблок
     if (!array_key_exists("IBlockPermission", $arParameters)) {
         $res = CIBlockWebdavSocnet::GetUserMaxPermission($arParameters["OwnerType"], $arParameters["OwnerId"], $userId, $arParameters["IBlockId"]);
         $arParameters["IBlockPermission"] = $res["PERMISSION"];
     }
     if (CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_read") < "R") {
         return false;
     } elseif ($operation != CBPWebDavCanUserOperateOperation::DeleteDocument && CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_edit") >= "W") {
         return true;
     } elseif ($operation == CBPWebDavCanUserOperateOperation::DeleteDocument && CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_delete") >= "X") {
         return true;
     } elseif ($operation == CBPWebDavCanUserOperateOperation::ReadDocument && $arParameters["Published"] == "Y") {
         return true;
     }
     // AllUserGroups
     if (!array_key_exists("AllUserGroups", $arParameters)) {
         $arParameters["AllUserGroups"] = CIBlockDocumentWebdavSocnet::GetUserGroups($arParameters["DocumentType"], $documentId, $userId);
     }
     // Если нам явно не сказали, то узнаем текущие статусы документа
     if (!array_key_exists("DocumentStates", $arParameters)) {
         $arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(array("webdav", "CIBlockDocumentWebdavSocnet", "x"), array("webdav", "CIBlockDocumentWebdavSocnet", $documentId));
     }
     if (array_key_exists("WorkflowId", $arParameters)) {
         if (array_key_exists($arParameters["WorkflowId"], $arParameters["DocumentStates"])) {
             $arParameters["DocumentStates"] = array($arParameters["WorkflowId"] => $arParameters["DocumentStates"][$arParameters["WorkflowId"]]);
         } else {
             return false;
         }
     }
     $arAllowableOperations = CBPDocument::GetAllowableOperations($userId, $arParameters["AllUserGroups"], $arParameters["DocumentStates"]);
     // $arAllowableOperations == null - поток не является автоматом
     // $arAllowableOperations == array() - в автомате нет допустимых операций
     // $arAllowableOperations == array("read", ...) - допустимые операции
     if (!is_array($arAllowableOperations)) {
         return false;
     }
     $r = false;
     switch ($operation) {
         case CBPWebDavCanUserOperateOperation::ViewWorkflow:
             // право на просмотр бизнес-процесса есть только у пользователей, которым разрешено читать
             $r = CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_read") >= "U" && !empty($arAllowableOperations);
             break;
         case CBPWebDavCanUserOperateOperation::StartWorkflow:
             $r = CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_bizproc_start") > "U" || in_array("write", $arAllowableOperations);
             break;
         case CBPWebDavCanUserOperateOperation::CreateWorkflow:
             $r = CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_edit") > "U";
             break;
         case CBPWebDavCanUserOperateOperation::WriteDocument:
             $r = CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_edit") > "U" || in_array("write", $arAllowableOperations);
             break;
         case CBPWebDavCanUserOperateOperation::DeleteDocument:
             $r = CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_delete") >= "X" || in_array("delete", $arAllowableOperations);
             break;
         case CBPWebDavCanUserOperateOperation::ReadDocument:
             $r = CWebDavIblock::CheckRight($arParameters["IBlockPermission"], "element_edit") > "U" || in_array("read", $arAllowableOperations) || in_array("write", $arAllowableOperations);
             break;
         default:
             $r = false;
     }
     return $r;
 }
Exemplo n.º 20
0
 public static function onBeforeConfirmNotify($module, $tag, $value, $arNotify)
 {
     global $USER;
     $userId = $USER->getId();
     if ($module == 'webdav' && $userId) {
         $tagData = explode('|', $tag);
         $folderInviteId = intval($tagData[2]);
         if ($tagData[0] == "WEBDAV" && $tagData[1] == "INVITE" && $folderInviteId > 0 && $userId == $tagData[3]) {
             if (\Bitrix\Main\Loader::includeModule('im')) {
                 CIMNotify::DeleteByTag(\Bitrix\Webdav\FolderInviteTable::getNotifyTag(array('ID' => $folderInviteId, 'INVITE_USER_ID' => $userId)));
             }
             //decline
             if ($value === 'N') {
                 \Bitrix\Webdav\FolderInviteTable::delete($folderInviteId);
                 return false;
             }
             $targetSectionData = CWebDavIblock::getRootSectionDataForUser($userId);
             if (!$targetSectionData) {
                 return false;
             }
             $folderInviteData = \Bitrix\Webdav\FolderInviteTable::getRowById($folderInviteId);
             if (!$folderInviteData) {
                 return false;
             }
             $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInviteData['SECTION_ID'], 'IBLOCK_ID' => $folderInviteData['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME', 'SOCNET_GROUP_ID'))->fetch();
             if (empty($sectionToShare['NAME']) || empty($sectionToShare['SOCNET_GROUP_ID'])) {
                 return false;
             }
             if (\Bitrix\Main\Loader::includeModule('socialnetwork')) {
                 $group = CSocNetGroup::GetList(array(), array('ID' => $sectionToShare['SOCNET_GROUP_ID']), false, false, array('NAME'))->fetch();
             }
             if (empty($group)) {
                 return false;
             }
             $groupId = $sectionToShare['SOCNET_GROUP_ID'];
             $dispatcher = new \Bitrix\Webdav\InviteDispatcher();
             $attachObjectType = CWebDavSymlinkHelper::ENTITY_TYPE_GROUP;
             $attachObjectId = (int) $groupId;
             $inviteComponentParams = array('attachObject' => array('id' => $attachObjectId, 'type' => $attachObjectType), 'attachToUserId' => $folderInviteData['INVITE_USER_ID'], 'inviteFromUserId' => $folderInviteData['USER_ID'], 'canEdit' => $folderInviteData['CAN_EDIT']);
             $response = $dispatcher->processActionConnect($inviteComponentParams);
             if ($response['status'] == $dispatcher::STATUS_SUCCESS) {
                 \Bitrix\Webdav\FolderInviteTable::update($folderInviteId, array('IS_APPROVED' => true, 'LINK_SECTION_ID' => $response['sectionId']));
             }
             return $response['status'] == $dispatcher::STATUS_SUCCESS;
         }
     }
 }
Exemplo n.º 21
0
    function __build_item_info(&$res, $arParams, $WrapLongWords = false)
    {
        global $DB, $USER;
        static $bTheFirstTimeonPage = true;
        static $bShowWebdav = true;
        static $arBPTemplates = array();
        static $arOfficeExtensions = false;
        static $checkParentSectionIsLink = array();
        $nameTemplate = "#NOBR##LAST_NAME# #NAME##/NOBR#";
        static $arNameFormats = array();
        if (!isset($arNameFormats[SITE_ID])) {
            $arNameFormats[SITE_ID] = CSite::GetNameFormat(false);
        }
        if (isset($arNameFormats[SITE_ID])) {
            $nameTemplate = $arNameFormats[SITE_ID];
        }
        if (!$arOfficeExtensions) {
            $arOfficeExtensions = __wd_get_office_extensions();
        }
        if (!isset($arParams["OBJECT"])) {
            return;
        }
        $ob = $arParams["OBJECT"];
        static $allowExtDocServices = null;
        if ($allowExtDocServices === null) {
            $allowExtDocServicesGlobal = CWebDavTools::allowUseExtServiceGlobal();
            $allowExtDocServicesLocal = CWebDavTools::allowUseExtServiceLocal();
            $allowExtDocServices = $allowExtDocServicesGlobal;
            if ($ob->arRootSection['UF_USE_EXT_SERVICES'] && $allowExtDocServicesLocal) {
                $allowExtDocServices = 'Y' == CWebDavIblock::resolveDefaultUseExtServices($ob->arRootSection['UF_USE_EXT_SERVICES']);
            }
        }
        static $rootDataForCurrentUser = null;
        static $isUserLib = null;
        if ($rootDataForCurrentUser === null && $USER->getId()) {
            $rootDataForCurrentUser = CWebDavIblock::getRootSectionDataForUser($USER->getId());
            $isUserLib = $ob->attributes['user_id'] == $USER->getId() && !($ob->meta_state == CWebDavIblock::DROPPED);
        }
        static $isExtranetUser = null;
        if ($isExtranetUser === null) {
            $isExtranetUser = !$USER->getId() || !CWebDavTools::isIntranetUser($USER->getId());
        }
        $bInTrash = "/" . $ob->meta_names["TRASH"]["alias"] == $ob->_udecode($ob->_path);
        if ($res["TYPE"] != "S" && $arBPTemplates != $arParams["TEMPLATES"]) {
            $bShowWebdav = true;
            $arBPTemplates = $arParams["TEMPLATES"];
            if (is_array($arParams["TEMPLATES"]) && !empty($arParams["TEMPLATES"])) {
                foreach ($arParams["TEMPLATES"] as $key => $arTemplateState) {
                    if (in_array($arTemplateState["AUTO_EXECUTE"], array(2, 3, 6, 7)) && (is_array($arTemplateState["PARAMETERS"]) || is_array($arTemplateState["TEMPLATE_PARAMETERS"]))) {
                        $arTemplateState["TEMPLATE_PARAMETERS"] = is_array($arTemplateState["PARAMETERS"]) ? $arTemplateState["PARAMETERS"] : $arTemplateState["TEMPLATE_PARAMETERS"];
                        foreach ($arTemplateState["TEMPLATE_PARAMETERS"] as $val) {
                            if ($val["Required"] == 1 && empty($val["Default"])) {
                                $bShowWebdav = false;
                                break;
                            }
                        }
                    }
                }
            }
        }
        $res["bShowWebDav"] = $bShowWebdav;
        /************** Grid Data ******************************************/
        $arActions = array();
        if ($res["TYPE"] == "S") {
            $arActions["section_open"] = array("ICONCLASS" => "section_open", "TITLE" => GetMessage("WD_OPEN_SECTION"), "TEXT" => GetMessage("WD_OPEN"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~THIS"]) . "');", "DEFAULT" => true);
            if ($res["SHOW"]["UNDELETE"] == "Y") {
                $arActions["section_undelete"] = array("ICONCLASS" => "section_download", "TITLE" => GetMessage("WD_UNDELETE_SECTION"), "TEXT" => GetMessage("WD_UNDELETE"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape(WDAddPageParams($res["URL"]["~UNDELETE"], array("edit_section" => "Y", "sessid" => bitrix_sessid()), false)) . "');", "DEFAULT" => false);
            }
            if ($res["SHOW"]["EDIT"] == "Y") {
                if ($ob->Type == "iblock" && $arParams["OBJECT"]->CheckWebRights("", false, array("action" => "create"))) {
                    //sharing with antoher user. Only user_lib files.
                    global $USER;
                    if (!empty($arParams["OBJECT"]->attributes['user_id']) && $arParams["OBJECT"]->attributes['user_id'] == $USER->getID() && !$isExtranetUser) {
                        if (empty($res['LINK'])) {
                            if (!empty($res['SHARED_SECTION'])) {
                                //usage. Show list user
                                $uriToShareSection = $GLOBALS['APPLICATION']->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'detail_user_share', 'shareSectionId' => $res["ID"])));
                                $arActions["section_share"] = array("ICONCLASS" => "section_share", "TITLE" => GetMessage("WD_SHARE_TITLE_2"), "TEXT" => GetMessage("WD_SHARE_NAME_2"), "ONCLICK" => "WDShareFolder('{$uriToShareSection}', {$res["ID"]}, null, '" . CUtil::JSEscape($res["NAME"]) . "')");
                            } else {
                                if (!isset($checkParentSectionIsLink[$res['IBLOCK_SECTION_ID']])) {
                                    $checkParentSectionIsLink[$res['IBLOCK_SECTION_ID']] = CWebDavSymlinkHelper::isLink(CWebDavSymlinkHelper::ENTITY_TYPE_USER, $arParams["OBJECT"]->attributes['user_id'], array('ID' => $res['IBLOCK_SECTION_ID'], 'IBLOCK_ID' => $res['IBLOCK_ID']));
                                }
                                //if element in link - don't share
                                if (!$checkParentSectionIsLink[$res['IBLOCK_SECTION_ID']]) {
                                    $uriToShareSection = $GLOBALS['APPLICATION']->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'detail_user_share', 'shareSectionId' => $res["ID"])));
                                    $arActions["section_share"] = array("ICONCLASS" => "section_share", "TITLE" => GetMessage("WD_SHARE_TITLE_2"), "TEXT" => GetMessage("WD_SHARE_NAME_2"), "ONCLICK" => "WDShareFolder('{$uriToShareSection}', {$res["ID"]}, null, '" . CUtil::JSEscape($res["NAME"]) . "')");
                                }
                            }
                        } else {
                            //usage. Show list user
                            $uriToShareSection = $GLOBALS['APPLICATION']->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'info_user_share', 'shareSectionId' => $res['LINK']['SECTION_ID'])));
                            $arActions["section_share"] = array("ICONCLASS" => "section_share", "TITLE" => GetMessage("WD_MANAGE_SHARE_TITLE"), "TEXT" => GetMessage("WD_MANAGE_SHARE_NAME"), "ONCLICK" => "WDShareFolder('{$uriToShareSection}', {$res['LINK']['SECTION_ID']}, '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "', '" . CUtil::JSEscape($res["NAME"]) . "')");
                        }
                    } elseif (CWebDavIblock::$possibleUseSymlinkByInternalSections && !$isExtranetUser) {
                        if (empty($res['LINK'])) {
                            if (!empty($res['SHARED_SECTION'])) {
                                //usage. Show list user
                                $uriToShareSection = $GLOBALS['APPLICATION']->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'info_user_share', 'shareSectionId' => $res["ID"])));
                                $uriToDisconnectSection = $GLOBALS['APPLICATION']->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'disconnect', 'shareSectionId' => $res["ID"])));
                                $arActions["section_share"] = array("ICONCLASS" => "section_share", "TITLE" => GetMessage("WD_MANAGE_SHARE_TITLE"), "TEXT" => GetMessage("WD_MANAGE_SHARE_TITLE"), "ONCLICK" => "WDShareFolderInSharedDocs('{$uriToShareSection}', {$res["ID"]}, '{$uriToDisconnectSection}', '" . CUtil::JSEscape($res["NAME"]) . "')");
                            } else {
                                $uriToShareSection = $GLOBALS['APPLICATION']->GetCurUri(http_build_query(array('toWDController' => 1, 'wdaction' => 'connect', 'shareSectionId' => $res["ID"])));
                                $arActions["section_share"] = array("ICONCLASS" => "section_share", "TITLE" => GetMessage("WD_SHARE_SECTION_CONNECT_TITLE"), "TEXT" => GetMessage("WD_SHARE_SECTION_CONNECT_NAME"), "ONCLICK" => "showWebdavSharedSectionDiskPopup('{$uriToShareSection}', {$res["ID"]}, null, '" . CUtil::JSEscape($res["NAME"]) . "')");
                            }
                        }
                    }
                }
                $arActions["section_rename"] = array("ICONCLASS" => "section_rename", "TITLE" => GetMessage("WD_RENAME_SECTION_TITLE"), "TEXT" => GetMessage("WD_RENAME_NAME"), "ONCLICK" => "WDRename(BX('ID_" . $res["TYPE"] . $res["ID"] . "'), bxGrid_" . $arParams["GRID_ID"] . ", '" . $arParams["GRID_ID"] . "')");
                if ($ob->Type == "iblock" && $arParams["OBJECT"]->CheckWebRights("", false, array("action" => "create"))) {
                    $url = WDAddPageParams($res["URL"]["SECTIONS_DIALOG"], array("ACTION" => "COPY", "NAME" => urlencode($res["NAME"]), "ID" => "S" . $res["ID"]), false);
                    $arActions["section_copy"] = array("ICONCLASS" => "section_copy", "TITLE" => GetMessage("WD_COPY_SECTION_TITLE"), "TEXT" => GetMessage("WD_COPY_NAME"), "ONCLICK" => "(new BX.CDialog({'width': 450, 'heght':400, 'content_url':'" . CUtil::JSEscape($url) . "'})).Show()");
                    $url = WDAddPageParams($res["URL"]["SECTIONS_DIALOG"], array("ACTION" => "MOVE", "NAME" => urlencode($res["NAME"]), "ID" => "S" . $res["ID"]), false);
                    $arActions["section_move"] = array("ICONCLASS" => "section_move", "TITLE" => GetMessage("WD_MOVE_SECTION_TITLE"), "TEXT" => GetMessage("WD_MOVE_NAME"), "ONCLICK" => "(new BX.CDialog({'width': 450, 'heght':400, 'content_url':'" . CUtil::JSEscape($url) . "'})).Show()");
                }
            }
            if ($res["SHOW"]["RIGHTS"] == "Y") {
                $urlParams = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ENTITY_TYPE" => "SECTION", "ENTITY_ID" => $res['ID'], "back_url" => urlencode($GLOBALS['APPLICATION']->GetCurPage()));
                if (isset($ob->attributes['user_id'])) {
                    $urlParams['SOCNET_TYPE'] = 'user';
                    $urlParams['SOCNET_ID'] = $ob->attributes['user_id'];
                } elseif (isset($ob->attributes['group_id'])) {
                    $urlParams['SOCNET_TYPE'] = 'group';
                    $urlParams['SOCNET_ID'] = $ob->attributes['group_id'];
                }
                $url = WDAddPageParams("/bitrix/components/bitrix/webdav.section.list/templates/.default/iblock_e_rights.php", $urlParams, false);
                $arActions["section_permissions"] = array("ICONCLASS" => "section_permissions", "TITLE" => GetMessage("WD_SECTION_PERMISSIONS"), "TEXT" => GetMessage("WD_PERMISSIONS"), "ONCLICK" => "(new BX.CDialog({'width': 750, 'heght':400, 'content_url':'" . CUtil::JSEscape($url) . "'})).Show()");
            }
            if ($res["SHOW"]["DELETE"] == "Y" && (!$bInTrash || $bInTrash && $arParams["PERMISSION"] > "W")) {
                if (!empty($res['LINK'])) {
                    $arActions["section_unshare"] = array("ICONCLASS" => "section_drop", "TITLE" => GetMessage("WD_UNSHARE_SECTION"), "TEXT" => GetMessage("WD_UNSHARE"), "ONCLICK" => "WDConfirm('" . CUtil::JSEscape(GetMessage("WD_UNSHARE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage("WD_UNSHARE_SECTION_CONFIRM", array('#NAME#' => $res['NAME']))) . "', function() {jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "')})");
                } elseif (!empty($res['SHARED_SECTION']) && isset($arActions["section_share"])) {
                    $arActions["section_drop"] = array("ICONCLASS" => "section_drop", "TITLE" => GetMessage("WD_DELETE_SECTION"), "TEXT" => GetMessage("WD_DELETE"), "ONCLICK" => "WDConfirm('" . CUtil::JSEscape(GetMessage("WD_DELETE_OWN_SHARE_SECTION_TITLE")) . "', '" . CUtil::JSEscape(GetMessage("WD_DELETE_OWN_SHARE_SECTION_CONFIRM", array('#NAME#' => $res['NAME']))) . "', function() {jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "')})");
                } else {
                    $forceDeleteUrl = CHTTP::urlAddParams($res["URL"]["~DELETE"], array('delete_without_trash' => 1));
                    $arActions["section_drop"] = array("ICONCLASS" => "section_drop", "TITLE" => GetMessage("WD_DELETE_SECTION"), "TEXT" => GetMessage("WD_DELETE"));
                    if ($res["SHOW"]["UNDELETE"] == "Y") {
                        $arActions["section_drop"]['ONCLICK'] = "WDConfirm('" . CUtil::JSEscape(GetMessage("WD_DELETE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage($res["SHOW"]["UNDELETE"] == "Y" ? "WD_DESTROY_SECTION_CONFIRM" : "WD_DELETE_SECTION_CONFIRM", array('#NAME#' => $res['NAME']))) . "', function() {jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "')})";
                    } elseif ($arParams['OBJECT']->CheckRight($res["E_RIGHTS"], "iblock_edit") >= "X") {
                        $arActions["section_drop"]['ONCLICK'] = "WDConfirmDelete('" . CUtil::JSEscape(GetMessage("WD_DELETE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage("WD_TRASH_DELETE_DESTROY_SECTION_CONFIRM", array("#NAME#" => $res['NAME']))) . "'" . ", '" . CUtil::JSEscape(GetMessage("WD_TRASH_DELETE_BUTTON")) . "'" . ", '" . CUtil::JSEscape(GetMessage("WD_TRASH_DESTROY_BUTTON")) . "'" . ", '" . CUtil::JSEscape(GetMessage("WD_TRASH_CANCEL_DELETE_BUTTON")) . "'" . ", function() { var urlDelete = '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "';  jsUtils.Redirect([], urlDelete)}" . ", function() { var urlDelete = '" . CUtil::JSEscape($forceDeleteUrl) . "'; jsUtils.Redirect([], urlDelete)})";
                    } else {
                        $arActions["section_drop"]['ONCLICK'] = "WDConfirm('" . CUtil::JSEscape(GetMessage("WD_DELETE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage("WD_DELETE_SECTION_CONFIRM", array("#NAME#" => $res['NAME']))) . "', function() { var urlDelete = '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "';  jsUtils.Redirect([], urlDelete)})";
                    }
                }
            }
            $arActions['preview_launch'] = array('type' => 'folder', 'src' => $res["URL"]["~THIS"], 'title' => $res['NAME'], 'owner' => CUser::FormatName(CSite::GetNameFormat(false), array('LOGIN' => $res['CREATED_BY']['LOGIN'], 'NAME' => $res['CREATED_BY']['NAME'], 'SECOND_NAME' => $res['CREATED_BY']['SECOND_NAME'], 'LAST_NAME' => $res['CREATED_BY']['LAST_NAME']), true, false), 'size' => CFile::FormatSize($res['PROPERTY_WEBDAV_SIZE_VALUE']), 'dateModify' => FormatDate('FULL', MakeTimeStamp($res["TIMESTAMP_X"])));
        } else {
            $arActions["element_open"] = array("ICONCLASS" => "element_open", "TITLE" => GetMessage("WD_OPEN_DOCUMENT"), "TEXT" => GetMessage("WD_OPEN"), "ONCLICK" => "OpenDoc('" . CUtil::JSEscape(htmlspecialcharsbx($res["URL"]["~THIS"])) . "', " . (in_array($res["FILE_EXTENTION"], $arOfficeExtensions) && $arParams['DEFAULT_EDIT'] === 'Y' ? "true" : "false") . ");", "DEFAULT" => true);
            if ($allowExtDocServices && CWebDavTools::allowPreviewFile($res["FILE_EXTENTION"], $res['PROPERTY_WEBDAV_SIZE_VALUE'])) {
                //showInViewer
                $downloadUrl = CUtil::JSEscape($res["URL"]["~DOWNLOAD"]);
                $editInUrl = $editrUrl = CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $res["URL"]["THIS"])) . '?' . bitrix_sessid_get() . '&editIn=' . CWebDavLogOnlineEditBase::DEFAULT_SERVICE_NAME . '&start=1';
                $downloadUrl .= (strpos($downloadUrl, "?") === false ? "?" : "&") . "ncc=1&force_download=1";
                $viewerUrl = CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $res["URL"]["THIS"])) . '?showInViewer=1';
                $arActions['preview_launch'] = array('type' => 'iframe', 'src' => $viewerUrl, 'download' => $downloadUrl, 'history' => CHTTP::urlAddParams($res['URL']['VIEW'], array('webdavForm' . $res['IBLOCK_ID'] . '_active_tab' => 'tab_history')), 'edit' => $res['LOCK_STATUS'] == 'green' && CWebDavEditDocGoogle::isEditable($res["FILE_EXTENTION"]) && $res['E_RIGHTS']['element_edit'] ? $editInUrl : '', 'askConvert' => CWebDavEditDocGoogle::isNeedConvertExtension($res["FILE_EXTENTION"]), 'title' => $res['NAME'], 'inPersonalLib' => $isUserLib && $res['LOCK_STATUS'] == 'green' && $res['E_RIGHTS']['element_edit'] ? '1' : '', 'externalId' => $isUserLib ? "st{$rootDataForCurrentUser['IBLOCK_ID']}|{$rootDataForCurrentUser['SECTION_ID']}|f{$res['ID']}" : '', 'relativePath' => $res['PATH']);
            } elseif ($allowExtDocServices && CWebDavEditDocGoogle::isEditable($res["FILE_EXTENTION"])) {
                //showInViewer
                $downloadUrl = CUtil::JSEscape($res["URL"]["~DOWNLOAD"]);
                $editInUrl = $editrUrl = CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $res["URL"]["THIS"])) . '?' . bitrix_sessid_get() . '&editIn=' . CWebDavLogOnlineEditBase::DEFAULT_SERVICE_NAME . '&start=1';
                $downloadUrl .= (strpos($downloadUrl, "?") === false ? "?" : "&") . "ncc=1&force_download=1";
                $viewerUrl = CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $res["URL"]["THIS"])) . '?showInViewer=1';
                $arActions['preview_launch'] = array('type' => 'onlyedit', 'src' => $viewerUrl, 'download' => $downloadUrl, 'history' => CHTTP::urlAddParams($res['URL']['VIEW'], array('webdavForm' . $res['IBLOCK_ID'] . '_active_tab' => 'tab_history')), 'edit' => $res['LOCK_STATUS'] == 'green' && CWebDavEditDocGoogle::isEditable($res["FILE_EXTENTION"]) && $res['E_RIGHTS']['element_edit'] ? $editInUrl : '', 'askConvert' => CWebDavEditDocGoogle::isNeedConvertExtension($res["FILE_EXTENTION"]), 'title' => $res['NAME'], 'owner' => CUser::FormatName(CSite::GetNameFormat(false), array('LOGIN' => $res['CREATED_BY']['LOGIN'], 'NAME' => $res['CREATED_BY']['NAME'], 'SECOND_NAME' => $res['CREATED_BY']['SECOND_NAME'], 'LAST_NAME' => $res['CREATED_BY']['LAST_NAME']), true, false), 'size' => CFile::FormatSize($res['PROPERTY_WEBDAV_SIZE_VALUE']), 'dateModify' => FormatDate('FULL', MakeTimeStamp($res["TIMESTAMP_X"])), 'tooBigSizeMsg' => true, 'inPersonalLib' => $isUserLib && $res['LOCK_STATUS'] == 'green' && $res['E_RIGHTS']['element_edit'] ? '1' : '', 'externalId' => $isUserLib ? "st{$rootDataForCurrentUser['IBLOCK_ID']}|{$rootDataForCurrentUser['SECTION_ID']}|f{$res['ID']}" : '', 'relativePath' => $res['PATH']);
            } elseif (CFile::IsImage($res['NAME'])) {
                $downloadUrl = CUtil::JSEscape($res["URL"]["~DOWNLOAD"]);
                $downloadUrl .= (strpos($downloadUrl, "?") === false ? "?" : "&") . "ncc=1&force_download=1";
                $arActions['preview_launch'] = array('type' => 'image', 'src' => $downloadUrl, 'download' => $downloadUrl, 'title' => $res['NAME']);
            } else {
                $downloadUrl = CUtil::JSEscape($res["URL"]["~DOWNLOAD"]);
                $downloadUrl .= (strpos($downloadUrl, "?") === false ? "?" : "&") . "ncc=1&force_download=1";
                $arActions['preview_launch'] = array('type' => 'unknown', 'src' => $downloadUrl, 'download' => $downloadUrl, 'title' => $res['NAME'], 'owner' => CUser::FormatName(CSite::GetNameFormat(false), array('LOGIN' => $res['CREATED_BY']['LOGIN'], 'NAME' => $res['CREATED_BY']['NAME'], 'SECOND_NAME' => $res['CREATED_BY']['SECOND_NAME'], 'LAST_NAME' => $res['CREATED_BY']['LAST_NAME']), true, false), 'size' => CFile::FormatSize($res['PROPERTY_WEBDAV_SIZE_VALUE']), 'dateModify' => FormatDate('FULL', MakeTimeStamp($res["TIMESTAMP_X"])), 'tooBigSizeMsg' => $allowExtDocServices && CWebDavTools::allowPreviewFile($res["FILE_EXTENTION"], $res['PROPERTY_WEBDAV_SIZE_VALUE'], false), 'inPersonalLib' => $isUserLib && $res['LOCK_STATUS'] == 'green' && $res['E_RIGHTS']['element_edit'] ? '1' : '', 'externalId' => $isUserLib ? "st{$rootDataForCurrentUser['IBLOCK_ID']}|{$rootDataForCurrentUser['SECTION_ID']}|f{$res['ID']}" : '', 'relativePath' => $res['PATH']);
            }
            $downloadUrl = CUtil::JSEscape($res["URL"]["~DOWNLOAD"]);
            $downloadUrl .= (strpos($downloadUrl, "?") === false ? "?" : "&") . "ncc=1&force_download=1";
            $arActions["element_download"] = array("ICONCLASS" => "element_download", "TITLE" => GetMessage("WD_DOWNLOAD_ELEMENT"), "TEXT" => GetMessage("WD_DOWNLOAD"), "ONCLICK" => "window.location.href = '" . $downloadUrl . "';", "DEFAULT" => false);
            if ($arParams["PERMISSION"] >= "U") {
                $urlT = CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $res["URL"]["THIS"]));
                $arActions["copy_ext_link"] = array("ICONCLASS" => "element_ext_link", "TITLE" => GetMessage("WD_COPY_EXT_LINK_TITLE"), "TEXT" => GetMessage("WD_COPY_EXT_LINK"), "ONCLICK" => CWebDavExtLinks::InsertDialogCallText($urlT));
            }
            if ($res["SHOW"]["UNDELETE"] == "Y") {
                $arActions["element_undelete"] = array("ICONCLASS" => "element_download", "TITLE" => GetMessage("WD_UNDELETE_ELEMENT"), "TEXT" => GetMessage("WD_UNDELETE"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape(WDAddPageParams($res["URL"]["~UNDELETE"], array("edit" => "Y", "sessid" => bitrix_sessid()), false)) . "');", "DEFAULT" => false);
            }
            if ($arParams["PERMISSION"] >= "U") {
                if ($res["SHOW"]["LOCK"] == "Y" || $res["SHOW"]["UNLOCK"] == "Y") {
                    $arActions["element_upload"] = array("ICONCLASS" => "element_edit", "TITLE" => GetMessage("WD_UPLOAD_ELEMENT"), "TEXT" => GetMessage("WD_UPLOAD"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"][$arParams["OBJECT"]->Type == "folder" ? "EDIT" : "~VIEW"] . '#upload') . "');");
                }
                if ($ob->Type == "iblock" && $res["SHOW"]["UNLOCK"] == "Y") {
                    $arActions["element_unlock"] = array("ICONCLASS" => "element_unlock", "TITLE" => GetMessage("WD_UNLOCK_ELEMENT"), "TEXT" => GetMessage("WD_UNLOCK"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~UNLOCK"]) . "');");
                }
                if ($ob->Type == "iblock" && $res["SHOW"]["LOCK"] == "Y") {
                    $arActions["element_lock"] = array("ICONCLASS" => "element_unlock", "TITLE" => GetMessage("WD_LOCK_ELEMENT"), "TEXT" => GetMessage("WD_LOCK"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~LOCK"]) . "');");
                }
                if (($res["SHOW"]["LOCK"] == "Y" || $res["SHOW"]["UNLOCK"] == "Y") && in_array($res["FILE_EXTENTION"], $arOfficeExtensions)) {
                    $arActions["element_edit_office"] = array("ICONCLASS" => "element_edit", "TITLE" => GetMessage("WD_EDIT_MSOFFICE"), "TEXT" => GetMessage("WD_EDIT_MSOFFICE_MENU"), "OFFICECHECK" => true, "DISABLED" => !($bShowWebdav && $res["SHOW"]["EDIT"] == "Y"), "ONCLICK" => 'return EditDocWithProgID(\'' . CUtil::addslashes($res["URL"]["~THIS"]) . '\');');
                }
            }
            $arActions["element_view"] = array("ICONCLASS" => "element_view", "TITLE" => GetMessage("WD_VIEW_ELEMENT"), "TEXT" => GetMessage($res["~TYPE"] == "FILE" ? "WD_PROPERTIES" : "WD_VIEW"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"][$res["~TYPE"] == "FILE" ? "EDIT" : "~VIEW"]) . "');");
            if ($arParams["USE_COMMENTS"] == "Y" && IsModuleInstalled("forum")) {
                $arActions["element_comment"] = array("ICONCLASS" => "element_comment", "TITLE" => GetMessage("WD_ELEMENT_COMMENT_NAME"), "TEXT" => GetMessage("WD_ELEMENT_COMMENT_TITLE"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~VIEW"] . "?webdavForm" . $arParams["IBLOCK_ID"] . "_active_tab=tab_comments") . "');");
            }
            if ($arParams["PERMISSION"] >= "U") {
                $arActions["copy_link"] = array("ICONCLASS" => "element_download", "TITLE" => GetMessage("WD_COPY_LINK_TITLE"), "TEXT" => GetMessage("WD_COPY_LINK"), "ONCLICK" => "WDCopyLinkDialog('" . CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http') . '://' . str_replace("//", "/", $_SERVER['HTTP_HOST'] . "/" . $res["URL"]["THIS"])) . "')");
                /*
                $urlT = CUtil::JSEscape(($GLOBALS['APPLICATION']->IsHTTPS() ? 'https' : 'http').'://'.str_replace("//", "/", $_SERVER['HTTP_HOST']."/".$res["URL"]["THIS"]));
                $arActions["copy_ext_link"] = array(
                	"ICONCLASS" => "element_download",
                	"TITLE" => GetMessage("WD_COPY_EXT_LINK_TITLE"),
                	"TEXT" => GetMessage("WD_COPY_EXT_LINK"),
                	"ONCLICK" => CWebDavExtLinks::InsertDialogCallText($urlT)
                );
                */
                if ($res["SHOW"]["HISTORY"] == "Y") {
                    $arActions["element_history"] = array("ICONCLASS" => "element_history" . ($res["SHOW"]["BP"] == "Y" ? " bizproc_history" : ""), "TITLE" => GetMessage("WD_HIST_ELEMENT_ALT"), "TEXT" => GetMessage("WD_HIST_ELEMENT"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~VIEW"] . "?webdavForm" . $arParams["IBLOCK_ID"] . "_active_tab=tab_history") . "');");
                }
                if ($res["SHOW"]["LOCK"] == "Y" || $res["SHOW"]["UNLOCK"] == "Y") {
                    if ($res["SHOW"]["BP_VIEW"] == "Y") {
                        $arActionsBpTmp[] = array("ICONCLASS" => "bizproc_document", "TITLE" => GetMessage("IBLIST_A_BP_H"), "TEXT" => GetMessage("IBLIST_A_BP_H"), "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~BP"]) . "');");
                    }
                    if ($res["SHOW"]["BP_START"] == "Y" && is_array($arParams["TEMPLATES"])) {
                        $arr = array();
                        foreach ($arParams["TEMPLATES"] as $key => $arWorkflowTemplate) {
                            if (!CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $GLOBALS["USER"]->GetID(), $res["DOCUMENT_ID"], array("UserGroups" => $res["USER_GROUPS"], "DocumentStates" => $res["~arDocumentStates"], "WorkflowTemplateList" => $arTemplates, "WorkflowTemplateId" => $arWorkflowTemplate["ID"]))) {
                                continue;
                            }
                            $url = $res["URL"]["~BP_START"];
                            $url .= (strpos($url, "?") === false ? "?" : "&") . "workflow_template_id=" . $arWorkflowTemplate["ID"] . '&' . bitrix_sessid_get();
                            $arr[] = array("ICONCLASS" => "", "TITLE" => $arWorkflowTemplate["DESCRIPTION"], "TEXT" => $arWorkflowTemplate["NAME"], "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "');");
                        }
                        if (!empty($arr)) {
                            $arActionsBpTmp[] = array("ICONCLASS" => "bizproc_start", "TITLE" => GetMessage("WD_START_BP_TITLE"), "TEXT" => GetMessage("WD_START_BP"), "MENU" => $arr);
                        }
                    }
                    //if ($res["SHOW"]["BP_CLONE"] == "Y")
                    //{
                    //$arActionsBpTmp[] = array(
                    //"ICONCLASS" => "bizproc_document",
                    //"TITLE" => GetMessage("WD_CREATE_VERSION_ALT"),
                    //"TEXT" => GetMessage("WD_CREATE_VERSION"),
                    //"ONCLICK" => "jsUtils.Redirect([], '".CUtil::JSEscape($res["URL"]["~CLONE"])."');");
                    //$arActionsBpTmp[] = array(
                    //"ICONCLASS" => "bizproc_document",
                    //"TITLE" => GetMessage("WD_VERSIONS_ALT"),
                    //"TEXT" => GetMessage("WD_VERSIONS"),
                    //"ONCLICK" => "jsUtils.Redirect([], '".CUtil::JSEscape($res["URL"]["~VERSIONS"])."');");
                    //}
                    if (!empty($arActionsBpTmp)) {
                        $arActions += $arActionsBpTmp;
                    }
                    $arActions["separator_del"] = array("SEPARATOR" => true);
                    if ($ob->Type == "folder" || $ob->Type == "iblock" && $res["WF_PARENT_ELEMENT_ID"] === null) {
                        $arActions["element_rename"] = array("ICONCLASS" => "element_rename", "TITLE" => GetMessage("WD_RENAME_TITLE"), "TEXT" => GetMessage("WD_RENAME_NAME"), "ONCLICK" => "WDRename(BX('ID_" . $res["TYPE"] . $res["ID"] . "'), bxGrid_" . $arParams["GRID_ID"] . ", '" . $arParams["GRID_ID"] . "')");
                    }
                }
                if ($res["SHOW"]["COPY"] == 'Y') {
                    $url = WDAddPageParams($res["URL"]["SECTIONS_DIALOG"], array("ACTION" => "COPY", "NAME" => urlencode($res["NAME"]), "ID" => "E" . $res["ID"]), false);
                    $arActions["element_copy"] = array("ICONCLASS" => "element_copy", "TITLE" => GetMessage("WD_COPY_TITLE"), "TEXT" => GetMessage("WD_COPY_NAME"), "ONCLICK" => "(new BX.CDialog({'width': 450, 'heght':400, 'content_url':'" . CUtil::JSEscape($url) . "'})).Show()");
                }
                if ($ob->Type == "iblock" && $res["WF_PARENT_ELEMENT_ID"] === null && $res["SHOW"]["EDIT"] == "Y") {
                    $url = WDAddPageParams($res["URL"]["SECTIONS_DIALOG"], array("ACTION" => "MOVE", "NAME" => urlencode($res["NAME"]), "ID" => "E" . $res["ID"]), false);
                    $arActions["element_move"] = array("ICONCLASS" => "element_move", "TITLE" => GetMessage("WD_MOVE_TITLE"), "TEXT" => GetMessage("WD_MOVE_NAME"), "ONCLICK" => "(new BX.CDialog({'width': 450, 'heght':400, 'content_url':'" . CUtil::JSEscape($url) . "'})).Show()");
                }
                if ($res["SHOW"]["RIGHTS"] == "Y") {
                    $urlParams = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ENTITY_TYPE" => "ELEMENT", "ENTITY_ID" => $res['ID'], "back_url" => urlencode($GLOBALS['APPLICATION']->GetCurPageParam()));
                    if (isset($ob->attributes['user_id'])) {
                        $urlParams['SOCNET_TYPE'] = 'user';
                        $urlParams['SOCNET_ID'] = $ob->attributes['user_id'];
                    } elseif (isset($ob->attributes['group_id'])) {
                        $urlParams['SOCNET_TYPE'] = 'group';
                        $urlParams['SOCNET_ID'] = $ob->attributes['group_id'];
                    }
                    $url = WDAddPageParams("/bitrix/components/bitrix/webdav.section.list/templates/.default/iblock_e_rights.php", $urlParams, false);
                    $arActions["element_permissions"] = array("ICONCLASS" => "element_permissions", "TITLE" => GetMessage("WD_ELEMENT_PERMISSIONS"), "TEXT" => GetMessage("WD_PERMISSIONS"), "ONCLICK" => "(new BX.CDialog({'width': 750, 'heght':400, 'content_url':'" . CUtil::JSEscape($url) . "'})).Show()");
                }
                if ($res["SHOW"]["DELETE"] == "Y" && (!$bInTrash || $bInTrash && $arParams["PERMISSION"] >= "X")) {
                    $forceDeleteUrl = CHTTP::urlAddParams($res["URL"]["~DELETE"], array('delete_without_trash' => 1));
                    $arActions["element_delete"] = array("ICONCLASS" => "element_delete", "TITLE" => GetMessage("WD_DELETE_ELEMENT"), "TEXT" => GetMessage("WD_DELETE"));
                    if ($res["SHOW"]["UNDELETE"] == "Y") {
                        $arActions["element_delete"]["ONCLICK"] = "WDConfirm('" . CUtil::JSEscape(GetMessage("WD_DELETE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage($res["SHOW"]["UNDELETE"] == "Y" ? "WD_DESTROY_CONFIRM" : "WD_DELETE_CONFIRM", array("#NAME#" => $res['NAME']))) . "', function() {jsUtils.Redirect([], '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "')})";
                    } elseif ($arParams['OBJECT']->CheckRight($res["E_RIGHTS"], "iblock_edit") >= "X") {
                        $arActions["element_delete"]['ONCLICK'] = "WDConfirmDelete('" . CUtil::JSEscape(GetMessage("WD_DELETE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage("WD_TRASH_DELETE_DESTROY_ELEMENT_CONFIRM", array("#NAME#" => $res['NAME']))) . "'" . ", '" . CUtil::JSEscape(GetMessage("WD_TRASH_DELETE_BUTTON")) . "'" . ", '" . CUtil::JSEscape(GetMessage("WD_TRASH_DESTROY_BUTTON")) . "'" . ", '" . CUtil::JSEscape(GetMessage("WD_TRASH_CANCEL_DELETE_BUTTON")) . "'" . ", function() { var urlDelete = '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "';  jsUtils.Redirect([], urlDelete)}" . ", function() { var urlDelete = '" . CUtil::JSEscape($forceDeleteUrl) . "'; jsUtils.Redirect([], urlDelete)})";
                    } else {
                        $arActions["element_delete"]['ONCLICK'] = "WDConfirm('" . CUtil::JSEscape(GetMessage("WD_DELETE_TITLE")) . "', '" . CUtil::JSEscape(GetMessage("WD_DELETE_CONFIRM", array("#NAME#" => $res['NAME']))) . "', function() { var urlDelete = '" . CUtil::JSEscape($res["URL"]["~DELETE"]) . "';  jsUtils.Redirect([], urlDelete)})";
                    }
                }
            }
        }
        foreach (array("MODIFIED_BY", "CREATED_BY", "WF_LOCKED_BY") as $user_key) {
            $aCols[$user_key] = is_array($res[$user_key]) ? $res[$user_key] : __parse_user($res[$user_key], $arParams["USER_VIEW_URL"], isset($arParams["NAME_TEMPLATE"]) ? $arParams["NAME_TEMPLATE"] : null);
            $aCols[$user_key] = "<div class=\"wd-user-link\">" . $aCols[$user_key]['main_user_link'] . "</div>";
        }
        if ($res["TYPE"] == "S") {
            $classNameForIcon = !empty($res['LINK']) || !empty($res['SHARED_SECTION']) ? 'shared-section-icon' : 'section-icon';
            $res["FTYPE"] = "folder";
            $aCols["PLAIN_NAME"] = $res["NAME"];
            $aCols["NAME"]['shared'] = $res["SHOW"]["SHARED"] ? '<div class="element-shared"></div>' : '';
            $aCols["NAME"] = '<div class="section-name">
					<div class="' . $classNameForIcon . '"></div>' . $aCols["NAME"]['shared'] . '<a class="section-title" id="sec' . $res['ID'] . '" href="' . $res["URL"]["THIS"] . '"' . 'data-bx-viewer="' . $arActions['preview_launch']['type'] . '" ' . 'data-bx-title="' . htmlspecialcharsbx($arActions['preview_launch']['title']) . '" ' . 'data-bx-src="' . $arActions['preview_launch']['src'] . '" ' . 'data-bx-size="' . $arActions['preview_launch']['size'] . '" ' . 'data-bx-owner="' . htmlspecialcharsbx($arActions['preview_launch']['owner']) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($arActions['preview_launch']['dateModify']) . '" ' . '>' . $res["NAME"] . '</a>
				</div>';
            if ((!empty($res['LINK']) || !empty($res['SHARED_SECTION'])) && isset($arActions["section_share"])) {
                $aCols['FILE_SIZE'] = '<div id="sec' . $res['ID'] . '-share" class="wd-share-hotkey-share section-name" onclick="' . $arActions["section_share"]['ONCLICK'] . '">' . GetMessage('WD_ALREADY_SHARE_SECTION') . '</div></div> ';
            } elseif (!empty($arParams["OBJECT"]->attributes['user_id']) && $arParams["OBJECT"]->attributes['user_id'] == $USER->getId() && !empty($arActions["section_share"]) && !$isExtranetUser) {
                $aCols['FILE_SIZE'] = '<div id="sec' . $res['ID'] . '-share" class="wd-share-hotkey-potential-share section-name" onclick="' . $arActions["section_share"]['ONCLICK'] . '"><div class="shared-section-icon"></div> ' . GetMessage('WD_MAKE_SHARE_SECTION') . '</div> ';
            } elseif (empty($arParams["OBJECT"]->attributes['user_id']) && CWebDavIblock::$possibleUseSymlinkByInternalSections && !empty($arActions["section_share"]) && !$isExtranetUser) {
                $aCols['FILE_SIZE'] = '<div id="sec' . $res['ID'] . '-share" class="wd-share-hotkey-potential-share section-name" onclick="' . $arActions["section_share"]['ONCLICK'] . '"><div class="shared-section-icon"></div> ' . GetMessage('WD_SHARE_SECTION_CONNECT_IN_GRID') . '</div> ';
            }
        } else {
            $aCols["NAME"] = array();
            $hintLink = __make_hint($res);
            if (!isset($arParams['MERGE_VIEW'])) {
                $aCols["NAME"]['hint'] = $res['HINT'];
            } else {
                $aCols["NAME"]['hint'] = '';
                $hintLink = '';
            }
            $aCols["NAME"]['icon'] = '<div class="element-icon icons icon-' . substr($res["FILE_EXTENTION"], 1) . '"></div>';
            $aCols["NAME"]['shared'] = $res["SHOW"]["SHARED"] ? '<div class="element-shared"></div>' : '';
            if (strlen($res["NAME"]) == 0) {
                $aCols["NAME"]["name"] = "<span>&nbsp;</span>";
            } else {
                $resName = $WrapLongWords ? WrapLongWords(htmlspecialcharsbx($res["NAME"])) : htmlspecialcharsbx($res["NAME"]);
                if ($ob->Type != "iblock") {
                    $aCols["NAME"]['name'] = '<a class="element-title ' . (strlen($hintLink) > 0 ? 'element-hint ' : ' ') . '" id="doc' . $res['ID'] . '" ' . $hintLink . 'href="' . htmlspecialcharsbx($res["URL"]["THIS"]) . '" onclick="return OpenDoc(this, ' . (in_array($res["FILE_EXTENTION"], $arOfficeExtensions) && $arParams['DEFAULT_EDIT'] == 'Y' ? "true" : "false") . ')"' . ' target="_blank"' . (strlen($hintLink) > 0 ? '' : ' title="' . GetMessage("WD_DOWNLOAD_ELEMENT") . '"') . '>' . $resName . '</a>';
                } else {
                    $aCols["NAME"]['name'] = '<a class="element-title ' . (strlen($hintLink) > 0 ? 'element-hint ' : ' ') . '" id="doc' . $res['ID'] . '" ' . $hintLink . ' ' . 'data-bx-viewer="' . $arActions['preview_launch']['type'] . '" ' . 'data-bx-title="' . htmlspecialcharsbx($arActions['preview_launch']['title']) . '" ' . 'data-bx-src="' . $arActions['preview_launch']['src'] . '" ' . 'data-bx-historyPage="' . $arActions['preview_launch']['history'] . '" ' . 'data-bx-edit="' . $arActions['preview_launch']['edit'] . '" ' . 'data-bx-isFromUserLib="' . $arActions['preview_launch']['inPersonalLib'] . '" ' . 'data-bx-externalId="' . $arActions['preview_launch']['externalId'] . '" ' . 'data-bx-relativePath="' . $arActions['preview_launch']['relativePath'] . '" ' . 'data-bx-askConvert="' . $arActions['preview_launch']['askConvert'] . '" ' . 'data-bx-download="' . $arActions['preview_launch']['download'] . '" ' . 'data-bx-size="' . $arActions['preview_launch']['size'] . '" ' . 'data-bx-owner="' . htmlspecialcharsbx($arActions['preview_launch']['owner']) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($arActions['preview_launch']['dateModify']) . '" ' . 'data-bx-tooBigSizeMsg="' . htmlspecialcharsbx($arActions['preview_launch']['tooBigSizeMsg']) . '" ' . '>' . $resName . '</a>';
                }
            }
            $aCols["NAME"]['status'] = '';
            if ($arParams["PERMISSION"] >= "U" && in_array($res['LOCK_STATUS'], array("red", "yellow"))) {
                $aCols["NAME"]['status'] .= '<div class="element-status-' . $res['LOCK_STATUS'] . '">';
                if ($res['LOCK_STATUS'] == "yellow") {
                    $aCols["NAME"]['status'] .= '[' . GetMessage("IBLOCK_YELLOW_MSG") . ']';
                } else {
                    if (!is_array($res['WF_LOCKED_BY']) && intval($res['WF_LOCKED_BY']) > 0) {
                        $rUserLockedBy = CUser::GetByID($res['WF_LOCKED_BY']);
                        $res['WF_LOCKED_BY'] = $rUserLockedBy->Fetch();
                    }
                    if (isset($res['WF_LOCKED_BY']['ID']) && $res['WF_LOCKED_BY']['ID'] > 0) {
                        $res['LOCKED_USER_NAME'] = CUser::FormatName($nameTemplate, $res['WF_LOCKED_BY']);
                        $aCols["NAME"]['status'] .= '[' . trim(GetMessage("IBLOCK_RED_MSG", array('#NAME#' => $res['LOCKED_USER_NAME']))) . ']';
                    } else {
                        $aCols["NAME"]['status'] .= '[' . GetMessage("IBLOCK_RED_MSG_OTHER") . ']';
                    }
                }
                $aCols["NAME"]['status'] .= '</div>';
            }
            if ($arParams["USE_COMMENTS"] == "Y" && intVal($res["PROPERTY_FORUM_MESSAGE_CNT_VALUE"]) > 0) {
                $aCols["NAME"]['comments'] = '<a href="' . $res["URL"]["VIEW"] . '?webdavForm' . $arParams["IBLOCK_ID"] . '_active_tab=tab_comments" class="element-properties element-comments" title="' . GetMessage("WD_COMMENTS_FOR_DOCUMENT") . " " . intVal($res["PROPERTY_FORUM_MESSAGE_CNT_VALUE"]) . '">' . intVal($res["PROPERTY_FORUM_MESSAGE_CNT_VALUE"]) . '</a>';
            }
            $aCols["PROPERTY_FORUM_MESSAGE_CNT"] = '<a href="' . $res["URL"]["VIEW"] . '">' . intVal($res["PROPERTY_FORUM_MESSAGE_CNT_VALUE"]) . '</a>';
            $aCols["BP_PUBLISHED"] = "<div class=\"wd-bp-published wd-bp-published-" . ($res["BP_PUBLISHED"] != "Y" ? "n" : "y") . "\"></div>";
            $aCols["NAME"]["version"] = "";
            if ($arParams["WORKFLOW"] == "bizproc" && $res["WF_PARENT_ELEMENT_ID"] > 0) {
                $aCols["NAME"]["version"] = "<span class=\"wd-element-version\">" . GetMessage("WD_NAME_VERSION") . "</span>";
            }
            $aCols["BIZPROC"] = "";
            if ($arParams["WORKFLOW"] == "bizproc" && !empty($res["arDocumentStates"])) {
                $arDocumentStates = $res["arDocumentStates"];
                if (count($arDocumentStates) == 1) {
                    $arDocumentState = reset($arDocumentStates);
                    $arTasksWorkflow = CBPDocument::GetUserTasksForWorkflow($GLOBALS["USER"]->GetID(), $arDocumentState["ID"]);
                    $aColss["BIZPROC"] = '<div class="bizproc-item-title">' . (!empty($arDocumentState["TEMPLATE_NAME"]) ? htmlspecialcharsbx(htmlspecialcharsbx($arDocumentState["TEMPLATE_NAME"])) : GetMessage("IBLIST_BP")) . ': ' . '<span class="bizproc-item-title bizproc-state-title" style="">' . '<a href="' . $res["URL"]["BP"] . '">' . (strlen($arDocumentState["STATE_TITLE"]) > 0 ? htmlspecialcharsbx(htmlspecialcharsbx($arDocumentState["STATE_TITLE"])) : htmlspecialcharsbx(htmlspecialcharsbx($arDocumentState["STATE_NAME"]))) . '</a>' . '</span>' . '</div>';
                    $aColss["BIZPROC"] = str_replace("'", "\"", $aColss["BIZPROC"]);
                    $aCols["NAME"]['bizproc'] = "<div class=\"element-bizproc-status bizproc-statuses " . (!(strlen($arDocumentState["ID"]) <= 0 || strlen($arDocumentState["WORKFLOW_STATUS"]) <= 0) ? 'bizproc-status-' . (empty($arTasksWorkflow) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($aColss["BIZPROC"]) . "\")'></div>";
                    if (!empty($arTasksWorkflow)) {
                        $tmp = array();
                        foreach ($arTasksWorkflow as $key => $val) {
                            $url = CComponentEngine::MakePathFromTemplate($arParams["WEBDAV_TASK_URL"], array("ELEMENT_ID" => $res["ID"], "ID" => $val["ID"]));
                            $url = WDAddPageParams($url, array("back_url" => urlencode($GLOBALS['APPLICATION']->GetCurPageParam())), false);
                            $tmp[] = '<a href="' . $url . '">' . $val["NAME"] . '</a>';
                        }
                        $aColss["BIZPROC"] .= '<div class="bizproc-tasks">' . implode(", ", $tmp) . '</div>';
                    }
                } else {
                    $arTasks = array();
                    $bInprogress = false;
                    $tmp = array();
                    foreach ($arDocumentStates as $key => $arDocumentState) {
                        $arTasksWorkflow = CBPDocument::GetUserTasksForWorkflow($GLOBALS["USER"]->GetID(), $arDocumentState["ID"]);
                        if (!$bInprogress) {
                            $bInprogress = strlen($arDocumentState["ID"]) > 0 && strlen($arDocumentState["WORKFLOW_STATUS"]) > 0;
                        }
                        $tmp[$key] = '<li class="bizproc-item">' . '<div class="bizproc-item-title">' . '<div class="bizproc-statuses ' . (strlen($arDocumentState["ID"]) > 0 && strlen($arDocumentState["WORKFLOW_STATUS"]) > 0 ? 'bizproc-status-' . (empty($arTasksWorkflow) ? "inprogress" : "attention") : '') . '"></div>' . (!empty($arDocumentState["TEMPLATE_NAME"]) ? $arDocumentState["TEMPLATE_NAME"] : GetMessage("IBLIST_BP")) . '</div>' . '<div class="bizproc-item-title bizproc-state-title">' . (strlen($arDocumentState["STATE_TITLE"]) > 0 ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]) . '</div>';
                        if (!empty($arTasksWorkflow)) {
                            $tmp_tasks = array();
                            foreach ($arTasksWorkflow as $val) {
                                $url = CComponentEngine::MakePathFromTemplate($arParams["WEBDAV_TASK_URL"], array("ELEMENT_ID" => $res["ID"], "ID" => $val["ID"]));
                                $url = WDAddPageParams($url, array("back_url" => urlencode($GLOBALS['APPLICATION']->GetCurPageParam())), false);
                                $tmp_tasks[] = '<a href="' . $url . '">' . $val["NAME"] . '</a>';
                                $arTasks[] = $val;
                            }
                            $tmp[$key] .= '<div class="bizproc-tasks">' . implode(", ", $tmp_tasks) . '</div>';
                        }
                        $tmp[$key] .= '</li>';
                    }
                    $aColss["BIZPROC"] = '<span class="bizproc-item-title">' . GetMessage("WD_BP_R_P") . ': <a href="' . $res["URL"]["BP"] . '" title="' . GetMessage("WD_BP_R_P_TITLE") . '">' . count($arDocumentStates) . '</a>' . '</span>' . (!empty($arTasks) ? '<br /><span class="bizproc-item-title">' . GetMessage("WD_TASKS") . ': <a href="' . $res["URL"]["BP_TASK"] . '" title="' . GetMessage("WD_TASKS_TITLE") . '">' . count($arTasks) . '</a></span>' : '');
                    $aCols["NAME"]['bizproc'] = "<div class=\"element-bizproc-status bizproc-statuses " . ($bInprogress ? ' bizproc-status-' . (empty($arTasks) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($aColss['BIZPROC']) . "\")'></div>";
                }
                $aCols['BIZPROC'] = $aColss['BIZPROC'];
            }
        }
        $aCols["ACTIVE"] = $res["ACTIVE"] == "Y" ? GetMessage("WD_Y") : GetMessage("WD_N");
        $aCols["TIMESTAMP_X"] = "<div class='wd_column_date'>" . FormatDate('X', MakeTimeStamp($res["TIMESTAMP_X"])) . "</div>";
        $aCols["DATE_CREATE"] = "<div class='wd_column_date'>" . FormatDate('X', MakeTimeStamp($res["DATE_CREATE"])) . "</div>";
        $sName = '';
        $sRating = '';
        if ($res['TYPE'] != 'S') {
            if ($arParams["SHOW_RATING"] == 'Y' && $arParams["RATING_TAG"] == 'Y') {
                $sRating = "#RATING#";
            }
            $aCols["NAME"] = $aCols["NAME"]["hint"] . "<div class=\"element-name\">" . $aCols["NAME"]["icon"] . $aCols["NAME"]["shared"] . "<div class=\"element-name-wrapper\">" . $aCols["NAME"]["name"] . $aCols["NAME"]["version"] . CWebDavExtLinks::$icoRepStr . $aCols["NAME"]["comments"] . $sRating . $aCols["NAME"]["status"] . "</div>" . $aCols["NAME"]["bizproc"] . "</div>";
        }
        if ($bTheFirstTimeonPage == true && $res["PERMISSION"] >= "U") {
            $bTheFirstTimeonPage = false;
            ?>
<script>
try {
if (/*@cc_on ! @*/ false && new ActiveXObject("SharePoint.OpenDocuments.2"))
{
	BX.ready(
		function()
		{
			setTimeout(
				function ()
				{
					try
					{
						var res = document.getElementsByTagName("A");
						for (var ii = 0; ii < res.length; ii++)
						{
							if (res[ii].className.indexOf("element-edit-office") >= 0) { res[ii].style.display = 'block'; }
						}
					}
					catch(e) {}
				}
				, 10
			)
		}
	);
}
} catch(e) {}

BX.message({
	'wd_desktop_disk_is_installed': '<?php 
            echo (bool) CWebDavTools::isDesktopDiskInstall();
            ?>
'
});

</script>
<?php 
        }
        return array("actions" => $arActions, "columns" => $aCols);
    }
Exemplo n.º 22
0
 public static final function disableUFSymlinkMode()
 {
     self::$_fetchUFSymlinkMode = false;
 }
Exemplo n.º 23
0
 /**
  * Add rights for reading files by given users.
  * @deprecated
  */
 private static function addFilesRights($taskId, $arFilesIds)
 {
     $arFilesIds = array_unique(array_filter($arFilesIds));
     // Nothing to do?
     if (empty($arFilesIds)) {
         return;
     }
     if (!CModule::IncludeModule('webdav')) {
         return;
     }
     $arRightsTasks = CWebDavIblock::GetTasks();
     // tasks-operations
     $oTask = new CTaskItem((int) $taskId, 1);
     $arTask = $oTask->getData(false);
     $arTaskMembers = array_unique(array_merge(array($arTask['CREATED_BY'], $arTask['RESPONSIBLE_ID']), $arTask['AUDITORS'], $arTask['ACCOMPLICES']));
     $ibe = new CIBlockElement();
     $dbWDFile = $ibe->GetList(array(), array('ID' => $arFilesIds, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'NAME', 'SECTION_ID', 'IBLOCK_ID', 'WF_NEW'));
     if ($dbWDFile) {
         $i = 0;
         $arRightsForTaskMembers = array();
         foreach ($arTaskMembers as $userId) {
             // For intranet users and their managers
             $arRightsForTaskMembers['n' . $i++] = array('GROUP_CODE' => 'IU' . $userId, 'TASK_ID' => $arRightsTasks['R']);
             // For extranet users
             $arRightsForTaskMembers['n' . $i++] = array('GROUP_CODE' => 'U' . $userId, 'TASK_ID' => $arRightsTasks['R']);
         }
         $iNext = $i;
         while ($arWDFile = $dbWDFile->Fetch()) {
             if (!$arWDFile['IBLOCK_ID']) {
                 continue;
             }
             $fileId = $arWDFile['ID'];
             if (CIBlock::GetArrayByID($arWDFile['IBLOCK_ID'], "RIGHTS_MODE") === "E") {
                 $ibRights = new CIBlockElementRights($arWDFile['IBLOCK_ID'], $fileId);
                 $arCurRightsRaw = $ibRights->getRights();
                 // Preserve existing rights
                 $i = $iNext;
                 $arRights = $arRightsForTaskMembers;
                 foreach ($arCurRightsRaw as $arRightsData) {
                     $arRights['n' . $i++] = array('GROUP_CODE' => $arRightsData['GROUP_CODE'], 'TASK_ID' => $arRightsData['TASK_ID']);
                 }
                 $ibRights->setRights($arRights);
             }
         }
     }
 }
Exemplo n.º 24
0
 public static function saveRawFilesToUF($arAttachedFilesRaw, $ufCode, &$arFields)
 {
     static $isDiskEnabled = false;
     static $isWebDavEnabled = false;
     if ($isDiskEnabled === false) {
         $isDiskEnabled = \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())) ? "Y" : "N";
     }
     if ($isWebDavEnabled === false) {
         $isWebDavEnabled = IsModuleInstalled('webdav') ? "Y" : "N";
     }
     if (empty($arFields[$ufCode])) {
         $arFields[$ufCode] = array();
     }
     $arRelation = array();
     foreach ($arAttachedFilesRaw as $attachedFileRow) {
         if (!empty($attachedFileRow["base64"]) && !empty($attachedFileRow["url"])) {
             $fileContent = base64_decode($attachedFileRow["base64"]);
             $arUri = parse_url($attachedFileRow["url"]);
             if (!empty($arUri) && !empty($arUri["path"])) {
                 $fileName = $arUri["path"];
             }
             if (!empty($fileContent) && !empty($fileName)) {
                 $fileName = CTempFile::GetFileName($fileName);
                 if (CheckDirPath($fileName)) {
                     file_put_contents($fileName, $fileContent);
                     $arFile = CFile::MakeFileArray($fileName);
                     if (is_array($arFile)) {
                         $resultId = false;
                         if ($isDiskEnabled == "Y") {
                             $file = $folder->uploadFile($arFile, array('NAME' => $arFile["name"], 'CREATED_BY' => $GLOBALS["USER"]->GetID()), array(), true);
                             if ($file) {
                                 $resultId = \Bitrix\Disk\Uf\FileUserType::NEW_FILE_PREFIX . $file->getId();
                             }
                         } elseif ($isWebDavEnabled == "Y") {
                             $webDavData = CWebDavIblock::getRootSectionDataForUser($GLOBALS["USER"]->GetID());
                             if (is_array($webDavData)) {
                                 $webDavObject = new CWebDavIblock($webDavData["IBLOCK_ID"], "", array("ROOT_SECTION_ID" => $webDavData["SECTION_ID"], "DOCUMENT_TYPE" => array("webdav", 'CIBlockDocumentWebdavSocnet', 'iblock_' . $webDavData['SECTION_ID'] . '_user_' . intval($GLOBALS["USER"]->GetID()))));
                                 if ($webDavObject) {
                                     $arParent = $webDavObject->GetObject(array("section_id" => $webDavObject->GetMetaID("DROPPED")));
                                     if (!$arParent["not_found"]) {
                                         $path = $webDavObject->_get_path($arParent["item_id"], false);
                                         $tmpName = str_replace(array(":", ".", "/", "\\"), "_", ConvertTimeStamp(time(), "FULL"));
                                         $tmpOptions = array("path" => str_replace("//", "/", $path . "/" . $tmpName));
                                         $arParent = $webDavObject->GetObject($tmpOptions);
                                         if ($arParent["not_found"]) {
                                             $rMKCOL = $webDavObject->MKCOL($tmpOptions);
                                             if (intval($rMKCOL) == 201) {
                                                 $webDavData["SECTION_ID"] = $webDavObject->arParams["changed_element_id"];
                                             }
                                         } else {
                                             $webDavData["SECTION_ID"] = $arParent['item_id'];
                                             if (!$webDavObject->CheckUniqueName($tmpName, $webDavData["SECTION_ID"], $tmpRes)) {
                                                 $path = $webDavObject->_get_path($webDavData["SECTION_ID"], false);
                                                 $tmpName = randString(6);
                                                 $tmpOptions = array("path" => str_replace("//", "/", $path . "/" . $tmpName));
                                                 $rMKCOL = $webDavObject->MKCOL($tmpOptions);
                                                 if (intval($rMKCOL) == 201) {
                                                     $webDavData["SECTION_ID"] = $webDavData->arParams["changed_element_id"];
                                                 }
                                             }
                                         }
                                     }
                                     $options = array("new" => true, 'dropped' => true, "arFile" => $arFile, "arDocumentStates" => false, "arUserGroups" => array_merge($webDavObject->USER["GROUPS"], array("Author")), "FILE_NAME" => $arFile["name"], "IBLOCK_ID" => $webDavData["IBLOCK_ID"], "IBLOCK_SECTION_ID" => $webDavData["SECTION_ID"], "USER_FIELDS" => array());
                                     $GLOBALS['USER_FIELD_MANAGER']->EditFormAddFields($webDavObject->GetUfEntity(), $options['USER_FIELDS']);
                                     $GLOBALS["DB"]->StartTransaction();
                                     if (!$webDavObject->put_commit($options)) {
                                         $GLOBALS["DB"]->Rollback();
                                     } else {
                                         $GLOBALS["DB"]->Commit();
                                         $resultId = $options['ELEMENT_ID'];
                                     }
                                 }
                             }
                         } else {
                             $resultId = CFile::SaveFile($arFile, $arFile["MODULE_ID"]);
                         }
                         if ($resultId) {
                             $arFields[$ufCode][] = $resultId;
                         }
                         if (!empty($attachedFileRow["id"])) {
                             $arRelation[$attachedFileRow["id"]] = $resultId;
                         }
                     }
                 }
             }
         }
     }
     if (!empty($arRelation)) {
         $arFields["DETAIL_TEXT"] = preg_replace_callback("/\\[DISK\\s+FILE\\s+ID\\s*=\\s*pseudo@([\\d]+)\\]/is" . BX_UTF_PCRE_MODIFIER, function ($matches) use($arRelation, $isDiskEnabled, $isWebDavEnabled) {
             if (isset($arRelation[intval($matches[1])])) {
                 if ($isDiskEnabled == "Y") {
                     return "[DISK FILE ID=" . $arRelation[intval($matches[1])] . "]";
                 } elseif ($isWebDavEnabled == "Y") {
                     return "[DOCUMENT ID=" . intval($arRelation[intval($matches[1])]) . "]";
                 } else {
                     return "[DISK FILE ID=pseudo@" . $matches[1] . "]";
                 }
             } else {
                 return "[DISK FILE ID=pseudo@" . $matches[1] . "]";
             }
         }, $arFields["DETAIL_TEXT"]);
     }
 }
Exemplo n.º 25
0
 public static function UpdateUFRights($files, $rights, $ufEntity = array())
 {
     static $arTasks = null;
     if (!is_array($rights) || sizeof($rights) <= 0) {
         return false;
     }
     if ($files === null || $files === false) {
         return false;
     }
     if (!is_array($files)) {
         $files = array($files);
     }
     if (sizeof($files) <= 0) {
         return false;
     }
     if (!CModule::IncludeModule('iblock') || !CModule::IncludeModule('webdav')) {
         return false;
     }
     $arFiles = array();
     foreach ($files as $id) {
         $id = intval($id);
         if (intval($id) > 0) {
             $arFiles[] = $id;
         }
     }
     if (sizeof($arFiles) <= 0) {
         return false;
     }
     if ($arTasks == null) {
         $arTasks = CWebDavIblock::GetTasks();
     }
     $arCodes = array();
     foreach ($rights as $value) {
         if (substr($value, 0, 2) === 'SG') {
             $arCodes[] = $value . '_K';
         }
         $arCodes[] = $value;
     }
     $arCodes = array_unique($arCodes);
     $i = 0;
     $arViewRights = $arEditRights = array();
     $curUserID = 'U' . $GLOBALS['USER']->GetID();
     foreach ($arCodes as $right) {
         if ($curUserID == $right) {
             // do not override owner's rights
             continue;
         }
         $key = 'n' . $i++;
         $arViewRights[$key] = array('GROUP_CODE' => $right, 'TASK_ID' => $arTasks['R']);
     }
     $ibe = new CIBlockElement();
     $dbWDFile = $ibe->GetList(array(), array('ID' => $arFiles, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'NAME', 'SECTION_ID', 'IBLOCK_ID', 'WF_NEW'));
     $iblockIds = array();
     if ($dbWDFile) {
         while ($arWDFile = $dbWDFile->Fetch()) {
             $id = $arWDFile['ID'];
             if ($arWDFile['WF_NEW'] == 'Y') {
                 $ibe->Update($id, array('BP_PUBLISHED' => 'Y'));
             }
             if (CIBlock::GetArrayByID($arWDFile['IBLOCK_ID'], "RIGHTS_MODE") === "E") {
                 $ibRights = CWebDavIblock::_get_ib_rights_object('ELEMENT', $id, $arWDFile['IBLOCK_ID']);
                 $ibRights->SetRights(CWebDavTools::appendRights($ibRights, $arViewRights, $arTasks));
                 if (empty($iblockIds[$arWDFile['IBLOCK_ID']])) {
                     $iblockIds[$arWDFile['IBLOCK_ID']] = $arWDFile['IBLOCK_ID'];
                 }
             }
         }
         global $CACHE_MANAGER;
         foreach ($iblockIds as $iblockId) {
             $CACHE_MANAGER->ClearByTag('iblock_id_' . $iblockId);
         }
         unset($iblockId);
     }
 }
Exemplo n.º 26
0
 private function getSectionDataByUserId($userId)
 {
     return \CWebDavIblock::getRootSectionDataForUser((int) $userId);
 }
Exemplo n.º 27
0
 protected static function groupSectionCreate($groupId)
 {
     $groupLib = CWebDavIblock::LibOptions('group_files', false, SITE_ID);
     if (!$groupLib || !isset($groupLib['id']) || !($iblockId = intval($groupLib['id']))) {
         return false;
     }
     $result = CIBlockWebdavSocnet::GetSectionID($iblockId, 'group', $groupId);
     if (intval($result) > 0) {
         return $result;
     }
     $dbRes = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => "UF_USE_BP"));
     if (!$dbRes || !($res = $dbRes->GetNext())) {
         $arFields = array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => "UF_USE_BP", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N", "SETTINGS" => array("DEFAULT_VALUE" => "Y"));
         $arFieldName = array();
         $rsLanguage = CLanguage::GetList($by, $order, array());
         while ($arLanguage = $rsLanguage->Fetch()) {
             $dir = str_replace(array("\\", "//"), "/", dirname(__FILE__));
             $dirs = explode("/", $dir);
             array_pop($dirs);
             $file = trim(implode("/", $dirs) . "/lang/" . $arLanguage["LID"] . "/include/webdav_settings.php");
             $tmp_mess = __IncludeLang($file, true);
             $arFieldName[$arLanguage["LID"]] = empty($tmp_mess["SONET_UF_USE_BP"]) ? "Use Business Process" : $tmp_mess["SONET_UF_USE_BP"];
         }
         $arFields["EDIT_FORM_LABEL"] = $arFieldName;
         $obUserField = new CUserTypeEntity();
         $obUserField->Add($arFields);
         $GLOBALS["USER_FIELD_MANAGER"]->arFieldsCache = array();
     }
     $arFields = array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N");
     $arFields["SOCNET_GROUP_ID"] = $groupId;
     $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $groupId;
     $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $groupId), false, false, array("ID", "SITE_ID", "NAME"));
     if ($arGroup = $dbGroup->Fetch()) {
         $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"];
     }
     if (CIBlock::GetarrayByID($iblockId, "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']));
     }
     $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"];
     $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $iblockId . "_SECTION", $arFields);
     $bs = new CIBlockSection();
     $sectionId = $bs->Add($arFields);
     if (!$sectionId) {
         return false;
     }
     return $sectionId;
 }
Exemplo n.º 28
0
?>
';
oText['wd_edit_in'] = '<?php 
echo CUtil::JSEscape(GetMessage("WD_MENU_EDIT_IN"));
?>
';
oText['wd_edit_in_other'] = '<?php 
echo CUtil::JSEscape(GetMessage("WD_MENU_EDIT_IN_OTHER"));
?>
';
oText['wd_install_cancel'] = '<?php 
echo CUtil::JSEscape(GetMessage("WD_BTN_INSTALL_CANCEL"));
?>
';
<?php 
if ($bIsFF) {
    $arUserOptions = CUserOptions::GetOption('webdav', 'suggest', array('ff_extension' => true));
    if ($arUserOptions['ff_extension'] === true) {
        ?>
window.suggest_ff_extension = true;
<?php 
    }
}
?>
</script><?php 
if (CWebDavIblock::needBlockByDisk()) {
    ShowError(GetMessage('WD_BLOCKED_BY_DISK'));
}
if (!empty($arButtons)) {
    $APPLICATION->IncludeComponent("bitrix:main.interface.toolbar", "", array("BUTTONS" => $arButtons), $this->__component->__parent ? $this->__component->__parent : $component);
}
Exemplo n.º 29
0
    if ($userLib && isset($userLib['id']) && ($iblockID = intval($userLib['id']))) {
        $sectionID = CIBlockWebdavSocnet::GetSectionID($iblockID, 'user', $userID);
        $libPath = CWebDavIblock::LibOptions('lib_paths', true, $iblockID);
        if ($libPath) {
            $tplUser = '******';
            if ($tplPos = strpos($libPath, $tplUser)) {
                $libPath = substr($libPath, 0, $tplPos + strlen($tplUser)) . '/files/lib/';
            }
            $libPath = str_replace('#user_id#', $userID, $libPath);
        }
    }
    if ($sectionID && $libPath) {
        $typeItems .= str_replace(array("#GROUP_ID#", "#GROUP_NAME#", "#LINK#", "#IBLOCK_ID#", "#SECTION_ID#"), array($userID, CUtil::JSEscape(GetMessage('WD_MY_DOCUMENTS')), CUtil::JSEscape($libPath), $iblockID, $sectionID), "'U#GROUP_ID#' : {'id' : 'U#GROUP_ID#', 'name' : '#GROUP_NAME#', 'type' : 'user', 'link' : '#LINK#', 'iblock_id': '#IBLOCK_ID#', 'section_id': '#SECTION_ID#'},\n");
    }
}
$sharedLibID = CWebDavIblock::LibOptions('shared_files', false, SITE_ID);
if ($sharedLibID && isset($sharedLibID['id']) && intval($sharedLibID['id']) > 0 && isset($sharedLibID['base_url']) && strlen($sharedLibID['base_url']) > 0) {
    if (substr($sharedLibID['base_url'], -1) == "/") {
        $sharedLibID['base_url'] .= "index.php";
    }
    $typeItems .= str_replace(array("#GROUP_ID#", "#GROUP_NAME#", "#LINK#", "#IBLOCK_ID#"), array(intval($sharedLibID['id']), CUtil::JSEscape(GetMessage('WD_SHARED_DOCUMENTS')), CUtil::JSEscape($sharedLibID['base_url']), intval($sharedLibID['id'])), "'IB#GROUP_ID#' : {'id' : 'IB#GROUP_ID#', 'name' : '#GROUP_NAME#', 'type' : 'library', 'link' : '#LINK#', 'iblock_id': '#IBLOCK_ID#', 'section_id':'0'},\n");
}
if (isset($arResult['USER_GROUPS'])) {
    foreach ($arResult['USER_GROUPS'] as $groupID => $arGroup) {
        if (intval($arGroup['SECTION_ID']) > 0) {
            $typeItems .= str_replace(array("#GROUP_ID#", "#GROUP_NAME#", "#LINK#", "#SECTION_ID#"), array(intval($groupID), CUtil::JSEscape($arGroup['GROUP_NAME']), CUtil::JSEscape($arGroup['PATH_FILES']), intval($arGroup['SECTION_ID'])), "'SG#GROUP_ID#' : {'id' : 'SG#GROUP_ID#', 'name' : '#GROUP_NAME#', 'type' : 'socnet', 'link' : '#LINK#', 'section_id': '#SECTION_ID#'},\n");
        }
    }
}
$typeItems .= "}";
$disabledItems = array();
Exemplo n.º 30
0
     $IBLOCK_SECTION_ID = intVal($_REQUEST["IBLOCK_SECTION_ID"]);
     if (!empty($arResult["ROOT_SECTION"])) {
         $IBLOCK_SECTION_ID = $IBLOCK_SECTION_ID <= 0 ? $arResult["ROOT_SECTION"]["ID"] : $IBLOCK_SECTION_ID;
         if ($arResult["ROOT_SECTION"]["ID"] != $IBLOCK_SECTION_ID) {
             $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ID" => $IBLOCK_SECTION_ID, "RIGHT_MARGIN" => $arResult["ROOT_SECTION"]["RIGHT_MARGIN"], "LEFT_MARGIN" => $arResult["ROOT_SECTION"]["LEFT_MARGIN"]);
             $db_res = CIBlockSection::GetList(array(), $arFilter);
             if (!($db_res && ($res = $db_res->Fetch()))) {
                 $IBLOCK_SECTION_ID = false;
             }
         }
     }
     if ($IBLOCK_SECTION_ID == $arResult["ELEMENT"]["IBLOCK_SECTION_ID"]) {
         $IBLOCK_SECTION_ID = false;
     }
 }
 $_REQUEST["NAME"] = CWebDavIblock::CorrectName($_REQUEST["NAME"]);
 if ($arResult["ELEMENT"]["FULL_NAME"] != $_REQUEST["NAME"] || $IBLOCK_SECTION_ID !== false) {
     $db_res = CIBlockElement::GetList(array(), array("SECTION_ID" => $IBLOCK_SECTION_ID === false ? $arParams["SECTION_ID"] : $IBLOCK_SECTION_ID, "NAME" => $_REQUEST["NAME"], "!=ID" => $arResult["ELEMENT"]["ID"]));
     if ($db_res && ($res = $db_res->Fetch())) {
         $arError[] = array("id" => "element_already_exists", "text" => GetMessage("WD_ERROR_ELEMENT_ALREADY_EXISTS"));
     } else {
         $rootPath = implode('/', array_slice(explode('/', $arResult['ELEMENT']['PATH']), 0, -1));
         $options = array("path" => $rootPath, "depth" => 1);
         $result = $ob->PROPFIND($options, $files, array("COLUMNS" => array("ID", "NAME"), "return" => "array"));
         if (!empty($result["RESULT"])) {
             foreach ($result["RESULT"] as $key => $res) {
                 $options = false;
                 if ($res["ID"] == $arParams["ELEMENT_ID"]) {
                     $options = array("element_id" => $res["ID"], "dest_url" => str_replace("//", "/", $ob->_get_path($_REQUEST["IBLOCK_SECTION_ID"], false) . "/" . $_REQUEST["NAME"]), "overwrite" => true);
                     $res = $ob->MOVE($options);
                 }