}

if (strlen($sLastFolder) > 0) {
    $aContext[] = array(
        "TEXT" => GetMessage("IBEL_A_UP"),
        "LINK" => CIBlock::GetAdminElementListLink($IBLOCK_ID, array(
            'find_section_section' => $lastSectionId[count($lastSectionId) - 2],
        )),
        "LINK_PARAM" => "",
        "TITLE" => GetMessage("IBEL_A_UP_TITLE"),
    );
}

if ($bBizproc && IsModuleInstalled("bizprocdesigner")) {
    $bCanDoIt = CBPDocument::CanUserOperateDocumentType(
                    CBPCanUserOperateOperation::CreateWorkflow, $USER->GetID(), array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID)
    );

    if ($bCanDoIt) {
        $aContext[] = array(
            "TEXT" => GetMessage("IBEL_BTN_BP"),
            "LINK" => 'iblock_bizproc_workflow_admin.php?document_type=iblock_' . $IBLOCK_ID . '&lang=' . LANGUAGE_ID . '&back_url_list=' . urlencode($REQUEST_URI),
            "LINK_PARAM" => "",
        );
    }
}
            
$lAdmin->AddAdminContextMenu($aContext);

$lAdmin->CheckListMode();
Beispiel #2
0
********************************************************************/
$arError = array();
if (strlen($arParams["MODULE_ID"]) <= 0) {
    $arError[] = array("id" => "empty_module_id", "text" => GetMessage("BPATT_NO_MODULE_ID"));
}
if (strlen($arParams["STORAGE_ID"]) <= 0) {
    $arError[] = array("id" => "empty_document_id", "text" => GetMessage("BPATT_NO_DOCUMENT_TYPE"));
}
$documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($arParams["STORAGE_ID"])), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($arParams["STORAGE_ID"])));
$arResult["STORAGE_ID"] = \Bitrix\Disk\BizProcDocument::generateDocumentType($arParams["STORAGE_ID"]);
$arParams["USER_GROUPS"] = $GLOBALS["USER"]->GetUserGroupArray();
if (method_exists($arParams["DOCUMENT_TYPE"][1], "GetUserGroups")) {
    $arParams["USER_GROUPS"] = call_user_func_array(array($arParams["ENTITY"], "GetUserGroups"), array($documentData['DISK']['DOCUMENT_TYPE'], $arResult["STORAGE_ID"], $GLOBALS["USER"]->GetID()));
}
if (empty($arError)) {
    if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $documentData['DISK']['DOCUMENT_TYPE'], array("UserGroups" => $arParams["USER_GROUPS"]))) {
        $arError[] = array("id" => "access_denied", "text" => GetMessage("BPATT_NO_PERMS"));
    }
}
if (!empty($arError)) {
    $e = new CAdminException($arError);
    ShowError($e->GetString());
    return false;
} elseif ($_REQUEST['action'] == 'create_default') {
    CBPDocument::AddDefaultWorkflowTemplates($documentData['DISK']['DOCUMENT_TYPE']);
    LocalRedirect($APPLICATION->GetCurPageParam("", array("action", "sessid")));
} elseif ($_REQUEST['action'] == 'delete') {
    $arErrorsTmp = array();
    foreach ($documentData as $nameModule => $data) {
        $dbRes = CBPWorkflowTemplateLoader::GetList(array($by => $order), array("DOCUMENT_TYPE" => $data["DOCUMENT_TYPE"], "ID" => $_REQUEST["ID"]), false, false, array("ID"));
        $availabilityTemplate = $dbRes->Fetch();
    $editPage = EDIT_PAGE;
}
$documentType = trim($_REQUEST["document_type"]);
$backUrl = "/" . ltrim(trim($_REQUEST["back_url_list"]), "\\/");
if (strlen($entity) <= 0) {
    $fatalErrorMessage .= GetMessage("BPATT_NO_ENTITY") . ". ";
}
if (strlen($documentType) <= 0) {
    $fatalErrorMessage .= GetMessage("BPATT_NO_DOC_TYPE") . ". ";
}
if (strlen($editPage) <= 0) {
    $fatalErrorMessage .= GetMessage("BPATT_NO_EDIT_PAGE") . ". ";
}
if (strlen($fatalErrorMessage) <= 0) {
    $documentType = array($moduleId, $entity, $documentType);
    $bCanUserWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $documentType, array("UserGroups" => $GLOBALS["USER"]->GetUserGroupArray()));
    if (!$bCanUserWrite) {
        $fatalErrorMessage .= GetMessage("BPATT_NO_PERMS") . ". ";
    }
}
if (strlen($fatalErrorMessage) > 0) {
    $APPLICATION->SetTitle(GetMessage("BPATT_ERROR"));
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
    echo ShowError($fatalErrorMessage);
    require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
    die;
}
$sTableID = "tbl_bizproc_workflow_templates";
$oSort = new CAdminSorting($sTableID, "ID", "DESC");
$lAdmin = new CAdminList($sTableID, $oSort);
$arFilterFields = array("filter_name", "filter_autoexecute");
Beispiel #4
0
 $listProcesses = array();
 $backUrl = $APPLICATION->GetCurPageParam();
 foreach ($documentStates as $documentState) {
     if (!$documentState["ID"]) {
         continue;
     }
     $actionsProcess = array();
     $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]), array("AllUserGroups" => $currentUserGroups, "DocumentStates" => $documentStates, "WorkflowId" => $documentState["ID"]));
     if ($canViewWorkflow) {
         /* Stop workflow */
         if (strlen($documentState["ID"]) && CIBlockElementRights::UserHasRightTo($arIBlock["ID"], $data["ID"], "element_rights_edit") && strlen($documentState["WORKFLOW_STATUS"])) {
             $actionsProcess[] = array("TEXT" => GetMessage("CT_BLL_BIZPROC_STOP"), "ONCLICK" => "javascript:BX['ListClass_" . $arResult["RAND_STRING"] . "']\n\t\t\t\t\t\t\t\t.performActionBp('" . $documentState['ID'] . "', " . $data["ID"] . ", 'stop');");
         }
         /* Removal workflow */
         if (strlen($documentState["STATE_NAME"]) && strlen($documentState["ID"])) {
             if (CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]), array("UserGroups" => $currentUserGroups))) {
                 $actionsProcess[] = array("TEXT" => GetMessage("CT_BLL_BIZPROC_DELETE"), "ONCLICK" => "javascript:BX['ListClass_" . $arResult["RAND_STRING"] . "']\n\t\t\t\t\t\t\t\t.performActionBp('" . $documentState['ID'] . "', " . $data["ID"] . ", 'delete');");
             }
         }
         /* Tasks workflow */
         if (strlen($documentState["ID"])) {
             $tasks = CBPDocument::getUserTasksForWorkflow($GLOBALS["USER"]->GetID(), $documentState["ID"]);
             if (!empty($tasks)) {
                 foreach ($tasks as $task) {
                     $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#task_id#", "#group_id#"), array($arIBlock["ID"], intval($arResult["SECTION_ID"]), $data["ID"], $task["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_TASK_URL"]), array("back_url" => $backUrl), array("skip_empty" => true, "encode" => true));
                     $actionsProcess[] = array("TEXT" => $task["NAME"], "ONCLICK" => "jsUtils.Redirect(arguments, '" . CUtil::JSEscape($url) . "')");
                 }
             }
         }
         if (!empty($actionsProcess)) {
             $listProcesses[] = array("TEXT" => $documentState["TEMPLATE_NAME"] . " (" . $documentState["STARTED"] . ")", "MENU" => $actionsProcess);
Beispiel #5
0
// Dont display activities in INTERNAL mode.
if (!$bInternal) {
    $arResult['HEADERS'][] = array('id' => 'ACTIVITY_ID', 'name' => GetMessage('CRM_COLUMN_ACTIVITY'), 'sort' => 'nearest_activity', 'default' => true);
}
$arResult['HEADERS'] = array_merge($arResult['HEADERS'], array(array('id' => 'CONTACT_COMPANY', 'name' => GetMessage('CRM_COLUMN_CONTACT_COMPANY_INFO'), 'sort' => 'company_title', 'default' => true, 'editable' => false), array('id' => 'PHOTO', 'name' => GetMessage('CRM_COLUMN_PHOTO'), 'sort' => false, 'default' => false, 'editable' => false), array('id' => 'NAME', 'name' => GetMessage('CRM_COLUMN_NAME'), 'sort' => 'name', 'default' => false, 'editable' => true, 'class' => 'username'), array('id' => 'LAST_NAME', 'name' => GetMessage('CRM_COLUMN_LAST_NAME'), 'sort' => 'last_name', 'default' => false, 'editable' => true, 'class' => 'username'), array('id' => 'SECOND_NAME', 'name' => GetMessage('CRM_COLUMN_SECOND_NAME'), 'sort' => 'second_name', 'default' => false, 'editable' => true, 'class' => 'username'), array('id' => 'BIRTHDATE', 'name' => GetMessage('CRM_COLUMN_BIRTHDATE'), 'sort' => 'BIRTHDATE', 'default' => false, 'editable' => true, 'type' => 'date'), array('id' => 'POST', 'name' => GetMessage('CRM_COLUMN_POST'), 'sort' => 'post', 'default' => false, 'editable' => true), array('id' => 'COMPANY_ID', 'name' => GetMessage('CRM_COLUMN_COMPANY_ID'), 'sort' => 'company_title', 'default' => false, 'editable' => false), array('id' => 'TYPE_ID', 'name' => GetMessage('CRM_COLUMN_TYPE'), 'sort' => 'type_id', 'default' => false, 'editable' => array('items' => CCrmStatus::GetStatusList('CONTACT_TYPE')), 'type' => 'list')));
$CCrmFieldMulti->PrepareListHeaders($arResult['HEADERS']);
if ($isInExportMode) {
    $CCrmFieldMulti->ListAddHeaders($arResult['HEADERS']);
}
$arResult['HEADERS'] = array_merge($arResult['HEADERS'], array(array('id' => 'ASSIGNED_BY', 'name' => GetMessage('CRM_COLUMN_ASSIGNED_BY'), 'sort' => 'assigned_by', 'default' => true, 'editable' => false, 'class' => 'username'), array('id' => 'FULL_ADDRESS', 'name' => EntityAddress::getFullAddressLabel(), 'sort' => false, 'default' => false, 'editable' => false), array('id' => 'ADDRESS', 'name' => $addressLabels['ADDRESS'], 'sort' => 'address', 'default' => false, 'editable' => false), array('id' => 'ADDRESS_2', 'name' => $addressLabels['ADDRESS_2'], 'sort' => 'address_2', 'default' => false, 'editable' => false), array('id' => 'ADDRESS_CITY', 'name' => $addressLabels['CITY'], 'sort' => 'address_city', 'default' => false, 'editable' => false), array('id' => 'ADDRESS_REGION', 'name' => $addressLabels['REGION'], 'sort' => 'address_region', 'default' => false, 'editable' => false), array('id' => 'ADDRESS_PROVINCE', 'name' => $addressLabels['PROVINCE'], 'sort' => 'address_province', 'default' => false, 'editable' => false), array('id' => 'ADDRESS_POSTAL_CODE', 'name' => $addressLabels['POSTAL_CODE'], 'sort' => 'address_postal_code', 'default' => false, 'editable' => false), array('id' => 'ADDRESS_COUNTRY', 'name' => $addressLabels['COUNTRY'], 'sort' => 'address_country', 'default' => false, 'editable' => false), array('id' => 'COMMENTS', 'name' => GetMessage('CRM_COLUMN_COMMENTS'), 'sort' => false, 'default' => false, 'editable' => false), array('id' => 'SOURCE_ID', 'name' => GetMessage('CRM_COLUMN_SOURCE'), 'sort' => 'source_id', 'default' => false, 'editable' => array('items' => CCrmStatus::GetStatusList('SOURCE')), 'type' => 'list'), array('id' => 'SOURCE_DESCRIPTION', 'name' => GetMessage('CRM_COLUMN_SOURCE_DESCRIPTION'), 'sort' => false, 'default' => false, 'editable' => false), array('id' => 'EXPORT', 'name' => GetMessage('CRM_COLUMN_EXPORT'), 'type' => 'checkbox', 'default' => false, 'editable' => true), array('id' => 'CREATED_BY', 'name' => GetMessage('CRM_COLUMN_CREATED_BY'), 'sort' => 'created_by', 'default' => false, 'editable' => false, 'class' => 'username'), array('id' => 'DATE_CREATE', 'name' => GetMessage('CRM_COLUMN_DATE_CREATE'), 'sort' => 'date_create', 'default' => false, 'class' => 'date'), array('id' => 'MODIFY_BY', 'name' => GetMessage('CRM_COLUMN_MODIFY_BY'), 'sort' => 'modify_by', 'default' => false, 'editable' => false, 'class' => 'username'), array('id' => 'DATE_MODIFY', 'name' => GetMessage('CRM_COLUMN_DATE_MODIFY'), 'sort' => 'date_modify', 'default' => false, 'class' => 'date')));
$CCrmUserType->ListAddHeaders($arResult['HEADERS']);
if (IsModuleInstalled('bizproc')) {
    $arBPData = CBPDocument::GetWorkflowTemplatesForDocumentType(array('crm', 'CCrmDocumentContact', 'CONTACT'));
    $arDocumentStates = CBPDocument::GetDocumentStates(array('crm', 'CCrmDocumentContact', 'CONTACT'), null);
    foreach ($arBPData as $arBP) {
        if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::StartWorkflow, $userID, array('crm', 'CCrmDocumentContact', 'CONTACT'), array('UserGroups' => $CCrmBizProc->arCurrentUserGroups, 'DocumentStates' => $arDocumentStates, 'WorkflowTemplateId' => $arBP['ID'], 'UserIsAdmin' => $isAdmin, 'CRMPermission' => $arResult['PERMS']['READ']))) {
            continue;
        }
        $arResult['HEADERS'][] = array('id' => 'BIZPROC_' . $arBP['ID'], 'name' => $arBP['NAME'], 'sort' => false, 'default' => false, 'editable' => false);
    }
}
unset($arHeader);
// <-- Headers initialization
// Try to extract user action data -->
// We have to extract them before call of CGridOptions::GetFilter() overvise the custom filter will be corrupted.
$actionData = array('METHOD' => $_SERVER['REQUEST_METHOD'], 'ACTIVE' => false);
if (check_bitrix_sessid()) {
    $postAction = 'action_button_' . $arResult['GRID_ID'];
    $getAction = 'action_' . $arResult['GRID_ID'];
    if ($actionData['METHOD'] == 'POST' && isset($_POST[$postAction])) {
        $actionData['ACTIVE'] = true;
Beispiel #6
0
     $arElement["RIGHTS"] = CListPermissions::MergeRights($arParams["~IBLOCK_TYPE_ID"], $arDBRights, $arPOSTRights);
 }
 //---BP---
 $arResult["isConstantsTuned"] = false;
 if ($bBizproc) {
     $documentType = BizProcDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]);
     $arDocumentStates = CBPDocument::GetDocumentStates($documentType, $arResult["ELEMENT_ID"] > 0 ? BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]) : null, "Y");
     $templatesOnStartup = false;
     $arCurrentUserGroups = $USER->GetUserGroupArray();
     if (!$arResult["ELEMENT_FIELDS"] || $arResult["ELEMENT_FIELDS"]["CREATED_BY"] == $USER->GetID()) {
         $arCurrentUserGroups[] = "author";
     }
     if ($arResult["ELEMENT_ID"]) {
         $canWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
     } else {
         $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), $documentType, array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
     }
     if (!$canWrite) {
         $strError = GetMessage("CC_BLEE_ACCESS_DENIED_STATUS");
     }
     if (!$strError) {
         $arBizProcParametersValues = array();
         foreach ($arDocumentStates as $arDocumentState) {
             if (strlen($arDocumentState["ID"]) <= 0) {
                 $templatesOnStartup = true;
                 $arErrorsTmp = array();
                 $arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflowParametersValidate($arDocumentState["TEMPLATE_ID"], $arDocumentState["TEMPLATE_PARAMETERS"], $documentType, $arErrorsTmp);
                 foreach ($arErrorsTmp as $e) {
                     $strError .= $e["message"] . "<br />";
                 }
             }
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
CModule::IncludeModule('bizproc');
global $APPLICATION;
if (!check_bitrix_sessid()) {
    die;
}
if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $_REQUEST['document_type'])) {
    die;
}
CUtil::DecodeUriComponent($_REQUEST);
$activityType = $_REQUEST['activity'];
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$arActivityDescription = $runtime->GetActivityDescription($activityType);
if ($arActivityDescription == null) {
    die("Bad activity type!" . htmlspecialcharsbx($activityType));
}
$runtime->IncludeActivityFile($activityType);
$isHtml = !empty($_REQUEST['content_type']) && $_REQUEST['content_type'] == 'html';
if ($isHtml) {
    $APPLICATION->ShowAjaxHead();
}
$res = CBPActivity::CallStaticMethod($activityType, "getAjaxResponse", array($_REQUEST));
echo $isHtml ? $res : CUtil::PhpToJSObject($res);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
Beispiel #8
0
$arResult["CAN_ADD_ELEMENT"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm > CListPermissions::CAN_READ || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_element_bind"));
$arResult["CAN_EDIT_SECTIONS"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_edit") || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_section_bind"));
$arResult["IBLOCK_PERM"] = $lists_perm;
$arResult["USER_GROUPS"] = $USER->GetUserGroupArray();
$arIBlock = CIBlock::GetArrayByID(intval($arParams["~IBLOCK_ID"]));
$arResult["~IBLOCK"] = $arIBlock;
$arResult["IBLOCK"] = htmlspecialcharsex($arIBlock);
$arResult["IBLOCK_ID"] = $arIBlock["ID"];
$arResult["PROCESSES"] = false;
$arResult["USE_COMMENTS"] = false;
if ($arParams["IBLOCK_TYPE_ID"] == COption::GetOptionString("lists", "livefeed_iblock_type_id")) {
    $arResult["USE_COMMENTS"] = (bool) CModule::includeModule("forum");
    $arResult["PROCESSES"] = true;
}
if ($arResult["IBLOCK"]["BIZPROC"] == "Y" && CModule::IncludeModule('bizproc')) {
    $arParams["CAN_EDIT_BIZPROC"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $USER->GetID(), BizprocDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $IBLOCK_ID), array("UserGroups" => $USER->GetUserGroupArray()));
}
if (isset($arParams["SOCNET_GROUP_ID"]) && $arParams["SOCNET_GROUP_ID"] > 0) {
    $arParams["SOCNET_GROUP_ID"] = intval($arParams["SOCNET_GROUP_ID"]);
} else {
    $arParams["SOCNET_GROUP_ID"] = "";
}
$arResult["GRID_ID"] = "lists_list_elements_" . $arResult["IBLOCK_ID"];
$arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0;
$arResult["SECTION"] = false;
$arResult["SECTION_ID"] = false;
$arResult["PARENT_SECTION_ID"] = false;
$arResult["SECTIONS"] = array();
$arResult["LIST_SECTIONS"] = array("0" => GetMessage("CC_BLL_UPPER_LEVEL"));
$arResult["~LIST_SECTIONS"] = array("0" => GetMessage("CC_BLL_UPPER_LEVEL"));
$arResult["SECTION_PATH"] = array();
Beispiel #9
0
    die;
}
if (!CModule::IncludeModule("bizproc")) {
    return false;
}
if (!$GLOBALS["USER"]->IsAuthorized()) {
    $GLOBALS["APPLICATION"]->AuthForm(GetMessage("ACCESS_DENIED"));
    die;
}
$arParams["ID"] = intval($arParams["ID"]);
$arTemplate = null;
$canWrite = false;
if ($arParams["ID"] > 0) {
    $dbTemplatesList = CBPWorkflowTemplateLoader::GetList(array(), array("ID" => $arParams["ID"]), false, false, array("ID", "DOCUMENT_TYPE", "NAME", "VARIABLES"));
    if ($arTemplate = $dbTemplatesList->Fetch()) {
        $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), $arTemplate["DOCUMENT_TYPE"]);
        $arResult["DOCUMENT_TYPE"] = $arTemplate["DOCUMENT_TYPE"];
        $arResult["NAME"] = $arTemplate["NAME"];
        $arResult["VARIABLES"] = $arTemplate["VARIABLES"];
        $arResult["ID"] = $arTemplate["ID"];
    }
}
if (!is_array($arTemplate) || !$canWrite) {
    $GLOBALS["APPLICATION"]->AuthForm(GetMessage("ACCESS_DENIED"));
    die;
}
$arParams["SET_TITLE"] = $arParams["SET_TITLE"] == "N" ? "N" : "Y";
$arParams["SET_NAV_CHAIN"] = $arParams["SET_NAV_CHAIN"] == "N" ? "N" : "Y";
$arResult['LIST_PAGE_URL'] = $arParams['LIST_PAGE_URL'];
$arResult["EDIT_PAGE_TEMPLATE"] = $arParams["EDIT_PAGE_TEMPLATE"];
$arResult["BackUrl"] = $_REQUEST["back_url"];
Beispiel #10
0
 function CheckWebRights($method = "", $arParams = array(), $simple = true)
 {
     if ($this->withoutAuthorization) {
         return true;
     }
     $strong = $method !== "";
     $path = '';
     if (is_array($arParams['arElement'])) {
         $path = isset($arParams['arElement']['item_id']) ? $arParams['arElement']['item_id'] : '';
     } elseif (is_string($arParams['arElement'])) {
         $path = $arParams['arElement'];
     }
     $result = $this->CheckRights($method, $strong, $path);
     if (!$result || $simple) {
         return $result;
     }
     $arError = array();
     $action = strtolower(is_set($arParams, "action") ? $arParams["action"] : $arParams["ACTION"]);
     $arElement = is_set($arParams, "arElement") ? $arParams["arElement"] : array();
     static $arErrors = array();
     $static_id = md5(serialize(array($action, $arElement["ID"], $GLOBALS["USER"]->GetID())));
     if (array_key_exists($static_id, $arErrors)) {
         $arError = $arErrors[$static_id];
     } else {
         if ($this->e_rights) {
             foreach (array('arElement', 'from', 'to') as $elm) {
                 if (is_set($arParams, $elm)) {
                     if ((!isset($arParams[$elm]['not_found']) || $arParams[$elm]['not_found'] === true) && !in_array($action, array('create', 'copy', 'move', 'mkcol'))) {
                         $arError[] = array("id" => "bad_element", "text" => GetMessage("WD_FILE_ERROR105"));
                     }
                 }
             }
             if (empty($arError)) {
                 if ($action == 'copy') {
                     //from[]
                     //to[]
                     $arTo = isset($arParams['to']) ? $arParams['to'] : array();
                     $arFrom = isset($arParams['from']) ? $arParams['from'] : array();
                     $nCount = min(sizeof($arTo), sizeof($arFrom));
                     for ($i = 0; $i < $nCount; $i++) {
                         $To = $arTo[$i];
                         $From = $arFrom[$i];
                         $type = $To['is_file'] ? 'ELEMENT' : 'SECTION';
                         $id = $To['not_found'] ? $To['parent_id'] : $To['item_id'];
                         $op = $From['is_file'] ? 'section_element_bind' : 'section_section_bind';
                         if (!$this->GetPermission($type, $id, $op)) {
                             $arError[] = array("id" => "", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                     }
                 } elseif ($action == 'create' || $action == 'mkcol') {
                     //arElement
                     //null
                     if (empty($arElement)) {
                         $arParent = $this->GetObject();
                         $bAllowEdit = false;
                         if ($arParent['not_found'] === false) {
                             $bAllowEdit = $this->GetPermission($arParent['is_file'] ? 'ELEMENT' : 'SECTION', $arParent['item_id'], 'element_edit');
                         }
                         return $bAllowEdit;
                     } else {
                         $type = 'SECTION';
                         if (isset($arElement['parent_id']) && $arElement['parent_id'] > 0) {
                             $id = $arElement['parent_id'];
                         } else {
                             $id = $this->IBLOCK_ID;
                             $type = 'IBLOCK';
                         }
                         if ($action == 'mkcol') {
                             return $this->GetPermission($type, $id, 'section_section_bind');
                         }
                         if ($arElement['is_dir']) {
                             if (!$this->GetPermission($type, $id, 'section_section_bind')) {
                                 $arError[] = array("id" => "", "text" => GetMessage("WD_ACCESS_DENIED"));
                             }
                         } else {
                             if (!empty($arParams['create_element_in_section']) || $this->workflow != "workflow" && $this->workflow != "bizproc") {
                                 if (!$this->GetPermission($type, $id, 'section_element_bind')) {
                                     $arError[] = array("id" => "cannot_create", "text" => GetMessage("WD_ACCESS_DENIED"));
                                 }
                             } elseif ($this->workflow == "workflow") {
                                 $db_res = CWorkflowStatus::GetDropDownList("N", "desc");
                                 if (!($db_res && ($res = $db_res->Fetch()))) {
                                     $arError[] = array("id" => "bad_wf_statuses", "text" => GetMessage("WD_ACCESS_DENIED"));
                                 }
                             } elseif ($this->workflow == 'bizproc') {
                                 $arDocumentStates = CBPDocument::GetDocumentStates($this->wfParams['DOCUMENT_TYPE'], null);
                                 $arUserGroups = $this->USER["GROUPS"];
                                 $arUserGroups[] = "Author";
                                 $canWrite = false;
                                 if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $this->wfParams['DOCUMENT_TYPE'], array("IBlockPermission" => $this->permission, "AllUserGroups" => $arUserGroups, "DocumentStates" => $arDocumentStates))) {
                                     $arError[] = array("id" => "bad_bizproc_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                                 }
                             }
                         }
                     }
                 } elseif ($action == 'delete' || $action == 'undelete') {
                     //arElement
                     $type = $arElement['is_dir'] ? 'SECTION' : 'ELEMENT';
                     if ($type == 'ELEMENT') {
                         $res = $this->GetPermission($type, $arElement['item_id'], 'element_delete');
                         if (!$res) {
                             $arError[] = array("id" => "", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                     } else {
                         $res = $this->GetPermission($type, $arElement['item_id'], 'section_delete', false);
                         if (!$res) {
                             $arError[] = array("id" => "", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                     }
                 } elseif ($action == 'destroy') {
                     //arElement
                     $id = $arElement['item_id'];
                     $type = $arElement['is_dir'] ? 'SECTION' : 'ELEMENT';
                     $op = $arElement['is_dir'] ? 'section_delete' : 'element_delete';
                     if (!$this->GetPermission($type, $id, $op, false)) {
                         $arError[] = array("id" => "", "text" => GetMessage("WD_ACCESS_DENIED"));
                     }
                 } elseif ($action == 'edit' || $action == 'lock' || $action == 'proppatch' || $action == 'delete_dropped') {
                     //arElement
                     $id = $arElement['item_id'];
                     $type = $arElement['is_dir'] ? 'SECTION' : 'ELEMENT';
                     if ($arElement['is_dir']) {
                         if (!$this->GetPermission($type, $id, 'section_edit')) {
                             $arError[] = array("id" => "", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                     } else {
                         if ($arElement["LOCK_STATUS_BP"] == "red") {
                             $arError[] = array("id" => "locked", "text" => GetMessage("WD_FILE_ERROR107"));
                         } elseif ($this->check_creator && $arElement["CREATED_BY"] != $GLOBALS["USER"]->GetID()) {
                             $arError[] = array("id" => "bad_author", "text" => GetMessage("WD_FILE_ERROR108"));
                         } elseif ($this->GetPermission($type, $id, 'element_edit_any_wf_status')) {
                             true;
                         } elseif ($this->workflow == "workflow" && $this->GetPermission($type, $id, 'element_edit')) {
                             $arWorkFlow = array("LAST_ID" => CIBlockElement::WF_GetLast($arElement["item_id"]));
                             $arWorkFlow["STATUS_ID"] = CIBlockElement::WF_GetCurrentStatus($arWorkFlow["LAST_ID"], $arWorkFlow["STATUS_TITLE"]);
                             $arWorkFlow["STATUS_PERMISSION"] = CIBlockElement::WF_GetStatusPermission($arWorkFlow["STATUS_ID"]);
                             if ($arWorkFlow["STATUS_ID"] > 1 && $arWorkFlow["STATUS_PERMISSION"] < 2) {
                                 $arError[] = array("id" => "bad_wf_status_permission", "text" => GetMessage("WD_FILE_ERROR109"));
                             }
                         } elseif ($this->workflow == 'bizproc' && $this->GetPermission($type, $id, 'element_edit')) {
                             $documentId = $this->wfParams['DOCUMENT_TYPE'];
                             $documentId[2] = $arElement["item_id"];
                             $arDocumentStates = CBPDocument::GetDocumentStates($this->wfParams['DOCUMENT_TYPE'], $documentId);
                             $arUserGroups = $this->USER["GROUPS"];
                             if ($arElement["CREATED_BY"] == $GLOBALS["USER"]->GetID()) {
                                 $arUserGroups[] = "Author";
                             }
                             if (!CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $documentId, array("IBlockPermission" => $this->permission, "AllUserGroups" => $arUserGroups, "DocumentStates" => $arDocumentStates))) {
                                 $arError[] = array("id" => "bad_bizproc_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                             }
                         } else {
                             $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                     }
                 } elseif ($action == 'read' || $action == 'propfind') {
                     //arElement, null
                     if ($arElement) {
                         $id = $arElement['item_id'];
                         $type = $arElement['is_dir'] ? 'SECTION' : 'ELEMENT';
                         $op = $arElement['is_dir'] ? 'section_read' : 'element_read';
                         if (!$this->GetPermission($type, $id, $op)) {
                             $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                         if ($type == 'SECTION' && $id == $this->GetMetaID('TRASH')) {
                             if (!$this->GetPermission($type, $id, 'section_delete')) {
                                 $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                             }
                         }
                     } else {
                         if (!$this->GetPermission('IBLOCK', $this->IBLOCK_ID, 'section_read')) {
                             $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                     }
                 } elseif ($action == 'move') {
                     //from // auto recusive
                     //to // auto recusive
                     $arTo = isset($arParams['to']) ? $arParams['to'] : array();
                     $arFrom = isset($arParams['from']) ? $arParams['from'] : array();
                     $nCount = min(sizeof($arTo), sizeof($arFrom));
                     for ($i = 0; $i < $nCount; $i++) {
                         $To = $arTo[$i];
                         $From = $arFrom[$i];
                         $type = $From['is_dir'] ? 'SECTION' : 'ELEMENT';
                         $id = $From['item_id'];
                         $op = $From['is_dir'] ? 'section_edit' : 'element_edit';
                         if (!$this->GetPermission($type, $id, $op)) {
                             $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                         }
                         if ($To['not_found']) {
                             $type = 'SECTION';
                             $id = $To['parent_id'];
                             $op = $arFrom['is_dir'] ? 'section_section_bind' : 'section_element_bind';
                             // TODO: bizproc ?
                             if (!$this->GetPermission($type, $id, $op)) {
                                 $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                             }
                         } else {
                             $type = $To['is_dir'] ? 'SECTION' : 'ELEMENT';
                             $id = $To['item_id'];
                             $op = $To['is_dir'] ? $arFrom['is_dir'] ? 'section_section_bind' : 'section_element_bind' : 'element_edit';
                             // TODO: bizproc ?
                             if (!$this->GetPermission($type, $id, $op)) {
                                 $arError[] = array("id" => "bad_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                             }
                         }
                     }
                 }
             }
         } else {
             // check iblock rights
             if ($this->permission < "R") {
                 $arError[] = array("id" => "cannot_read", "text" => GetMessage("WD_ACCESS_DENIED"));
             } elseif ($this->permission > "U") {
                 true;
             } elseif ($action == "read" || $action == "propfind") {
                 true;
             } elseif ($this->permission < "U") {
                 $arError[] = array("id" => "cannot_workflow", "text" => GetMessage("WD_ACCESS_DENIED"));
             } elseif ($action == "create") {
                 if ($this->workflow != "workflow" && $this->workflow != "bizproc") {
                     $arError[] = array("id" => "cannot_write", "text" => GetMessage("WD_ACCESS_DENIED"));
                 } elseif ($this->workflow == "workflow") {
                     $db_res = CWorkflowStatus::GetDropDownList("N", "desc");
                     if (!($db_res && ($res = $db_res->Fetch()))) {
                         $arError[] = array("id" => "bad_wf_statuses", "text" => GetMessage("WD_ACCESS_DENIED"));
                     }
                 } elseif ($this->workflow == 'bizproc') {
                     $arDocumentStates = CBPDocument::GetDocumentStates($this->wfParams['DOCUMENT_TYPE'], null);
                     $arUserGroups = $this->USER["GROUPS"];
                     $arUserGroups[] = "Author";
                     $canWrite = false;
                     if (!CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $this->wfParams['DOCUMENT_TYPE'], array("IBlockPermission" => $this->permission, "AllUserGroups" => $arUserGroups, "DocumentStates" => $arDocumentStates))) {
                         $arError[] = array("id" => "bad_bizproc_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                     }
                 }
             } elseif (!is_array($arElement) || empty($arElement)) {
                 $arError[] = array("id" => "bad_element", "text" => GetMessage("WD_FILE_ERROR105"));
             } elseif ($action == "clone") {
                 if ($this->workflow != "bizproc") {
                     $arError[] = array("id" => "bad_workflow", "text" => GetMessage("WD_FILE_ERROR106"));
                 } else {
                     // User has to have permissions to read parent document && to create new document
                     $arDocumentStates = CBPDocument::GetDocumentStates($this->wfParams['DOCUMENT_TYPE'], null);
                     if (!($arElement["PERMISSION"] >= "R" && CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $this->wfParams['DOCUMENT_TYPE'], array("IBlockPermission" => $this->permission, "AllUserGroups" => array_merge($this->USER["GROUPS"], array("author")), "DocumentStates" => $arDocumentStates)))) {
                         $arError[] = array("id" => "bad_permission", "text" => GetMessage("WD_ACCESS_DENIED"));
                     }
                 }
             } elseif (!in_array($action, array("delete", "move", "edit", "unlock", "lock"))) {
                 $arError[] = array("id" => "bad_action", "text" => GetMessage("WD_ERROR_BAD_ACTION"));
             } else {
                 if ($arElement["LOCK_STATUS_BP"] == "red") {
                     $arError[] = array("id" => "locked", "text" => GetMessage("WD_FILE_ERROR107"));
                 } elseif ($arElement["LOCK_STATUS"] == "red" && ($action != "unlock" || $arElement["SHOW"]["UNLOCK"] != "Y")) {
                     $arError[] = array("id" => "locked", "text" => str_replace(array("#ID#", "#DATE#"), array($arElement["locked_by"], $arElement["date_lock"]), GetMessage("WD_ERROR_ELEMENT_LOCKED")));
                 } elseif ($this->check_creator && $arElement["CREATED_BY"] != $GLOBALS["USER"]->GetID()) {
                     $arError[] = array("id" => "bad_author", "text" => GetMessage("WD_FILE_ERROR108"));
                 } elseif ($this->workflow == "workflow") {
                     $arWorkFlow = array("LAST_ID" => CIBlockElement::WF_GetLast($arElement["item_id"]));
                     $arWorkFlow["STATUS_ID"] = CIBlockElement::WF_GetCurrentStatus($arWorkFlow["LAST_ID"], $arWorkFlow["STATUS_TITLE"]);
                     $arWorkFlow["STATUS_PERMISSION"] = CIBlockElement::WF_GetStatusPermission($arWorkFlow["STATUS_ID"]);
                     if ($arWorkFlow["STATUS_ID"] > 1 && $arWorkFlow["STATUS_PERMISSION"] < 2) {
                         $arError[] = array("id" => "bad_wf_status_permission", "text" => GetMessage("WD_FILE_ERROR109"));
                     }
                 } elseif ($this->workflow == 'bizproc') {
                     $documentId = $this->wfParams['DOCUMENT_TYPE'];
                     $documentId[2] = $arElement["item_id"];
                     $arDocumentStates = CBPDocument::GetDocumentStates($this->wfParams['DOCUMENT_TYPE'], $documentId);
                     $arUserGroups = $this->USER["GROUPS"];
                     if ($arElement["CREATED_BY"] == $GLOBALS["USER"]->GetID()) {
                         $arUserGroups[] = "Author";
                     }
                     if (!CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $documentId, array("IBlockPermission" => $this->permission, "AllUserGroups" => $arUserGroups, "DocumentStates" => $arDocumentStates))) {
                         $arError[] = array("id" => "bad_bizproc_permision", "text" => GetMessage("WD_ACCESS_DENIED"));
                     }
                 }
             }
         }
         $arErrors[$static_id] = $arError;
     }
     if (empty($arError)) {
         $e = new CAdminException($arError);
         $this->LAST_ERROR = $e->GetString();
         if ($this->LAST_ERROR == '<br>') {
             $this->LAST_ERROR = '';
         }
         return true;
     } else {
         $e = new CAdminException($arError);
         $this->LAST_ERROR = $e->GetString();
         if ($this->LAST_ERROR == '<br>') {
             $this->LAST_ERROR = '';
         }
         return false;
     }
 }
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/bizproc/include.php";
IncludeModuleLangFile(__FILE__);
if (!$USER->IsAuthorized()) {
    die('<script>alert("' . GetMessage("ACCESS_DENIED") . '");</script>');
}
CUtil::DecodeUriComponent($_POST);
$activityName = $_REQUEST['id'];
$activityType = $_REQUEST['activity'];
//$runtime = CBPRuntime::GetRuntime();
//$arActivityDescription = $runtime->GetActivityDescription($activityType);
//if ($arActivityDescription == null)
//	die ("Bad activity type!".$activityType);
$documentType = array(MODULE_ID, ENTITY, $_POST['document_type']);
try {
    $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $documentType);
} catch (Exception $e) {
    $canWrite = false;
}
if (!$canWrite) {
    echo '<script>alert("' . GetMessage("ACCESS_DENIED") . '");</script>';
    die;
}
$arWorkflowTemplate = isset($_POST['arWorkflowTemplate']) && is_array($_POST['arWorkflowTemplate']) ? $_POST['arWorkflowTemplate'] : array();
$arWorkflowParameters = isset($_POST['arWorkflowParameters']) && is_array($_POST['arWorkflowParameters']) ? $_POST['arWorkflowParameters'] : array();
$arWorkflowVariables = isset($_POST['arWorkflowVariables']) && is_array($_POST['arWorkflowVariables']) ? $_POST['arWorkflowVariables'] : array();
$arWorkflowConstants = isset($_POST['arWorkflowConstants']) && is_array($_POST['arWorkflowConstants']) ? $_POST['arWorkflowConstants'] : array();
$runtime = CBPRuntime::GetRuntime();
$runtime->StartRuntime();
$documentService = $runtime->GetService("DocumentService");
$documentFields = $documentService->GetDocumentFields($documentType);
Beispiel #12
0
    } elseif (empty($_REQUEST["WF_STATUS_ID"]) && $iEditStatus > 0) {
        if (array_key_exists(1, $arResult["WF_STATUSES"])) {
            $_REQUEST["WF_STATUS_ID"] = 1;
        } else {
            $_REQUEST["WF_STATUS_ID"] = $iEditStatus;
        }
    }
} elseif ($ob->workflow == "bizproc") {
    $docID = null;
    if (!empty($arParams['ELEMENT_ID'])) {
        $docID = $arParams['DOCUMENT_TYPE'];
        $docID[2] = intval($arParams['ELEMENT_ID']);
    }
    $arDocumentStates = CBPDocument::GetDocumentStates($arParams["DOCUMENT_TYPE"], $docID);
    $arResult['DOCUMENT_STATES'] = $arDocumentStates;
    $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $GLOBALS["USER"]->GetID(), $arParams["DOCUMENT_TYPE"], array("SectionId" => $arParams["SECTION_ID"], "AllUserGroups" => $arResult["CurrentUserGroups"], "DocumentStates" => $arDocumentStates));
    if (!$canWrite) {
        $arFilter = array("DOCUMENT_TYPE" => $ob->wfParams['DOCUMENT_TYPE'], "ACTIVE" => "Y");
        $dbWFTemplates = CBPWorkflowTemplateLoader::GetList(array(), $arFilter, false, false, array("ID"));
        if ($dbWFTemplates && ($arWFTemplates = $dbWFTemplates->Fetch())) {
            if (empty($arDocumentStates) && $arParams['PERMISSION'] === 'U') {
                $sErrMsg = GetMessage("WD_NO_BP_AUTORUN");
            } elseif (!empty($arDocumentStates) && $arParams['PERMISSION'] === 'U') {
                $sErrMsg = GetMessage("WD_BP_ACTIVE_STATES");
            } else {
                $sErrMsg = GetMessage("WD_ACCESS_DENIED");
            }
        } else {
            $sErrMsg = GetMessage("WD_NO_BP_TEMPLATES");
        }
        if (!$ob->e_rights && $arParams["PERMISSION"] >= "X") {
Beispiel #13
0
            ShowError(GetMessage("CC_BLL_UNKNOWN_ERROR"));
            return;
    }
} elseif ($lists_perm < CListPermissions::CAN_READ && !(CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "element_read") || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_element_bind"))) {
    ShowError(GetMessage("CC_BLL_ACCESS_DENIED"));
    return;
}
$arParams["CAN_EDIT"] = $lists_perm >= CListPermissions::IS_ADMIN || CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_edit");
$arResult["IBLOCK_PERM"] = $lists_perm;
$arResult["USER_GROUPS"] = $USER->GetUserGroupArray();
$arIBlock = CIBlock::GetArrayByID(intval($arParams["~IBLOCK_ID"]));
$arResult["~IBLOCK"] = $arIBlock;
$arResult["IBLOCK"] = htmlspecialcharsex($arIBlock);
$arResult["IBLOCK_ID"] = $arIBlock["ID"];
if ($arResult["IBLOCK"]["BIZPROC"] == "Y" && CModule::IncludeModule('bizproc')) {
    $arParams["CAN_EDIT_BIZPROC"] = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID), array("UserGroups" => $GLOBALS["USER"]->GetUserGroupArray()));
}
if (isset($arParams["SOCNET_GROUP_ID"]) && $arParams["SOCNET_GROUP_ID"] > 0) {
    $arParams["SOCNET_GROUP_ID"] = intval($arParams["SOCNET_GROUP_ID"]);
} else {
    $arParams["SOCNET_GROUP_ID"] = "";
}
$arResult["GRID_ID"] = "lists_list_elements_" . $arResult["IBLOCK_ID"];
$arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0;
$arResult["SECTION"] = false;
$arResult["SECTION_ID"] = false;
$arResult["PARENT_SECTION_ID"] = false;
$arResult["SECTIONS"] = array();
$arResult["LIST_SECTIONS"] = array("0" => GetMessage("CC_BLL_UPPER_LEVEL"));
$arResult["~LIST_SECTIONS"] = array("0" => GetMessage("CC_BLL_UPPER_LEVEL"));
$arResult["SECTION_PATH"] = array();
Beispiel #14
0
 $DOCUMENT_TYPE = "iblock_" . $arResult["IBLOCK_ID"];
 CBPDocument::AddShowParameterInit("iblock", "only_users", $DOCUMENT_TYPE);
 $arTab2Fields = array();
 $arTab2Fields[] = array("id" => "BIZPROC_WF_STATUS", "name" => GetMessage("CT_BLEE_BIZPROC_PUBLISHED"), "type" => "label", "value" => $arResult["ELEMENT_FIELDS"]["BP_PUBLISHED"] == "Y" ? GetMessage("MAIN_YES") : GetMessage("MAIN_NO"));
 $bizProcIndex = 0;
 $arDocumentStates = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", $DOCUMENT_TYPE), $arResult["ELEMENT_ID"] > 0 ? array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]) : null, "Y");
 $custom_html .= '<input type="hidden" name="stop_bizproc" id="stop_bizproc" value="">';
 $runtime = CBPRuntime::GetRuntime();
 $runtime->StartRuntime();
 $documentService = $runtime->GetService("DocumentService");
 foreach ($arDocumentStates as $arDocumentState) {
     $bizProcIndex++;
     if ($arResult["ELEMENT_ID"] > 0) {
         $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"] > 0 ? $arDocumentState["ID"] : $arDocumentState["TEMPLATE_ID"]));
     } else {
         $canViewWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", "iblock_" . $arResult["IBLOCK_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"] > 0 ? $arDocumentState["ID"] : $arDocumentState["TEMPLATE_ID"]));
     }
     if ($canViewWorkflow) {
         $arTab2Fields[] = array("id" => "BIZPROC_TITLE" . $bizProcIndex, "name" => $arDocumentState["TEMPLATE_NAME"], "type" => "section");
         if (strlen($arDocumentState["ID"]) && strlen($arDocumentState["WORKFLOW_STATUS"]) && CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_rights_edit")) {
             $arTab2Fields[] = array("id" => "BIZPROC_STOP" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STOP_LABEL"), "type" => "label", "value" => '<a href="javascript:jsStopBP(\'' . CUtil::JSEscape('form_' . $arResult["FORM_ID"]) . '\', \'' . CUtil::JSEscape($arDocumentState["ID"]) . '\');">' . GetMessage("CT_BLEE_BIZPROC_STOP") . '</a>');
         }
         $arTab2Fields[] = array("id" => "BIZPROC_NAME" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_NAME"), "type" => "label", "value" => $arDocumentState["TEMPLATE_NAME"]);
         if ($arDocumentState["TEMPLATE_DESCRIPTION"] != '') {
             $arTab2Fields[] = array("id" => "BIZPROC_DESC" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DESC"), "type" => "label", "value" => $arDocumentState["TEMPLATE_DESCRIPTION"]);
         }
         if (strlen($arDocumentState["STATE_MODIFIED"])) {
             $arTab2Fields[] = array("id" => "BIZPROC_DATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DATE"), "type" => "label", "value" => $arDocumentState["STATE_MODIFIED"]);
         }
         if (strlen($arDocumentState["STATE_NAME"])) {
             $url = str_replace(array("#list_id#", "#document_state_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arDocumentState["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_LOG_URL"]);
     if (!$APPLICATION->CaptchaCheckCode($_REQUEST["captcha_word"], $_REQUEST["captcha_sid"])) {
         $arResult["ERRORS"][] = GetMessage("IBLOCK_FORM_WRONG_CAPTCHA");
     }
 }
 //---BP---
 if ($bBizproc) {
     $DOCUMENT_TYPE = "iblock_" . $arIBlock["ID"];
     $arDocumentStates = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", $DOCUMENT_TYPE), $arParams["ID"] > 0 ? array("iblock", "CIBlockDocument", $arParams["ID"]) : null, "Y");
     $arCurrentUserGroups = $USER->GetUserGroupArray();
     if (!$arElement || $arElement["CREATED_BY"] == $USER->GetID()) {
         $arCurrentUserGroups[] = "Author";
     }
     if ($arParams["ID"]) {
         $canWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array("iblock", "CIBlockDocument", $arParams["ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
     } else {
         $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array("iblock", "CIBlockDocument", $DOCUMENT_TYPE), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
     }
     if (!$canWrite) {
         $arResult["ERRORS"][] = GetMessage("CC_BIEAF_ACCESS_DENIED_STATUS");
     }
     if (count($arResult["ERRORS"]) == 0) {
         $arBizProcParametersValues = array();
         foreach ($arDocumentStates as $arDocumentState) {
             if (strlen($arDocumentState["ID"]) <= 0) {
                 $arErrorsTmp = array();
                 $arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflowParametersValidate($arDocumentState["TEMPLATE_ID"], $arDocumentState["TEMPLATE_PARAMETERS"], array("iblock", "CIBlockDocument", $DOCUMENT_TYPE), $arErrorsTmp);
                 foreach ($arErrorsTmp as $e) {
                     $arResult["ERRORS"][] = $e["message"];
                 }
             }
         }
Beispiel #16
0
			}

			if($arParams["ID"])
			{
				$canWrite = CBPDocument::CanUserOperateDocument(
					CBPCanUserOperateOperation::WriteDocument,
					$USER->GetID(),
					array("iblock", "CIBlockDocument", $arParams["ID"]),
					array(/*"IBlockPermission" => $arResult["IBLOCK_PERM"],*/ "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates)
				);
			}
			else
			{
				$canWrite = CBPDocument::CanUserOperateDocumentType(
					CBPCanUserOperateOperation::WriteDocument,
					$USER->GetID(),
					array("iblock", "CIBlockDocument", $DOCUMENT_TYPE),
					array(/*"IBlockPermission" => $arResult["IBLOCK_PERM"],*/ "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates)
				);
			}

			if(!$canWrite)
				$arResult["ERRORS"][] = GetMessage("CC_BIEAF_ACCESS_DENIED_STATUS");

			if(empty($arResult["ERRORS"]))
			{
				$arBizProcParametersValues = array();
				foreach ($arDocumentStates as $arDocumentState)
				{
					if(strlen($arDocumentState["ID"]) <= 0)
					{
						$arErrorsTmp = array();
	{
		$bizProcIndex++;
		if (strlen($arDocumentState["ID"]) > 0)
		{
			$canViewWorkflow = CBPDocument::CanUserOperateDocument(
				CBPCanUserOperateOperation::ViewWorkflow,
				$GLOBALS["USER"]->GetID(),
				array(MODULE_ID, ENTITY, $ID),
				array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"] > 0 ? $arDocumentState["ID"] : $arDocumentState["TEMPLATE_ID"])
			);
		}
		else
		{
			$canViewWorkflow = CBPDocument::CanUserOperateDocumentType(
				CBPCanUserOperateOperation::ViewWorkflow,
				$GLOBALS["USER"]->GetID(),
				array(MODULE_ID, ENTITY, DOCUMENT_TYPE),
				array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"] > 0 ? $arDocumentState["ID"] : $arDocumentState["TEMPLATE_ID"])
			);
		}
		if (!$canViewWorkflow)
			continue;
		?>
		<tr class="heading">
			<td colspan="2">
				<?php 
echo htmlspecialcharsbx($arDocumentState["TEMPLATE_NAME"]);
?>
				<?if (strlen($arDocumentState["ID"]) > 0 && strlen($arDocumentState["WORKFLOW_STATUS"]) > 0):?>
					(<a href="<?echo htmlspecialcharsbx("/bitrix/admin/".CIBlock::GetAdminElementEditLink($IBLOCK_ID, $ID, array(
						"WF"=>$WF,
						"find_section_section" => $find_section_section,
Beispiel #18
0
	function CanUserOperateDocument($operation, $userId, $documentId, $arParameters = array())
	{
		$documentId = trim($documentId);
		if (strlen($documentId) <= 0)
			return false;

		if (!array_key_exists("IBlockId", $arParameters)
			&& (
				!array_key_exists("IBlockPermission", $arParameters)
				|| !array_key_exists("DocumentStates", $arParameters)
				|| !array_key_exists("IBlockRightsMode", $arParameters)
				|| array_key_exists("IBlockRightsMode", $arParameters) && ($arParameters["IBlockRightsMode"] === "E")
			)
			|| !array_key_exists("CreatedBy", $arParameters) && !array_key_exists("AllUserGroups", $arParameters))
		{
			$dbElementList = CIBlockElement::GetList(
				array(),
				array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"),
				false,
				false,
				array("ID", "IBLOCK_ID", "CREATED_BY")
			);
			$arElement = $dbElementList->Fetch();

			if (!$arElement)
				return false;

			$arParameters["IBlockId"] = $arElement["IBLOCK_ID"];
			$arParameters["CreatedBy"] = $arElement["CREATED_BY"];
		}

		if (!array_key_exists("IBlockRightsMode", $arParameters))
			$arParameters["IBlockRightsMode"] = CIBlock::GetArrayByID($arParameters["IBlockId"], "RIGHTS_MODE");

		if ($arParameters["IBlockRightsMode"] === "E")
		{
			if ($operation === CBPCanUserOperateOperation::ReadDocument)
				return CIBlockElementRights::UserHasRightTo($arParameters["IBlockId"], $documentId, "element_read");
			elseif ($operation === CBPCanUserOperateOperation::WriteDocument)
				return CIBlockElementRights::UserHasRightTo($arParameters["IBlockId"], $documentId, "element_edit");
			elseif (
				$operation === CBPCanUserOperateOperation::StartWorkflow
				|| $operation === CBPCanUserOperateOperation::ViewWorkflow
			)
			{
				if (CIBlockElementRights::UserHasRightTo($arParameters["IBlockId"], $documentId, "element_edit"))
					return true;

				if (!array_key_exists("WorkflowId", $arParameters))
					return false;

				if (!CIBlockElementRights::UserHasRightTo($arParameters["IBlockId"], $documentId, "element_read"))
					return false;

				$userId = intval($userId);
				if (!array_key_exists("AllUserGroups", $arParameters))
				{
					if (!array_key_exists("UserGroups", $arParameters))
						$arParameters["UserGroups"] = CUser::GetUserGroup($userId);

					$arParameters["AllUserGroups"] = $arParameters["UserGroups"];
					if ($userId == $arParameters["CreatedBy"])
						$arParameters["AllUserGroups"][] = "Author";
				}

				if (!array_key_exists("DocumentStates", $arParameters))
				{
					if ($operation === CBPCanUserOperateOperation::StartWorkflow)
						$arParameters["DocumentStates"] = CBPWorkflowTemplateLoader::GetDocumentTypeStates(array("iblock", "CIBlockDocument", "iblock_".$arParameters["IBlockId"]));
					else
						$arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(
							array("iblock", "CIBlockDocument", "iblock_".$arParameters["IBlockId"]),
							array("iblock", "CIBlockDocument", $documentId)
						);
				}

				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"]
				);

				if (!is_array($arAllowableOperations))
					return false;

				if (($operation === CBPCanUserOperateOperation::ViewWorkflow) && in_array("read", $arAllowableOperations)
					|| ($operation === CBPCanUserOperateOperation::StartWorkflow) && in_array("write", $arAllowableOperations))
					return true;

				$chop = ($operation === CBPCanUserOperateOperation::ViewWorkflow) ? "element_read" : "element_edit";

				foreach ($arAllowableOperations as $op)
				{
					$ar = CTask::GetOperations($op, true);
					if (in_array($chop, $ar))
						return true;
				}
			}
			elseif (
				$operation === CBPCanUserOperateOperation::CreateWorkflow
			)
			{
				return CBPDocument::CanUserOperateDocumentType(
					CBPCanUserOperateOperation::CreateWorkflow,
					$userId,
					array("iblock", "CIBlockDocument", $documentId),
					$arParameters
				);
			}

			return false;
		}

		if (!array_key_exists("IBlockPermission", $arParameters))
		{
			if (CModule::IncludeModule('lists'))
				$arParameters["IBlockPermission"] = CLists::GetIBlockPermission($arParameters["IBlockId"], $userId);
			else
				$arParameters["IBlockPermission"] = CIBlock::GetPermission($arParameters["IBlockId"], $userId);
		}

		if ($arParameters["IBlockPermission"] <= "R")
			return false;
		elseif ($arParameters["IBlockPermission"] >= "W")
			return true;

		$userId = intval($userId);
		if (!array_key_exists("AllUserGroups", $arParameters))
		{
			if (!array_key_exists("UserGroups", $arParameters))
				$arParameters["UserGroups"] = CUser::GetUserGroup($userId);

			$arParameters["AllUserGroups"] = $arParameters["UserGroups"];
			if ($userId == $arParameters["CreatedBy"])
				$arParameters["AllUserGroups"][] = "Author";
		}

		if (!array_key_exists("DocumentStates", $arParameters))
		{
			$arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(
				array("iblock", "CIBlockDocument", "iblock_".$arParameters["IBlockId"]),
				array("iblock", "CIBlockDocument", $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"]
		);

		if (!is_array($arAllowableOperations))
			return false;

		$r = false;
		switch ($operation)
		{
			case CBPCanUserOperateOperation::ViewWorkflow:
				$r = in_array("read", $arAllowableOperations);
				break;
			case CBPCanUserOperateOperation::StartWorkflow:
				$r = in_array("write", $arAllowableOperations);
				break;
			case CBPCanUserOperateOperation::CreateWorkflow:
				$r = false;
				break;
			case CBPCanUserOperateOperation::WriteDocument:
				$r = in_array("write", $arAllowableOperations);
				break;
			case CBPCanUserOperateOperation::ReadDocument:
				$r = in_array("read", $arAllowableOperations) || in_array("write", $arAllowableOperations);
				break;
			default:
				$r = false;
		}

		return $r;
	}
        $workflowTemplateName = $arTemplate["NAME"];
        $workflowTemplateDescription = $arTemplate["DESCRIPTION"];
        $workflowTemplateAutostart = $arTemplate["AUTO_EXECUTE"];
        $arWorkflowTemplate = $arTemplate["TEMPLATE"];
        $arWorkflowParameters = $arTemplate["PARAMETERS"];
        $arWorkflowVariables = $arTemplate["VARIABLES"];
        $arWorkflowConstants = $arTemplate["CONSTANTS"];
    } else {
        $ID = 0;
    }
}
if ($ID <= 0) {
    if (strlen($document_type) <= 0) {
        $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED") . " " . GetMessage("BIZPROC_WFEDIT_ERROR_TYPE"));
    }
    $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), array(MODULE_ID, ENTITY, $document_type));
    $workflowTemplateName = GetMessage("BIZPROC_WFEDIT_DEFAULT_TITLE");
    $workflowTemplateDescription = '';
    $workflowTemplateAutostart = 1;
    if ($_GET['init'] == 'statemachine') {
        $arWorkflowTemplate = array(array("Type" => "StateMachineWorkflowActivity", "Name" => "Template", "Properties" => array(), "Children" => array()));
    } else {
        $arWorkflowTemplate = array(array("Type" => "SequentialWorkflowActivity", "Name" => "Template", "Properties" => array(), "Children" => array()));
    }
    $arWorkflowParameters = array();
    $arWorkflowVariables = array();
    $arWorkflowConstants = array();
}
if (!$canWrite) {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
Beispiel #20
0
 $arTab2Fields[] = array("id" => "BIZPROC_TITLE" . $bizProcIndex, "name" => $arDocumentState["TEMPLATE_NAME"], "type" => "section");
 if (strlen($arDocumentState["ID"]) && strlen($arDocumentState["WORKFLOW_STATUS"]) && CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_rights_edit")) {
     $arTab2Fields[] = array("id" => "BIZPROC_STOP" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STOP_LABEL"), "type" => "label", "value" => '<a href="javascript:jsStopBP(\'' . CUtil::JSEscape('form_' . $arResult["FORM_ID"]) . '\', \'' . CUtil::JSEscape($arDocumentState["ID"]) . '\');">' . GetMessage("CT_BLEE_BIZPROC_STOP") . '</a>');
 }
 $arTab2Fields[] = array("id" => "BIZPROC_NAME" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_NAME"), "type" => "label", "value" => $arDocumentState["TEMPLATE_NAME"]);
 if ($arDocumentState["TEMPLATE_DESCRIPTION"] != '') {
     $arTab2Fields[] = array("id" => "BIZPROC_DESC" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DESC"), "type" => "label", "value" => $arDocumentState["TEMPLATE_DESCRIPTION"]);
 }
 if (strlen($arDocumentState["STATE_MODIFIED"])) {
     $arTab2Fields[] = array("id" => "BIZPROC_DATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DATE"), "type" => "label", "value" => $arDocumentState["STATE_MODIFIED"]);
 }
 if (strlen($arDocumentState["STATE_NAME"])) {
     $url = str_replace(array("#list_id#", "#document_state_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arDocumentState["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_LOG_URL"]);
     if (strlen($arDocumentState["ID"])) {
         $arTab2Fields[] = array("id" => "BIZPROC_STATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STATE"), "type" => "label", "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . (strlen($arDocumentState["STATE_TITLE"]) ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]) . '</a>');
         $canDeleteWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]), array("UserGroups" => $arCurrentUserGroups));
         if ($canDeleteWorkflow) {
             $back_url = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array("lists_element_edit_active_tab")), array("lists_element_edit_active_tab" => "tab_bp"));
             $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_WORKFLOW_DELETE_URL"]), array("id" => $arDocumentState["ID"], "back_url" => $back_url, "sessid" => bitrix_sessid()), array("skip_empty" => true, "encode" => true));
             $arTab2Fields[] = array("id" => "BIZPROC_DELETE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DELETE_LABEL"), "type" => "label", "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . GetMessage("CT_BLEE_BIZPROC_DELETE") . '</a>');
         }
     } else {
         $arTab2Fields[] = array("id" => "BIZPROC_STATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STATE"), "type" => "label", "value" => strlen($arDocumentState["STATE_TITLE"]) ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]);
     }
 }
 //CBPDocument::StartWorkflowParametersShow($templateId, $arWorkflowParameters, $formName, $bVarsFromForm)
 $templateId = intval($arDocumentState["TEMPLATE_ID"]);
 $arWorkflowParameters = $arDocumentState["TEMPLATE_PARAMETERS"];
 if (!is_array($arWorkflowParameters)) {
     $arWorkflowParameters = array();
 }
Beispiel #21
0
 public function CheckFields($ID = false, $bAutoExec = false, $CreatedBy = 0, $arEntityAttr = array())
 {
     global $USER;
     $this->LAST_ERROR = '';
     if (!CModule::IncludeModule('bizproc')) {
         return true;
     }
     $this->arDocumentStates = CBPDocument::GetDocumentStates(array('crm', $this->sDocument, $this->sEntityType), $ID == false ? null : array('crm', $this->sDocument, $this->sEntityType . '_' . $ID));
     $arCurrentUserGroups = $this->arCurrentUserGroups;
     if (is_object($USER)) {
         if ($ID == false) {
             $arCurrentUserGroups[] = 'Author';
             $bCanWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array('crm', $this->sDocument, $this->sEntityType), array('AllUserGroups' => $arCurrentUserGroups, 'DocumentStates' => $this->arDocumentStates, 'UserIsAdmin' => $USER->IsAdmin()));
         } else {
             if ($USER->GetID() == $CreatedBy) {
                 $arCurrentUserGroups[] = 'Author';
             }
             $bCanWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array('crm', $this->sDocument, $this->sEntityType . '_' . $ID), array('AllUserGroups' => $arCurrentUserGroups, 'DocumentStates' => $this->arDocumentStates, 'CreatedBy' => $CreatedBy != 0 ? $CreatedBy : 0, 'UserIsAdmin' => $USER->IsAdmin(), 'CRMEntityAttr' => $arEntityAttr));
         }
     } else {
         $bCanWrite = true;
     }
     if (!$bCanWrite) {
         $this->LAST_ERROR = GetMessage('CRM_PERMISSION_DENIED');
         return false;
     }
     $arBizProcParametersValues = array();
     foreach ($this->arDocumentStates as $arDocumentState) {
         if (strlen($arDocumentState['ID']) <= 0) {
             if ($bAutoExec) {
                 foreach ($arDocumentState['TEMPLATE_PARAMETERS'] as $parameterKey => $arParam) {
                     if ($arParam['Required'] && !isset($_REQUEST['bizproc' . $arDocumentState['TEMPLATE_ID'] . '_' . $parameterKey]) && strlen($arParam['Default']) > 0) {
                         $_REQUEST['bizproc' . $arDocumentState['TEMPLATE_ID'] . '_' . $parameterKey] = $arParam['Default'];
                     }
                 }
             }
             $arErrorsTmp = array();
             $arBizProcParametersValues[$arDocumentState['TEMPLATE_ID']] = CBPDocument::StartWorkflowParametersValidate($arDocumentState['TEMPLATE_ID'], $arDocumentState['TEMPLATE_PARAMETERS'], array('crm', $this->sDocument, $ID == false ? $this->sEntityType : $this->sEntityType . '_' . $ID), $arErrorsTmp);
             if (count($arErrorsTmp) > 0) {
                 $this->LAST_ERROR = '';
                 foreach ($arErrorsTmp as $e) {
                     $this->LAST_ERROR .= $e['message'] . '<br />';
                 }
                 return false;
             }
         }
     }
     return $arBizProcParametersValues;
 }
Beispiel #22
0
 }
 $arTab2Fields[] = array("id" => "BIZPROC_NAME" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_NAME"), "type" => "label", "value" => $arDocumentState["TEMPLATE_NAME"]);
 if ($arDocumentState["TEMPLATE_DESCRIPTION"] != '') {
     $arTab2Fields[] = array("id" => "BIZPROC_DESC" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DESC"), "type" => "label", "value" => $arDocumentState["TEMPLATE_DESCRIPTION"]);
 }
 if (strlen($arDocumentState["STATE_MODIFIED"])) {
     $arTab2Fields[] = array("id" => "BIZPROC_DATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DATE"), "type" => "label", "value" => $arDocumentState["STATE_MODIFIED"]);
 }
 if (strlen($arDocumentState["STATE_NAME"])) {
     $backUrl = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array($arResult["FORM_ID"] . "_active_tab")), array($arResult["FORM_ID"] . "_active_tab" => "tab_bp"));
     $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#document_state_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arDocumentState["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_LOG_URL"]), array("back_url" => $backUrl), array("skip_empty" => true, "encode" => true));
     if (strlen($arDocumentState["ID"])) {
         $arTab2Fields[] = array("id" => "BIZPROC_STATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STATE"), "type" => "label", "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . (strlen($arDocumentState["STATE_TITLE"]) ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]) . '</a>');
         $canDeleteWorkflow = false;
         if ($arParams["IBLOCK_TYPE_ID"] != COption::GetOptionString("lists", "livefeed_iblock_type_id")) {
             $canDeleteWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array("UserGroups" => $arCurrentUserGroups));
         }
         if ($canDeleteWorkflow) {
             $backUrl = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array($arResult["FORM_ID"] . "_active_tab")), array($arResult["FORM_ID"] . "_active_tab" => "tab_bp"));
             $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_WORKFLOW_DELETE_URL"]), array("id" => $arDocumentState["ID"], "back_url" => $backUrl, "sessid" => bitrix_sessid()), array("skip_empty" => true, "encode" => true));
             $arTab2Fields[] = array("id" => "BIZPROC_DELETE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DELETE_LABEL"), "type" => "label", "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . GetMessage("CT_BLEE_BIZPROC_DELETE") . '</a>');
         }
     } else {
         $arTab2Fields[] = array("id" => "BIZPROC_STATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STATE"), "type" => "label", "value" => strlen($arDocumentState["STATE_TITLE"]) ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]);
     }
 }
 $templateId = intval($arDocumentState["TEMPLATE_ID"]);
 $arWorkflowParameters = $arDocumentState["TEMPLATE_PARAMETERS"];
 if (!is_array($arWorkflowParameters)) {
     $arWorkflowParameters = array();
 }
Beispiel #23
0
}

if(strlen($sLastFolder)>0)
{
	$aContext[] = Array(
		"TEXT" => GetMessage("IBLIST_A_UP"),
		"LINK" => $sLastFolder,
		"TITLE" => GetMessage("IBLIST_A_UP_TITLE"),
	);
}

if($bBizproc && IsModuleInstalled("bizprocdesigner"))
{
	$bCanDoIt = CBPDocument::CanUserOperateDocumentType(
		CBPCanUserOperateOperation::CreateWorkflow,
		$USER->GetID(),
		array(MODULE_ID, ENTITY, DOCUMENT_TYPE)
		);

	if($bCanDoIt)
	{
		$aContext[] = array(
			"TEXT" => GetMessage("IBLIST_BTN_BP"),
			"ICON" => "btn_bp",
			"LINK" => 'iblock_bizproc_workflow_admin.php?document_type=iblock_'.$IBLOCK_ID.'&lang='.LANGUAGE_ID.'&back_url_list='.urlencode($REQUEST_URI),
		);
	}
}

$lAdmin->AddAdminContextMenu($aContext);
     }
 } elseif ($bBizproc) {
     $arDocumentStates = CBPDocument::GetDocumentStates(array(MODULE_ID, ENTITY, DOCUMENT_TYPE), $ID > 0 ? array(MODULE_ID, ENTITY, $ID) : null, "Y");
     $arCurrentUserGroups = $USER->GetUserGroupArray();
     if ($ID > 0 && is_array($arElement)) {
         if ($USER->GetID() == $arElement["CREATED_BY"]) {
             $arCurrentUserGroups[] = "Author";
         }
     } else {
         $arCurrentUserGroups[] = "Author";
     }
     if ($ID > 0) {
         $canWrite = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array(MODULE_ID, ENTITY, $ID), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $canRead = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ReadDocument, $USER->GetID(), array(MODULE_ID, ENTITY, $ID), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
     } else {
         $canWrite = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array(MODULE_ID, ENTITY, DOCUMENT_TYPE), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
         $canRead = false;
     }
     if (!$canWrite && !$canRead) {
         $error = new _CIBlockError(1, "ACCESS_DENIED", GetMessage("IBLOCK_ACCESS_DENIED_STATUS"));
         break;
     }
 }
 //Find out files properties
 $arFileProps = array();
 $propertyIterator = Iblock\PropertyTable::getList(array('select' => array('ID'), 'filter' => array('=IBLOCK_ID' => $IBLOCK_ID, '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_FILE, '=ACTIVE' => 'Y')));
 while ($property = $propertyIterator->fetch()) {
     $arFileProps[] = $property['ID'];
 }
 unset($property, $propertyIterator);
 //Assembly properties values from $_POST and $_FILES
Beispiel #25
0
 protected function getBizprocData()
 {
     $userId = $this->getUser()->getID();
     $currentUserGroups = $this->getUser()->getUserGroupArray();
     if (!$this->lists['ELEMENT_FIELDS'] || $this->lists['ELEMENT_FIELDS']['CREATED_BY'] == $userId) {
         $currentUserGroups[] = 'Author';
     }
     $documentType = 'iblock_' . $this->iblockId;
     CBPDocument::addShowParameterInit('lists', 'only_users', $documentType);
     $this->lists['BIZPROC_FIELDS'] = array();
     $bizprocIndex = 0;
     $documentStates = CBPDocument::getDocumentStates(array('lists', 'BizprocDocument', $documentType), null);
     $runtime = CBPRuntime::getRuntime();
     $runtime->startRuntime();
     $documentService = $runtime->getService('DocumentService');
     foreach ($documentStates as $documentState) {
         $bizprocIndex++;
         $viewWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::StartWorkflow, $userId, array('lists', 'BizprocDocument', $documentType), array('sectionId' => 0, 'AllUserGroups' => $currentUserGroups, 'DocumentStates' => $documentStates, 'WorkflowId' => $documentState['ID'] > 0 ? $documentState['ID'] : $documentState['TEMPLATE_ID']));
         if ($viewWorkflow) {
             $templateId = intval($documentState['TEMPLATE_ID']);
             $workflowParameters = $documentState['TEMPLATE_PARAMETERS'];
             if (!is_array($workflowParameters)) {
                 $workflowParameters = array();
             }
             if (strlen($documentState["ID"]) <= 0 && $templateId > 0) {
                 $parametersValues = array();
                 $keys = array_keys($workflowParameters);
                 foreach ($keys as $key) {
                     $value = $workflowParameters[$key]["Default"];
                     if (!is_array($value)) {
                         $parametersValues[$key] = htmlspecialcharsbx($value);
                     } else {
                         $keys1 = array_keys($value);
                         foreach ($keys1 as $key1) {
                             $parametersValues[$key][$key1] = htmlspecialcharsbx($value[$key1]);
                         }
                     }
                 }
                 foreach ($workflowParameters as $parameterKey => $arParameter) {
                     $parameterKeyExt = "bizproc" . $templateId . "_" . $parameterKey;
                     $html = $documentService->GetFieldInputControl(array('lists', 'BizprocDocument', $documentType), $arParameter, array("Form" => "start_workflow_form1", "Field" => $parameterKeyExt), $parametersValues[$parameterKey], false, true);
                     $this->lists['BIZPROC_FIELDS'][$parameterKeyExt . $bizprocIndex] = array("id" => $parameterKeyExt . $bizprocIndex, "required" => $arParameter["Required"], "name" => $arParameter["Name"], "title" => $arParameter["Description"], "type" => "custom", "value" => $html, 'show' => 'Y');
                 }
             }
         }
     }
 }
Beispiel #26
0
    }
} elseif ($lists_perm < CListPermissions::CAN_READ && !(CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "element_read") || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_element_bind"))) {
    ShowError(GetMessage("CC_BLL_ACCESS_DENIED"));
    return;
}
$arParams["CAN_EDIT"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::IS_ADMIN || CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_edit"));
$arResult["CAN_ADD_ELEMENT"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm > CListPermissions::CAN_READ || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_element_bind"));
$arResult["CAN_EDIT_SECTIONS"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_edit") || CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $section_id, "section_section_bind"));
$arResult["IBLOCK_PERM"] = $lists_perm;
$arResult["USER_GROUPS"] = $USER->GetUserGroupArray();
$arIBlock = CIBlock::GetArrayByID(intval($arParams["~IBLOCK_ID"]));
$arResult["~IBLOCK"] = $arIBlock;
$arResult["IBLOCK"] = htmlspecialcharsex($arIBlock);
$arResult["IBLOCK_ID"] = $arIBlock["ID"];
if ($arResult["IBLOCK"]["BIZPROC"] == "Y" && CModule::IncludeModule('bizproc')) {
    $arParams["CAN_EDIT_BIZPROC"] = !$arResult["IS_SOCNET_GROUP_CLOSED"] && CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $USER->GetID(), array("iblock", "CIBlockDocument", "iblock_" . $IBLOCK_ID), array("UserGroups" => $USER->GetUserGroupArray()));
}
if (isset($arParams["SOCNET_GROUP_ID"]) && $arParams["SOCNET_GROUP_ID"] > 0) {
    $arParams["SOCNET_GROUP_ID"] = intval($arParams["SOCNET_GROUP_ID"]);
} else {
    $arParams["SOCNET_GROUP_ID"] = "";
}
$arResult["GRID_ID"] = "lists_list_elements_" . $arResult["IBLOCK_ID"];
$arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0;
$arResult["SECTION"] = false;
$arResult["SECTION_ID"] = false;
$arResult["PARENT_SECTION_ID"] = false;
$arResult["SECTIONS"] = array();
$arResult["LIST_SECTIONS"] = array("0" => GetMessage("CC_BLL_UPPER_LEVEL"));
$arResult["~LIST_SECTIONS"] = array("0" => GetMessage("CC_BLL_UPPER_LEVEL"));
$arResult["SECTION_PATH"] = array();