added isWritable check

This commit is contained in:
Roland Gruber 2011-12-10 08:46:16 +00:00
parent 6376cae6e3
commit c57efe1a4c
1 changed files with 15 additions and 0 deletions

View File

@ -213,6 +213,21 @@ function saveSelfServiceProfile($name, $scope, $profile) {
return true;
}
/**
* Checks if a service profile is writable.
*
* @param string $name profile name
* @param string $scope account type
* @return boolean true if file is writable
*/
function isSelfServiceProfileWritable($name, $scope) {
// check profile name
if (!preg_match("/^[0-9a-z _-]+$/i", $scope)) return false;
if (!preg_match("/^[0-9a-z _-]+$/i", $name)) return false;
$path = substr(__FILE__, 0, strlen(__FILE__) - 20) . "/config/selfService/" . $name . "." . $scope;
return is_writable($path);
}
/**
* Returns a hash array (module name => elements) of all module options for the configuration page.
*