4 require_once(
"classes/class.ilFileData.php");
39 define(
'EXERCISE_PATH',
'exercise');
48 $this->obj_id = $a_obj_id;
69 $dp = opendir($this->exercise_path);
71 while(
$file = readdir($dp))
80 if(!is_dir($this->exercise_path.
'/'.
$file))
84 'size' => filesize($this->exercise_path.
'/'.
$file),
86 'fullpath' => $this->exercise_path.
'/'.
$file);
99 $this->getExercisePath().
"/".$a_new_obj_id.
'_'.$file[
"name"]);
110 $delivered_file_path = $this->
getExercisePath() .
"/" . $this->obj_id .
"/";
111 if (is_dir($delivered_file_path))
113 include_once
"./Services/Utilities/classes/class.ilUtil.php";
133 if ($secure_filename)
140 if(isset($a_http_post_file) && $a_http_post_file[
'size'])
155 rename($a_http_post_file[
'tmp_name'],
176 if ($secure_filename)
183 if(count($content) > 0 )
192 if (!$vir[0] ||$vir[1] !=
"")
209 function deliverFile($a_http_post_file, $user_id, $is_unziped =
false)
215 if(isset($a_http_post_file) && $a_http_post_file[
'size'])
227 $savepath .=
'/' .$user_id;
228 if(!is_dir($savepath))
234 if (!is_dir($savepath))
236 require_once
"./Services/Utilities/classes/class.ilUtil.php";
237 #ilUtil::makeDirParents($savepath);
241 $prefix = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
"year"], $now[
"mon"], $now[
"mday"], $now[
"hours"],
242 $now[
"minutes"], $now[
"seconds"]);
248 $savepath .
"/" . $prefix .
"_" .
$filename);
253 rename($a_http_post_file[
'tmp_name'],
254 $savepath .
"/" . $prefix .
"_" .
$filename);
257 require_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
259 if (is_file($savepath .
"/" . $prefix .
"_" .
$filename))
262 "filename" => $prefix .
"_" . $filename,
263 "fullname" => $savepath .
"/" . $prefix .
"_" . $filename,
278 require_once
"./Services/Utilities/classes/class.ilUtil.php";
279 global
$lng, $ilObjDataCache;
290 if (!is_dir($savepath))
305 foreach ($members as $id => $object) {
306 $directory = $savepath.DIRECTORY_SEPARATOR.$id;
309 if ($dirsize > disk_free_space($tmpdir)) {
318 foreach ($members as $id =>
$user)
320 $sourcedir = $savepath.DIRECTORY_SEPARATOR.$id;
321 if (!is_dir($sourcedir))
325 if (array_key_exists($directory,
$cache))
329 if (array_key_exists($directory,
$cache)) {
331 $directory .=
"_".$id;
335 $cache[$directory] = $directory;
337 $sourcefiles = scandir($sourcedir);
338 foreach ($sourcefiles as $sourcefile) {
339 if ($sourcefile ==
"." || $sourcefile ==
"..")
341 $targetfile = trim(basename($sourcefile));
342 $pos = strpos($targetfile,
"_");
347 $targetfile= substr($targetfile, $pos + 1);
349 $targetfile = $directory.DIRECTORY_SEPARATOR.$targetfile;
350 $sourcefile = $sourcedir.DIRECTORY_SEPARATOR.$sourcefile;
352 if (!copy ($sourcefile, $targetfile))
355 $this->ilias->raiseError(
'Could not copy '.basename($sourcefile).
" to '".$targetfile.
"'.",
356 $this->ilias->error_obj->MESSAGE);
361 touch($targetfile, filectime($sourcefile));
368 $tmpzipfile = $tmpfile .
".zip";
374 $exerciseTitle = $ilObjDataCache->lookupTitle($this->
getObjId());
375 ilUtil::deliverFile($tmpzipfile, (strlen($exerciseTitle) == 0? strtolower($lng->txt(
"excs")) : $exerciseTitle).
".zip");
390 if(is_array($a_filenames))
392 foreach($a_filenames as
$file)
410 if(file_exists($this->exercise_path.
'/'.$this->obj_id.
'_'.$a_filename))
412 return unlink($this->exercise_path.
'/'.$this->obj_id.
'_'.$a_filename);
423 return $this->exercise_path.
'/'.$this->obj_id.
'_'.$a_path;
436 foreach($a_files as
$file)
438 if(!file_exists($this->exercise_path.
'/'.$this->obj_id.
'_'.$file))
467 if(is_writable($this->exercise_path) && is_readable($this->exercise_path))
473 $this->ilias->raiseError(
"Exercise directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
484 if(is_writable($this->
getPath()))
499 if(file_exists($a_path))
502 return rename($a_path,$a_path.
'.old');