<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$file = trim(preg_replace("'[\\\\/]+'", "/", dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/result_modifier.php"));
__IncludeLang($file);
$arArrays = array();
$arElements = array();
$arSections = array();
$CURRENT_USER_ID = $GLOBALS["USER"]->GetID();
$CURRENT_USER_GROUPS = $GLOBALS["USER"]->GetUserGroupArray();
foreach ($arResult["ELEMENTS_ROWS"] as $i => $arRow) {
    if ($arResult["BIZPROC"] == "Y") {
        $arDocumentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]), BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arRow["data"]["ID"]));
        $USER_GROUPS = $CURRENT_USER_GROUPS;
        if ($arRow["data"]["~CREATED_BY"] == $CURRENT_USER_ID) {
            $USER_GROUPS[] = "Author";
        }
        $ii = 0;
        $html = "";
        $proccesses = false;
        if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) {
            $proccesses = true;
            $workflows = array();
        }
        foreach ($arDocumentStates as $kk => $vv) {
            if ($vv["ID"] && $proccesses && !empty($arRow["data"]["WORKFLOW_ID"])) {
                $workflows[] = 'WF_' . $vv["ID"];
            }
            $canViewWorkflow = CIBlockDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $CURRENT_USER_ID, $arRow["data"]["ID"], array("IBlockPermission" => $arResult["IBLOCK_PERM"], "AllUserGroups" => $USER_GROUPS, "DocumentStates" => $arDocumentStates, "WorkflowId" => $kk));
Beispiel #2
0
							$sHTML .= '<input type="hidden" name="CATALOG_QUANTITY_TO['.$f_ID.']['.$CatGroup["ID"].']" value="'.$arRes["CATALOG_QUANTITY_TO_".$CatGroup["ID"]].'">';

							$row->AddEditField("CATALOG_GROUP_".$CatGroup["ID"], $sHTML);
						}
					}
				}
			}
		}
	}

	if ($bBizproc)
	{
		if ($f_TYPE == "E")
		{
			$arDocumentStates = CBPDocument::GetDocumentStates(
				array(MODULE_ID, ENTITY, DOCUMENT_TYPE),
				array(MODULE_ID, ENTITY, $f_ID)
			);

			$arRes["CURENT_USER_GROUPS"] = $USER->GetUserGroupArray();
			if ($arRes["CREATED_BY"] == $USER->GetID())
				$arRes["CURENT_USER_GROUPS"][] = "Author";

			$arStr = array();
			$arStr1 = array();
			foreach ($arDocumentStates as $kk => $vv)
			{
				$canViewWorkflow = call_user_func(array(ENTITY, "CanUserOperateDocument"),
					CBPCanUserOperateOperation::ViewWorkflow,
					$USER->GetID(),
					$f_ID,
					array("AllUserGroups" => $arRes["CURENT_USER_GROUPS"], "DocumentStates" => $arDocumentStates, "WorkflowId" => $kk)
Beispiel #3
0
 if (isset($arContact['~ACTIVITY_TIME'])) {
     $time = MakeTimeStamp($arContact['~ACTIVITY_TIME']);
     $arContact['~ACTIVITY_EXPIRED'] = $time <= $now;
     $arContact['~ACTIVITY_IS_CURRENT_DAY'] = $arContact['~ACTIVITY_EXPIRED'] || CCrmActivity::IsCurrentDay($time);
 }
 if ($arResult['ENABLE_TASK']) {
     $arContact['PATH_TO_TASK_EDIT'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate(COption::GetOptionString('tasks', 'paths_task_user_edit', ''), array('task_id' => 0, 'user_id' => $userID)), array('UF_CRM_TASK' => 'C_' . $arContact['ID'], 'TITLE' => urlencode(GetMessage('CRM_TASK_TITLE_PREFIX')), 'TAGS' => urlencode(GetMessage('CRM_TASK_TAG')), 'back_url' => urlencode($arParams['PATH_TO_CONTACT_LIST'])));
 }
 if (IsModuleInstalled('sale')) {
     $arContact['PATH_TO_QUOTE_ADD'] = CHTTP::urlAddParams(CComponentEngine::makePathFromTemplate($arParams['PATH_TO_QUOTE_EDIT'], array('quote_id' => 0)), array('contact_id' => $arContact['ID']));
     $arContact['PATH_TO_INVOICE_ADD'] = CHTTP::urlAddParams(CComponentEngine::makePathFromTemplate($arParams['PATH_TO_INVOICE_EDIT'], array('invoice_id' => 0)), array('contact' => $arContact['ID']));
 }
 if ($arResult['ENABLE_BIZPROC']) {
     $arContact['BIZPROC_STATUS'] = '';
     $arContact['BIZPROC_STATUS_HINT'] = '';
     $arDocumentStates = CBPDocument::GetDocumentStates(array('crm', 'CCrmDocumentContact', 'CONTACT'), array('crm', 'CCrmDocumentContact', 'CONTACT_' . $arContact['ID']));
     $arContact['PATH_TO_BIZPROC_LIST'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $arContact['ID'])), array('CRM_CONTACT_SHOW_V12_active_tab' => 'tab_bizproc'));
     $totalTaskQty = 0;
     $docStatesQty = count($arDocumentStates);
     if ($docStatesQty === 1) {
         $arDocState = $arDocumentStates[array_shift(array_keys($arDocumentStates))];
         $docTemplateID = $arDocState['TEMPLATE_ID'];
         $paramName = "BIZPROC_{$docTemplateID}";
         $docTtl = isset($arDocState['STATE_TITLE']) ? $arDocState['STATE_TITLE'] : '';
         $docName = isset($arDocState['STATE_NAME']) ? $arDocState['STATE_NAME'] : '';
         $docTemplateName = isset($arDocState['TEMPLATE_NAME']) ? $arDocState['TEMPLATE_NAME'] : '';
         if ($isInExportMode) {
             $arContact[$paramName] = $docTtl;
         } else {
             $arContact[$paramName] = '<a href="' . htmlspecialcharsbx($arContact['PATH_TO_BIZPROC_LIST']) . '">' . htmlspecialcharsbx($docTtl) . '</a>';
             $docID = $arDocState['ID'];
Beispiel #4
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 #5
0
     $data["MODIFIED_BY"] = "[" . $data["MODIFIED_BY"] . "] " . $data["USER_NAME"];
 }
 if (isset($data["ACTIVE_FROM"])) {
     $data['ACTIVE_FROM'] = FormatDateFromDB($data['ACTIVE_FROM']);
 }
 if (isset($data["ACTIVE_TO"])) {
     $data['ACTIVE_TO'] = FormatDateFromDB($data['ACTIVE_TO']);
 }
 if (isset($data["DATE_CREATE"])) {
     $data['DATE_CREATE'] = FormatDateFromDB($data['DATE_CREATE']);
 }
 if (isset($data["TIMESTAMP_X"])) {
     $data['TIMESTAMP_X'] = FormatDateFromDB($data['TIMESTAMP_X']);
 }
 if (CModule::IncludeModule("bizproc")) {
     $documentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($arIBlock["IBLOCK_TYPE_ID"], $arIBlock["ID"]), BizProcDocument::getDocumentComplexId($arIBlock["IBLOCK_TYPE_ID"], $data["ID"]));
     if ($arResult["PROCESSES"] && $arResult["USE_COMMENTS"]) {
         if (!empty($documentStates)) {
             $stateTemporary = current($documentStates);
             $data["WORKFLOW_ID"] = $stateTemporary["ID"];
         } else {
             $data["WORKFLOW_ID"] = '';
         }
     }
 }
 $arUserGroupsForBPTmp = $arUserGroupsForBP;
 if ($USER->GetID() == $data["CREATED_BY"]) {
     $arUserGroupsForBPTmp[] = "Author";
 }
 $arBPStart = array();
 if (CModule::IncludeModule('bizproc')) {
?>
</td>
	</tr>
	<?
	$tabControl->EndCustomField("BIZPROC_WF_STATUS", '');

	$tabControl->BeginCustomField("BIZPROC", GetMessage("IBEL_E_TAB_BIZPROC"));

	CBPDocument::AddShowParameterInit(MODULE_ID, "only_users", DOCUMENT_TYPE);

	$bizProcIndex = 0;
	if (!isset($arDocumentStates))
	{
		$arDocumentStates = CBPDocument::GetDocumentStates(
			array(MODULE_ID, ENTITY, DOCUMENT_TYPE),
			($ID > 0) ? array(MODULE_ID, ENTITY, $ID) : null,
			"Y"
		);
	}
	foreach ($arDocumentStates as $arDocumentState)
	{
		$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"])
			);
		}
Beispiel #7
0
                         $sHTML .= '<input type="hidden" id="CATALOG_EXTRA[' . $f_ID . '][' . $CatGroup["ID"] . ']" name="CATALOG_EXTRA[' . $f_ID . '][' . $CatGroup["ID"] . ']" value="' . $arRes["CATALOG_EXTRA_ID_" . $CatGroup["ID"]] . '">';
                     }
                     $sHTML .= '<input type="hidden" name="CATALOG_old_PRICE[' . $f_ID . '][' . $CatGroup["ID"] . ']" value="' . $arRes["CATALOG_PRICE_" . $CatGroup["ID"]] . '">';
                     $sHTML .= '<input type="hidden" name="CATALOG_old_CURRENCY[' . $f_ID . '][' . $CatGroup["ID"] . ']" value="' . $arRes["CATALOG_CURRENCY_" . $CatGroup["ID"]] . '">';
                     $sHTML .= '<input type="hidden" name="CATALOG_PRICE_ID[' . $f_ID . '][' . $CatGroup["ID"] . ']" value="' . $arRes["CATALOG_PRICE_ID_" . $CatGroup["ID"]] . '">';
                     $sHTML .= '<input type="hidden" name="CATALOG_QUANTITY_FROM[' . $f_ID . '][' . $CatGroup["ID"] . ']" value="' . $arRes["CATALOG_QUANTITY_FROM_" . $CatGroup["ID"]] . '">';
                     $sHTML .= '<input type="hidden" name="CATALOG_QUANTITY_TO[' . $f_ID . '][' . $CatGroup["ID"] . ']" value="' . $arRes["CATALOG_QUANTITY_TO_" . $CatGroup["ID"]] . '">';
                     $row->arRes['price']["CATALOG_GROUP_" . $CatGroup["ID"]] = $sHTML;
                 }
             }
         }
         unset($CatGroup);
     }
 }
 if ($boolSubBizproc) {
     $arDocumentStates = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", "iblock_" . $intSubIBlockID), array("iblock", "CIBlockDocument", $f_ID));
     $arRes["CURRENT_USER_GROUPS"] = $USER->GetUserGroupArray();
     if ($arRes["CREATED_BY"] == $USER->GetID()) {
         $arRes["CURRENT_USER_GROUPS"][] = "Author";
     }
     $row->arRes["CURRENT_USER_GROUPS"] = $arRes["CURRENT_USER_GROUPS"];
     $arStr = array();
     $arStr1 = array();
     foreach ($arDocumentStates as $kk => $vv) {
         $canViewWorkflow = CIBlockDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $USER->GetID(), $f_ID, array("AllUserGroups" => $arRes["CURRENT_USER_GROUPS"], "DocumentStates" => $arDocumentStates, "WorkflowId" => $kk));
         if (!$canViewWorkflow) {
             continue;
         }
         $arStr1[$vv["TEMPLATE_ID"]] = $vv["TEMPLATE_NAME"];
         $arStr[$vv["TEMPLATE_ID"]] .= "<a href=\"/bitrix/admin/bizproc_log.php?ID=" . $kk . "\">" . (strlen($vv["STATE_TITLE"]) > 0 ? $vv["STATE_TITLE"] : $vv["STATE_NAME"]) . "</a><br />";
         if (strlen($vv["ID"]) > 0) {
Beispiel #8
0
 public function executeComponent()
 {
     if (!empty($this->arParams['ERROR'])) {
         ShowError(array_shift($this->arParams['ERROR']));
         return;
     }
     $this->arResult['USER_ID'] = $this->arParams['USER_ID'];
     $this->arResult['GRID_ID'] = 'lists_processes';
     $selectFields = array('ID', 'IBLOCK_TYPE_ID', 'IBLOCK_ID', 'NAME');
     $gridOptions = new CGridOptions($this->arResult['GRID_ID']);
     $gridColumns = $gridOptions->getVisibleColumns();
     $gridSort = $gridOptions->getSorting(array('sort' => array('ID' => 'desc')));
     $this->arResult['HEADERS'] = array(array("id" => "ID", "name" => "ID", "default" => false, "sort" => "ID"), array('id' => 'DOCUMENT_NAME', 'name' => Loc::getMessage('CC_BLL_DOCUMENT_NAME'), 'default' => true, 'sort' => 'DOCUMENT_NAME'), array('id' => 'COMMENTS', 'name' => Loc::getMessage('CC_BLL_COMMENTS'), 'default' => true, 'sort' => '', 'hideName' => true, 'iconCls' => 'bp-comments-icon'), array('id' => 'WORKFLOW_PROGRESS', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_PROGRESS'), 'default' => true, 'sort' => ''), array('id' => 'WORKFLOW_STATE', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_STATE'), 'default' => false, 'sort' => ''));
     $this->arResult['FILTER'] = array(array("id" => "NAME", "name" => GetMessage("BPATL_NAME"), "type" => "string"), array('id' => 'TIMESTAMP_X', 'name' => Loc::getMessage('CC_BLL_MODIFIED'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => Loc::getMessage('CC_BLL_CREATED'), 'type' => 'date', 'default' => true));
     $gridFilter = $gridOptions->getFilter($this->arResult['FILTER']);
     foreach ($gridFilter as $key => $value) {
         if (substr($key, -5) == "_from") {
             $op = ">=";
             $newKey = substr($key, 0, -5);
         } elseif (substr($key, -3) == "_to") {
             $op = "<=";
             $newKey = substr($key, 0, -3);
             if (in_array($newKey, array("TIMESTAMP_X", 'DATE_CREATE'))) {
                 if (!preg_match("/\\d\\d:\\d\\d:\\d\\d\$/", $value)) {
                     $value .= " 23:59:59";
                 }
             }
         } else {
             $op = "";
             $newKey = $key;
         }
         $filter[$op . $newKey] = $value;
     }
     $this->arResult['SORT'] = $gridSort['sort'];
     $useComments = (bool) CModule::includeModule("forum");
     $workflows = array();
     $this->arResult['DATA'] = array();
     $this->arResult["COMMENTS_COUNT"] = array();
     $filter['CREATED_BY'] = $this->arParams['USER_ID'];
     $iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $filter['IBLOCK_TYPE'] = $iblockTypeId;
     $filter['CHECK_PERMISSIONS'] = $this->arParams['LIST_PERM'] >= CListPermissions::CAN_READ ? "N" : "Y";
     $elementObject = CIBlockElement::getList($gridSort['sort'], $filter, false, $gridOptions->getNavParams(), $selectFields);
     $documentState = true;
     $path = rtrim(SITE_DIR, '/');
     while ($element = $elementObject->fetch()) {
         $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($iblockTypeId, $element['IBLOCK_ID']), BizprocDocument::getDocumentComplexId($iblockTypeId, $element['ID']));
         $this->arResult['DATA'][$element['ID']]['ID'] = $element['ID'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_NAME'] = $element['NAME'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_URL'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $element['ID'];
         if (!empty($documentState)) {
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = true;
             $documentState = current($documentState);
             $this->arResult['DATA'][$element['ID']]['WORKFLOW_ID'] = $documentState['ID'];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_NAME"] = $documentState["TEMPLATE_NAME"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STATE"] = $documentState["STATE_TITLE"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED"] = FormatDateFromDB($documentState["STARTED_FORMATTED"]);
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = "";
             if (intval($documentState["STARTED_BY"]) > 0) {
                 $dbUserTmp = CUser::getByID($documentState["STARTED_BY"]);
                 $arUserTmp = $dbUserTmp->fetch();
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = CUser::FormatName($this->arParams["NAME_TEMPLATE"], $arUserTmp, true);
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] .= " [" . $documentState["STARTED_BY"] . "]";
             }
             $this->arResult['DATA'][$element['ID']]['MODULE_ID'] = $documentState["DOCUMENT_ID"][0];
             $this->arResult['DATA'][$element['ID']]['ENTITY'] = $documentState["DOCUMENT_ID"][1];
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_ID'] = $documentState["DOCUMENT_ID"][2];
         } else {
             $documentState = false;
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = false;
         }
     }
     foreach ($this->arResult['DATA'] as $data) {
         if ($documentState) {
             if ($useComments) {
                 $workflows[] = 'WF_' . $data['WORKFLOW_ID'];
             }
         }
         $actions = array();
         if (strlen($data["DOCUMENT_URL"]) > 0) {
             $actions[] = array('ICONCLASS' => '', 'DEFAULT' => false, 'TEXT' => Loc::getMessage('CC_BLL_C_DOCUMENT'), 'ONCLICK' => 'window.open("' . $data["DOCUMENT_URL"] . '");');
         }
         $this->arResult['RECORDS'][] = array('data' => $data, 'actions' => $actions);
     }
     if ($useComments && $documentState) {
         $workflows = array_unique($workflows);
         if ($workflows) {
             $iterator = CForumTopic::getList(array(), array("@XML_ID" => $workflows));
             while ($row = $iterator->fetch()) {
                 $this->arResult["COMMENTS_COUNT"][$row['XML_ID']] = $row['POSTS'];
             }
         }
     }
     $this->arResult['COUNTERS'] = array('all' => 0);
     $this->arResult["ROWS_COUNT"] = $elementObject->selectedRowsCount();
     $this->arResult["NAV_RESULT"] = $elementObject;
     if ($this->arParams['SET_TITLE'] == 'Y') {
         $this->getApplication()->setTitle(Loc::getMessage('CC_BLL_TITLE'));
     }
     $this->includeComponentTemplate();
 }
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
$file = trim(preg_replace("'[\\\\/]+'", "/", dirname(__FILE__) . "/lang/" . LANGUAGE_ID . "/result_modifier.php"));
__IncludeLang($file);
$arArrays = array();
$arElements = array();
$arSections = array();
$CURRENT_USER_ID = $GLOBALS["USER"]->GetID();
$CURRENT_USER_GROUPS = $GLOBALS["USER"]->GetUserGroupArray();
foreach ($arResult["ELEMENTS_ROWS"] as $i => $arRow) {
    if ($arResult["BIZPROC"] == "Y") {
        $arDocumentStates = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", "iblock_" . $arResult["IBLOCK_ID"]), array("iblock", "CIBlockDocument", $arRow["data"]["ID"]));
        $USER_GROUPS = $CURRENT_USER_GROUPS;
        if ($arRow["data"]["~CREATED_BY"] == $CURRENT_USER_ID) {
            $USER_GROUPS[] = "Author";
        }
        $ii = 0;
        $html = "";
        foreach ($arDocumentStates as $kk => $vv) {
            $canViewWorkflow = CIBlockDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $CURRENT_USER_ID, $arRow["data"]["ID"], array("IBlockPermission" => $arResult["IBLOCK_PERM"], "AllUserGroups" => $USER_GROUPS, "DocumentStates" => $arDocumentStates, "WorkflowId" => $kk));
            if (!$canViewWorkflow) {
                continue;
            }
            if (strlen($vv["TEMPLATE_NAME"]) > 0) {
                $html .= "<b>" . $vv["TEMPLATE_NAME"] . "</b>:<br />";
            } else {
                $html .= "<b>" . ++$ii . "</b>:<br />";
            }
function GetTasksList($iblockId, $arOrder = array("SORT" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
{
    global $USER;
    $iblockId = IntVal($iblockId);
    $arFilter["IBLOCK_ID"] = $iblockId;
    $arFilter["SHOW_NEW"] = "Y";
    if (count($arSelectFields) > 0) {
        if (!in_array("IBLOCK_SECTION_ID", $arSelectFields)) {
            $arSelectFields[] = "IBLOCK_SECTION_ID";
        }
        if (!in_array("ID", $arSelectFields)) {
            $arSelectFields[] = "ID";
        }
        if (!in_array("IBLOCK_ID", $arSelectFields)) {
            $arSelectFields[] = "IBLOCK_ID";
        }
        if (!in_array("CREATED_BY", $arSelectFields)) {
            $arSelectFields[] = "CREATED_BY";
        }
    }
    $arResultList = array();
    $arCache = array();
    $isInSecurity = CModule::IncludeModule("security");
    $dbTasksList = CIBlockElement::GetList($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelectFields);
    while ($obTask = $dbTasksList->GetNextElement()) {
        $arResult = array();
        $arFields = $obTask->GetFields();
        foreach ($arFields as $fieldKey => $fieldValue) {
            if (substr($fieldKey, 0, 1) == "~") {
                continue;
            }
            $arResult[$fieldKey] = $fieldValue;
            if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) {
                $arResult[$fieldKey . "_PRINTABLE"] = CIntranetTasks::PrepareUserForPrint($fieldValue);
            } elseif ($fieldKey == "DETAIL_TEXT") {
                if ($isInSecurity) {
                    $filter = new CSecurityFilter();
                    $arResult["DETAIL_TEXT_PRINTABLE"] = $filter->TestXSS($arFields["~DETAIL_TEXT"]);
                    $arResult["DETAIL_TEXT"] = $arResult["DETAIL_TEXT_PRINTABLE"];
                } else {
                    $arResult["DETAIL_TEXT_PRINTABLE"] = nl2br($arFields["DETAIL_TEXT"]);
                    $arResult["DETAIL_TEXT"] = $arFields["DETAIL_TEXT"];
                }
            } else {
                $arResult[$fieldKey . "_PRINTABLE"] = $fieldValue;
            }
        }
        $arProperties = $obTask->GetProperties();
        foreach ($arProperties as $propertyKey => $propertyValue) {
            $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
            if (strtoupper($propertyKey) == "TASKCOMPLETE") {
                $ps = intval($propertyValue["VALUE"]);
                if ($ps > 100) {
                    $ps = 100;
                } elseif ($ps < 0) {
                    $ps = 0;
                }
                $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = '<div class="task-complete-bar-out" title="' . GetMessage("INTASK_L_TASKCOMPLETE", array("#PRC#" => IntVal($propertyValue["VALUE"]))) . '">';
                if ($ps > 0) {
                    $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] .= '<div class="task-complete-bar-in" style="width:' . $ps . '%;"><div class="empty"></div></div>';
                }
                $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] .= '</div>';
            } elseif (strlen($propertyValue["USER_TYPE"]) > 0) {
                if ($propertyValue["USER_TYPE"] == "UserID") {
                    $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = CIntranetTasks::PrepareUserForPrint($propertyValue["VALUE"]);
                } else {
                    $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = $propertyValue["VALUE"];
                }
            } elseif ($propertyValue["PROPERTY_TYPE"] == "G") {
                $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = array();
                $vx = CIntranetTasks::PrepareSectionForPrint($propertyValue["VALUE"], $propertyValue["LINK_IBLOCK_ID"]);
                foreach ($vx as $vx1 => $vx2) {
                    $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$vx1] = $vx2["NAME"];
                }
            } elseif ($propertyValue["PROPERTY_TYPE"] == "L") {
                $arResult["PROPERTY_" . $propertyKey] = array();
                $arPropertyValue = $propertyValue["VALUE"];
                $arPropertyKey = $propertyValue["VALUE_ENUM_ID"];
                if (!is_array($arPropertyValue)) {
                    $arPropertyValue = array($arPropertyValue);
                    $arPropertyKey = array($arPropertyKey);
                }
                for ($i = 0, $cnt = count($arPropertyValue); $i < $cnt; $i++) {
                    $arResult["PROPERTY_" . $propertyKey][$arPropertyKey[$i]] = $arPropertyValue[$i];
                }
                $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = $arResult["PROPERTY_" . $propertyKey];
            } elseif ($propertyValue["PROPERTY_TYPE"] == "S" && $propertyValue["ROW_COUNT"] > 1) {
                if (is_array($propertyValue["VALUE"])) {
                    $arResult["PROPERTY_" . $propertyKey] = array();
                    $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = array();
                    if ($isInSecurity) {
                        foreach ($propertyValue["~VALUE"] as $k => $v) {
                            $filter = new CSecurityFilter();
                            $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$k] = $filter->TestXSS($v);
                            $arResult["PROPERTY_" . $propertyKey][$k] = $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$k];
                        }
                    } else {
                        foreach ($propertyValue["VALUE"] as $k => $v) {
                            $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$k] = nl2br($v);
                            $arResult["PROPERTY_" . $propertyKey][$k] = $v;
                        }
                    }
                } else {
                    if ($isInSecurity) {
                        $filter = new CSecurityFilter();
                        $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = $filter->TestXSS($propertyValue["~VALUE"]);
                        $arResult["PROPERTY_" . $propertyKey] = $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"];
                    } else {
                        $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = nl2br($propertyValue["VALUE"]);
                        $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
                    }
                }
            }
        }
        $arResult["ROOT_SECTION_ID"] = 0;
        $arResult["IBLOCK_SECTION_ID_PRINTABLE"] = array();
        $v = CIntranetTasks::PrepareSectionForPrint($arResult["IBLOCK_SECTION_ID"], $iblockId);
        if (is_array($v)) {
            foreach ($v as $k1 => $v1) {
                if ($arResult["ROOT_SECTION_ID"] == 0) {
                    $arResult["ROOT_SECTION_ID"] = $k1;
                    $taskType = $v1["XML_ID"] == "users_tasks" ? "user" : "group";
                    $ownerId = $taskType == "user" ? $arResult["PROPERTY_TaskAssignedTo"] : $v1["XML_ID"];
                } else {
                    $arResult["IBLOCK_SECTION_ID_PRINTABLE"][$k1] = $v1["NAME"];
                }
            }
        }
        if (!array_key_exists($taskType . "_" . $ownerId, $arCache)) {
            $arCurrentUserGroups = array();
            if ($taskType == "group") {
                $arCurrentUserGroups[] = SONET_ROLES_ALL;
                if ($GLOBALS["USER"]->IsAuthorized()) {
                    $arCurrentUserGroups[] = SONET_ROLES_AUTHORIZED;
                }
                $r = CSocNetUserToGroup::GetUserRole($USER->GetID(), $ownerId);
                if (strlen($r) > 0) {
                    $arCurrentUserGroups[] = $r;
                }
            } else {
                $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_ALL;
                if ($GLOBALS["USER"]->IsAuthorized()) {
                    $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_AUTHORIZED;
                }
                if (CSocNetUserRelations::IsFriends($USER->GetID(), $ownerId)) {
                    $arCurrentUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS;
                }
            }
            $arCache[$taskType . "_" . $ownerId] = $arCurrentUserGroups;
        }
        $arCurrentUserGroups = $arCache[$taskType . "_" . $ownerId];
        if ($USER->GetID() == $arResult["CREATED_BY"]) {
            $arCurrentUserGroups[] = "author";
        }
        if ($USER->GetID() == $arResult["PROPERTY_TaskAssignedTo"]) {
            $arCurrentUserGroups[] = "responsible";
        }
        if (is_array($arResult["PROPERTY_TaskTrackers"]) && in_array($USER->GetID(), $arResult["PROPERTY_TaskTrackers"])) {
            $arCurrentUserGroups[] = "trackers";
        }
        $arResult["DocumentState"] = array();
        $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $iblockId), array("intranet", "CIntranetTasksDocument", $arResult["ID"]));
        $kk = array_keys($arDocumentStates);
        foreach ($kk as $k) {
            $arResult["DocumentState"] = $arDocumentStates[$k];
            $arResult["DocumentState"]["AllowableEvents"] = CBPDocument::GetAllowableEvents($GLOBALS["USER"]->GetID(), $arCurrentUserGroups, $arDocumentStates[$k]);
        }
        $arResult["TaskType"] = $taskType;
        $arResult["OwnerId"] = $ownerId;
        $arResult["CurrentUserCanViewTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_READ_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
        $arResult["CurrentUserCanCommentTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_COMMENT_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
        $arResult["CurrentUserCanDeleteTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_DELETE_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
        $arResult["CurrentUserCanWriteTask"] = CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_WRITE_DOCUMENT, $GLOBALS["USER"]->GetID(), $arResult["ID"], array("TaskType" => $taskType, "OwnerId" => $ownerId, "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates));
        $arResultList[] = $arResult;
    }
    $dbTasksList = new CDBResult();
    $dbTasksList->InitFromArray($arResultList);
    return $dbTasksList;
}
Beispiel #11
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;
     }
 }
Beispiel #12
0
                    }
                    $bpId = $arBizProcWorkflowId[$bpTemplateId];
                }
                $needUpdateStatesList = true;
                $arErrorTmp = array();
                CBPDocument::SendExternalEvent($bpId, $bpEvent, array("Groups" => $arParams["USER_GROUPS"], "User" => $GLOBALS["USER"]->GetID()), $arErrorTmp);
                if (count($arErrorsTmp) > 0) {
                    foreach ($arErrorsTmp as $e) {
                        $strWarning .= $e["message"] . "<br />";
                    }
                    $arError[] = array("id" => "update_workfow", "text" => $strWarning);
                }
            }
        }
        if ($needUpdateStatesList && empty($arError)) {
            $arResult['DOCUMENT_STATES'] = CBPDocument::GetDocumentStates($arParams["DOCUMENT_TYPE"], $arParams["DOCUMENT_ID"]);
        }
    }
    if (!empty($arError)) {
        $e = new CAdminException($arError);
        $arResult["ERROR_MESSAGE"] = $e->GetString();
    } else {
        $url = !empty($arParams["back_url"]) ? $arParams["back_url"] : $APPLICATION->GetCurPageParam("", array("action", "id", "sessid"));
        $url = empty($_POST["apply"]) ? $url : $APPLICATION->GetCurPageParam("", array("action", "id", "sessid"));
        if (isset($_REQUEST['action'])) {
            LocalRedirect($url);
        }
    }
}
/********************************************************************
				/Action
Beispiel #13
0
// Contacts selector
$arResult['FIELDS']['tab_1'][] = array('id' => 'section_contacts', 'name' => GetMessage('CRM_SECTION_CONTACTS'), 'type' => 'section');
if (CCrmContact::CheckReadPermission(0, $userPermissions)) {
    ob_start();
    $GLOBALS['APPLICATION']->IncludeComponent('bitrix:crm.entity.selector', '', array('ENTITY_TYPE' => 'CONTACT', 'INPUT_NAME' => 'CONTACT_ID', 'INPUT_VALUE' => isset($arResult['CONTACT_ID']) ? $arResult['CONTACT_ID'] : '', 'FORM_NAME' => $arResult['FORM_ID'], 'MULTIPLE' => 'Y'), false, array('HIDE_ICONS' => 'Y'));
    $sVal = ob_get_contents();
    ob_end_clean();
    $arResult['FIELDS']['tab_1'][] = array('id' => 'CONTACT_ID', 'name' => GetMessage('CRM_FIELD_CONTACT_ID'), 'type' => 'custom', 'wrap' => true, 'value' => $sVal);
}
$arResult['FIELDS']['tab_1'][] = array('id' => 'section_additional', 'name' => GetMessage('CRM_SECTION_ADDITIONAL'), 'type' => 'section');
$CCrmUserType->AddFields($arResult['FIELDS']['tab_1'], $arResult['ELEMENT']['ID'], $arResult['FORM_ID'], $bConvert ? isset($arParams['~VARS_FROM_FORM']) && $arParams['~VARS_FROM_FORM'] === true : $bVarsFromForm, false, false, array('FILE_URL_TEMPLATE' => "/bitrix/components/bitrix/crm.company.show/show_file.php?ownerId=#owner_id#&fieldName=#field_name#&fileId=#file_id#"));
if (IsModuleInstalled('bizproc')) {
    CBPDocument::AddShowParameterInit('crm', 'only_users', 'COMPANY');
    $bizProcIndex = 0;
    if (!isset($arDocumentStates)) {
        $arDocumentStates = CBPDocument::GetDocumentStates(array('crm', 'CCrmDocumentCompany', 'COMPANY'), $bEdit ? array('crm', 'CCrmDocumentCompany', 'COMPANY_' . $arResult['ELEMENT']['ID']) : null);
    }
    foreach ($arDocumentStates as $arDocumentState) {
        $bizProcIndex++;
        $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $USER->GetID(), array('crm', 'CCrmDocumentCompany', $bEdit ? 'COMPANY_' . $arResult['ELEMENT']['ID'] : 'COMPANY_0'), array('UserGroups' => $CCrmBizProc->arCurrentUserGroups, 'DocumentStates' => $arDocumentStates, 'WorkflowId' => $arDocumentState['ID'] > 0 ? $arDocumentState['ID'] : $arDocumentState['TEMPLATE_ID'], 'CreatedBy' => $arResult['ELEMENT']['ASSIGNED_BY'], 'UserIsAdmin' => $USER->IsAdmin()));
        if (!$canViewWorkflow) {
            continue;
        }
        $arResult['FIELDS']['tab_1'][] = array('id' => 'section_bp_name_' . $bizProcIndex, 'name' => $arDocumentState['TEMPLATE_NAME'], 'type' => 'section');
        if ($arDocumentState['TEMPLATE_DESCRIPTION'] != '') {
            $arResult['FIELDS']['tab_1'][] = array('id' => 'BP_DESC_' . $bizProcIndex, 'name' => GetMessage('CRM_FIELD_BP_TEMPLATE_DESC'), 'type' => 'label', 'colspan' => true, 'value' => $arDocumentState['TEMPLATE_DESCRIPTION']);
        }
        if (!empty($arDocumentState['STATE_MODIFIED'])) {
            $arResult['FIELDS']['tab_1'][] = array('id' => 'BP_STATE_MODIFIED_' . $bizProcIndex, 'name' => GetMessage('CRM_FIELD_BP_STATE_MODIFIED'), 'type' => 'label', 'value' => $arDocumentState['STATE_MODIFIED']);
        }
        if (!empty($arDocumentState['STATE_NAME'])) {
Beispiel #14
0
 protected function getCommentsProcess($elementId)
 {
     $countComments = 0;
     $this->arResult["ELEMENTS_HEADERS"]["COMMENTS"] = Loc::getMessage("CC_BLL_COMMENTS");
     if (!$this->arResult["BIZPROC"] || !$elementId) {
         return $countComments;
     }
     $documentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($this->arParams["IBLOCK_TYPE_ID"], $this->arResult["IBLOCK_ID"]), BizProcDocument::getDocumentComplexId($this->arParams["IBLOCK_TYPE_ID"], $elementId));
     if (!empty($documentStates)) {
         $state = current($documentStates);
     } else {
         return $countComments;
     }
     $query = CForumTopic::getList(array(), array("@XML_ID" => 'WF_' . $state["ID"]));
     while ($row = $query->fetch()) {
         $countComments = $row["POSTS"];
     }
     return $countComments;
 }
Beispiel #15
0
    }
}
$arTabSection = array(array("id" => "IBLOCK_SECTION_ID", "name" => $arResult["IBLOCK"]["SECTIONS_NAME"], "type" => 'list', "items" => $arResult["LIST_SECTIONS"], "params" => array("size" => 15)));
$arTabs = array(array("id" => "tab_el", "name" => $arResult["IBLOCK"]["ELEMENT_NAME"], "icon" => "", "fields" => $arTabElement), array("id" => "tab_se", "name" => $arResult["IBLOCK"]["SECTION_NAME"], "icon" => "", "fields" => $arTabSection));
$custom_html = "";
if (CModule::IncludeModule("bizproc") && $arResult["IBLOCK"]["BIZPROC"] != "N") {
    $arCurrentUserGroups = $GLOBALS["USER"]->GetUserGroupArray();
    if (!$arResult["ELEMENT_FIELDS"] || $arResult["ELEMENT_FIELDS"]["CREATED_BY"] == $GLOBALS["USER"]->GetID()) {
        $arCurrentUserGroups[] = "Author";
    }
    $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>');
Beispiel #16
0
 function UpdateListItems($listName, $updates)
 {
     global $USER;
     $arPaths = array('user' => COption::GetOptionString('intranet', 'path_task_user_entry', '/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/'), 'group' => COption::GetOptionString('intranet', 'path_task_group_entry', '/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/'));
     if (!$this->__Init()) {
         return $this->error;
     }
     if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
         return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
     }
     $listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
     // one more dirty hack. now for bx.
     //define('BX_INTASKS_FROM_COMPONENT', true);
     //CModule::IncludeModule('socialnetwork');
     //include($_SERVER['DOCUMENT_ROOT'].BX_PERSONAL_ROOT.'/components/bitrix/intranet.tasks/init.php');
     //include($_SERVER['DOCUMENT_ROOT'].BX_PERSONAL_ROOT.'/components/bitrix/intranet.tasks/action.php');
     $obResponse = new CXMLCreator('Results');
     $arStatusValues = array();
     $obStatus = CIBlockProperty::GetPropertyEnum('TaskStatus', array('SORT' => 'asc'), array('IBLOCK_ID' => $this->IBLOCK_ID));
     while ($arStatus = $obStatus->Fetch()) {
         $arStatusValues[$arStatus['XML_ID']] = $arStatus['ID'];
         if ($arStatus['XML_ID'] == 'NotAccepted') {
             $arStatusValues[$arStatus['VALUE']] = $arStatus['ID'];
         }
     }
     /*
     $arPriorityValues = array();
     $obPriority = CIBlockProperty::GetPropertyEnum('TaskPriority', array('SORT' => 'asc'), array('IBLOCK_ID' => $this->IBLOCK_ID));
     while ($arPriority = $obPriority->Fetch())
     	$arPriorityValues[$arPriority['XML_ID']] = $arPriority['ID'];
     */
     $arPriorityValues = array_flip($this->arProperties['TaskPriority']['VARIANTS_ID']);
     $arStatusValues = array_flip($this->arProperties['TaskStatus']['VARIANTS_ID']);
     $arStatusXML_ID = array_flip($this->arProperties['TaskStatus']['VARIANTS']);
     $obBatch = $updates->children[0];
     $atrONERROR = $obBatch->getAttribute('OnError');
     $atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
     $atrPROPERTIES = $obBatch->getAttribute('Properties');
     $arChanges = $obBatch->children;
     $arResultIDs = array();
     $dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
     $arResponseRows = array();
     $arResponseRowsError = array();
     $arReplicationIDs = array();
     foreach ($arChanges as $obMethod) {
         $arData = array('_command' => $obMethod->getAttribute('Cmd'));
         $ID = false;
         $bUpdate = true;
         $arElement = false;
         $arSection = $this->arUsersSection;
         foreach ($obMethod->children as $obField) {
             $name = $obField->getAttribute('Name');
             if ($name == 'MetaInfo') {
                 $name .= '_' . $obField->getAttribute('Property');
             }
             $arData[$name] = $obField->content;
         }
         $obResponseRow = new CXMLCreator('Result');
         $obResponseRow->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
         $obResponseRow->setAttribute('List', $listName);
         $obResponseRow->addChild($obErrorCode = new CXMLCreator('ErrorCode'));
         if ($arData['ID'] > 0) {
             //$dbRes = CIBlockElement::GetByID($arData['ID']);
             $arElement = CIntranetTasks::GetById($arData['ID']);
             if (!is_array($arElement)) {
                 $obErrorCode->setData('0x81020016');
                 $bUpdate = false;
             } else {
                 //$arElement = $obElement->GetFields();
                 //$arElement['prop'] = $obElement->GetProperties();
                 if ($arElement['IBLOCK_SECTION_ID'] != $arSection['ID']) {
                     if (!($arSection = $this->__getSection($arElement['IBLOCK_SECTION_ID']))) {
                         return new CSoapFault('Some error', 'Unknown error with iblock sections');
                     }
                 }
                 // don't forget about depth of sections, Max has modification
                 if ($arElement['taskType'] == "group") {
                     $arGroupTmp = CSocNetGroup::GetByID($arElement['ownerId']);
                     if ($arGroupTmp["CLOSED"] == "Y") {
                         if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
                             return new CSoapFault('Cannot modify archive group task', 'Cannot modify archive group task');
                         }
                     }
                 }
                 $arElement['arParams'] = array($arElement['taskType'] == 'user' ? 'PATH_TO_USER_TASKS_TASK' : 'PATH_TO_GROUP_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $arElement['ID']), $arPaths[$arElement['taskType']]));
             }
         }
         if ($bUpdate) {
             if ($arData['_command'] == 'Delete') {
                 $arError = false;
                 if (CIntranetTasksDocument::CanUserOperateDocument(INTASK_DOCUMENT_OPERATION_DELETE_DOCUMENT, $USER->GetID(), $arElement['ID'], array())) {
                     if (!CIntranetTasks::Delete($arElement['ID'], $arError)) {
                         $obErrorCode->setData('0x81020014');
                     } else {
                         $obErrorCode->setData('0x00000000');
                     }
                 } else {
                     $obErrorCode->setData('0x81020014');
                 }
                 /*
                 	0x00000000 - ok
                 	0x81020015 - data conflict
                 	0x81020014 - generic error such as invalid value for Field
                 	0x81020016 - item does not exist
                 */
             } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') {
                 /*
                 $arData['Body'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Body']);
                 $arData['Body'] = strip_tags($arData['Body']);
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = htmlspecialcharsback($arData['Body']);
                 */
                 $arData['Body'] = trim($arData['Body']);
                 $arData['Body'] = str_replace(array("&#10;", "&#13;", '&nbsp;'), "", $arData['Body']);
                 $arData['Body'] = preg_replace("/<![^>]*>/", '', $arData['Body']);
                 if (($pos = strpos($arData['Body'], '<BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], $pos + 6);
                 }
                 echo $pos . ' ';
                 if (($pos = strpos($arData['Body'], '</BODY>')) !== false) {
                     $arData['Body'] = substr($arData['Body'], 0, $pos);
                 }
                 echo $pos . ' ';
                 $TZBias = intval(date('Z'));
                 $arData['StartDate'] = $arData['StartDate'] ? $this->__makeTS($arData['StartDate']) + $TZBias : '';
                 $arData['DueDate'] = $arData['DueDate'] ? $this->__makeTS($arData['DueDate']) + $TZBias : '';
                 $arData['MetaInfo_DateComplete'] = $arData['MetaInfo_DateComplete'] ? $this->__makeTS($arData['EndDate']) + $TZBias : '';
                 if ($arData['Status'] == $arStatusValues['NotAccepted']) {
                     $arData['Status'] = 'NotAccepted';
                 }
                 $arFields = array('IBLOCK_ID' => $this->IBLOCK_ID, 'IBLOCK_SECTION_ID' => $arSection['ID'], 'MODIFIED_BY' => $USER->GetID(), 'NAME' => $arData['Title'] ? $arData['Title'] : GetMessage('INTR_OUTLOOK_TASK_NO_TITLE'), 'DATE_ACTIVE_FROM' => $arData['StartDate'] ? ConvertTimeStamp($arData['StartDate']) : '', 'DATE_ACTIVE_TO' => $arData['DueDate'] ? ConvertTimeStamp($arData['DueDate']) : '', 'DETAIL_TEXT_TYPE' => 'html', 'DETAIL_TEXT' => $arData['Body'], 'PROPERTY_TaskPriority' => $arData['Priority'] ? $arPriorityValues[$arData['Priority']] : false, 'PROPERTY_TaskComplete' => $arData['PercentComplete'] * 100, 'PROPERTY_TaskSize' => $arData['MetaInfo_TotalWork'] / 60, 'PROPERTY_TaskSizeReal' => $arData['MetaInfo_ActualWork'] / 60, 'PROPERTY_TaskFinish' => $arData['MetaInfo_DateComplete'] ? ConvertTimeStamp($arData['MetaInfo_DateComplete']) : '');
                 if (false === $arFields['PROPERTY_TaskPriority']) {
                     $arPrior = array_keys($arElement['PROPERTY_TaskPriority']);
                     $arFields['PROPERTY_TaskPriority'] = $arPrior[0];
                 }
                 if ($assigned_to = $arData['AssignedTo']) {
                     if ($USER_ID = $this->__getUser($assigned_to)) {
                         $arFields['PROPERTY_TaskAssignedTo'] = $USER_ID;
                     } else {
                         $obErrorCode->setData('0x81020054');
                         $bUpdate = false;
                     }
                 }
                 if ($bUpdate) {
                     $bConfirm = false;
                     $bComplete = false;
                     if ($arData['_command'] != 'New') {
                         if (false && $arElement['PROPERTY_VERSION'] > $arData['owshiddenversion']) {
                             $obErrorCode->setData('0x81020015');
                             $bUpdate = false;
                         } else {
                             foreach ($arElement as $fld => $value) {
                                 if (substr($fld, 0, 9) == 'PROPERTY_') {
                                     if (!$arFields[$fld] && $fld != 'PROPERTY_TaskFiles') {
                                         $arFields[$fld] = $arElement[$fld];
                                     }
                                 }
                             }
                             $arFields['PROPERTY_VERSION']++;
                         }
                         $statusOld = $this->__GetTaskStatus($arElement['ID'], $arElement['IBLOCK_ID']);
                     } else {
                         $arFields['PROPERTY_VERSION'] = $arData['owshiddenversion'];
                         $statusOld = -1;
                     }
                     if (!$arFields['PROPERTY_TaskPriority']) {
                         $arFields['PROPERTY_TaskPriority'] = 2;
                     }
                     if (!$arFields['PROPERTY_TaskAssignedTo']) {
                         $arFields['PROPERTY_TaskAssignedTo'] = $USER->GetID();
                     } elseif ($arFields['PROPERTY_TaskAssignedTo'] != $USER->GetID()) {
                         $arData['Status'] = 'NotAccepted';
                     }
                     $statusNew = $arData['Status'] ? $arStatusXML_ID[$arData['Status']] : $statusOld;
                     $ID = 0;
                     if ($bUpdate) {
                         $arError = false;
                         if ($arData['_command'] == 'New') {
                             if ($ID = CIntranetTasks::Add($arFields, $arError)) {
                                 $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $this->IBLOCK_ID), null);
                                 $arDocumentStates = array_values($arDocumentStates);
                                 $pathTemplate = str_replace(array("#USER_ID#", "#TASK_ID#"), array($USER->GetID(), "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
                                 $arErrors = array();
                                 CBPDocument::StartWorkflow($arDocumentStates[0]["TEMPLATE_ID"], array("intranet", "CIntranetTasksDocument", $ID), array("OwnerId" => $arFields['PROPERTY_TaskAssignedTo'], "TaskType" => 'user', "PathTemplate" => $pathTemplate, "ForumId" => COption::GetOptionInt('intranet', 'task_forum_id', 0), "IBlockId" => $this->IBLOCK_ID), $arErrors);
                                 CIntranetTasks::ChangeStatus($ID, $statusNew);
                                 $arReplicationIDs[$ID] = $arData['MetaInfo_ReplicationID'];
                                 $obErrorCode->setData('0x00000000');
                             }
                         } else {
                             if (CIntranetTasks::Update($arData['ID'], $arFields, $arError)) {
                                 if ($statusOld != $statusNew) {
                                     CIntranetTasks::ChangeStatus($arData['ID'], $statusNew);
                                 }
                                 $ID = $arData['ID'];
                                 $obErrorCode->setData('0x00000000');
                             }
                         }
                         if (is_array($arError) && count($arError) > 0) {
                             $ID = 0;
                             $obErrorCode->setData('0x81020014');
                             $bUpdate = false;
                         } else {
                             $taskType = $arElement ? $arElement['taskType'] : 'user';
                             $ownerId = $arElement ? $arElement['ownerId'] : $USER->GetID();
                             $arParams = $arElement ? $arElement['arParams'] : array('PATH_TO_USER_TASKS_TASK' => str_replace(array('#USER_ID#', '#GROUP_ID#', '#TASK_ID#'), array($USER->GetID(), $arSection['XML_ID'], $ID), $arPaths['user']));
                         }
                     }
                 }
             }
         }
         if ($ID > 0) {
             $arResponseRows[$ID] = $obResponseRow;
         } else {
             $arResponseRowsError[] = $obResponseRow;
         }
     }
     $dbRes = CIntranetTasks::GetList(array('ID' => 'ASC'), array('IBLOCK_ID' => $this->IBLOCK_ID, 'ID' => array_keys($arResponseRows)));
     while ($arRes = $dbRes->Fetch()) {
         if ($arResponseRows[$arRes['ID']]) {
             $obRow = $this->__getRow($arRes, $listName, $last_change = 0);
             if ($arReplicationIDs[$arRes['ID']]) {
                 $obRow->setAttribute('ows_MetaInfo_ReplicationID', $arReplicationIDs[$arRes['ID']]);
             }
             $obRow->setAttribute('xmlns:z', "#RowsetSchema");
             $arResponseRows[$arRes['ID']]->addChild($obRow);
             $obResponse->addChild($arResponseRows[$arRes['ID']]);
         }
     }
     foreach ($arResponseRowsError as $obChange) {
         $obResponse->addChild($obChange);
     }
     return array('UpdateListItemsResult' => $obResponse);
 }
         }
     }
     if ($bError) {
         $arResult["ERRORS"][] = str_replace("#PROPERTY_NAME#", intval($propertyID) > 0 ? $arResult["PROPERTY_LIST_FULL"][$propertyID]["NAME"] : (!empty($arParams["CUSTOM_TITLE_" . $propertyID]) ? $arParams["CUSTOM_TITLE_" . $propertyID] : GetMessage("IBLOCK_FIELD_" . $propertyID)), GetMessage("IBLOCK_ADD_ERROR_REQUIRED"));
     }
 }
 // check captcha
 if ($arParams["USE_CAPTCHA"] == "Y" && $arParams["ID"] <= 0) {
     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) {
Beispiel #18
0
$APPLICATION->IncludeComponent('bitrix:crm.product_row.list', '', $componentSettings, false, array('HIDE_ICONS' => 'Y', 'ACTIVE_COMPONENT' => 'Y'));
$sProductsHtml .= ob_get_contents();
ob_end_clean();
unset($componentSettings);
$arResult['FIELDS']['tab_1'][] = array('id' => 'PRODUCT_ROWS', 'name' => GetMessage('CRM_FIELD_PRODUCT_ROWS'), 'colspan' => true, 'type' => 'custom', 'value' => $sProductsHtml);
$arResult['FIELDS']['tab_1'][] = array('id' => 'section_additional', 'name' => GetMessage('CRM_SECTION_ADDITIONAL'), 'type' => 'section');
$icnt = count($arResult['FIELDS']['tab_1']);
$CCrmUserType->AddFields($arResult['FIELDS']['tab_1'], $arResult['ELEMENT']['ID'], $arResult['FORM_ID'], $bConvert ? isset($arParams['~VARS_FROM_FORM']) && $arParams['~VARS_FROM_FORM'] === true : $bVarsFromForm, false, false, array('FILE_URL_TEMPLATE' => "/bitrix/components/bitrix/crm.deal.show/show_file.php?ownerId=#owner_id#&fieldName=#field_name#&fileId=#file_id#"));
if (count($arResult['FIELDS']['tab_1']) == $icnt) {
    unset($arResult['FIELDS']['tab_1'][$icnt - 1]);
}
if (IsModuleInstalled('bizproc')) {
    CBPDocument::AddShowParameterInit('crm', 'only_users', 'DEAL');
    $bizProcIndex = 0;
    if (!isset($arDocumentStates)) {
        $arDocumentStates = CBPDocument::GetDocumentStates(array('crm', 'CCrmDocumentDeal', 'DEAL'), $bEdit ? array('crm', 'CCrmDocumentDeal', 'DEAL_' . $arResult['ELEMENT']['ID']) : null);
    }
    foreach ($arDocumentStates as $arDocumentState) {
        $bizProcIndex++;
        $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $USER->GetID(), array('crm', 'CCrmDocumentDeal', $bEdit ? 'DEAL_' . $arResult['ELEMENT']['ID'] : 'DEAL_0'), array('UserGroups' => $CCrmBizProc->arCurrentUserGroups, 'DocumentStates' => $arDocumentStates, 'WorkflowId' => $arDocumentState['ID'] > 0 ? $arDocumentState['ID'] : $arDocumentState['TEMPLATE_ID'], 'CreatedBy' => $arResult['ELEMENT']['ASSIGNED_BY'], 'UserIsAdmin' => $USER->IsAdmin()));
        if (!$canViewWorkflow) {
            continue;
        }
        $arResult['FIELDS']['tab_1'][] = array('id' => 'section_bp_name_' . $bizProcIndex, 'name' => $arDocumentState['TEMPLATE_NAME'], 'type' => 'section');
        if ($arDocumentState['TEMPLATE_DESCRIPTION'] != '') {
            $arResult['FIELDS']['tab_1'][] = array('id' => 'BP_DESC_' . $bizProcIndex, 'name' => GetMessage('CRM_FIELD_BP_TEMPLATE_DESC'), 'type' => 'label', 'colspan' => true, 'value' => $arDocumentState['TEMPLATE_DESCRIPTION']);
        }
        if (!empty($arDocumentState['STATE_MODIFIED'])) {
            $arResult['FIELDS']['tab_1'][] = array('id' => 'BP_STATE_MODIFIED_' . $bizProcIndex, 'name' => GetMessage('CRM_FIELD_BP_STATE_MODIFIED'), 'type' => 'label', 'value' => $arDocumentState['STATE_MODIFIED']);
        }
        if (!empty($arDocumentState['STATE_NAME'])) {
Beispiel #19
0
     } else {
         $arPOSTRights = array();
     }
     if ($ELEMENT_ID) {
         $obRights = new CIBlockElementRights($arResult["IBLOCK_ID"], $ELEMENT_ID);
     } else {
         $obRights = new CIBlockSectionRights($arResult["IBLOCK_ID"], $SECTION_ID);
     }
     $arDBRights = $obRights->GetRights();
     $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();
Beispiel #20
0
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    $arResult["Block"] = null;
    $db = CIBlock::GetList(array(), array("ID" => $arParams["BLOCK_ID"], "TYPE" => $arParams["IBLOCK_TYPE"], "ACTIVE" => "Y"));
    if ($ar = $db->GetNext()) {
        $arResult["Block"] = $ar;
    } else {
        $arResult["FatalErrorMessage"] .= GetMessage("BPWC_WRC_WRONG_IBLOCK") . ". ";
    }
}
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    $arResult["AdminAccess"] = $USER->IsAdmin() || is_array($arParams["ADMIN_ACCESS"]) && count(array_intersect($USER->GetUserGroupArray(), $arParams["ADMIN_ACCESS"])) > 0;
    $arMessagesTmp = CIBlock::GetMessages($arResult["Block"]["ID"]);
    $arResult["CreateTitle"] = htmlspecialcharsbx(is_array($arMessagesTmp) && array_key_exists("ELEMENT_ADD", $arMessagesTmp) ? $arMessagesTmp["ELEMENT_ADD"] : "");
    $arResult["ShowMode"] = "SelectWorkflow";
    $documentType = array("bizproc", "CBPVirtualDocument", "type_" . $arParams["BLOCK_ID"]);
    $arDocumentTypeStates = CBPDocument::GetDocumentStates($documentType, null);
    $arCurrentUserGroups = $GLOBALS["USER"]->GetUserGroupArray();
    $arCurrentUserGroups[] = "user_" . $GLOBALS["USER"]->GetID();
    $ks = array_keys($arCurrentUserGroups);
    foreach ($ks as $k) {
        $arCurrentUserGroups[$k] = strtolower($arCurrentUserGroups[$k]);
    }
    $arResult["TEMPLATES"] = array();
    foreach ($arDocumentTypeStates as $arState) {
        $bUserCanAcess = false;
        if ($arResult["AdminAccess"] || !is_array($arState["STATE_PERMISSIONS"]) || count($arState["STATE_PERMISSIONS"]) <= 0) {
            $bUserCanAcess = true;
        } else {
            if (array_key_exists("create", $arState["STATE_PERMISSIONS"])) {
                if (in_array("author", $arState["STATE_PERMISSIONS"]["create"])) {
                    $bUserCanAcess = true;
Beispiel #21
0
            if (CheckDateTime($arRecord[$key])) {
                $arRecord[$key] = FormatDateFromDB($arRecord[$key]);
            }
        }
        $arResult["BP"] = $arRecord;
    } else {
        $arResult["FatalErrorMessage"] .= GetMessage("BPWC_WLC_WRONG_BP") . ". ";
    }
}
if (strlen($arResult["FatalErrorMessage"]) <= 0) {
    $arCurrentUserGroups = $GLOBALS["USER"]->GetUserGroupArray();
    if ("user_" . $GLOBALS["USER"]->GetID() == $arResult["BP"]["CREATED_BY"]) {
        $arCurrentUserGroups[] = "author";
    }
    $documentId = array("bizproc", "CBPVirtualDocument", $arResult["BP"]["ID"]);
    $arDocumentStates = CBPDocument::GetDocumentStates($documentType, $documentId);
    foreach ($arDocumentStates as $arDocumentState) {
        $arResult["BP"]["DOCUMENT_STATE"] = $arDocumentState;
        $ar = CBPDocument::GetAllowableEvents($GLOBALS["USER"]->GetID(), $arCurrentUserGroups, $arDocumentState);
        foreach ($ar as $ar1) {
            $ar1["URL"] = $APPLICATION->GetCurPageParam("bizproc_id=" . $arDocumentState["ID"] . "&process_state_event=Y&bizproc_event=" . htmlspecialcharsbx($ar1["NAME"]) . "&" . bitrix_sessid_get(), array("sessid", "stop_bizproc_id", "process_state_event", "bizproc_event", "bizproc_id"));
            $arResult["BP"]["DOCUMENT_STATE_EVENTS"][] = $ar1;
        }
        if (count($arResult["BP"]["DOCUMENT_STATE_EVENTS"]) > 0) {
            $arResult["ShowStateEvents"] = true;
        }
        $arResult["BP"]["DOCUMENT_STATE_TASKS"] = array();
        $ar = CBPDocument::GetUserTasksForWorkflow($GLOBALS["USER"]->GetID(), $arDocumentState["ID"]);
        foreach ($ar as $ar1) {
            $ar1["URL"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_TASK"], array("task_id" => $ar1["ID"], "block_id" => $arParams["BLOCK_ID"]));
            $arResult["BP"]["DOCUMENT_STATE_TASKS"][] = $ar1;
Beispiel #22
0
$sVal = ob_get_contents();
ob_end_clean();
$arResult['FIELDS']['tab_1'][] = array('id' => 'COMMENTS', 'name' => GetMessage('CRM_FIELD_COMMENTS'), 'params' => array(), 'type' => 'vertical_container', 'value' => $sVal);
$arResult['FIELDS']['tab_1'][] = array('id' => 'OPENED', 'name' => GetMessage('CRM_FIELD_OPENED'), 'type' => 'vertical_checkbox', 'params' => array(), 'value' => isset($arResult['ELEMENT']['OPENED']) ? $arResult['ELEMENT']['OPENED'] : true, 'title' => GetMessage('CRM_FIELD_OPENED_TITLE'));
$arResult['FIELDS']['tab_1'][] = array('id' => 'EXPORT', 'name' => GetMessage('CRM_FIELD_EXPORT'), 'type' => 'vertical_checkbox', 'params' => array(), 'value' => isset($arResult['ELEMENT']['EXPORT']) ? $arResult['ELEMENT']['EXPORT'] : 'Y');
$arResult['FIELDS']['tab_1'][] = array('id' => 'section_additional', 'name' => GetMessage('CRM_SECTION_ADDITIONAL'), 'type' => 'section');
$arResult['FIELDS']['tab_1'][] = array('id' => 'TYPE_ID', 'name' => GetMessage('CRM_FIELD_TYPE_ID'), 'type' => 'list', 'items' => $arResult['TYPE_LIST'], 'value' => isset($arResult['ELEMENT']['TYPE_ID']) ? $arResult['ELEMENT']['TYPE_ID'] : '');
$arResult['FIELDS']['tab_1'][] = array('id' => 'ASSIGNED_BY_ID', 'componentParams' => array('NAME' => 'crm_contact_edit_resonsible', 'INPUT_NAME' => 'ASSIGNED_BY_ID', 'SEARCH_INPUT_NAME' => 'ASSIGNED_BY_NAME', 'NAME_TEMPLATE' => $arParams['NAME_TEMPLATE']), 'name' => GetMessage('CRM_FIELD_ASSIGNED_BY_ID'), 'type' => 'intranet_user_search', 'value' => isset($arResult['ELEMENT']['ASSIGNED_BY_ID']) ? $arResult['ELEMENT']['ASSIGNED_BY_ID'] : $USER->GetID());
$arResult['FIELDS']['tab_1'][] = array('id' => 'SOURCE_ID', 'name' => GetMessage('CRM_FIELD_SOURCE_ID'), 'type' => 'list', 'items' => $arResult['SOURCE_LIST'], 'value' => isset($arResult['ELEMENT']['~SOURCE_ID']) ? $arResult['ELEMENT']['~SOURCE_ID'] : '');
$arResult['FIELDS']['tab_1'][] = array('id' => 'SOURCE_DESCRIPTION', 'name' => GetMessage('CRM_FIELD_SOURCE_DESCRIPTION'), 'type' => 'textarea', 'params' => array(), 'value' => isset($arResult['ELEMENT']['SOURCE_DESCRIPTION']) ? $arResult['ELEMENT']['SOURCE_DESCRIPTION'] : '');
$CCrmUserType->AddFields($arResult['FIELDS']['tab_1'], $arResult['ELEMENT']['ID'], $arResult['FORM_ID'], $bConvert ? isset($arParams['~VARS_FROM_FORM']) && $arParams['~VARS_FROM_FORM'] === true : $varsFromForm, false, false, array('FILE_URL_TEMPLATE' => "/bitrix/components/bitrix/crm.contact.show/show_file.php?ownerId=#owner_id#&fieldName=#field_name#&fileId=#file_id#"));
if (IsModuleInstalled('bizproc')) {
    CBPDocument::AddShowParameterInit('crm', 'only_users', 'CONTACT');
    $bizProcIndex = 0;
    if (!isset($arDocumentStates)) {
        $arDocumentStates = CBPDocument::GetDocumentStates(array('crm', 'CCrmDocumentContact', 'CONTACT'), $bEdit ? array('crm', 'CCrmDocumentContact', 'CONTACT_' . $arResult['ELEMENT']['ID']) : null);
    }
    foreach ($arDocumentStates as $arDocumentState) {
        $bizProcIndex++;
        $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $USER->GetID(), array('crm', 'CCrmDocumentContact', $bEdit ? 'CONTACT_' . $arResult['ELEMENT']['ID'] : 'CONTACT_0'), array('UserGroups' => $CCrmBizProc->arCurrentUserGroups, 'DocumentStates' => $arDocumentStates, 'WorkflowId' => $arDocumentState['ID'] > 0 ? $arDocumentState['ID'] : $arDocumentState['TEMPLATE_ID'], 'CreatedBy' => $arResult['ELEMENT']['ASSIGNED_BY'], 'UserIsAdmin' => $USER->IsAdmin()));
        if (!$canViewWorkflow) {
            continue;
        }
        $arResult['FIELDS']['tab_1'][] = array('id' => 'section_bp_name_' . $bizProcIndex, 'name' => $arDocumentState['TEMPLATE_NAME'], 'type' => 'section');
        if ($arDocumentState['TEMPLATE_DESCRIPTION'] != '') {
            $arResult['FIELDS']['tab_1'][] = array('id' => 'BP_DESC_' . $bizProcIndex, 'name' => GetMessage('CRM_FIELD_BP_TEMPLATE_DESC'), 'type' => 'label', 'colspan' => true, 'value' => $arDocumentState['TEMPLATE_DESCRIPTION']);
        }
        if (!empty($arDocumentState['STATE_MODIFIED'])) {
            $arResult['FIELDS']['tab_1'][] = array('id' => 'BP_STATE_MODIFIED_' . $bizProcIndex, 'name' => GetMessage('CRM_FIELD_BP_STATE_MODIFIED'), 'type' => 'label', 'value' => $arDocumentState['STATE_MODIFIED']);
        }
        if (!empty($arDocumentState['STATE_NAME'])) {
Beispiel #23
0
 function CanUserOperateDocumentType($operation, $userId, $documentType, $arParameters = array())
 {
     $documentType = trim($documentType);
     if (strlen($documentType) <= 0) {
         return false;
     }
     $userId = intval($userId);
     if (array_key_exists("UserIsAdmin", $arParameters)) {
         if ($arParameters["UserIsAdmin"] === true) {
             return true;
         }
     } else {
         $arGroups = CUser::GetUserGroup($userId);
         if (in_array(1, $arGroups)) {
             return true;
         }
     }
     if (!array_key_exists("AllUserGroups", $arParameters)) {
         if (!array_key_exists("UserGroups", $arParameters)) {
             $arParameters["UserGroups"] = CUser::GetUserGroup($userId);
         }
         $arParameters["AllUserGroups"] = $arParameters["UserGroups"];
         $arParameters["AllUserGroups"][] = "author";
     }
     if (!array_key_exists("DocumentStates", $arParameters)) {
         $arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(array("bizproc", "CBPVirtualDocument", $documentType), null);
     }
     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 - workflow is not a statemachine
     // $arAllowableOperations == array() - no allowable operations
     // $arAllowableOperations == array("read", ...) - allowable operations list
     if (!is_array($arAllowableOperations) && $operation != 4) {
         return true;
     }
     if ($operation == 4) {
         return true;
     }
     $r = false;
     switch ($operation) {
         case 0:
             // DOCUMENT_OPERATION_VIEW_WORKFLOW
             $r = false;
             break;
         case 1:
             // DOCUMENT_OPERATION_START_WORKFLOW
             $r = in_array("create", $arAllowableOperations);
             break;
         case 4:
             // DOCUMENT_OPERATION_CREATE_WORKFLOW
             $r = false;
             break;
         case 2:
             // DOCUMENT_OPERATION_WRITE_DOCUMENT
             $r = in_array("create", $arAllowableOperations);
             break;
         case 3:
             // DOCUMENT_OPERATION_READ_DOCUMENT
             $r = false;
             break;
         default:
             $r = false;
     }
     return $r;
 }
Beispiel #24
0
 protected function getArrayBizproc($data = array())
 {
     $currentUserId = $GLOBALS["USER"]->GetID();
     $html = "";
     if ($this->arResult["IBLOCK"]["BIZPROC"] == "Y" && CModule::IncludeModule('bizproc')) {
         $this->arResult["ELEMENTS_HEADERS"]["BIZPROC"] = array("name" => Loc::getMessage("CC_BLL_COLUMN_BIZPROC"), "default" => true, "sort" => false);
         $arDocumentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($this->arParams["IBLOCK_TYPE_ID"], $this->arResult["IBLOCK_ID"]), BizProcDocument::getDocumentComplexId($this->arParams["IBLOCK_TYPE_ID"], $data["ID"]));
         $userGroups = $GLOBALS["USER"]->GetUserGroupArray();
         if ($data["~CREATED_BY"] == $currentUserId) {
             $userGroups[] = "Author";
         }
         $ii = 0;
         foreach ($arDocumentStates as $workflowId => $workflowState) {
             if (strlen($workflowState["TEMPLATE_NAME"]) > 0) {
                 $html .= "" . $workflowState["TEMPLATE_NAME"] . ":\r\n";
             } else {
                 $html .= "" . ++$ii . ":\r\n";
             }
             $html .= "" . (strlen($workflowState["STATE_TITLE"]) > 0 ? $workflowState["STATE_TITLE"] : $workflowState["STATE_NAME"]) . "\r\n";
         }
     }
     return $html;
 }
Beispiel #25
0
 function CanUserOperateDocumentType($operation, $userId, $documentType, $arParameters = array())
 {
     $documentType = trim($documentType);
     if (strlen($documentType) <= 0) {
         return false;
     }
     $arParameters["IBlockId"] = intval(substr($documentType, strlen("iblock_")));
     if (!array_key_exists("IBlockRightsMode", $arParameters)) {
         $arParameters["IBlockRightsMode"] = CIBlock::GetArrayByID($arParameters["IBlockId"], "RIGHTS_MODE");
     }
     if ($arParameters["IBlockRightsMode"] === "E") {
         if ($operation === CBPCanUserOperateOperation::CreateWorkflow) {
             return CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "iblock_rights_edit");
         } elseif ($operation === CBPCanUserOperateOperation::WriteDocument) {
             return CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "section_element_bind");
         } elseif ($operation === CBPCanUserOperateOperation::ViewWorkflow || $operation === CBPCanUserOperateOperation::StartWorkflow) {
             if (!array_key_exists("WorkflowId", $arParameters)) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::ViewWorkflow && !CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "element_read")) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::StartWorkflow && !CIBlockRights::UserHasRightTo($arParameters["IBlockId"], $arParameters["IBlockId"], "section_element_bind")) {
                 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"];
                 $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"]), null);
                 }
             }
             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" : "section_element_bind";
             foreach ($arAllowableOperations as $op) {
                 $ar = CTask::GetOperations($op, true);
                 if (in_array($chop, $ar)) {
                     return true;
                 }
             }
         }
         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"];
         $arParameters["AllUserGroups"][] = "Author";
     }
     if (!array_key_exists("DocumentStates", $arParameters)) {
         $arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", "iblock_" . $arParameters["IBlockId"]), null);
     }
     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 = in_array("write", $arAllowableOperations);
             break;
         case CBPCanUserOperateOperation::WriteDocument:
             $r = in_array("write", $arAllowableOperations);
             break;
         case CBPCanUserOperateOperation::ReadDocument:
             $r = false;
             break;
         default:
             $r = false;
     }
     return $r;
 }
 /**
  * Метод проверяет права на выполнение операций над документами заданного типа. Проверяются операции 4 - право изменять шаблоны рабочий потоков для данного типа документа.
  *
  * @param int $operation - операция.
  * @param int $userId - код пользователя, для которого проверяется право на выполнение операции.
  * @param string $documentId - код типа документа, к которому применяется операция.
  * @param array $arParameters - ассициативный массив вспомогательных параметров. Используется для того, чтобы не рассчитывать заново те вычисляемые значения, которые уже известны на момент вызова метода. Стандартными являются ключи массива DocumentStates - массив состояний рабочих потоков данного документа, WorkflowId - код рабочего потока (если требуется проверить операцию на одном рабочем потоке). Массив может быть дополнен другими произвольными ключами.
  * @return bool
  */
 function CanUserOperateDocumentType($operation, $userId, $documentType, $arParameters = array())
 {
     $documentType = trim($documentType);
     if (strlen($documentType) <= 0) {
         return false;
     }
     if ($storage = self::needProxyToDiskByDocType($documentType)) {
         return self::proxyToDisk(__FUNCTION__, array($operation, $userId, \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentType($storage->getId()), $arParameters));
     }
     $userId = intval($userId);
     global $USER;
     // Если пользователь является администратором модуля соц. сети, то возвращаем true
     if ($USER->IsAuthorized() && $USER->GetID() == $userId && CSocNetUser::IsCurrentUserModuleAdmin()) {
         return true;
     }
     $res = explode("_", $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;
     } 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 ($arParameters["IBlockPermission"] < "R") {
         return false;
     } elseif ($arParameters["IBlockPermission"] >= "W") {
         return true;
     }
     // Если мы тут, то инфоблочные права равны U
     // Если нам явно не сказали, то узнаем группы пользователя
     if (!array_key_exists("AllUserGroups", $arParameters)) {
         $arParameters["AllUserGroups"] = CIBlockDocumentWebdavSocnet::GetUserGroups($documentType, null, $userId);
     }
     // Если нам явно не сказали, то узнаем текущие статусы документа
     if (!array_key_exists("DocumentStates", $arParameters)) {
         $arParameters["DocumentStates"] = CBPDocument::GetDocumentStates(array("webdav", "CIBlockDocumentWebdavSocnet", "x"), null);
     }
     // Если нужно проверить только для одного рабочего потока
     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 CBPCanUserOperateOperation::ViewWorkflow:
             $r = false;
             break;
         case CBPCanUserOperateOperation::StartWorkflow:
             $r = false;
             break;
         case CBPCanUserOperateOperation::CreateWorkflow:
             $r = in_array("write", $arAllowableOperations);
             break;
         case CBPCanUserOperateOperation::WriteDocument:
             $r = in_array("write", $arAllowableOperations);
             break;
         case CBPCanUserOperateOperation::ReadDocument:
             $r = false;
             break;
         default:
             $r = false;
     }
     return $r;
 }
Beispiel #27
0
        } elseif (strlen($arr1["STATE_MODIFIED"]) > 0 && strlen($arr1["STATE_MODIFIED"]) <= 0) {
            return 1;
        }
        $res1 = MakeTimeStamp($arr1["STATE_MODIFIED"]);
        $res2 = MakeTimeStamp($arr2["STATE_MODIFIED"]);
        return $res1 < $res2 ? 1 : -1;
    }
}
if (!empty($arResult["ERROR_MESSAGE"])) {
    ShowError($arResult["ERROR_MESSAGE"]);
}
CBPDocument::AddShowParameterInit($arParams["MODULE_ID"], "only_users", $arParams["DOCUMENT_TYPE"]);
$bizProcIndex = 0;
$bEmpty = true;
$bShowButtons = false;
$arDocumentStates = CBPDocument::GetDocumentStates($arParams["DOCUMENT_TYPE"], $arParams["DOCUMENT_ID"]);
$arGroups = CBPDocument::GetAllowableUserGroups($arParams["DOCUMENT_TYPE"]);
$arUsers = array();
uasort($arDocumentStates, "__bp_sort_in_template_by_modified");
?>
<div class="bizproc-page-document">

<form action="<?php 
echo POST_FORM_ACTION_URI;
?>
" method="POST" class="bizproc-form" name="start_workflow_form1" id="start_workflow_form1">
	<?php 
echo bitrix_sessid_post();
?>
	<input type="hidden" name="back_url" value="<?php 
echo htmlspecialcharsbx($arParams["back_url"]);
Beispiel #28
0
 $arLead['LEAD_FORMATTED_NAME'] = htmlspecialcharsbx($arLead['~LEAD_FORMATTED_NAME']);
 if (isset($arLead['~ACTIVITY_TIME'])) {
     $time = MakeTimeStamp($arLead['ACTIVITY_TIME']);
     $arLead['~ACTIVITY_EXPIRED'] = $time <= $now;
     $arLead['~ACTIVITY_IS_CURRENT_DAY'] = $arLead['~ACTIVITY_EXPIRED'] || CCrmActivity::IsCurrentDay($time);
 }
 if ($arResult['ENABLE_TASK']) {
     $arLead['PATH_TO_TASK_EDIT'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate(COption::GetOptionString('tasks', 'paths_task_user_edit', ''), array('task_id' => 0, 'user_id' => $userID)), array('UF_CRM_TASK' => 'L_' . $arLead['ID'], 'TITLE' => urlencode(GetMessage('CRM_TASK_TITLE_PREFIX')), 'TAGS' => urlencode(GetMessage('CRM_TASK_TAG')), 'back_url' => urlencode($arParams['PATH_TO_LEAD_LIST'])));
 }
 if (IsModuleInstalled('sale')) {
     $arLead['PATH_TO_QUOTE_ADD'] = CHTTP::urlAddParams(CComponentEngine::makePathFromTemplate($arParams['PATH_TO_QUOTE_EDIT'], array('quote_id' => 0)), array('lead_id' => $arLead['ID']));
 }
 if ($arResult['ENABLE_BIZPROC']) {
     $arLead['BIZPROC_STATUS'] = '';
     $arLead['BIZPROC_STATUS_HINT'] = '';
     $arDocumentStates = CBPDocument::GetDocumentStates(array('crm', 'CCrmDocumentLead', 'LEAD'), array('crm', 'CCrmDocumentLead', 'LEAD_' . $arLead['ID']));
     $arLead['PATH_TO_BIZPROC_LIST'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_LEAD_SHOW'], array('lead_id' => $arLead['ID'])), array('CRM_LEAD_SHOW_V12_active_tab' => 'tab_bizproc'));
     $totalTaskQty = 0;
     $docStatesQty = count($arDocumentStates);
     if ($docStatesQty === 1) {
         $arDocState = $arDocumentStates[array_shift(array_keys($arDocumentStates))];
         $docTemplateID = $arDocState['TEMPLATE_ID'];
         $paramName = "BIZPROC_{$docTemplateID}";
         $docTtl = isset($arDocState['STATE_TITLE']) ? $arDocState['STATE_TITLE'] : '';
         $docName = isset($arDocState['STATE_NAME']) ? $arDocState['STATE_NAME'] : '';
         $docTemplateName = isset($arDocState['TEMPLATE_NAME']) ? $arDocState['TEMPLATE_NAME'] : '';
         if ($isInExportMode) {
             $arLead[$paramName] = $docTtl;
         } else {
             $arLead[$paramName] = '<a href="' . htmlspecialcharsbx($arLead['PATH_TO_BIZPROC_LIST']) . '">' . htmlspecialcharsbx($docTtl) . '</a>';
             $docID = $arDocState['ID'];
Beispiel #29
0
 protected function processActionCheckDataElementCreation()
 {
     if ($_POST["save"] != "Y" && $_POST["changePostFormTab"] != "lists" && !check_bitrix_sessid()) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK'))));
     }
     if (!Loader::IncludeModule('bizproc')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_BIZPROC'))));
     }
     if (!Loader::includeModule('iblock')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_CONNECTION_MODULE_IBLOCK'))));
     }
     $this->iblockId = intval($this->request->getPost('IBLOCK_ID'));
     $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $this->checkPermissionElement();
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $templateId = intval($_POST['TEMPLATE_ID']);
     $documentType = BizprocDocument::generateDocumentComplexType(COption::GetOptionString("lists", "livefeed_iblock_type_id"), $this->iblockId);
     if (!empty($templateId)) {
         if (CModule::IncludeModule('bizproc')) {
             if (!CBPWorkflowTemplateLoader::isConstantsTuned($templateId)) {
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_CONSTANTS_TUNED_NEW'))));
                 $this->sendJsonErrorResponse();
             }
         }
     } else {
         if (CModule::IncludeModule("bizproc")) {
             $templateObject = CBPWorkflowTemplateLoader::getTemplatesList(array('ID' => 'DESC'), array('DOCUMENT_TYPE' => $documentType, 'AUTO_EXECUTE' => CBPDocumentEventType::Create), false, false, array('ID'));
             $template = $templateObject->fetch();
             if (!empty($template)) {
                 if (!CBPWorkflowTemplateLoader::isConstantsTuned($template["ID"])) {
                     $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_CONSTANTS_TUNED_NEW'))));
                     $this->sendJsonErrorResponse();
                 }
             } else {
                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_NOT_BIZPROC_TEMPLATE'))));
                 $this->sendJsonErrorResponse();
             }
         }
     }
     $list = new CList($this->iblockId);
     $fields = $list->getFields();
     $elementData = array("IBLOCK_ID" => $this->iblockId, "NAME" => $_POST["NAME"]);
     $props = array();
     foreach ($fields as $fieldId => $field) {
         if ($fieldId == "PREVIEW_PICTURE" || $fieldId == "DETAIL_PICTURE") {
             $elementData[$fieldId] = $_FILES[$fieldId];
             if (isset($_POST[$fieldId . "_del"]) && $_POST[$fieldId . "_del"] == "Y") {
                 $elementData[$fieldId]["del"] = "Y";
             }
         } elseif ($fieldId == "PREVIEW_TEXT" || $fieldId == "DETAIL_TEXT") {
             if (isset($field["SETTINGS"]) && is_array($field["SETTINGS"]) && $field["SETTINGS"]["USE_EDITOR"] == "Y") {
                 $elementData[$fieldId . "_TYPE"] = "html";
             } else {
                 $elementData[$fieldId . "_TYPE"] = "text";
             }
             $elementData[$fieldId] = $_POST[$fieldId];
         } elseif ($fieldId == 'ACTIVE_FROM' || $fieldId == 'ACTIVE_TO') {
             $elementData[$fieldId] = array_shift($_POST[$fieldId]);
         } elseif ($list->is_field($fieldId)) {
             $elementData[$fieldId] = $_POST[$fieldId];
         } elseif ($field["PROPERTY_TYPE"] == "F") {
             if (isset($_POST[$fieldId . "_del"])) {
                 $deleteArray = $_POST[$fieldId . "_del"];
             } else {
                 $deleteArray = array();
             }
             $props[$field["ID"]] = array();
             $files = $this->unEscape($_FILES);
             CFile::ConvertFilesToPost($files[$fieldId], $props[$field["ID"]]);
             foreach ($props[$field["ID"]] as $fileId => $file) {
                 if (isset($deleteArray[$fileId]) && (!is_array($deleteArray[$fileId]) && $deleteArray[$fileId] == "Y" || is_array($deleteArray[$fileId]) && $deleteArray[$fileId]["VALUE"] == "Y")) {
                     if (isset($props[$field["ID"]][$fileId]["VALUE"])) {
                         $props[$field["ID"]][$fileId]["VALUE"]["del"] = "Y";
                     } else {
                         $props[$field["ID"]][$fileId]["del"] = "Y";
                     }
                 }
             }
         } elseif ($field["PROPERTY_TYPE"] == "N") {
             if (is_array($_POST[$fieldId]) && !array_key_exists("VALUE", $_POST[$fieldId])) {
                 $props[$field["ID"]] = array();
                 foreach ($_POST[$fieldId] as $key => $value) {
                     if (is_array($value)) {
                         if (strlen($value["VALUE"])) {
                             $value = str_replace(" ", "", str_replace(",", ".", $value["VALUE"]));
                             if (!is_numeric($value)) {
                                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                                 $this->sendJsonErrorResponse();
                             }
                             $props[$field["ID"]][$key] = doubleval($value);
                         }
                     } else {
                         if (strlen($value)) {
                             $value = str_replace(" ", "", str_replace(",", ".", $value));
                             if (!is_numeric($value)) {
                                 $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                                 $this->sendJsonErrorResponse();
                             }
                             $props[$field["ID"]][$key] = doubleval($value);
                         }
                     }
                 }
             } else {
                 if (is_array($_POST[$fieldId])) {
                     if (strlen($_POST[$fieldId]["VALUE"])) {
                         $value = str_replace(" ", "", str_replace(",", ".", $_POST[$fieldId]["VALUE"]));
                         if (!is_numeric($value)) {
                             $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                             $this->sendJsonErrorResponse();
                         }
                         $props[$field["ID"]] = doubleval($value);
                     }
                 } else {
                     if (strlen($_POST[$fieldId])) {
                         $value = str_replace(" ", "", str_replace(",", ".", $_POST[$fieldId]));
                         if (!is_numeric($value)) {
                             $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_VALIDATE_FIELD_ERROR', array('#NAME#' => $field['NAME'])))));
                             $this->sendJsonErrorResponse();
                         }
                         $props[$field["ID"]] = doubleval($value);
                     }
                 }
             }
         } else {
             $props[$field["ID"]] = $_POST[$fieldId];
         }
     }
     $elementData["MODIFIED_BY"] = $this->getUser()->getID();
     unset($elementData["TIMESTAMP_X"]);
     if (!empty($props)) {
         $elementData["PROPERTY_VALUES"] = $props;
     }
     $documentStates = CBPDocument::GetDocumentStates($documentType, null);
     $userId = $this->getUser()->getId();
     $write = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::WriteDocument, $userId, $documentType, array('AllUserGroups' => array(), 'DocumentStates' => $documentStates));
     if (!$write) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_IS_ACCESS_DENIED_STATUS'))));
         $this->sendJsonErrorResponse();
     }
     $bizprocParametersValues = array();
     foreach ($documentStates as $documentState) {
         if (strlen($documentState["ID"]) <= 0) {
             $errors = array();
             $bizprocParametersValues[$documentState['TEMPLATE_ID']] = CBPDocument::StartWorkflowParametersValidate($documentState['TEMPLATE_ID'], $documentState['TEMPLATE_PARAMETERS'], $documentType, $errors);
             $stringError = '';
             foreach ($errors as $e) {
                 $stringError .= $e['message'] . '<br />';
             }
         }
     }
     if (!empty($stringError)) {
         $this->errorCollection->add(array(new Error($stringError)));
         $this->sendJsonErrorResponse();
     }
     $objectElement = new CIBlockElement();
     $idElement = $objectElement->Add($elementData, false, true, true);
     if ($idElement) {
         $bizProcWorkflowId = array();
         foreach ($documentStates as $documentState) {
             if (strlen($documentState["ID"]) <= 0) {
                 $errorsTmp = array();
                 $bizProcWorkflowId[$documentState['TEMPLATE_ID']] = CBPDocument::StartWorkflow($documentState['TEMPLATE_ID'], array('lists', 'BizprocDocument', $idElement), array_merge($bizprocParametersValues[$documentState['TEMPLATE_ID']], array('TargetUser' => 'user_' . intval($this->getUser()->getID()))), $errorsTmp);
             }
         }
         if (!empty($errorsTmp)) {
             $documentStates = null;
             CBPDocument::AddDocumentToHistory(array('lists', 'BizprocDocument', $idElement), $elementData['NAME'], $this->getUser()->getID());
         }
     } else {
         $this->errorCollection->add(array(new Error($objectElement->LAST_ERROR)));
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse(array());
 }
Beispiel #30
0
 function ChangeStatus($taskId, $newStatus, $userId = 0)
 {
     CModule::IncludeModule("socialnetwork");
     $taskId = intval($taskId);
     $userId = intval($userId);
     if ($userId == 0) {
         $userId = $GLOBALS["USER"]->GetID();
     }
     $arTask = CIntranetTasks::GetById($taskId);
     if (!$arTask) {
         return;
     }
     $arDocumentStates = CBPDocument::GetDocumentStates(array("intranet", "CIntranetTasksDocument", "x" . $arTask["IBLOCK_ID"]), array("intranet", "CIntranetTasksDocument", $taskId));
     $arCurrentUserGroups = array();
     if ($arTask["TaskType"] == "group") {
         $arCurrentUserGroups[] = SONET_ROLES_ALL;
         if ($GLOBALS["USER"]->IsAuthorized()) {
             $arCurrentUserGroups[] = SONET_ROLES_AUTHORIZED;
         }
         $r = CSocNetUserToGroup::GetUserRole($userId, $arTask["OwnerId"]);
         if (strlen($r) > 0) {
             $arCurrentUserGroups[] = $r;
         }
     }
     if ($userId == $arTask["CREATED_BY"]) {
         $arCurrentUserGroups[] = "author";
     }
     if ($userId == $arTask["PROPERTY_TaskAssignedTo"]) {
         $arCurrentUserGroups[] = "responsible";
     }
     if (is_array($arTask["PROPERTY_TaskTrackers"]) && in_array($userId, $arTask["PROPERTY_TaskTrackers"])) {
         $arCurrentUserGroups[] = "trackers";
     }
     $arStateCommand = array("NotAccepted" => array("NotStarted" => array("HEEA_NotAccepted_ApproveEvent"), "InProgress" => array("HEEA_NotAccepted_InProgressEvent"), "Completed" => array("HEEA_NotAccepted_CompleteEvent"), "Closed" => array("HEEA_NotAccepted_CloseEvent"), "Waiting" => array("HEEA_NotAccepted_ApproveEvent", "HEEA_NotStarted_WaitingEvent"), "Deferred" => array("HEEA_NotAccepted_ApproveEvent", "HEEA_NotStarted_DeferredEvent")), "NotStarted" => array("InProgress" => array("HEEA_NotStarted_InProgressEvent"), "Completed" => array("HEEA_NotStarted_CompleteEvent"), "Closed" => array("HEEA_NotStarted_CloseEvent"), "Waiting" => array("HEEA_NotStarted_WaitingEvent"), "Deferred" => array("HEEA_NotStarted_DeferredEvent")), "InProgress" => array("Completed" => array("HEEA_InProgress_CompleteEvent"), "Closed" => array("HEEA_InProgress_CloseEvent"), "Waiting" => array("HEEA_InProgress_WaitingEvent"), "Deferred" => array("HEEA_InProgress_DeferredEvent")), "Completed" => array("InProgress" => array("HEEA_Completed_InProgressEvent"), "Closed" => array("HEEA_Completed_CloseEvent")), "Waiting" => array("NotStarted" => array("HEEA_Waiting_NotStartedEvent"), "InProgress" => array("HEEA_Waiting_InProgressEvent"), "Completed" => array("HEEA_Waiting_CompleteEvent"), "Closed" => array("HEEA_Waiting_CloseEvent"), "Deferred" => array("HEEA_Waiting_DeferredEvent")), "Deferred" => array("NotStarted" => array("HEEA_Deferred_NotStartedEvent"), "InProgress" => array("HEEA_Deferred_InProgressEvent"), "Completed" => array("HEEA_Deferred_CompleteEvent"), "Closed" => array("HEEA_Deferred_CloseEvent"), "Waiting" => array("HEEA_Deferred_WaitingEvent")));
     foreach ($arDocumentStates as $documentState) {
         $oldState = $documentState["STATE_NAME"];
         if (!array_key_exists($oldState, $arStateCommand) || count($arStateCommand[$oldState]) <= 0) {
             continue;
         }
         if (!array_key_exists($newStatus, $arStateCommand[$oldState]) || count($arStateCommand[$oldState][$newStatus]) <= 0) {
             continue;
         }
         foreach ($arStateCommand[$oldState][$newStatus] as $sc) {
             CBPDocument::SendExternalEvent($documentState["ID"], $sc, array("Groups" => $arCurrentUserGroups, "User" => $userId), $arErrorTmp);
         }
     }
 }