event_handler(
array site_path,
array permissions
);
The
OnChangePermissions event fires when the file or folder access permission is modified by a call to
$APPLICATION->SetFileAccessPermission.
Parameters
Parameter | Description |
site_path |
Array in the format array("site ID", "file path relative to the site root"). |
permissions |
Array of access permissions. |
See Also
Example
<?
// file /bitrix/modules/search/classes/mysql/search.php
class CSearch extends CAllSearch
{
// create handler "OnChangePermissions"
function OnChangeFilePermissions($path, $permission)
{
CMain::InitPathVars($site, $path);
$DOC_ROOT = CSite::GetSiteDocRoot($site);
// trim / in the end
while(strlen($path)>0 && $path[strlen($path)-1]=="/")
$path=substr($path, 0, strlen($path)-1);
global $APPLICATION, $DB;
if(file_exists($DOC_ROOT.$path))
{
@set_time_limit(300);
$arGroups = CSearch::GetGroupCached();
if(is_dir($DOC_ROOT.$path))
{
$handle = @opendir($DOC_ROOT.$path);
while($file = @readdir($handle))
{
if($file == "." || $file == "..") continue;
if(is_dir($DOC_ROOT.$path."/".$file))
{
if($path."/".$file=="/bitrix")
continue;
}
CSearch::OnChangeFilePermissions(Array($site,
$path."/".$file),
Array());
}
}
else //if(is_dir($DOCUMENT_ROOT.$path))
{
$strGPerm = "0";
for ($i=0; $i<count($arGroups); $i++)
{
if ($arGroups[$i]>1)
{
$p =
$APPLICATION->GetFileAccessPermission(Array($site,
$path),
Array($arGroups[$i]));
if ($p>="R")
{
$strGPerm .= ",".$arGroups[$i];
if($arGroups[$i]==2) break;
}
}
}
$r = $DB->Query("SELECT ID FROM b_search_content WHERE ".
"MODULE_ID='main' AND ITEM_ID='".$site."|".$path."'");
while ($arR = $r->Fetch())
$DB->Query("DELETE FROM b_search_content_group "
"WHERE SEARCH_CONTENT_ID=".$arR["ID"]);
$strSql =
"INSERT INTO b_search_content_group(SEARCH_CONTENT_ID, GROUP_ID) ".
"SELECT S.ID, G.ID ".
"FROM b_search_content S, b_group G ".
"WHERE MODULE_ID='main' ".
" AND ITEM_ID='".$site."|".$path."' ".
" AND G.ID IN (".$strGPerm.") ";
$DB->Query($strSql);
} //if(is_dir($DOCUMENT_ROOT.$path))
}//if(file_exists($DOCUMENT_ROOT.$path))
}
}
?>
Example of handler registration
<?
// register handler "OnChangePermissions"
RegisterModuleDependences("main",
"OnChangePermissions",
"search", "CSearch",
"OnChangeFilePermissions");
?>