bool event_handler( int template_id );
The OnBeforeEventMessageDelete event fires before the mail template is deleted. A common use of this module is to allow or disallow the template deletion.
Parameter | Description |
---|---|
template_id | The ID of the template which is to be deleted. |
To cancel the template deletion and terminate the CEventMessage::Delete method, raise an exception from within the handler using the method
<? // file /bitrix/modules/my_module_id/include.php class MyClass { // create handler "OnBeforeEventMessageDelete" function OnBeforeEventMessageDeleteHandler($template_id) { // check if any records exist bound to the deleted template $strSql = "SELECT * FROM my_table WHERE EMAIL_TEMPLATE_ID=".intval($template_id); $rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__); // if found... if ($ar = $rs->Fetch()) { // cancel deletion. global $APPLICATION; $APPLICATION->throwException("My table has bound records."); return false; } } } ?>
<? // register handler "OnBeforeEventMessageDelete" RegisterModuleDependences("main", "OnBeforeEventMessageDelete", "my_module_id", "MyClass", "OnBeforeEventMessageDeleteHandler"); ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |