Documentation

CopyFileAccessPermission

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

The method copies the access permissions of one file or folder to another file or folder. Returns true if access permissions are copied successfully and false otherwise. Non-static method.

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", "To copy from the 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", "Copy to the path")
overwrite If true, the method does not preserve the existing permissions of the target object.
Optional parameter; false by default.

See Also

Examples of use

<?
// 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 "/en/index.php"
    if ($APPLICATION->CopyFileAccessPermission("/en/index.php", "/de/index.php", true))
         ShowNote("Access permissions successfully copied.");
}
?>


© «Bitrix24», 2001-2024
Up