Bitrix Site Manager

CMain::CopyFileAccessPermission

bool
CMain::CopyFileAccessPermission(
 string path_from,
 string path_to,
 bool overwrite = false
)

The method CopyFileAccessPermission copies the access permissions of one file or folder to another file or folder.

Parameters

ParameterDescription
path_from Source object to copy the permissions from. In case of multiple sites, if the DOCUMENT_ROOT (specified in the field Path to the web server root folder in the site settings, System settings -> Sites -> the site) of the source and target sites are different, pass an array in the following format:
array("Site ID", "Source path")
path_to Target object to assign the permissions to. In case of multiple sites, if the DOCUMENT_ROOT (specified in the field Path to the web server root folder in the site settings, System settings -> Sites -> the site) of the source and target sites are different, pass an array in the following format:
array("Site ID", "Target path")
overwrite If true, the method does not preserve the existing permissions of the target object.
Optional; false by default.

Return Values

Returns true on success or false otherwise.

See Also

Example



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

    // copy the permissions of the file "/en/index.php" to the file "/de/index.php"
    if ($APPLICATION->CopyFileAccessPermission("/en/index.php", "/de/index.php", true))
         ShowNote("Access permissions successfully copied.");
}
?>