[svn r13082] add api_chmod_R function and chmod imported scorm directory (recursively)

skala
Eric Marguin 17 years ago
parent 1606dbf6d6
commit 9214f00d43
  1. 27
      main/inc/lib/main_api.lib.php
  2. 9
      main/newscorm/scorm.class.php

@ -1978,4 +1978,31 @@ function copyr($source, $dest, $exclude=array(), $copied_files=array())
return $zip_files;
}
function api_chmod_R($path, $filemode) {
if (!is_dir($path))
return chmod($path, $filemode);
$dh = opendir($path);
while ($file = readdir($dh)) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
if(!is_dir($fullpath)) {
if (!chmod($fullpath, $filemode))
return FALSE;
} else {
if (!api_chmod_R($fullpath, $filemode))
return FALSE;
}
}
}
closedir($dh);
if(chmod($path, $filemode))
return TRUE;
else
return FALSE;
}
?>

@ -595,10 +595,6 @@ class scorm extends learnpath {
*/
if(is_dir($course_sys_dir.$new_dir) OR @mkdir($course_sys_dir.$new_dir))
{
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
chmod($course_sys_dir.$new_dir , $perm);
// PHP method - slower...
if($this->debug>=1){error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir,0);}
@ -662,6 +658,11 @@ class scorm extends learnpath {
closedir($dir);
chdir($saved_dir);
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
api_chmod_R($course_sys_dir.$new_dir , $perm);
}
}else{
return '';

Loading…
Cancel
Save