Exemplo n.º 1
0
 /**
  * This function is deprecated, it wont work with a new disk-based file attachment mechanism.
  * Use getAttachedFiles() instead
  * @deprecated
  */
 public function getFiles()
 {
     // ensure we have access to the task
     $this->checkCanReadThrowException();
     if ($this->arTaskFiles === null) {
         $rsFiles = CTaskFiles::GetList(array(), array('TASK_ID' => $this->taskId));
         $this->arTaskFiles = array();
         while ($arFile = $rsFiles->fetch()) {
             $this->arTaskFiles[] = $arFile['FILE_ID'];
         }
     }
     return $this->arTaskFiles;
 }
Exemplo n.º 2
0
 /**
  * @param integer $TASK_ID
  * @param array $SAVE_FILES
  * @return bool|CDBResult
  *
  * @var CDatabase $DB
  */
 public static function DeleteByTaskID($TASK_ID, $SAVE_FILES = array())
 {
     global $DB;
     $rsTaskFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $TASK_ID));
     $sqrWhereAdditional = '';
     if (is_array($SAVE_FILES) && count($SAVE_FILES)) {
         $sqrWhereAdditional .= 'AND FILE_ID NOT IN (' . implode(',', array_map('intval', $SAVE_FILES)) . ')';
     }
     $TASK_ID = intval($TASK_ID);
     $strSql = "DELETE FROM b_tasks_file WHERE TASK_ID = " . $TASK_ID . ' ' . $sqrWhereAdditional;
     $result = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($result) {
         $arFilesToDelete = array();
         while ($arTaskFiles = $rsTaskFiles->Fetch()) {
             // Skip files, that attached to some existing tasks
             $rsFiles = CTaskFiles::GetList(array(), array("FILE_ID" => $arTaskFiles["FILE_ID"]));
             if (!($arFile = $rsFiles->Fetch())) {
                 if (!in_array($arTaskFiles["FILE_ID"], $SAVE_FILES)) {
                     $arFilesToDelete[] = $arTaskFiles["FILE_ID"];
                 }
             }
         }
         foreach ($arFilesToDelete as $file) {
             CFile::Delete($file);
         }
     }
     return $result;
 }
Exemplo n.º 3
0
 $depth = intval($_POST["depth"]) + 1;
 $bGannt = false;
 if (isset($_POST['bGannt'])) {
     $bGannt = (bool) $_POST['bGannt'];
 }
 // Override CHECK_PERMISSIONS, if it was given in $_POST['filter']
 $arFilter['CHECK_PERMISSIONS'] = 'Y';
 $rsTasks = CTasks::GetList($arOrder, $arFilter);
 $arTasks = array();
 $arTasksIDs = array();
 $arViewed = array();
 while ($task = $rsTasks->GetNext()) {
     $arTasks[$task["ID"]] = $task;
     $arTasksIDs[] = $task["ID"];
     $arViewed[$task["ID"]] = $task["VIEWED_DATE"] ? $task["VIEWED_DATE"] : $task["CREATED_DATE"];
     $rsTaskFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $task["ID"]));
     $task["FILES"] = array();
     while ($arTaskFile = $rsTaskFiles->Fetch()) {
         $rsFile = CFile::GetByID($arTaskFile["FILE_ID"]);
         if ($arFile = $rsFile->Fetch()) {
             $task["FILES"][] = $arFile;
         }
     }
     $arTasks[$task["ID"]] = $task;
 }
 unset($arFilter["PARENT_ID"]);
 $rsChildrenCount = CTasks::GetChildrenCount($arFilter, $arTasksIDs);
 if ($rsChildrenCount) {
     while ($arChildrens = $rsChildrenCount->Fetch()) {
         $arChildrenCount["PARENT_" . $arChildrens["PARENT_ID"]] = $arChildrens["CNT"];
     }
Exemplo n.º 4
0
             if (!is_array($arFields[$ufName])) {
                 $arFields[$ufName] = '';
             }
         }
     }
 }
 // USER FIELDS END
 $template = new CTaskTemplates();
 if ($arResult["ACTION"] == "edit") {
     $arFields["RESPONSIBLE_ID"] = $_POST["RESPONSIBLE_ID"];
     if (isset($_POST["FILES_TO_DELETE"]) && sizeof($_POST["FILES_TO_DELETE"])) {
         $arFilesToUnlink = array();
         foreach ($_POST["FILES_TO_DELETE"] as $file) {
             if (in_array($file, $arData["FILES"])) {
                 // Skip files, that attached to some existing tasks
                 $rsFiles = CTaskFiles::GetList(array(), array('FILE_ID' => $file));
                 // There is no tasks with this file, so it can be removed
                 if (!($arFile = $rsFiles->Fetch())) {
                     $arFilesToUnlink[] = $file;
                 }
             }
         }
         foreach ($arFilesToUnlink as $file) {
             CFile::Delete($file);
         }
     }
     $result = $template->Update($arParams["TEMPLATE_ID"], $arFields, array('CHECK_RIGHTS_ON_FILES' => true, 'USER_ID' => (int) $USER->getId()));
     $templateID = $arParams["TEMPLATE_ID"];
 } else {
     $templateID = $result = $template->Add($arFields, array('CHECK_RIGHTS_ON_FILES' => true, 'USER_ID' => (int) $USER->getId()));
 }
Exemplo n.º 5
0
 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("&#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 : '';
                 $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);
 }
Exemplo n.º 6
0
}
unset($rsUser, $arUser);
// Store photos links in task data
foreach ($arResult['TASKS'] as $key => $value) {
    $arResult['TASKS'][$key]['META::ORIGINATOR_PHOTO_SRC'] = false;
    $arResult['TASKS'][$key]['META::RESPONSIBLE_PHOTO_SRC'] = false;
    if (isset($arUsersPhotos[$value['CREATED_BY']])) {
        $arResult['TASKS'][$key]['META::ORIGINATOR_PHOTO_SRC'] = $arUsersPhotos[$value['CREATED_BY']];
    }
    if (isset($arUsersPhotos[$value['RESPONSIBLE_ID']])) {
        $arResult['TASKS'][$key]['META::RESPONSIBLE_PHOTO_SRC'] = $arUsersPhotos[$value['RESPONSIBLE_ID']];
    }
}
if (!$bSkipFiles) {
    if (count($arTasksIDs)) {
        $rsTaskFiles = CTaskFiles::GetList(array(), array('TASK_ID' => $arTasksIDs));
        while ($arTaskFile = $rsTaskFiles->Fetch()) {
            $rsFile = CFile::GetByID($arTaskFile['FILE_ID']);
            if ($arFile = $rsFile->Fetch()) {
                $arResult['TASKS'][$arTaskFile['TASK_ID']]['FILES'][] = $arFile;
            }
        }
    }
}
if (!$bSkipUpdatesCount) {
    $arResult['UPDATES_COUNT'] = CTasks::GetUpdatesCount($arViewedDates);
}
if (!$bSkipGroupsDataFetch) {
    // collect groups with tasks
    $arResult['GROUPS'] = array(0 => array('ID' => 0, 'NAME' => GetMessage('MB_TASKS_TASKS_LIST_PSEUDO_GROUP_NAME'), 'META:TASKS_IN_GROUP' => $arGroupsStat[0]['TASKS_IN_GROUP'], 'META:TASKS_STATUSES' => $arGroupsStat[0]['STATUSES'], 'META:TASKS_PRIORITIES' => $arGroupsStat[0]['PRIORITIES']));
    // List of groups to be fetched from DB
Exemplo n.º 7
0
 function Delete($ID)
 {
     global $DB, $USER_FIELD_MANAGER;
     $ID = intval($ID);
     if ($ID > 0) {
         $rsTemplate = CTaskTemplates::GetByID($ID);
         if ($arTemplate = $rsTemplate->Fetch()) {
             // Remove all agents for this template
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             CAgent::RemoveAgent('CTasks::RepeatTaskByTemplateId(' . $ID . ');', 'tasks');
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             CAgent::RemoveAgent('CTasks::RepeatTaskByTemplateId(' . $ID . ', 0);', 'tasks');
             /** @noinspection PhpDynamicAsStaticMethodCallInspection */
             CAgent::RemoveAgent('CTasks::RepeatTaskByTemplateId(' . $ID . ', 1);', 'tasks');
             if ($arTemplate["FILES"]) {
                 $arFiles = unserialize($arTemplate["FILES"]);
                 if (is_array($arFiles)) {
                     $arFilesToDelete = array();
                     foreach ($arFiles as $file) {
                         $rsFile = CTaskFiles::GetList(array(), array("FILE_ID" => $file));
                         if (!($arFile = $rsFile->Fetch())) {
                             $arFilesToDelete[] = $file;
                         }
                     }
                     foreach ($arFilesToDelete as $file) {
                         CFile::Delete($file);
                     }
                 }
             }
             $dbConnection = \Bitrix\Main\HttpApplication::getConnection();
             $strSql = "DELETE FROM b_tasks_template WHERE ID = " . $ID;
             if ($DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
                 $USER_FIELD_MANAGER->Delete("TASKS_TASK_TEMPLATE", $ID);
                 // drop children (sub-templates)
                 $dbConnection->query("delete from b_tasks_template where ID in (" . Template\DependencyTable::getSubTreeSql($ID) . ")");
                 // drop tree records for this templates and it`s children
                 try {
                     Template\DependencyTable::dropLinkL($ID);
                 } catch (\Bitrix\Tasks\DB\Tree\TargetNodeNotFoundException $e) {
                 }
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 8
0
 /**
  * This method is deprecated. Use CTaskItem class instead.
  * @deprecated
  */
 public static function GetByID($ID, $bCheckPermissions = true, $arParams = array())
 {
     $bReturnAsArray = false;
     $bSkipExtraData = false;
     $arGetListParams = array();
     if (isset($arParams['returnAsArray'])) {
         $bReturnAsArray = $arParams['returnAsArray'] === true;
     }
     if (isset($arParams['bSkipExtraData'])) {
         $bSkipExtraData = $arParams['bSkipExtraData'] === true;
     }
     if (isset($arParams['USER_ID'])) {
         $arGetListParams['USER_ID'] = $arParams['USER_ID'];
     }
     $arFilter = array("ID" => (int) $ID);
     if (!$bCheckPermissions) {
         $arFilter["CHECK_PERMISSIONS"] = "N";
     }
     $res = CTasks::GetList(array(), $arFilter, array("*", "UF_*"), $arGetListParams);
     if ($res && ($task = $res->Fetch())) {
         $task["ACCOMPLICES"] = $task["AUDITORS"] = array();
         $rsMembers = CTaskMembers::GetList(array(), array("TASK_ID" => $ID));
         while ($arMember = $rsMembers->Fetch()) {
             if ($arMember["TYPE"] == "A") {
                 $task["ACCOMPLICES"][] = $arMember["USER_ID"];
             } elseif ($arMember["TYPE"] == "U") {
                 $task["AUDITORS"][] = $arMember["USER_ID"];
             }
         }
         if (!$bSkipExtraData) {
             $arTagsFilter = array("TASK_ID" => $ID);
             $arTagsOrder = array("NAME" => "ASC");
             $rsTags = CTaskTags::GetList($arTagsOrder, $arTagsFilter);
             $task["TAGS"] = array();
             while ($arTag = $rsTags->Fetch()) {
                 $task["TAGS"][] = $arTag["NAME"];
             }
             $rsFiles = CTaskFiles::GetList(array(), array("TASK_ID" => $ID));
             $task["FILES"] = array();
             while ($arFile = $rsFiles->Fetch()) {
                 $task["FILES"][] = $arFile["FILE_ID"];
             }
             $rsDependsOn = CTaskDependence::GetList(array(), array("TASK_ID" => $ID));
             $task["DEPENDS_ON"] = array();
             while ($arDependsOn = $rsDependsOn->Fetch()) {
                 $task["DEPENDS_ON"][] = $arDependsOn["DEPENDS_ON_ID"];
             }
         }
         if ($bReturnAsArray) {
             return $task;
         } else {
             $rsTask = new CDBResult();
             $rsTask->InitFromarray(array($task));
             return $rsTask;
         }
     } else {
         if ($bReturnAsArray) {
             return false;
         } else {
             return $res;
         }
     }
 }
Exemplo n.º 9
0
 public function getFiles()
 {
     if ($this->arTaskFiles === null) {
         $rsFiles = CTaskFiles::GetList(array(), array('TASK_ID' => $this->taskId));
         $this->arTaskFiles = array();
         while ($arFile = $rsFiles->fetch()) {
             $this->arTaskFiles[] = $arFile['FILE_ID'];
         }
     }
     return $this->arTaskFiles;
 }
Exemplo n.º 10
0
    } 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;
        $arData["DESCRIPTION"] = $arData["~DESCRIPTION"];
        $arData["CREATED_BY_NAME"] = $arData["~CREATED_BY_NAME"];
        $arData["CREATED_BY_LAST_NAME"] = $arData["~CREATED_BY_LAST_NAME"];
        $arData["CREATED_BY_SECOND_NAME"] = $arData["~CREATED_BY_SECOND_NAME"];