bool event_handler( int group_id );
The OnBeforeGroupDelete event fires before the user group deletion. A common use of this module is to allow or disallow the user group deletion.
Parameter | Description |
---|---|
group_id | The ID of the user group which is to be deleted. |
To cancel the user deletion and terminate the CGroup::Delete method, raise an exception from within the handler using the method
<? // file /bitrix/php_interface/init.php // register handler AddEventHandler("main", "OnBeforeGroupDelete", Array("MyClass", "OnBeforeGroupDeleteHandler")); class MyClass { // create handler "OnBeforeGroupDelete" function OnBeforeGroupDeleteHandler($group_id) { // check if any records exist bound to the deleted group $strSql = "SELECT * FROM my_table WHERE GROUP_ID=".intval($group_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 "OnBeforeGroupDelete" for module my_module_id RegisterModuleDependences("main", "OnBeforeGroupDelete", "my_module_id", "MyClass", "OnBeforeGroupDeleteHandler"); ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |