Documentation

SetFileAccessPermission

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

The method sets the access permissions for a file or folder. Returns true on success and false otherwise. Non-static method.

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 file or folder relative to the root")
permissions Array with access permissions of the Array("user group ID"=>"access permissions" [, ...]) format type. "Access permissions" can have the following values:
  • 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. By default value is true.

See Also

Examples of use

<?
// 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.");
?>


© «Bitrix24», 2001-2024
Up