Documentation

OnBeforeGroupDelete

bool
handler function(
 int group_id
);
The event "OnBeforeGroupDelete" fires before user group is deleted. Usually, the purpose of this event handler is to allow or deny deletion of user group.

Parameters

ParameterDescription
group_id Deleted user group ID.

Returned value

To cancel user deletion and terminate the execution for the method CGroup::Delete, throw an exception in the handler function via the method$APPLICATION->ThrowException() and return false.

See Also

Example:

<?
// file /bitrix/php_interface/init.php
// register the handler
AddEventHandler("main", "OnBeforeGroupDelete", Array("MyClass", "OnBeforeGroupDeleteHandler"));
class MyClass { // create the event handler "OnBeforeGroupDelete" public static function OnBeforeGroupDeleteHandler($group_id) { // check if records, associated with the deleted group are available $strSql = "SEL ECT * FR OM my_table WHERE GROUP_ID=".intval($group_id); $rs = $DB->Query($strSql, false, "FILE: ".__FILE__."<br>LINE: ".__LINE__); // if associated records are available if ($ar = $rs->Fetch()) { // deny the deletion of user group global $APPLICATION; $APPLICATION->throwException("My table has the associated records."); return false; } } } ?>

Example of handler function registration:

<?
// register the event handler "OnBeforeGroupDelete" for the my_module_id
RegisterModuleDependences("main", "OnBeforeGroupDelete", 
     "my_module_id", "MyClass", "OnBeforeGroupDeleteHandler");
?>


© «Bitrix24», 2001-2024
Up