Documentation

OnBeforeSendMailToAuthor

Description and parameters

handler function(
 array $arFields,
 bool $is_new
)
The event "OnBeforeSendMailToAuthor" is called directly before sending email to an employee in the Support module. Usually, the objective of this event handler is to execute a specific action before sending an e-mail.

Parameters

Parameter Description
$arFields

Array contains event parameters, passed to an event handler.

Array example:
Array
(
    [ID] => 1
    [LANGUAGE] => en
    [LANGUAGE_ID] => en
    [WHAT_CHANGE] => < added message >
< category updated >
< criticality updated >
< status updated  >

    [DATE_CREATE] => 24.07.2011 19:22:38
    [TIMESTAMP] => 24.07.2011 19:29:38
    [DATE_CLOSE] => 
    [TITLE] => My first query/ticket
    [STATUS] => Problem solving in progress
    [DIFFICULTY] => Medium
    [CATEGORY] => General
    [CRITICALITY] => High
    [RATE] => 
    [SLA] => By default
    [SOURCE] => 
    [MESSAGES_AMOUNT] => 4
    [SPAM_MARK] => 
    [ADMIN_EDIT_URL] => /bitrix/admin/ticket_edit.php
    [PUBLIC_EDIT_URL] => /support/ticket_edit.php
    [OWNER_EMAIL] => mifd@dfdf.com
    [OWNER_USER_ID] => 2
    [OWNER_USER_NAME] => John Smith
    [OWNER_USER_LOGIN] => bx_test
    [OWNER_USER_EMAIL] => mifd@dfdf.com
    [OWNER_TEXT] => [2] (bx_test) John Smith
    [OWNER_SID] => 
    [SUPPORT_EMAIL] => my@email.com
    [RESPONSIBLE_USER_ID] => 
    [RESPONSIBLE_USER_NAME] =>  
    [RESPONSIBLE_USER_LOGIN] => 
    [RESPONSIBLE_USER_EMAIL] => 
    [RESPONSIBLE_TEXT] => 
    [SUPPORT_ADMIN_EMAIL] => 
    [CREATED_USER_ID] => 2
    [CREATED_USER_LOGIN] => bx_test
    [CREATED_USER_EMAIL] => mifd@dfdf.com
    [CREATED_USER_NAME] => John Smith
    [CREATED_MODULE_NAME] => 
    [CREATED_TEXT] => [2] (bx_test) John Smith
    [MODIFIED_USER_ID] => 1
    [MODIFIED_USER_LOGIN] => admin
    [MODIFIED_USER_EMAIL] => my@email.com
    [MODIFIED_USER_NAME] => John Smith
    [MODIFIED_MODULE_NAME] => 
    [MODIFIED_TEXT] => [1] (admin) John Smith [technical support]
    [MESSAGE_AUTHOR_USER_ID] => 1
    [MESSAGE_AUTHOR_USER_NAME] => John Smith
    [MESSAGE_AUTHOR_USER_LOGIN] => admin
    [MESSAGE_AUTHOR_USER_EMAIL] => my@email.com
    [MESSAGE_AUTHOR_TEXT] => [1] (admin) Иван Иванов [technical support]
    [MESSAGE_AUTHOR_SID] => 
    [MESSAGE_SOURCE] => 
    [MESSAGE_HEADER] => ======================= СООБЩЕНИЕ ==================================
    [MESSAGE_BODY] => 

Do you have a solution to my issue?

    [MESSAGE_FOOTER] => ====================================================================
    [FILES_LINKS] => 
    [IMAGE_LINK] => 
    [SUPPORT_COMMENTS] => 
)
 
$is_new Contains true in case this is a first message in a query, otherwise returns false

Returned value

None

See Also

Handler function example

//Duplicate message in social network
//Handler in file /bitrix/php_interface/init.php
AddEventHandler("support", "OnBeforeSendMailToAuthor", array("MyClass", "OnBeforeSendMailToAuthorHandler"));
class MyClass
{
	public static function OnBeforeSendMailToAuthorHandler($arFields, $is_new)
	{
		if (CModule::IncludeModule("socialnetwork"))
		{
			$servername = "site.com";
			$message = "";
			$message .= "Тема: ".$arFields["TITLE"]."[".$arFields["ID"]."] (Query edited)\r\n";
			$message .= $arFields["WHAT_CHANGE"]."\r\n";
			$message .= "From: ".$arFields["MESSAGE_SOURCE"]." ".$arFields["MESSAGE_AUTHOR_SID"]." ".$arFields["MESSAGE_AUTHOR_TEXT"]."\r\n";
			$message .= $arFields["MESSAGE_HEADER"];
			$message .= $arFields["MESSAGE_BODY"];
			$message .= $arFields["MESSAGE_FOOTER"]."\r\n";
			$message .= "For viewing and editing the query, use the link:\r\n";
			$message .= "http://".$servername.$arFields["ADMIN_EDIT_URL"]."?ID=".$arFields["ID"]."\r\n";
			
			$arPamams = array( 
				"FROM_USER_ID" => 1, 
				"TO_USER_ID" => 1, 
				"MESSAGE" => $message, 
				"=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), 
				"MESSAGE_TYPE" => "P", 
			); 
			CSocNetMessages::Add($arPamams);
		}
	}
}
© «Bitrix24», 2001-2024
Up