MDL-21915 fixing remaining chmod and mkdir to use moodle file permissions

This commit is contained in:
Petr Skoda 2010-10-06 19:06:52 +00:00
parent 29d488cffc
commit 4756e9c9e2
5 changed files with 17 additions and 11 deletions

View File

@ -159,6 +159,7 @@ class entities {
}
public function move_files ($files, $destination_folder) {
global $CFG;
if (!empty($files)) {
@ -174,7 +175,7 @@ class entities {
//echo 'Copy the file: ' . $source . ' to ' . $destination . '<br>';
if (!file_exists($destination_directory)) {
mkdir($destination_directory, 0777, true);
mkdir($destination_directory, $CFG->directorypermissions, true);
}
$copy_success = @copy($source, $destination);

View File

@ -96,6 +96,7 @@
//it supports a excluded dit too
//Copied from the web !!
function delete_dir_contents ($dir,$excludeddir="") {
global $CFG;
if (!is_dir($dir)) {
// if we've been given a directory that doesn't exist yet, return true.
@ -110,7 +111,7 @@
$dir_subdirs = array();
// Make sure we can delete it
chmod($dir, 0777);
chmod($dir, $CFG->directorypermissions);
if ((($handle = opendir($dir))) == FALSE) {
// The directory could not be opened
@ -129,7 +130,7 @@
// Delete all files in the curent directory return false and halt if a file cannot be removed
for($i=0; $i<count($dir_files); $i++) {
chmod($dir_files[$i], 0777);
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == FALSE) {
return false;
}
@ -137,7 +138,7 @@
// Empty sub directories and then remove the directory
for($i=0; $i<count($dir_subdirs); $i++) {
chmod($dir_subdirs[$i], 0777);
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if (delete_dir_contents($dir_subdirs[$i]) == FALSE) {
return false;
}

View File

@ -65,6 +65,8 @@ abstract class backup_helper {
* TODO: Modernise this
*/
static public function delete_dir_contents($dir, $excludeddir='') {
global $CFG;
if (!is_dir($dir)) {
// if we've been given a directory that doesn't exist yet, return true.
// this happens when we're trying to clear out a course that has only just
@ -78,7 +80,7 @@ abstract class backup_helper {
$dir_subdirs = array();
// Make sure we can delete it
chmod($dir, 0777);
chmod($dir, $CFG->directorypermissions);
if ((($handle = opendir($dir))) == false) {
// The directory could not be opened
@ -97,7 +99,7 @@ abstract class backup_helper {
// Delete all files in the curent directory return false and halt if a file cannot be removed
for ($i=0; $i<count($dir_files); $i++) {
chmod($dir_files[$i], 0777);
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == false) {
return false;
}
@ -105,7 +107,7 @@ abstract class backup_helper {
// Empty sub directories and then remove the directory
for ($i=0; $i<count($dir_subdirs); $i++) {
chmod($dir_subdirs[$i], 0777);
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if (self::delete_dir_contents($dir_subdirs[$i]) == false) {
return false;
} else {

View File

@ -639,7 +639,7 @@ function clam_scan_moodle_file(&$file, $course) {
$cmd = $CFG->pathtoclam .' '. $fullpath ." 2>&1";
// before we do anything we need to change perms so that clamscan can read the file (clamdscan won't work otherwise)
chmod($fullpath,0644);
chmod($fullpath, $CFG->directorypermissions);
exec($cmd, $output, $return);

View File

@ -38,6 +38,8 @@ class qformat_blackboard_six extends qformat_default {
}
function clean_temp_dir($dir='') {
global $CFG;
// for now we will just say everything happened okay note
// that a mess may be piling up in $CFG->dataroot/temp/bbquiz_import
// TODO return true at top of the function renders all the following code useless
@ -53,7 +55,7 @@ class qformat_blackboard_six extends qformat_default {
$dir_subdirs = array();
// Make sure we can delete it
chmod($dir, 0777);
chmod($dir, $CFG->directorypermissions);
if ((($handle = opendir($dir))) == FALSE) {
// The directory could not be opened
@ -72,7 +74,7 @@ class qformat_blackboard_six extends qformat_default {
// Delete all files in the curent directory return false and halt if a file cannot be removed
for($i=0; $i<count($dir_files); $i++) {
chmod($dir_files[$i], 0777);
chmod($dir_files[$i], $CFG->directorypermissions);
if (((unlink($dir_files[$i]))) == FALSE) {
return false;
}
@ -80,7 +82,7 @@ class qformat_blackboard_six extends qformat_default {
// Empty sub directories and then remove the directory
for($i=0; $i<count($dir_subdirs); $i++) {
chmod($dir_subdirs[$i], 0777);
chmod($dir_subdirs[$i], $CFG->directorypermissions);
if ($this->clean_temp_dir($dir_subdirs[$i]) == FALSE) {
return false;
}