Exemple #1
0
						$lAdmin->AddGroupError(GetMessage("IBLIST_A_SAVE_ERROR", array("#ID#" => $ID, "#ERROR_MESSAGE#" => GetMessage("IBLIST_A_ACCESS_DENIED_STATUS")." [".$new_status."].<br>")), $TYPE.$ID);
					}
				}
			}
			break;
		case "lock":
			if ($TYPE=="E")
			{
				if ($bWorkflow && !CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit"))
				{
					$lAdmin->AddGroupError(GetMessage("IBLIST_A_UPDERR_ACCESS", array("#ID#" => $ID)), $TYPE.$ID);
					continue;
				}
				else
				{
					CIBlockElement::WF_Lock($ID);
				}
			}
			break;
		case "unlock":
			if ($TYPE=="E")
			{
				if ($bWorkflow && !CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit"))
				{
					$lAdmin->AddGroupError(GetMessage("IBLIST_A_UPDERR_ACCESS", array("#ID#" => $ID)), $TYPE.$ID);
					continue;
				}
				if ($bBizproc)
					call_user_func(array(ENTITY, "UnlockDocument"), $ID, "");
				else
					CIBlockElement::WF_UnLock($ID);
Exemple #2
0
            ShowError(GetMessage("WD_ERROR_ELEMENT_NOT_FOUND"));
            die;
        }
    }
}
if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) {
    /** @var \Bitrix\Disk\File $diskFile */
    $diskFile = \Bitrix\Disk\File::load(array('XML_ID' => $arResult['ELEMENT']['ID']), array('STORAGE'));
    if ($diskFile) {
        LocalRedirect(\Bitrix\Disk\Driver::getInstance()->getUrlManager()->getPathFileDetail($diskFile));
    }
}
$ob->_get_file_info_arr($arResult["ELEMENT"]);
$arResult["WRITEABLE"] = $arResult['ELEMENT']['SHOW']['EDIT'];
if (in_array($arParams["ACTION"], array("EDIT", "PULL")) && $arParams["DOCUMENT_LOCK"] != "N") {
    CIBlockElement::WF_Lock($arParams["ELEMENT_ID"], $ob->workflow == "workflow");
    /**
     * This part of code is necessary because info about element is got
     * already but information about locking is absent. We can not lock
     * element until check all rulles.
     */
    $arResult["ELEMENT"]["LOCK_STATUS"] = CIBlockElement::WF_GetLockStatus($arParams["ELEMENT_ID"], $arResult['ELEMENT']['WF_LOCKED_BY'], $arResult['ELEMENT']['WF_DATE_LOCK']);
}
/********************************************************************
				Default params
********************************************************************/
CJSCore::Init(array('viewer'));
__prepare_item_info($arResult["ELEMENT"], $arParams);
$arResult["ELEMENT"]['URL']['THIS'] = $ob->_uencode($arResult["ELEMENT"]['URL']['THIS'], array("utf8" => "Y", "convert" => $arParams["CONVERT"]));
$arError = array();
$bVarsFromForm = false;
Exemple #3
0
                                 $res = $obE->Update($subID, array("WF_STATUS_ID" => $new_status, "MODIFIED_BY" => $USER->GetID()), true);
                                 if (!$res) {
                                     $lAdmin->AddGroupError(GetMessage("IBEL_A_SAVE_ERROR", array("#ID#" => $subID, "#ERROR_TEXT#" => $obE->LAST_ERROR)), $subID);
                                 }
                             }
                         } else {
                             $lAdmin->AddGroupError(GetMessage("IBEL_A_UPDERR3") . " (ID:" . $subID . ")", $subID);
                         }
                     }
                 }
                 break;
             case "lock":
                 if ($bWorkFlow && !CIBlockElementRights::UserHasRightTo($intSubIBlockID, $subID, "element_edit")) {
                     $lAdmin->AddGroupError(GetMessage("IBEL_A_UPDERR3") . " (ID:" . $subID . ")", $subID);
                 }
                 CIBlockElement::WF_Lock($subID);
                 break;
             case "unlock":
                 if ($bWorkFlow && !CIBlockElementRights::UserHasRightTo($intSubIBlockID, $subID, "element_edit")) {
                     $lAdmin->AddGroupError(GetMessage("IBEL_A_UPDERR3") . " (ID:" . $ID . ")", $ID);
                     continue;
                 }
                 if ($bBizproc) {
                     call_user_func(array(ENTITY, "UnlockDocument"), $subID, "");
                 } else {
                     CIBlockElement::WF_UnLock($subID);
                 }
                 break;
         }
     }
 }
Exemple #4
0
 function _set_lock(&$options, $op)
 {
     $lock = $op == 'LOCK';
     $is_dir = false;
     $ID = 0;
     $bFirstElement = false;
     $arProps = $this->_get_lock($options);
     if (!$this->CheckWebRights("", array('action' => 'lock', 'arElement' => $this->arParams))) {
         return $this->ThrowAccessDenied(__LINE__);
     }
     if (!is_array($arProps)) {
         if ($lock && $this->arParams['not_found'] === true) {
             if (!$this->CheckName($this->arParams["basename"])) {
                 return "400 bad request";
             } elseif ($this->check_creator && $this->arParams["is_file"] === true && $this->arParams["element_array"]["CREATED_BY"] != $GLOBALS["USER"]->GetID()) {
                 return $this->ThrowAccessDenied(__LINE__);
             } elseif ($this->arParams["parent_id"] !== false) {
                 $options1 = array('path' => $options["path"], 'content_length' => 0, 'content_type' => "", 'WF_COMMENTS' => GetMessage("WD_FILE_IS_CREATED_BY_LOCK"));
                 $stat = $this->PUT($options1);
                 if ($stat === false) {
                     return $this->ThrowAccessDenied(__LINE__);
                 } elseif (is_string($stat)) {
                     return $stat;
                 } else {
                     if (is_resource($stat) && get_resource_type($stat) == 'stream') {
                         fclose($stat);
                     }
                     if (!$this->CheckWebRights("", array("action" => "create", "arElement" => $this->arParams))) {
                         return $this->ThrowAccessDenied(__LINE__);
                     }
                     $this->put_commit($options1);
                 }
                 $ID = intVal($options1["ELEMENT_ID"]);
                 if ($ID <= 0) {
                     return "409 Conflict";
                 } else {
                     return "200 OK";
                 }
             } else {
                 return $arProps;
                 // 404 not found
             }
         }
         return $arProps;
         // error in _get_lock
     }
     $ID = $this->arParams['item_id'];
     $is_dir = $this->arParams["is_dir"];
     if ($lock) {
         if ($is_dir && !empty($options["depth"])) {
             return "409 Conflict";
         } elseif (!$is_dir && CIBlockElement::WF_IsLocked($ID, $locked_by, $date_lock)) {
             return false;
         }
         $options["timeout"] = time() + 300;
         // 5min. hardcoded
         if (isset($options["update"])) {
             $token = $options["update"];
             $arProps["LOCK"] = is_array($arProps["LOCK"]) ? $arProps["LOCK"] : array();
             if (array_key_exists($token, $arProps["LOCK"]) && strlen($arProps["LOCK"][$token]["exclusivelock"]) > 0) {
                 $arProps["LOCK"][$token]["expires"] = $options["timeout"];
                 $arProps["LOCK"][$token]["modified"] = time();
                 if (array_key_exists("owner", $arProps["LOCK"][$token])) {
                     $options["owner"] = $arProps["LOCK"][$token]["owner"];
                 }
                 $options["scope"] = $arProps["LOCK"][$token]["exclusivelock"] ? "exclusive" : "shared";
                 $options["type"] = $arProps["LOCK"][$token]["exclusivelock"] ? "write" : "read";
                 if ($bFirstElement) {
                     $arProps["FIRST"] = "Y";
                 }
                 CIBlockElement::SetPropertyValues($ID, $this->IBLOCK_ID, serialize($arProps), "WEBDAV_INFO");
                 CIBlockElement::WF_Lock($ID);
                 $this->_onEvent('Lock', $ID);
                 return true;
             } else {
                 return false;
             }
         }
         $arProps["LOCK"][$options["locktoken"]] = array("created" => time(), "modified" => time(), "owner" => $options["owner"], "expires" => $options["timeout"], "locktoken" => $options["locktoken"], "exclusivelock" => $options["scope"] === "exclusive" ? 1 : 0);
     } else {
         if (!empty($options["token"])) {
             $token = $options["token"];
             unset($arProps["LOCK"][$token]);
         } else {
             unset($arProps["LOCK"]);
         }
         if ($this->workflow == 'bizproc' && $GLOBALS['USER']->CanDoOperation('webdav_change_settings')) {
             $arDocId = $this->wfParams["DOCUMENT_TYPE"];
             $arDocId[2] = $ID;
             $arStates = CBPDocument::GetDocumentStates($this->wfParams["DOCUMENT_TYPE"], $arDocId);
             foreach ($arStates as $workflowId => $arState) {
                 CIBlockDocumentWebdav::UnlockDocument($ID, $workflowId);
             }
         }
     }
     if ($is_dir) {
         $se = new CIBlockSection();
         $x = $se->Update($ID, array("DESCRIPTION" => serialize($arProps)));
     } else {
         if ($lock && $bFirstElement) {
             $arProps["FIRST"] = "Y";
         }
         CIBlockElement::SetPropertyValues($ID, $this->IBLOCK_ID, serialize($arProps), "WEBDAV_INFO");
         if ($lock) {
             CIBlockElement::WF_Lock($ID, $this->workflow == "workflow");
         } else {
             CIBlockElement::WF_UnLock($ID, $this->workflow == "workflow");
         }
         $this->_onEvent($lock ? 'Lock' : 'Unlock', $ID);
         $x = true;
     }
     return $x ? $lock ? "200 OK" : "204 No Content" : "409 Conflict";
 }