Ejemplo n.º 1
0
        $arResult["FatalErrorMessage"] .= GetMessage("BPWC_WIC_WRONG_IBLOCK_TYPE") . ". ";
    }
}
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    $arResult["AdminAccess"] = $USER->IsAdmin() || is_array($arParams["ADMIN_ACCESS"]) && count(array_intersect($USER->GetUserGroupArray(), $arParams["ADMIN_ACCESS"])) > 0;
    $deleteBlockId = intval($_REQUEST["delete_block_id"]);
    if ($deleteBlockId > 0 && $arResult["AdminAccess"] && check_bitrix_sessid()) {
        $db = CIBlock::GetList(array(), array("ID" => $deleteBlockId, "SITE_ID" => SITE_ID, "TYPE" => $arParams["IBLOCK_TYPE"]));
        if ($ar = $db->GetNext()) {
            $db1 = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $ar["ID"], "SHOW_NEW" => "Y"), false, false, array("IBLOCK_ID", "ID"));
            while ($ar1 = $db1->Fetch()) {
                CBPDocument::OnDocumentDelete(array("bizproc", "CBPVirtualDocument", $ar1["ID"]), $arErrorsTmp);
            }
            $db2 = CBPWorkflowTemplateLoader::GetList(array(), array("DOCUMENT_TYPE" => array("bizproc", "CBPVirtualDocument", "type_" . $ar["ID"])), false, false, array("ID"));
            while ($ar2 = $db2->Fetch()) {
                CBPWorkflowTemplateLoader::Delete($ar2["ID"]);
            }
            CIBlock::Delete($ar["ID"]);
        }
    }
}
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    $arResult["Blocks"] = array();
    $dbBlockList = CIBlock::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "SITE_ID" => SITE_ID, "TYPE" => $arParams["IBLOCK_TYPE"]));
    while ($arBlock = $dbBlockList->GetNext()) {
        $arBlock["LIST_URL"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_LIST"], array("block_id" => $arBlock["ID"]));
        if (intval($arBlock["PICTURE"]) <= 0) {
            $arBlock["PICTURE"] = "/bitrix/images/bizproc/vd_bp.jpg";
        }
        $arMessagesTmp = CIBlock::GetMessages($arBlock["ID"]);
        $arBlock["CreateTitle"] = htmlspecialcharsbx(is_array($arMessagesTmp) && array_key_exists("ELEMENT_ADD", $arMessagesTmp) ? $arMessagesTmp["ELEMENT_ADD"] : "");
Ejemplo n.º 2
0
	/**
	* Метод удаляет шаблон рабочего потока.
	*
	* @param int $id - код шаблона рабочего потока.
	* @param array $documentType - код типа документа в виде массива array(модуль, сущность, код_типа_документа_в_модуле).
	* @param array $arErrors - массив ошибок, которые произошли при выполнении в виде array(array("code" => код_ошибки, "message" => сообщение, "file" => путь_к_файлу), ...).
	*/
	public static function DeleteWorkflowTemplate($id, $documentType, &$arErrors)
	{
		$arErrors = array();

		$dbTemplates = CBPWorkflowTemplateLoader::GetList(
			array(),
			array("ID" => $id, "DOCUMENT_TYPE" => $documentType),
			false,
			false,
			array("ID")
		);
		$arTemplate = $dbTemplates->Fetch();
		if (!$arTemplate)
		{
			$arErrors[] = array(
				"code" => 0,
				"message" => str_replace("#ID#", $id, GetMessage("BPCGDOC_INVALID_WF_ID")),
				"file" => ""
			);
			return;
		}

		try
		{
			CBPWorkflowTemplateLoader::Delete($id);
		}
		catch (Exception $e)
		{
			$arErrors[] = array(
				"code" => $e->getCode(),
				"message" => $e->getMessage(),
				"file" => $e->getFile()." [".$e->getLine()."]"
			);
		}
	}