Ejemplo n.º 1
0
 public static function SendUpdateMessage($arFields, $arTask, $bSpawnedByAgent = false, array $parameters = array())
 {
     global $USER;
     $occurAsUserId = self::getOccurAsUserId($arFields, $arTask, $bSpawnedByAgent, $parameters);
     $effectiveUserId = self::getEffectiveUserId($arFields, $arTask, $bSpawnedByAgent, $parameters);
     // generally, $occurAsUserId === $effectiveUserId, but sometimes dont
     /*
     $bSpawnedByAgent === true means that this task was "created\updated" on angent, and 
     in case of that, message author is defined as $arTask['CRAETED_BY'] (below)
     */
     if (!$bSpawnedByAgent && $parameters['THROTTLE_MESSAGES']) {
         AgentManager::checkAgentIsAlive("notificationThrottleRelease()", 300);
         ThrottleTable::submitUpdateMessage($arTask['ID'], $occurAsUserId, $arTask, $arFields);
         return;
     }
     $isBbCodeDescription = true;
     if (isset($arFields['DESCRIPTION_IN_BBCODE'])) {
         if ($arFields['DESCRIPTION_IN_BBCODE'] === 'N') {
             $isBbCodeDescription = false;
         }
     } elseif (isset($arTask['DESCRIPTION_IN_BBCODE'])) {
         if ($arTask['DESCRIPTION_IN_BBCODE'] === 'N') {
             $isBbCodeDescription = false;
         }
     }
     $taskReassignedTo = null;
     if (isset($arFields['RESPONSIBLE_ID']) && $arFields['RESPONSIBLE_ID'] > 0 && $arFields['RESPONSIBLE_ID'] != $arTask['RESPONSIBLE_ID']) {
         $taskReassignedTo = $arFields['RESPONSIBLE_ID'];
     }
     foreach (array('CREATED_BY', 'RESPONSIBLE_ID', 'ACCOMPLICES', 'AUDITORS', 'TITLE') as $field) {
         if (!isset($arFields[$field]) && isset($arTask[$field])) {
             $arFields[$field] = $arTask[$field];
         }
     }
     $cacheWasEnabled = self::enableStaticCache();
     // $arChanges contains datetimes IN SERVER TIME, NOT CLIENT
     $arChanges = CTaskLog::GetChanges($arTask, $arFields);
     $arMerged = array('ADDITIONAL_RECIPIENTS' => array());
     if (isset($arTask['CREATED_BY'])) {
         $arMerged['ADDITIONAL_RECIPIENTS'][] = $arTask['CREATED_BY'];
     }
     if (isset($arTask['RESPONSIBLE_ID'])) {
         $arMerged['ADDITIONAL_RECIPIENTS'][] = $arTask['RESPONSIBLE_ID'];
     }
     if (isset($arTask['ACCOMPLICES']) && is_array($arTask['ACCOMPLICES'])) {
         foreach ($arTask['ACCOMPLICES'] as $userId) {
             $arMerged['ADDITIONAL_RECIPIENTS'][] = $userId;
         }
     }
     if (isset($arTask['AUDITORS']) && is_array($arTask['AUDITORS'])) {
         foreach ($arTask['AUDITORS'] as $userId) {
             $arMerged['ADDITIONAL_RECIPIENTS'][] = $userId;
         }
     }
     if (isset($arFields['ADDITIONAL_RECIPIENTS'])) {
         $arFields['ADDITIONAL_RECIPIENTS'] = array_merge($arFields['ADDITIONAL_RECIPIENTS'], $arMerged['ADDITIONAL_RECIPIENTS']);
     } else {
         $arFields['ADDITIONAL_RECIPIENTS'] = $arMerged['ADDITIONAL_RECIPIENTS'];
     }
     $arUsers = CTaskNotifications::__GetUsers($arFields);
     $ignoreAuthor = isset($parameters['IGNORE_AUTHOR']) ? !!$parameters['IGNORE_AUTHOR'] : true;
     $arRecipientsIDs = array_unique(CTaskNotifications::GetRecipientsIDs($arFields, $ignoreAuthor, false, $occurAsUserId));
     if (!empty($arRecipientsIDs) && (is_object($USER) && $USER->GetID() || $arFields["CREATED_BY"])) {
         $curUserTzOffset = (int) self::getUserTimeZoneOffset();
         $arInvariantChangesStrs = array();
         $arVolatileDescriptions = array();
         $arRecipientsIDsByTimezone = array();
         $i = 0;
         foreach ($arChanges as $key => $value) {
             ++$i;
             $actionMessage = GetMessage("TASKS_MESSAGE_" . $key);
             if (strlen($actionMessage)) {
                 $changeMessage = $actionMessage;
                 $tmpStr = '';
                 switch ($key) {
                     case 'TIME_ESTIMATE':
                         $tmpStr .= self::formatTimeHHMM($value["FROM_VALUE"], true) . " -> " . self::formatTimeHHMM($value["TO_VALUE"], true);
                         break;
                     case "TITLE":
                         $tmpStr .= $value["FROM_VALUE"] . " -> " . $value["TO_VALUE"];
                         break;
                     case "RESPONSIBLE_ID":
                         $tmpStr .= CTaskNotifications::__Users2String($value["FROM_VALUE"], $arUsers, $arFields["NAME_TEMPLATE"]) . ' -> ' . CTaskNotifications::__Users2String($value["TO_VALUE"], $arUsers, $arFields["NAME_TEMPLATE"]);
                         break;
                     case "ACCOMPLICES":
                     case "AUDITORS":
                         $tmpStr .= CTaskNotifications::__Users2String(explode(",", $value["FROM_VALUE"]), $arUsers, $arFields["NAME_TEMPLATE"]) . ' -> ' . CTaskNotifications::__Users2String(explode(",", $value["TO_VALUE"]), $arUsers, $arFields["NAME_TEMPLATE"]);
                         break;
                     case "DEADLINE":
                     case "START_DATE_PLAN":
                     case "END_DATE_PLAN":
                         // $arChanges ALREADY contains server time, no need to substract user timezone again
                         $utsFromValue = $value['FROM_VALUE'];
                         // - $curUserTzOffset;
                         $utsToValue = $value['TO_VALUE'];
                         // - $curUserTzOffset;
                         // It will be replaced below to formatted string with correct dates for different timezones
                         $placeholder = '###PLACEHOLDER###' . $i . '###';
                         $tmpStr .= $placeholder;
                         // Collect recipients' timezones
                         foreach ($arRecipientsIDs as $userId) {
                             $tzOffset = (int) self::getUserTimeZoneOffset($userId);
                             if (!isset($arVolatileDescriptions[$tzOffset])) {
                                 $arVolatileDescriptions[$tzOffset] = array();
                             }
                             if (!isset($arVolatileDescriptions[$tzOffset][$placeholder])) {
                                 // Make bitrix timestamps for given user
                                 $bitrixTsFromValue = $utsFromValue + $tzOffset;
                                 $bitrixTsToValue = $utsToValue + $tzOffset;
                                 $description = '';
                                 if ($utsFromValue > 360000) {
                                     $fromValueAsString = FormatDate('^' . CDatabase::DateFormatToPHP(FORMAT_DATETIME), $bitrixTsFromValue);
                                     $description .= $fromValueAsString;
                                 }
                                 $description .= ' --> ';
                                 if ($utsToValue > 360000) {
                                     $toValueAsString = FormatDate('^' . CDatabase::DateFormatToPHP(FORMAT_DATETIME), $bitrixTsToValue);
                                     $description .= $toValueAsString;
                                 }
                                 $arVolatileDescriptions[$tzOffset][$placeholder] = $description;
                             }
                             $arRecipientsIDsByTimezone[$tzOffset][] = $userId;
                         }
                         break;
                     case "DESCRIPTION":
                         $tmpStr .= HTMLToTxt($arFields["DESCRIPTION"]);
                         break;
                     case "TAGS":
                         $tmpStr .= ($value["FROM_VALUE"] ? str_replace(",", ", ", $value["FROM_VALUE"]) . " -> " : "") . ($value["TO_VALUE"] ? str_replace(",", ", ", $value["TO_VALUE"]) : GetMessage("TASKS_MESSAGE_NO_VALUE"));
                         break;
                     case "PRIORITY":
                         $tmpStr .= GetMessage("TASKS_PRIORITY_" . $value["FROM_VALUE"]) . " -> " . GetMessage("TASKS_PRIORITY_" . $value["TO_VALUE"]);
                         break;
                     case "GROUP_ID":
                         if ($value["FROM_VALUE"] && self::checkUserCanViewGroup($effectiveUserId, $value["FROM_VALUE"])) {
                             $arGroupFrom = self::getSocNetGroup($value["FROM_VALUE"]);
                             if ($arGroupFrom) {
                                 $tmpStr .= $arGroupFrom["NAME"] . " -> ";
                             }
                         }
                         if ($value["TO_VALUE"] && self::checkUserCanViewGroup($effectiveUserId, $value["TO_VALUE"])) {
                             $arGroupTo = self::getSocNetGroup($value["TO_VALUE"]);
                             if ($arGroupTo) {
                                 $tmpStr .= $arGroupTo["NAME"];
                             }
                         } else {
                             $tmpStr .= GetMessage("TASKS_MESSAGE_NO_VALUE");
                         }
                         break;
                     case "PARENT_ID":
                         if ($value["FROM_VALUE"]) {
                             $rsTaskFrom = CTasks::GetList(array(), array("ID" => $value["FROM_VALUE"]), array('ID', 'TITLE'));
                             if ($arTaskFrom = $rsTaskFrom->GetNext()) {
                                 $tmpStr .= $arTaskFrom["TITLE"] . " -> ";
                             }
                         }
                         if ($value["TO_VALUE"]) {
                             $rsTaskTo = CTasks::GetList(array(), array("ID" => $value["TO_VALUE"]), array('ID', 'TITLE'));
                             if ($arTaskTo = $rsTaskTo->GetNext()) {
                                 $tmpStr .= $arTaskTo["TITLE"];
                             }
                         } else {
                             $tmpStr .= GetMessage("TASKS_MESSAGE_NO_VALUE");
                         }
                         break;
                     case "DEPENDS_ON":
                         $arTasksFromStr = array();
                         if ($value["FROM_VALUE"]) {
                             $rsTasksFrom = CTasks::GetList(array(), array("ID" => explode(",", $value["FROM_VALUE"])), array('ID', 'TITLE'));
                             while ($arTaskFrom = $rsTasksFrom->GetNext()) {
                                 $arTasksFromStr[] = $arTaskFrom["TITLE"];
                             }
                         }
                         $arTasksToStr = array();
                         if ($value["TO_VALUE"]) {
                             $rsTasksTo = CTasks::GetList(array(), array("ID" => explode(",", $value["TO_VALUE"])), array('ID', 'TITLE'));
                             while ($arTaskTo = $rsTasksTo->GetNext()) {
                                 $arTasksToStr[] = $arTaskTo["TITLE"];
                             }
                         }
                         $tmpStr .= ($arTasksFromStr ? implode(", ", $arTasksFromStr) . " -> " : "") . ($arTasksToStr ? implode(", ", $arTasksToStr) : GetMessage("TASKS_MESSAGE_NO_VALUE"));
                         break;
                     case "MARK":
                         $tmpStr .= (!$value["FROM_VALUE"] ? GetMessage("TASKS_MARK_NONE") : GetMessage("TASKS_MARK_" . $value["FROM_VALUE"])) . " -> " . (!$value["TO_VALUE"] ? GetMessage("TASKS_MARK_NONE") : GetMessage("TASKS_MARK_" . $value["TO_VALUE"]));
                         break;
                     case "ADD_IN_REPORT":
                         $tmpStr .= ($value["FROM_VALUE"] == "Y" ? GetMessage("TASKS_MESSAGE_IN_REPORT_YES") : GetMessage("TASKS_MESSAGE_IN_REPORT_NO")) . " -> " . ($value["TO_VALUE"] == "Y" ? GetMessage("TASKS_MESSAGE_IN_REPORT_YES") : GetMessage("TASKS_MESSAGE_IN_REPORT_NO"));
                         break;
                     case "DELETED_FILES":
                         $tmpStr .= $value["FROM_VALUE"];
                         $tmpStr .= $value["TO_VALUE"];
                         break;
                     case "NEW_FILES":
                         $tmpStr .= $value["TO_VALUE"];
                         break;
                 }
                 if ((string) $tmpStr != '') {
                     $changeMessage .= ": [COLOR=#000]" . $tmpStr . "[/COLOR]";
                 }
                 $arInvariantChangesStrs[] = $changeMessage;
             }
         }
         $recp2tz = array();
         foreach ($arRecipientsIDsByTimezone as $tz => $rcp) {
             foreach ($rcp as $uid) {
                 $recp2tz[$uid] = $tz;
             }
         }
         $invariantDescription = null;
         if (!empty($arInvariantChangesStrs)) {
             $invariantDescription = implode("\r\n", $arInvariantChangesStrs);
         }
         if ($invariantDescription !== null && !empty($arRecipientsIDs)) {
             // If there is no volatile part of descriptions, send to all recipients at once
             if (empty($arVolatileDescriptions)) {
                 $arVolatileDescriptions['some_timezone'] = array();
                 $arRecipientsIDsByTimezone['some_timezone'] = $arRecipientsIDs;
             }
             $updateMessage = self::getGenderMessage($occurAsUserId, 'TASKS_TASK_CHANGED_MESSAGE');
             $taskName = self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID'], false);
             $instant = str_replace(array("#TASK_TITLE#"), array($taskName), $updateMessage);
             $email = str_replace(array("#TASK_TITLE#"), array(strip_tags($taskName)), $updateMessage);
             //_dump_r('Sending UPDATE from '.$occurAsUserId.' TO '.implode(':', $arRecipientsIDs));
             CTaskNotifications::sendMessageEx($arTask["ID"], $occurAsUserId, $arRecipientsIDs, array('INSTANT' => $instant, 'EMAIL' => $email, 'PUSH' => self::makePushMessage('TASKS_TASK_CHANGED_MESSAGE', $occurAsUserId, $arTask)), array('EVENT_DATA' => array('ACTION' => 'TASK_UPDATE', 'arFields' => $arFields, 'arChanges' => $arChanges), 'TASK_ASSIGNED_TO' => $taskReassignedTo, 'CALLBACK' => array('BEFORE_SEND' => function ($message) use($isBbCodeDescription, $invariantDescription, $arVolatileDescriptions, $recp2tz) {
                 $rcp = $message['TO_USER_IDS'][0];
                 $volatile = $arVolatileDescriptions[$recp2tz[$rcp]];
                 if (is_array($volatile)) {
                     $description = str_replace(array_keys($volatile), $volatile, $invariantDescription);
                 } else {
                     $description = $invariantDescription;
                 }
                 $message['MESSAGE']['INSTANT'] = str_replace(array("#TASK_EXTRA#"), array($description), $message['MESSAGE']['INSTANT']);
                 if ($isBbCodeDescription) {
                     $parser = new CTextParser();
                     $description = str_replace("\t", '    ', $parser->convertText($description));
                 }
                 $message['MESSAGE']['EMAIL'] = str_replace(array("#TASK_EXTRA#"), array($description), $message['MESSAGE']['EMAIL']);
                 return $message;
             })));
         }
     }
     // sonet log
     self::SendMessageToSocNet($arFields, $bSpawnedByAgent, $arChanges, $arTask, $parameters);
     if ($cacheWasEnabled) {
         self::disableStaticCache();
     }
 }
Ejemplo n.º 2
0
 public static function SendUpdateMessage($arFields, $arTask, $bSpawnedByAgent = false)
 {
     global $USER;
     $isBbCodeDescription = true;
     if (isset($arFields['DESCRIPTION_IN_BBCODE'])) {
         if ($arFields['DESCRIPTION_IN_BBCODE'] === 'N') {
             $isBbCodeDescription = false;
         }
     } elseif (isset($arTask['DESCRIPTION_IN_BBCODE'])) {
         if ($arTask['DESCRIPTION_IN_BBCODE'] === 'N') {
             $isBbCodeDescription = false;
         }
     }
     $taskReassignedTo = null;
     if (isset($arFields['RESPONSIBLE_ID']) && $arFields['RESPONSIBLE_ID'] > 0 && $arFields['RESPONSIBLE_ID'] != $arTask['RESPONSIBLE_ID']) {
         $taskReassignedTo = $arFields['RESPONSIBLE_ID'];
     }
     foreach (array('CREATED_BY', 'RESPONSIBLE_ID', 'ACCOMPLICES', 'AUDITORS', 'TITLE') as $field) {
         if (!isset($arFields[$field]) && isset($arTask[$field])) {
             $arFields[$field] = $arTask[$field];
         }
     }
     $arChanges = CTaskLog::GetChanges($arTask, $arFields);
     $arMerged = array('ADDITIONAL_RECIPIENTS' => array());
     if (isset($arTask['CREATED_BY'])) {
         $arMerged['ADDITIONAL_RECIPIENTS'][] = $arTask['CREATED_BY'];
     }
     if (isset($arTask['RESPONSIBLE_ID'])) {
         $arMerged['ADDITIONAL_RECIPIENTS'][] = $arTask['RESPONSIBLE_ID'];
     }
     if (isset($arTask['ACCOMPLICES']) && is_array($arTask['ACCOMPLICES'])) {
         foreach ($arTask['ACCOMPLICES'] as $userId) {
             $arMerged['ADDITIONAL_RECIPIENTS'][] = $userId;
         }
     }
     if (isset($arTask['AUDITORS']) && is_array($arTask['AUDITORS'])) {
         foreach ($arTask['AUDITORS'] as $userId) {
             $arMerged['ADDITIONAL_RECIPIENTS'][] = $userId;
         }
     }
     if (isset($arFields['ADDITIONAL_RECIPIENTS'])) {
         $arFields['ADDITIONAL_RECIPIENTS'] = array_merge($arFields['ADDITIONAL_RECIPIENTS'], $arMerged['ADDITIONAL_RECIPIENTS']);
     } else {
         $arFields['ADDITIONAL_RECIPIENTS'] = $arMerged['ADDITIONAL_RECIPIENTS'];
     }
     $arUsers = CTaskNotifications::__GetUsers($arFields);
     $arRecipientsIDs = array_unique(CTaskNotifications::GetRecipientsIDs($arFields));
     if (!empty($arRecipientsIDs) && (is_object($USER) && $USER->GetID() || $arFields["CREATED_BY"])) {
         $curUserTzOffset = (int) CTasksTools::getTimeZoneOffset();
         $arInvariantChangesStrs = array();
         $arVolatileDescriptions = array();
         $arRecipientsIDsByTimezone = array();
         $i = 0;
         foreach ($arChanges as $key => $value) {
             ++$i;
             $actionMessage = GetMessage("TASKS_MESSAGE_" . $key);
             if (strlen($actionMessage)) {
                 $tmpStr = $actionMessage . ": [COLOR=#000]";
                 switch ($key) {
                     case 'TIME_ESTIMATE':
                         $tmpStr .= self::formatTimeHHMM($value["FROM_VALUE"], true) . " -> " . self::formatTimeHHMM($value["TO_VALUE"], true);
                         break;
                     case "TITLE":
                         $tmpStr .= $value["FROM_VALUE"] . " -> " . $value["TO_VALUE"];
                         break;
                     case "RESPONSIBLE_ID":
                         $tmpStr .= CTaskNotifications::__Users2String($value["FROM_VALUE"], $arUsers, $arFields["NAME_TEMPLATE"]) . ' -> ' . CTaskNotifications::__Users2String($value["TO_VALUE"], $arUsers, $arFields["NAME_TEMPLATE"]);
                         break;
                     case "ACCOMPLICES":
                     case "AUDITORS":
                         $tmpStr .= CTaskNotifications::__Users2String(explode(",", $value["FROM_VALUE"]), $arUsers, $arFields["NAME_TEMPLATE"]) . ' -> ' . CTaskNotifications::__Users2String(explode(",", $value["TO_VALUE"]), $arUsers, $arFields["NAME_TEMPLATE"]);
                         break;
                     case "DEADLINE":
                     case "START_DATE_PLAN":
                     case "END_DATE_PLAN":
                         // CTasks::Log() returns bitrix timestamps for dates, so adjust them to correct unix timestamps.
                         $utsFromValue = $value['FROM_VALUE'] - $curUserTzOffset;
                         $utsToValue = $value['TO_VALUE'] - $curUserTzOffset;
                         // It will be replaced below to formatted string with correct dates for different timezones
                         $placeholder = '###PLACEHOLDER###' . $i . '###';
                         $tmpStr .= $placeholder;
                         // Collect recipients' timezones
                         foreach ($arRecipientsIDs as $userId) {
                             $tzOffset = (int) CTasksTools::getTimeZoneOffset($userId);
                             if (!isset($arVolatileDescriptions[$tzOffset])) {
                                 $arVolatileDescriptions[$tzOffset] = array();
                             }
                             if (!isset($arVolatileDescriptions[$tzOffset][$placeholder])) {
                                 // Make bitrix timestamps for given user
                                 $bitrixTsFromValue = $utsFromValue + $tzOffset;
                                 $bitrixTsToValue = $utsToValue + $tzOffset;
                                 $description = '';
                                 if ($utsFromValue > 360000) {
                                     $fromValueAsString = FormatDate('^' . CDatabase::DateFormatToPHP(FORMAT_DATETIME), $bitrixTsFromValue);
                                     $description .= $fromValueAsString;
                                 }
                                 $description .= ' --> ';
                                 if ($utsToValue > 360000) {
                                     $toValueAsString = FormatDate('^' . CDatabase::DateFormatToPHP(FORMAT_DATETIME), $bitrixTsToValue);
                                     $description .= $toValueAsString;
                                 }
                                 $arVolatileDescriptions[$tzOffset][$placeholder] = $description;
                             }
                             $arRecipientsIDsByTimezone[$tzOffset][] = $userId;
                         }
                         break;
                     case "DESCRIPTION":
                         $tmpStr .= HTMLToTxt($arFields["DESCRIPTION"]);
                         break;
                     case "TAGS":
                         $tmpStr .= ($value["FROM_VALUE"] ? str_replace(",", ", ", $value["FROM_VALUE"]) . " -> " : "") . ($value["TO_VALUE"] ? str_replace(",", ", ", $value["TO_VALUE"]) : GetMessage("TASKS_MESSAGE_NO_VALUE"));
                         break;
                     case "PRIORITY":
                         $tmpStr .= GetMessage("TASKS_PRIORITY_" . $value["FROM_VALUE"]) . " -> " . GetMessage("TASKS_PRIORITY_" . $value["TO_VALUE"]);
                         break;
                     case "GROUP_ID":
                         if ($value["FROM_VALUE"] && CSocNetGroup::CanUserViewGroup($USER->GetID(), $value["FROM_VALUE"])) {
                             $arGroupFrom = CSocNetGroup::GetByID($value["FROM_VALUE"]);
                             if ($arGroupFrom) {
                                 $tmpStr .= $arGroupFrom["NAME"] . " -> ";
                             }
                         }
                         if ($value["TO_VALUE"] && CSocNetGroup::CanUserViewGroup($USER->GetID(), $value["TO_VALUE"])) {
                             $arGroupTo = CSocNetGroup::GetByID($value["TO_VALUE"]);
                             if ($arGroupTo) {
                                 $tmpStr .= $arGroupTo["NAME"];
                             }
                         } else {
                             $tmpStr .= GetMessage("TASKS_MESSAGE_NO_VALUE");
                         }
                         break;
                     case "PARENT_ID":
                         if ($value["FROM_VALUE"]) {
                             $rsTaskFrom = CTasks::GetList(array(), array("ID" => $value["FROM_VALUE"]), array('ID', 'TITLE'));
                             if ($arTaskFrom = $rsTaskFrom->GetNext()) {
                                 $tmpStr .= $arTaskFrom["TITLE"] . " -> ";
                             }
                         }
                         if ($value["TO_VALUE"]) {
                             $rsTaskTo = CTasks::GetList(array(), array("ID" => $value["TO_VALUE"]), array('ID', 'TITLE'));
                             if ($arTaskTo = $rsTaskTo->GetNext()) {
                                 $tmpStr .= $arTaskTo["TITLE"];
                             }
                         } else {
                             $tmpStr .= GetMessage("TASKS_MESSAGE_NO_VALUE");
                         }
                         break;
                     case "DEPENDS_ON":
                         $arTasksFromStr = array();
                         if ($value["FROM_VALUE"]) {
                             $rsTasksFrom = CTasks::GetList(array(), array("ID" => explode(",", $value["FROM_VALUE"])), array('ID', 'TITLE'));
                             while ($arTaskFrom = $rsTasksFrom->GetNext()) {
                                 $arTasksFromStr[] = $arTaskFrom["TITLE"];
                             }
                         }
                         $arTasksToStr = array();
                         if ($value["TO_VALUE"]) {
                             $rsTasksTo = CTasks::GetList(array(), array("ID" => explode(",", $value["TO_VALUE"])), array('ID', 'TITLE'));
                             while ($arTaskTo = $rsTasksTo->GetNext()) {
                                 $arTasksToStr[] = $arTaskTo["TITLE"];
                             }
                         }
                         $tmpStr .= ($arTasksFromStr ? implode(", ", $arTasksFromStr) . " -> " : "") . ($arTasksToStr ? implode(", ", $arTasksToStr) : GetMessage("TASKS_MESSAGE_NO_VALUE"));
                         break;
                     case "MARK":
                         $tmpStr .= (!$value["FROM_VALUE"] ? GetMessage("TASKS_MARK_NONE") : GetMessage("TASKS_MARK_" . $value["FROM_VALUE"])) . " -> " . (!$value["TO_VALUE"] ? GetMessage("TASKS_MARK_NONE") : GetMessage("TASKS_MARK_" . $value["TO_VALUE"]));
                         break;
                     case "ADD_IN_REPORT":
                         $tmpStr .= ($value["FROM_VALUE"] == "Y" ? GetMessage("TASKS_MESSAGE_IN_REPORT_YES") : GetMessage("TASKS_MESSAGE_IN_REPORT_NO")) . " -> " . ($value["TO_VALUE"] == "Y" ? GetMessage("TASKS_MESSAGE_IN_REPORT_YES") : GetMessage("TASKS_MESSAGE_IN_REPORT_NO"));
                         break;
                     case "DELETED_FILES":
                         $tmpStr .= $value["FROM_VALUE"];
                         $tmpStr .= $value["TO_VALUE"];
                         break;
                     case "NEW_FILES":
                         $tmpStr .= $value["TO_VALUE"];
                         break;
                 }
                 $tmpStr .= "[/COLOR]";
                 $arInvariantChangesStrs[] = $tmpStr;
             }
         }
         $occurAsUserId = CTasksTools::getOccurAsUserId();
         if (!$occurAsUserId) {
             $occurAsUserId = is_object($USER) && $USER->GetID() ? $USER->GetID() : $arFields["CREATED_BY"];
         }
         $invariantDescription = null;
         if (!empty($arInvariantChangesStrs)) {
             $invariantDescription = implode("\r\n", $arInvariantChangesStrs);
         }
         if ($invariantDescription !== null && !empty($arRecipientsIDs)) {
             // If there is no volatile part of descriptions, send to all recipients at once
             if (empty($arVolatileDescriptions)) {
                 $arVolatileDescriptions['some_timezone'] = array();
                 $arRecipientsIDsByTimezone['some_timezone'] = $arRecipientsIDs;
             }
             foreach ($arVolatileDescriptions as $tzOffset => $arVolatileDescriptionsData) {
                 $strDescription = $invariantDescription;
                 foreach ($arVolatileDescriptionsData as $placeholder => $strReplaceTo) {
                     $strDescription = str_replace($placeholder, $strReplaceTo, $strDescription);
                 }
                 $message = str_replace(array("#TASK_TITLE#", "#TASK_EXTRA#"), array(self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID'], true), $strDescription), GetMessage("TASKS_TASK_CHANGED_MESSAGE"));
                 if ($isBbCodeDescription) {
                     $parser = new CTextParser();
                     $htmlDescription = str_replace("\t", '    ', $parser->convertText($strDescription));
                 } else {
                     $htmlDescription = $strDescription;
                 }
                 $message_email = str_replace(array("#TASK_TITLE#", "#TASK_EXTRA#"), array(self::formatTaskName($arTask['ID'], $arTask['TITLE'], $arTask['GROUP_ID']), $htmlDescription . "\r\n" . GetMessage('TASKS_MESSAGE_LINK') . ': #PATH_TO_TASK#'), GetMessage("TASKS_TASK_CHANGED_MESSAGE"));
                 CTaskNotifications::SendMessage($occurAsUserId, $arRecipientsIDsByTimezone[$tzOffset], $message, $arTask["ID"], $message_email, array('ACTION' => 'TASK_UPDATE', 'arFields' => $arFields, 'arChanges' => $arChanges), $taskReassignedTo);
             }
         }
     }
     // sonet log
     self::SendMessageToSocNet($arFields, $bSpawnedByAgent, $arChanges, $arTask);
 }