Inheritance diagram for ilFileDataExercise:
Collaboration diagram for ilFileDataExercise:Public Member Functions | |
| ilFileDataExercise ($a_obj_id=0) | |
| Constructor call base constructors checks if directory is writable and sets the optional obj_id. | |
| getObjId () | |
| getExercisePath () | |
| get exercise path public | |
| getFiles () | |
| ilClone ($a_new_obj_id) | |
| delete () | |
| storeUploadedFile ($a_http_post_file, $secure_filename=false) | |
| store uploaded file in filesystem | |
| deliverFile ($a_http_post_file, $user_id) | |
| store delivered file in filesystem | |
| downloadAllDeliveredFiles ($members) | |
| unlinkFiles ($a_filenames) | |
| unlink files: expects an array of filenames e.g. | |
| unlinkFile ($a_filename) | |
| unlink one uploaded file expects a filename e.g 'foo' | |
| getAbsolutePath ($a_path) | |
| get absolute path of filename | |
| checkFilesExist ($a_files) | |
| check if files exist | |
| __checkPath () | |
| __checkReadWrite () | |
| check if directory is writable overwritten method from base class private | |
| __initDirectory () | |
| init directory overwritten method public | |
| __rotateFiles ($a_path) | |
| rotate files with same name recursive method | |
Data Fields | |
| $obj_id | |
| $exercise_path | |
Definition at line 35 of file class.ilFileDataExercise.php.
| ilFileDataExercise::__checkPath | ( | ) |
Definition at line 333 of file class.ilFileDataExercise.php.
References __checkReadWrite(), and getExercisePath().
Referenced by ilFileDataExercise().
{
if(!@file_exists($this->getExercisePath()))
{
return false;
}
$this->__checkReadWrite();
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilFileDataExercise::__checkReadWrite | ( | ) |
check if directory is writable overwritten method from base class private
Definition at line 349 of file class.ilFileDataExercise.php.
Referenced by __checkPath().
{
if(is_writable($this->exercise_path) && is_readable($this->exercise_path))
{
return true;
}
else
{
$this->ilias->raiseError("Exercise directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
}
}
Here is the caller graph for this function:| ilFileDataExercise::__initDirectory | ( | ) |
init directory overwritten method public
Definition at line 366 of file class.ilFileDataExercise.php.
References ilFileData::getPath(), and ilUtil::makeDir().
Referenced by ilFileDataExercise().
{
if(is_writable($this->getPath()))
{
return ilUtil::makeDir($this->excercise_path = $this->getPath().'/'.EXERCISE_PATH);
}
return false;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilFileDataExercise::__rotateFiles | ( | $ | a_path | ) |
rotate files with same name recursive method
| string | filename private |
Definition at line 381 of file class.ilFileDataExercise.php.
Referenced by storeUploadedFile().
{
if(file_exists($a_path))
{
$this->__rotateFiles($a_path.".old");
return rename($a_path,$a_path.'.old');
}
return true;
}
Here is the caller graph for this function:| ilFileDataExercise::checkFilesExist | ( | $ | a_files | ) |
check if files exist
| array | filenames to check public |
Definition at line 316 of file class.ilFileDataExercise.php.
References $file.
{
if($a_files)
{
foreach($a_files as $file)
{
if(!file_exists($this->exercise_path.'/'.$this->obj_id.'_'.$file))
{
return false;
}
}
return true;
}
return true;
}
| ilFileDataExercise::delete | ( | ) |
Definition at line 123 of file class.ilFileDataExercise.php.
References $file, ilUtil::escapeShellArg(), getExercisePath(), getFiles(), and unlinkFile().
{
foreach($this->getFiles() as $file)
{
$this->unlinkFile($file["name"]);
}
$delivered_file_path = $this->getExercisePath() . "/" . $this->obj_id . "/";
if (is_dir($delivered_file_path))
{
system("rm -rf " . ilUtil::escapeShellArg($delivered_file_path));
}
return true;
}
Here is the call graph for this function:| ilFileDataExercise::deliverFile | ( | $ | a_http_post_file, | |
| $ | user_id | |||
| ) |
store delivered file in filesystem
| array | HTTP_POST_FILES | |
| numeric | database id of the user who delivered the file public |
Definition at line 178 of file class.ilFileDataExercise.php.
References $result, getExercisePath(), ilObjMediaObject::getMimeType(), ilUtil::makeDir(), and ilUtil::moveUploadedFile().
Referenced by downloadAllDeliveredFiles().
{
// TODO:
// CHECK UPLOAD LIMIT
//
$result = false;
if(isset($a_http_post_file) && $a_http_post_file['size'])
{
$filename = $a_http_post_file['name'];
// replace whitespaces with underscores
$filename = preg_replace("/\s/", "_", $filename);
// remove all special characters
$filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
if(!is_dir($savepath = $this->getExercisePath()."/".$this->obj_id))
{
ilUtil::makeDir($savepath);
}
$savepath .= '/' .$user_id;
if(!is_dir($savepath))
{
ilUtil::makeDir($savepath);
}
// CHECK IF FILE PATH EXISTS
if (!is_dir($savepath))
{
require_once "./classes/class.ilUtil.php";
#ilUtil::makeDirParents($savepath);
ilUtil::makeDir($savepath);
}
$now = getdate();
$prefix = sprintf("%04d%02d%02d%02d%02d%02d", $now["year"], $now["mon"], $now["mday"], $now["hours"],
$now["minutes"], $now["seconds"]);
//move_uploaded_file($a_http_post_file["tmp_name"], $savepath . $prefix . "_" . $filename);
ilUtil::moveUploadedFile($a_http_post_file["tmp_name"], $a_http_post_file["name"],
$savepath . "/" . $prefix . "_" . $filename);
require_once "./content/classes/Media/class.ilObjMediaObject.php";
$result = array(
"filename" => $prefix . "_" . $filename,
"fullname" => $savepath . "/" . $prefix . "_" . $filename,
"mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
);
}
return $result;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilFileDataExercise::downloadAllDeliveredFiles | ( | $ | members | ) |
Definition at line 225 of file class.ilFileDataExercise.php.
References $id, $lng, deliverFile(), ilUtil::escapeShellArg(), getExercisePath(), and ilUtil::ilTempnam().
{
require_once "./classes/class.ilUtil.php";
global $lng;
ksort($members);
$tmpfile = ilUtil::ilTempnam();
$fh = fopen($tmpfile, "w");
if ($fh)
{
foreach ($members as $id => $member)
{
fwrite($fh, "$id\t$member\n");
}
fclose($fh);
}
$savepath = $this->getExercisePath() . "/" . $this->obj_id . "/";
copy($tmpfile, $savepath . "users.txt");
$cdir = getcwd();
// important check: if the directory does not exist
// ILIAS stays in the current directory (echoing only a warning)
// and the zip command below archives the whole ILIAS directory
// (including the data directory) and sends a mega file to the user :-o
if (!is_dir($savepath))
{
return;
}
chdir($savepath);
$zip = PATH_TO_ZIP;
$tmpfile = ilUtil::ilTempnam();
$tmpzipfile = $tmpfile . ".zip";
$zipcmd = $zip." -r ".ilUtil::escapeShellArg($tmpzipfile)." *";
exec($zipcmd);
ilUtil::deliverFile($tmpzipfile, strtolower($lng->txt("excs")) . ".zip");
chdir($cdir);
unlink($savepath . "users.txt");
unlink($tmpfile);
unlink($tmpzipfile);
}
Here is the call graph for this function:| ilFileDataExercise::getAbsolutePath | ( | $ | a_path | ) |
get absolute path of filename
| string | relative path public |
Definition at line 305 of file class.ilFileDataExercise.php.
{
return $this->exercise_path.'/'.$this->obj_id.'_'.$a_path;
}
| ilFileDataExercise::getExercisePath | ( | ) |
get exercise path public
Definition at line 82 of file class.ilFileDataExercise.php.
Referenced by __checkPath(), delete(), deliverFile(), downloadAllDeliveredFiles(), ilClone(), and storeUploadedFile().
{
return $this->exercise_path;
}
Here is the caller graph for this function:| ilFileDataExercise::getFiles | ( | ) |
Definition at line 87 of file class.ilFileDataExercise.php.
References $file, $obj_id, and ilFormat::formatDate().
Referenced by delete(), and ilClone().
{
$files = array();
$dp = opendir($this->exercise_path);
while($file = readdir($dp))
{
if(is_dir($file))
{
continue;
}
list($obj_id,$rest) = split('_',$file,2);
if($obj_id == $this->obj_id)
{
if(!is_dir($this->exercise_path.'/'.$file))
{
$files[] = array(
'name' => $rest,
'size' => filesize($this->exercise_path.'/'.$file),
'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($this->exercise_path.'/'.$file))));
}
}
}
closedir($dp);
return $files;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilFileDataExercise::getObjId | ( | ) |
Definition at line 72 of file class.ilFileDataExercise.php.
{
return $this->obj_id;
}
| ilFileDataExercise::ilClone | ( | $ | a_new_obj_id | ) |
Definition at line 114 of file class.ilFileDataExercise.php.
References $file, getExercisePath(), and getFiles().
{
foreach($this->getFiles() as $file)
{
@copy($this->getExercisePath()."/".$this->obj_id.'_'.$file["name"],
$this->getExercisePath()."/".$a_new_obj_id.'_'.$file["name"]);
}
return true;
}
Here is the call graph for this function:| ilFileDataExercise::ilFileDataExercise | ( | $ | a_obj_id = 0 |
) |
Constructor call base constructors checks if directory is writable and sets the optional obj_id.
| integereger | obj_id public |
Definition at line 58 of file class.ilFileDataExercise.php.
References __checkPath(), __initDirectory(), ilFileData::getPath(), and ilFileData::ilFileData().
{
define('EXERCISE_PATH','exercise');
parent::ilFileData();
$this->exercise_path = parent::getPath()."/".EXERCISE_PATH;
// IF DIRECTORY ISN'T CREATED CREATE IT
if(!$this->__checkPath())
{
$this->__initDirectory();
}
$this->obj_id = $a_obj_id;
}
Here is the call graph for this function:| ilFileDataExercise::storeUploadedFile | ( | $ | a_http_post_file, | |
| $ | secure_filename = false | |||
| ) |
store uploaded file in filesystem
| array | HTTP_POST_FILES public |
Definition at line 145 of file class.ilFileDataExercise.php.
References __rotateFiles(), getExercisePath(), and ilUtil::moveUploadedFile().
{
// TODO:
// CHECK UPLOAD LIMIT
//
$filename = $a_http_post_file['name'];
if ($secure_filename)
{
// replace whitespaces with underscores
$filename = preg_replace("/\s/", "_", $filename);
// remove all special characters
$filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
}
if(isset($a_http_post_file) && $a_http_post_file['size'])
{
// CHECK IF FILE WITH SAME NAME EXISTS
$this->__rotateFiles($this->getExercisePath().'/'.$this->obj_id.'_'.$filename);
//move_uploaded_file($a_http_post_file['tmp_name'],$this->getExercisePath().'/'.$this->obj_id.'_'.
// $filename);
ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'],
$this->getExercisePath().'/'.$this->obj_id.'_'.$filename);
}
return true;
}
Here is the call graph for this function:| ilFileDataExercise::unlinkFile | ( | $ | a_filename | ) |
unlink one uploaded file expects a filename e.g 'foo'
| string | filename to delete public |
Definition at line 292 of file class.ilFileDataExercise.php.
Referenced by delete(), and unlinkFiles().
{
if(file_exists($this->exercise_path.'/'.$this->obj_id.'_'.$a_filename))
{
return unlink($this->exercise_path.'/'.$this->obj_id.'_'.$a_filename);
}
}
Here is the caller graph for this function:| ilFileDataExercise::unlinkFiles | ( | $ | a_filenames | ) |
unlink files: expects an array of filenames e.g.
array('foo','bar')
| array | filenames to delete public |
Definition at line 272 of file class.ilFileDataExercise.php.
References $file, and unlinkFile().
{
if(is_array($a_filenames))
{
foreach($a_filenames as $file)
{
if(!$this->unlinkFile($file))
{
return $file;
}
}
}
return '';
}
Here is the call graph for this function:| ilFileDataExercise::$exercise_path |
Definition at line 49 of file class.ilFileDataExercise.php.
| ilFileDataExercise::$obj_id |
Definition at line 42 of file class.ilFileDataExercise.php.
Referenced by getFiles().
1.7.1