Exemplo n.º 1
0
 public static function Notify(&$arFields, $schemeTypeID, $tag = '')
 {
     if (!is_array($arFields)) {
         return false;
     }
     $responsibleID = $arFields['RESPONSIBLE_ID'] ? intval($arFields['RESPONSIBLE_ID']) : 0;
     if ($responsibleID <= 0) {
         return false;
     }
     if ($schemeTypeID === CCrmNotifierSchemeType::IncomingEmail) {
         $showUrl = CCrmOwnerType::GetShowUrl($arFields['OWNER_TYPE_ID'] ? intval($arFields['OWNER_TYPE_ID']) : 0, $arFields['OWNER_ID'] ? intval($arFields['OWNER_ID']) : 0);
         if ($showUrl === '') {
             return false;
         }
         $subject = isset($arFields['SUBJECT']) ? $arFields['SUBJECT'] : '';
         $addresserHtml = '';
         $communications = isset($arFields['COMMUNICATIONS']) ? $arFields['COMMUNICATIONS'] : array();
         if (!empty($communications)) {
             $comm = $communications[0];
             $caption = '';
             if (isset($comm['ENTITY_TYPE_ID']) && isset($comm['ENTITY_ID'])) {
                 $caption = CCrmOwnerType::GetCaption($comm['ENTITY_TYPE_ID'], $comm['ENTITY_ID']);
             }
             if ($caption === '') {
                 $caption = $comm['VALUE'];
             }
             $addresserShowUrl = CCrmOwnerType::GetShowUrl($comm['ENTITY_TYPE_ID'], $comm['ENTITY_ID']);
             $addresserHtml = $addresserShowUrl !== '' ? '<a target="_blank" href="' . htmlspecialcharsbx($addresserShowUrl) . '">' . htmlspecialcharsbx($caption) . '</a>' : htmlspecialcharsbx($caption);
         }
         if ($addresserHtml === '') {
             $messageTemplate = GetMessage('CRM_ACTIVITY_NOTIFY_MESSAGE_INCOMING_EMAIL');
             return CCrmNotifier::Notify($responsibleID, str_replace('#VIEW_URL#', htmlspecialcharsbx($showUrl), $messageTemplate), str_replace('#VIEW_URL#', htmlspecialcharsbx(CCrmUrlUtil::ToAbsoluteUrl($showUrl)), $messageTemplate), $schemeTypeID, $tag);
         }
         $messageTemplate = GetMessage('CRM_ACTIVITY_NOTIFY_MESSAGE_INCOMING_EMAIL_EXT');
         return CCrmNotifier::Notify($responsibleID, str_replace(array('#VIEW_URL#', '#SUBJECT#', '#ADDRESSER#'), array(htmlspecialcharsbx($showUrl), htmlspecialcharsbx($subject), $addresserHtml), $messageTemplate), str_replace(array('#VIEW_URL#', '#SUBJECT#', '#ADDRESSER#'), array(htmlspecialcharsbx(CCrmUrlUtil::ToAbsoluteUrl($showUrl)), htmlspecialcharsbx($subject), $addresserHtml), $messageTemplate), $schemeTypeID, $tag);
     }
     return false;
 }
Exemplo n.º 2
0
 private static function ClearErrors()
 {
     if (!empty(self::$ERRORS)) {
         self::$ERRORS = array();
     }
 }