Example #1
0
 public function eventHandler(\Bitrix\Main\Entity\Event $event)
 {
     //die();
     $result = new \Bitrix\Main\Entity\EventResult();
     echo 'Тело события<br>';
     $result->modifyFields(array('result' => 'Сообщение вернул обработчик'));
     return $result;
 }
Example #2
0
 public static function OnBeforeIntantMessangerChatAdd(\Bitrix\Main\Entity\Event $event)
 {
     $result = new \Bitrix\Main\Entity\EventResult();
     $fields = $event->getParameter('fields');
     $entityType = isset($fields['ENTITY_TYPE']) ? $fields['ENTITY_TYPE'] : '';
     $m = null;
     if (preg_match('/^CRM_([A-Z]+)$/i', $entityType, $m) === 1) {
         $entityTypeName = isset($m[1]) ? $m[1] : '';
         $ownerTypeID = CCrmOwnerType::ResolveID($entityTypeName);
         $ownerID = isset($fields['ENTITY_ID']) ? intval($fields['ENTITY_ID']) : 0;
         $ownerInfo = null;
         if (CCrmOwnerType::IsDefined($ownerTypeID) && $ownerID > 0 && CCrmOwnerType::TryGetInfo($ownerTypeID, $ownerID, $ownerInfo, false)) {
             $changedFields['TITLE'] = $ownerInfo['CAPTION'];
             $changedFields['AVATAR'] = $ownerInfo['IMAGE_ID'];
             $result->modifyFields($changedFields);
         }
     }
     return $result;
 }