Remove hotpotatoes delete bug - ref #2165

skala
Hubert Borderiou 13 years ago
parent 0d1825b1f4
commit fe5498aa6f
  1. 6
      main/exercice/exercice.php
  2. 18
      main/inc/lib/fileManage.lib.php

@ -287,8 +287,10 @@ if ($is_allowedToEdit) {
if (my_delete($documentPath . $file)) {
update_db_info("delete", $file);
}
my_delete($documentPath . $uploadPath . "/" . $fld . "/");
break;
// hotpotatoes folder may contains several tests so don't delete folder if not empty : http://support.chamilo.org/issues/2165
if (!(strstr($uploadPath, DIR_HOTPOTATOES) && !folder_is_empty($documentPath . $uploadPath . "/" . $fld . "/"))) {
my_delete($documentPath . $uploadPath . "/" . $fld . "/");
} break;
case 'enable' : // enables an exercise
$newVisibilityStatus = "1"; //"visible"
$query = "SELECT id FROM $TBL_DOCUMENT WHERE c_id = $course_id AND path='" . Database :: escape_string($file) . "'";

@ -157,6 +157,24 @@ function removeDir($dir) {
return true;
}
/**
* Return true if folder is empty
* @author : hubert.borderiou@grenet.fr
* @param string $in_folder : folder path on disk
* @return 1 if folder is empty, 0 otherwise
*/
function folder_is_empty($in_folder) {
$tab_folder_content = scandir($in_folder);
$folder_is_empty = 0;
if ((count($tab_folder_content) == 2 && in_array(".", $tab_folder_content) && in_array("..", $tab_folder_content)) || (count($tab_folder_content) < 2)) {
$folder_is_empty = 1;
}
return $folder_is_empty;
}
/**
* Renames a file or a directory
*

Loading…
Cancel
Save