Bitrix Site Manager

CMain::SetFileAccessPermission

bool
CMain::SetFileAccessPermission(
 string path,
 array permissions,
 bool overwrite = true
)

The method SetFileAccessPermission sets the access permissions for a file or folder.

Parameters

ParameterDescription
path Path to the file or folder relative to the root. In case of multiple sites, if the root directory is different, this parameters should specify an array:
array("site ID", "Path to the file or folder relative to the site root")
permissions Array with the access permissions in the format Array("user group ID"=>"permission" [, ...]). The permission can be the following:
  • D - access denied;
  • R - read (view file contents);
  • U - workflow (edit file in the Workflow);
  • W - write (direct editing);
  • X - full access (direct editing and permission modification).
The user group ID key can have the value of "*", which means all user groups.
overwrite If true, the existing permissions will be overwritten.
Optional; true by default.

Return Values

Returns true on success or false otherwise.

See Also

Example



<?
// set the following permissions for the file /en/index.php:
// for group #23 - read
// for group #5 - write
// other groups - deny access
if ($APPLICATION->SetFileAccessPermission("/en/index.php", 
    array("23" => "R", "5" => "W", "*" => "D")))
    ShowNote("Permissions successfully modified.");
?>