<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } CUtil::InitJSCore(array('popup', 'tooltip')); //$GLOBALS['APPLICATION']->AddHeadScript("/bitrix/components/bitrix/tasks.task.edit/templates/.default/script.js"); $GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/intranet/intranet-common.css"); $GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/main/core/css/core_popup.css"); $GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/tasks/css/tasks.css"); $GLOBALS["APPLICATION"]->IncludeComponent('bitrix:main.calendar', '', array('SILENT' => 'Y'), null, array('HIDE_ICONS' => 'Y')); $arPriorities = array(array("name" => GetMessage("TASKS_PRIORITY_LOW"), "class" => "low"), array("name" => GetMessage("TASKS_PRIORITY_MIDDLE"), "class" => "middle"), array("name" => GetMessage("TASKS_PRIORITY_HIGH"), "class" => "high")); $arPeriods = array(array("key" => "daily", "name" => GetMessage("TASKS_REPEAT_PERIOD_DAILY")), array("key" => "weekly", "name" => GetMessage("TASKS_REPEAT_PERIOD_WEEKLY")), array("key" => "monthly", "name" => GetMessage("TASKS_REPEAT_PERIOD_MONTHLY")), array("key" => "yearly", "name" => GetMessage("TASKS_REPEAT_PERIOD_YEARLY"))); $arData =& $arResult["DATA"]; $bSubordinate = CTasks::IsSubordinate($arData["RESPONSIBLE_ID"], $arData["CREATED_BY"]); $taskDescriptionEditorId = 'task' . intval($arResult['DATA']['ID']) . 'description'; ?> <script type="text/javascript"> BX.message({ TASKS_DEFAULT_TITLE : '<?php echo CUtil::JSEscape(GetMessage("TASKS_DEFAULT_TITLE")); ?> ', TASKS_CANCEL : '<?php echo CUtil::JSEscape(GetMessage("TASKS_CANCEL")); ?> ', TASKS_SELECT : '<?php echo CUtil::JSEscape(GetMessage("TASKS_SELECT")); ?> ',
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $request = \Bitrix\Main\HttpApplication::getInstance()->getContext()->getRequest(); $arDefaultValues = array('GROUP_ID' => 0, 'SHOW_TASK_LIST_MODES' => 'Y', 'SHOW_HELP_ICON' => 'Y', 'SHOW_SEARCH_FIELD' => 'Y', 'SHOW_TEMPLATES_TOOLBAR' => 'Y', 'SHOW_QUICK_TASK_ADD' => 'Y', 'SHOW_ADD_TASK_BUTTON' => 'Y', 'SHOW_SECTIONS_BAR' => 'N', 'SHOW_FILTER_BAR' => 'N', 'SHOW_COUNTERS_BAR' => 'N', 'SHOW_SECTION_MANAGE' => 'A', 'MARK_ACTIVE_ROLE' => 'N', 'MARK_SECTION_MANAGE' => 'N', 'MARK_SECTION_PROJECTS' => 'N', 'MARK_SECTION_REPORTS' => 'N', 'SECTION_URL_PREFIX' => '', 'PATH_TO_DEPARTMENTS' => null, 'PATH_TO_REPORTS' => null); if (!isset($arParams['NAME_TEMPLATE'])) { $arParams['NAME_TEMPLATE'] = CSite::GetNameFormat(false); } $loggedInUserId = (int) $USER->getId(); $isAccessToCounters = $arParams['USER_ID'] == $loggedInUserId || $USER->isAdmin() || CTasksTools::IsPortalB24Admin() || CTasks::IsSubordinate($arParams['USER_ID'], $loggedInUserId); if ($arParams["GROUP_ID"] > 0) { $arParams['SHOW_SECTION_COUNTERS'] = 'N'; } if (!$isAccessToCounters) { $arParams['SHOW_SECTION_COUNTERS'] = 'N'; } // Set default values for omitted parameters foreach ($arDefaultValues as $paramName => $paramDefaultValue) { if (!array_key_exists($paramName, $arParams)) { $arParams[$paramName] = $paramDefaultValue; } } if (!$arParams['PATH_TO_REPORTS']) { $arParams['PATH_TO_REPORTS'] = $arParams['SECTION_URL_PREFIX'] . 'report/'; } if (!$arParams['PATH_TO_DEPARTMENTS']) { $arParams['PATH_TO_DEPARTMENTS'] = $arParams['SECTION_URL_PREFIX'] . 'departments/'; } if (isset($arParams['SHOW_SECTION_PROJECTS']) && $arParams['SHOW_SECTION_PROJECTS'] === 'Y' && isset($arParams['PATH_TO_PROJECTS']) && !empty($arParams['PATH_TO_PROJECTS']) && $arParams['USER_ID'] == $loggedInUserId) {
function UpdateListItems($listName, $updates) { global $USER, $DB; $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)); $obResponse = new CXMLCreator('Results'); $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) { $rsElement = CTasks::GetById($arData['ID']); if ($rsElement && ($arElement = $rsElement->Fetch())) { if (!is_array($arElement)) { $obErrorCode->setData('0x81020016'); $bUpdate = false; } else { 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(intval($arElement['GROUP_ID']) > 0 ? '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']])); } } else { $obErrorCode->setData('0x81020016'); $bUpdate = false; } } if ($bUpdate) { if ($arData['_command'] == 'Delete' && $arElement["CREATED_BY"] == $USER->GetID()) { $arError = false; if (!CTasks::Delete($arElement['ID'])) { $obErrorCode->setData('0x81020014'); } else { $obErrorCode->setData('0x00000000'); } } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') { $arData['Body'] = trim($arData['Body']); $arData['Body'] = str_replace(array(" ", " ", ' '), "", $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 : ''; $probablyHtmlInDescription = strpos($arData['Body'], '<') !== false && strpos($arData['Body'], '>'); $arFields = array('DESCRIPTION_IN_BBCODE' => $probablyHtmlInDescription ? 'N' : 'Y', 'CHANGED_BY' => $USER->GetID(), 'CHANGED_DATE' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time()), 'SITE_ID' => SITE_ID, 'TITLE' => $arData['Title'], 'START_DATE_PLAN' => $arData['StartDate'] ? ConvertTimeStamp($arData['StartDate']) : '', 'DEADLINE' => $arData['DueDate'] ? ConvertTimeStamp($arData['DueDate']) : '', 'DESCRIPTION' => $arData['Body'], 'PRIORITY' => isset($arData['Priority']) ? intval($arData['Priority']) : 1, 'DURATION_PLAN' => $arData['MetaInfo_TotalWork'] / 60, 'DURATION_FACT' => $arData['MetaInfo_ActualWork'] / 60, 'CLOSED_DATE' => $arData['MetaInfo_DateComplete'] ? ConvertTimeStamp($arData['MetaInfo_DateComplete']) : ''); if (in_array($arData['Status'], $this->arStatuses)) { $arFields["STATUS"] = $arData['Status']; } if ($assigned_to = $arData['AssignedTo']) { if ($USER_ID = $this->__getUser($assigned_to)) { $arFields['RESPONSIBLE_ID'] = $USER_ID; } else { $obErrorCode->setData('0x81020054'); $bUpdate = false; } } else { $arFields['RESPONSIBLE_ID'] = $USER->getId(); } if ($bUpdate) { CTimeZone::Disable(); $ID = 0; $obTask = new CTasks(); $arError = false; if ($arData['_command'] == 'New') { if ($arFields["RESPONSIBLE_ID"] == $USER->GetID() || CTasks::IsSubordinate($arFields["RESPONSIBLE_ID"], $USER->GetID())) { $arFields["STATUS"] = 2; } else { $arFields["STATUS"] = 1; } $arFields['OUTLOOK_VERSION'] = 1; $arFields["CREATED_BY"] = $USER->GetID(); $arFields["CREATED_DATE"] = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time()); if ($ID = $obTask->Add($arFields)) { $arReplicationIDs[$ID] = $arData['MetaInfo_ReplicationID']; $obErrorCode->setData('0x00000000'); } } else { if ($arElement["CREATED_BY"] == $USER->GetID() || $arElement["RESPONSIBLE_ID"] == $USER->GetID()) { if ($arElement["CREATED_BY"] != $USER->GetID()) { unset($arFields["TITLE"], $arFields["START_DATE_PLAN"], $arFields["DESCRIPTION"], $arFields["PRIORITY"], $arFields["DURATION_PLAN"], $arFields["CLOSED_DATE"]); if ($arElement["ALLOW_CHANGE_DEADLINE"] != "Y") { unset($arFields["DEADLINE"]); } if ($arElement["TASK_CONTROL"] != "Y" && $arFields["STATUS"] == 5) { $arFields["STATUS"] = 4; } } elseif ($arElement["RESPONSIBLE_ID"] != $USER->GetID() && ($arFields["STATUS"] == 6 || $arFields["STATUS"] == 3)) { unset($arFields["STATUS"]); } $arFields['OUTLOOK_VERSION'] = $arData['owshiddenversion']; if (sizeof($arFields) > 0) { if ($obTask->Update($arData['ID'], $arFields)) { $ID = $arData['ID']; $obErrorCode->setData('0x00000000'); } } } } CTimeZone::Enable(); if (is_array($obTask->GetErrors()) && count($obTask->GetErrors()) > 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; } } if (sizeof($arResponseRows) > 0) { $dbRes = CTasks::GetList(array('ID' => 'ASC'), array('ID' => array_keys($arResponseRows), 'MEMBER' => $USER->GetID())); while ($arRes = $dbRes->Fetch()) { if ($arResponseRows[$arRes['ID']]) { $rsFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $arRes["ID"])); $arRes["FILES"] = array(); while ($arFiles = $rsFiles->Fetch()) { $arRes["FILES"][] = $arFiles["FILE_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); }
exit; } CUtil::InitJSCore(array('popup', 'tooltip')); $GLOBALS['APPLICATION']->AddHeadScript("/bitrix/components/bitrix/tasks.task.edit/templates/.default/script.js"); $GLOBALS['APPLICATION']->AddHeadScript("/bitrix/js/tasks/task-popups.js"); $GLOBALS['APPLICATION']->AddHeadScript("/bitrix/js/tasks/task-reminders.js"); $GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/intranet/intranet-common.css"); $GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/main/core/css/core_popup.css"); $GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/tasks/css/tasks.css"); $GLOBALS["APPLICATION"]->IncludeComponent('bitrix:main.calendar', '', array('SILENT' => 'Y'), null, array('HIDE_ICONS' => 'Y')); $arPriorities = array(array("name" => GetMessage("TASKS_PRIORITY_LOW"), "class" => "low"), array("name" => GetMessage("TASKS_PRIORITY_MIDDLE"), "class" => "middle"), array("name" => GetMessage("TASKS_PRIORITY_HIGH"), "class" => "high")); $arPeriods = array(array("key" => "daily", "name" => GetMessage("TASKS_REPEAT_PERIOD_DAILY")), array("key" => "weekly", "name" => GetMessage("TASKS_REPEAT_PERIOD_WEEKLY")), array("key" => "monthly", "name" => GetMessage("TASKS_REPEAT_PERIOD_MONTHLY")), array("key" => "yearly", "name" => GetMessage("TASKS_REPEAT_PERIOD_YEARLY"))); $arData =& $arResult["DATA"]; $arPaths = array("PATH_TO_TASKS_TASK" => $arParams["PATH_TO_TASKS_TASK"], "PATH_TO_USER_PROFILE" => $arParams["PATH_TO_USER_PROFILE"]); // Will be true, if $arData["CREATED_BY"] is manager of $arData["RESPONSIBLE_ID"] $bSubordinate = CTasks::IsSubordinate($arData["RESPONSIBLE_ID"], $arData["CREATED_BY"]) || CTasks::IsSubordinate($arData["RESPONSIBLE_ID"], $USER->getId()); $taskDescriptionEditorId = 'task' . intval($arResult['DATA']['ID']) . 'description'; ?> <script type="text/javascript"> BX.message({ TASKS_DEFAULT_TITLE : '<?php echo CUtil::JSEscape(GetMessage("TASKS_DEFAULT_TITLE")); ?> ', TASKS_CANCEL : '<?php echo CUtil::JSEscape(GetMessage("TASKS_CANCEL")); ?> ', TASKS_SELECT : '<?php echo CUtil::JSEscape(GetMessage("TASKS_SELECT")); ?>