Bitrix Site Manager

OnBeforeLanguageDelete

bool
event_handler(
 string language_id
);

The OnBeforeLanguageDelete event fires before the language deletion. A common use of this module is to allow or disallow the language deletion.

Parameters

ParameterDescription
language_id The ID of the language which is to be deleted.

Return Values

To cancel the language deletion and terminate the CLanguage::Delete method, raise an exception from within the handler using the method $APPLICATION->ThrowException() and return false.

See Also

Example



<?
// file /bitrix/modules/my_module_id/include.php
class MyClass
{
    // create handler "OnBeforeLanguageDelete"
    function OnBeforeLanguageDeleteHandler($language_id)
    {
        // check if any records exist bound to the deleted language
        $strSql = "SELECT * FROM my_table WHERE LANGUAGE_ID=".$DB->ForSql($language_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;
        }
    }
}
?>

Example of handler registration


<?
// register handler "OnBeforeLanguageDelete"
RegisterModuleDependences("main", 
                          "OnBeforeLanguageDelete", 
                          "my_module_id", 
                          "MyClass", 
                          "OnBeforeLanguageDeleteHandler");
?>