}
public function move_files ($files, $destination_folder) {
+ global $CFG;
if (!empty($files)) {
//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);
//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.
$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
// 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;
}
// 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;
}
* 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
$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
// 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;
}
// 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 {
$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);
}
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
$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
// 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;
}
// 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;
}