[svn r15180] Improvements and cleanup for the course archiver tool

skala
Yannick Warnier 18 years ago
parent 22575299ab
commit f705aad0f7
  1. 30
      main/coursecopy/classes/CourseArchiver.class.php
  2. 11
      main/coursecopy/classes/mkdirr.php
  3. 18
      main/coursecopy/classes/rmdirr.php

@ -1,5 +1,5 @@
<?php
// $Id: CourseArchiver.class.php 11378 2007-03-04 01:34:09Z yannoo $
// $Id: CourseArchiver.class.php 15180 2008-04-29 22:40:16Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -70,11 +70,29 @@ class CourseArchiver
$zip_dir = api_get_path(SYS_ARCHIVE_PATH).'';
$user = api_get_user_info();
$zip_file = $user['user_id'].'_'.$course->code.'_'.date("YmdHis").'.zip';
mkdir($backup_dir, 0755);
$res = @mkdir($backup_dir, 0755);
if($res == false)
{
//TODO set and handle an error message telling the user to review the permissions on the archive directory
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini').' - This error, occuring because your archive directory will not let this script write data into it, will prevent courses backups to be created',0);
}
// Write the course-object to the file
$fp = fopen($course_info_file, 'w');
fwrite($fp, base64_encode(serialize($course)));
fclose($fp);
$fp = @fopen($course_info_file, 'w');
if($fp == false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
$res = @fwrite($fp, base64_encode(serialize($course)));
if($res == false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
$res = @fclose($fp);
if($res == false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
// Copy all documents to the temp-dir
if( is_array($course->resources[RESOURCE_DOCUMENT]))
@ -193,4 +211,4 @@ class CourseArchiver
return $course;
}
}
?>
?>

@ -1,4 +1,4 @@
<?php // $Id: mkdirr.php 3305 2005-02-03 12:44:01Z bmol $
<?php // $Id: mkdirr.php 15180 2008-04-29 22:40:16Z yannoo $
/**
* Create a directory structure recursively
*
@ -25,11 +25,16 @@ function mkdirr($pathname, $mode = null)
$next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
if (mkdirr($next_pathname, $mode)) {
if (!file_exists($pathname)) {
return mkdir($pathname, $mode);
$res = @mkdir($pathname, $mode);
if($res == false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
return $res;
}
}
return false;
}
?>
?>

@ -1,4 +1,4 @@
<?php // $Id: rmdirr.php 3305 2005-02-03 12:44:01Z bmol $
<?php // $Id: rmdirr.php 15180 2008-04-29 22:40:16Z yannoo $
/**
* Delete a file, or a folder and its contents
*
@ -16,7 +16,12 @@ function rmdirr($dirname)
// Simple delete for a file
if (is_file($dirname)) {
return unlink($dirname);
$res = @unlink($dirname);
if($res === false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
return $res;
}
// Loop through the folder
@ -33,7 +38,12 @@ function rmdirr($dirname)
// Clean up
$dir->close();
return rmdir($dirname);
$res = @rmdir($dirname);
if($res === false)
{
error_log(__FILE__.' line '.__LINE__.': '.(ini_get('track_errors')!=false?$php_errormsg:'error not recorded because track_errors is off in your php.ini'),0);
}
return $res;
}
?>
?>

Loading…
Cancel
Save