} if (!$arFields["AUDITORS"]) { $arFields["AUDITORS"] = array(); } } if (!empty($arFields)) { $oTask->update($arFields); } $task = $oTask->getData(); // count children tasks $childrenCnt = 0; $arFilter = array(); if (is_array($_POST['arFilter'])) { $arFilter = $_POST['arFilter']; } if ($rsChildrenCount = CTasks::GetChildrenCount($arFilter, array($task['ID']))) { if ($arChildrens = $rsChildrenCount->fetch()) { $childrenCnt = $arChildrens["CNT"]; } } $bGannt = false; if (isset($_POST['bGannt'])) { $bGannt = (bool) $_POST['bGannt']; } ob_start(); $params = array("PATHS" => $arPaths, "PLAIN" => false, "DEFER" => true, "SITE_ID" => $SITE_ID, "TASK_ADDED" => false, 'IFRAME' => 'N', "NAME_TEMPLATE" => $nameTemplate, 'DATA_COLLECTION' => array(array("CHILDREN_COUNT" => $childrenCnt, "DEPTH" => 0, "UPDATES_COUNT" => 0, "PROJECT_EXPANDED" => true, 'ALLOWED_ACTIONS' => null, "TASK" => $task))); if ($columnsOrder !== null) { $params['COLUMNS_IDS'] = $columnsOrder; } $APPLICATION->IncludeComponent('bitrix:tasks.list.items', '.default', $params, null, array("HIDE_ICONS" => "Y")); $arAdditionalFields = array('html' => "'" . CUtil::JSEscape(ob_get_clean()) . "'");
} // Is task id the result of previous operation in batch? $taskId = BXTasksResolveDynaParamValue($arAction['taskData']['ID'], array('$arOperationsResults' => $arOperationsResults)); CTaskAssert::assertLaxIntegers($taskId); $oTask = CTaskItem::getInstanceFromPool($taskId, $loggedInUserId); $returnValue = null; $arTask = $oTask->getData($bSpecialChars = false); if ($arTask['GROUP_ID']) { $arTask['GROUP_NAME'] = ''; $arGroup = CSocNetGroup::GetByID($arTask['GROUP_ID']); if ($arGroup) { $arTask['GROUP_NAME'] = $arGroup['~NAME']; } } $childrenCount = 0; $rsChildrenCount = CTasks::GetChildrenCount($arFilter = array(), array($taskId)); if ($rsChildrenCount) { if ($arChildrens = $rsChildrenCount->Fetch()) { $childrenCount = $arChildrens['CNT']; } } $arPathes = array('PATH_TO_TASKS_TASK' => str_replace("#user_id#", $loggedInUserId, COption::GetOptionString('tasks', 'paths_task_user_action', null, $SITE_ID))); $arTaskEscaped = array(); foreach ($arTask as $key => $value) { if (is_array($value)) { foreach ($value as $key2 => $value2) { $arTaskEscaped[$key][$key2] = htmlspecialcharsbx($value2); } } else { $arTaskEscaped[$key] = htmlspecialcharsbx($value); }
$arPrevTasksIds = array(); while ($arPrevTask = $rsPrevTasksIds->fetch()) { $arPrevTasksIds[] = (int) $arPrevTask['DEPENDS_ON_ID']; } $arResult["PREV_TASKS"] = array(); if (!empty($arPrevTasksIds)) { $rsPrevtasks = CTasks::GetList(array('GROUP_ID' => 'ASC'), array('ID' => $arPrevTasksIds)); while ($arPrevTask = $rsPrevtasks->GetNext()) { $arResult["PREV_TASKS"][] = $arPrevTask; $arTasksIDs[] = $arPrevTask["ID"]; if ($arPrevTask["GROUP_ID"] && !in_array($arPrevTask["GROUP_ID"], $arGroupsIDs)) { $arGroupsIDs[] = $arPrevTask["GROUP_ID"]; } } } $rsChildrenCount = CTasks::GetChildrenCount(array(), $arTasksIDs); if ($rsChildrenCount) { while ($arChildrenCount = $rsChildrenCount->Fetch()) { $arResult["CHILDREN_COUNT"]["PARENT_" . $arChildrenCount["PARENT_ID"]] = $arChildrenCount["CNT"]; } } // groups $arResult["GROUPS"] = array(); $arOpenedProjects = CUserOptions::GetOption("tasks", "opened_projects", array()); if ($arResult["TASK_TYPE"] != "group" && sizeof($arGroupsIDs)) { $rsGroups = CSocNetGroup::GetList(array("ID" => "ASC"), array("ID" => $arGroupsIDs)); while ($arGroup = $rsGroups->GetNext()) { $arGroup["EXPANDED"] = array_key_exists($arGroup["ID"], $arOpenedProjects) && $arOpenedProjects[$arGroup["ID"]] == "false" ? false : true; $arResult["GROUPS"][$arGroup["ID"]] = $arGroup; } }
$arResult['TASKS'][$taskId]['FILES'][] = $arFile; } } } } $arResult["GROUPS"] = array(); $arOpenedProjects = CUserOptions::GetOption("tasks", "opened_projects", array()); if (!empty($arGroupsIDs)) { $rsGroups = CSocNetGroup::GetList(array("ID" => "ASC"), array("ID" => $arGroupsIDs)); while ($arGroup = $rsGroups->GetNext()) { $arGroup["EXPANDED"] = array_key_exists($arGroup["ID"], $arOpenedProjects) && $arOpenedProjects[$arGroup["ID"]] == "false" ? false : true; $arResult["GROUPS"][$arGroup["ID"]] = $arGroup; } } $arResult["CHILDREN_COUNT"] = array(); $rsChildrenCount = CTasks::GetChildrenCount($arFilter, $arTasksIDs); if ($rsChildrenCount) { while ($arChildrenCount = $rsChildrenCount->Fetch()) { $arResult["CHILDREN_COUNT"]["PARENT_" . $arChildrenCount["PARENT_ID"]] = $arChildrenCount["CNT"]; } } $arResult["UPDATES_COUNT"] = CTasks::GetUpdatesCount($arViewed); $rsTemplates = CTaskTemplates::GetList(array("ID" => "DESC"), array("CREATED_BY" => $USER->GetID(), 'BASE_TEMPLATE_ID' => false, '!TPARAM_TYPE' => CTaskTemplates::TYPE_FOR_NEW_USER), array('NAV_PARAMS' => array('nTopCount' => 10))); $arResult["TEMPLATES"] = array(); while ($template = $rsTemplates->GetNext()) { $arResult["TEMPLATES"][] = $template; } $sTitle = ""; if ($taskType == "group") { $sTitle = $sTitleShort = GetMessage("TASKS_TITLE_GROUP_TASKS"); } else {
$arData = $_POST; $arData['CHECKLIST_ITEMS'] = $arChecklistItems; } } } else { $arResult['ERRORS'] = array(); $arResult['ERRORS'][] = array('text' => 'Duplicate POST-request', 'id' => 'ERROR_TASKS_DUPLICATE_POST_REQUEST'); $arResult["bVarsFromForm"] = true; $arData = $_POST; } } else { if (isset($arResult["CALLBACK"]) && $arResult["CALLBACK"] && intval($_GET["TASK_ID"]) > 0) { $rsTask = CTasks::GetByID(intval($_GET["TASK_ID"])); if ($callbackTask = $rsTask->GetNext()) { $arResult["TASK"] = $callbackTask; $rsChildrenCount = CTasks::GetChildrenCount(array(), $arResult["TASK"]["ID"]); if ($arChildrenCount = $rsChildrenCount->Fetch()) { $arResult["TASK"]["CHILDREN_COUNT"] = $arChildrenCount["CNT"]; } $rsTaskFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $arResult["TASK"]["ID"])); $arResult["TASK"]["FILES"] = array(); while ($arTaskFile = $rsTaskFiles->Fetch()) { $rsFile = CFile::GetByID($arTaskFile["FILE_ID"]); if ($arFile = $rsFile->Fetch()) { $arResult["TASK"]["FILES"][] = $arFile; } } } } if ($arResult["ACTION"] == "edit") { $arData = $arTask;