OnBeforeMessageNotifyAdd
Event is used to work with messages in the Web Messenger. Add the event handler for im module to accomplish this.
For example, message sending can be cancelled. To do that, either false must be returned, or an array Array('result' => false, 'reason' => 'reason for cancellation')
. Then this text will be specified in the chat interface inside the messenger. Limited html - a, b, i, u, br - is available in the text.
Examples of use
AddEventHandler("im", "OnBeforeMessageNotifyAdd", "___OnBeforeMessageNotifyAdd"); public static function ___OnBeforeMessageNotifyAdd($arFields) { global $USER; if(!$USER->IsAdmin() && $arFields['MESSAGE_TYPE'] == 'P') { $imMaxMessagePerDay = 10; $date = date('Ymd'); $_SESSION['IM_ANTI_SPAM'][$date]++; if ($_SESSION['IM_ANTI_SPAM'][$date] > $imMaxMessagePerDay) { return Array( 'reason' => 'You cannot send more than 10 messages per day', 'result' => false, ); } } }
Result:
© «Bitrix24», 2001-2024