3 declare(strict_types=0);
44 $this->
lng = $DIC->language();
45 $this->db = $DIC->database();
46 $this->error = $DIC[
'ilErr'];
47 $this->file_id = $a_file_id;
51 public static function _cloneFiles(
int $a_source_id,
int $a_target_id): void
57 $new_file->setCourseId($a_target_id);
58 $new_file->setFileName($file_obj->getFileName());
59 $new_file->setFileSize($file_obj->getFileSize());
60 $new_file->setFileType($file_obj->getFileType());
61 $new_file->create(
false);
64 $target->initInfoDirectory();
66 $file_obj->getAbsolutePath(),
67 $new_file->fss_storage->getInfoDirectory() .
'/' . $new_file->getFileId()
74 $this->file_id = $a_id;
89 $this->course_id = $a_course_id;
94 $this->file_name = $a_name;
104 $this->file_type = $a_type;
114 $this->file_size = $a_size;
124 $this->tmp_name = $a_name;
134 $this->error_code = $a_code;
149 $file = $this->fss_storage->getInfoDirectory() .
'/' . $this->
getFileId();
150 if (!file_exists($file)) {
151 $file = $this->fss_storage->getInfoDirectory() .
'/' . $this->
getFileId() .
'.sec';
153 if (file_exists($file)) {
161 if (is_object($this->fss_storage)) {
162 return $this->fss_storage->getInfoDirectory();
170 case UPLOAD_ERR_INI_SIZE:
171 $this->error->appendMessage($this->
lng->txt(
'file_upload_ini_size'));
173 case UPLOAD_ERR_FORM_SIZE:
174 $this->error->appendMessage($this->
lng->txt(
'file_upload_form_size'));
177 case UPLOAD_ERR_PARTIAL:
178 $this->error->appendMessage($this->
lng->txt(
'file_upload_only_partial'));
181 case UPLOAD_ERR_NO_TMP_DIR:
182 $this->error->appendMessage($this->
lng->txt(
'file_upload_no_tmp_dir'));
185 case UPLOAD_ERR_NO_FILE:
194 public function create(
bool $a_upload =
true): bool
199 $next_id = $this->db->nextId(
'crs_file');
200 $query =
"INSERT INTO crs_file (file_id,course_id,file_name,file_size,file_type) " .
202 $this->db->quote($next_id,
'integer') .
", " .
203 $this->db->quote($this->
getCourseId(),
'integer') .
", " .
204 $this->db->quote($this->
getFileName(),
'text') .
", " .
205 $this->db->quote($this->
getFileSize(),
'integer') .
", " .
206 $this->db->quote($this->
getFileType(),
'text') .
" " .
212 $this->fss_storage->initInfoDirectory();
219 $this->fss_storage->getInfoDirectory() .
'/' . $this->
getFileId()
225 public function delete():
void 228 $query =
"DELETE FROM crs_file " .
229 "WHERE file_id = " . $this->db->quote($this->
getFileId(),
'integer') .
"";
242 $ilDB = $DIC[
'ilDB'];
245 $query =
"DELETE FROM crs_file " .
246 "WHERE course_id = " .
$ilDB->quote($a_course_id,
'integer') .
"";
258 $ilDB = $DIC->database();
259 $query =
"SELECT * FROM crs_file " .
260 "WHERE course_id = " .
$ilDB->quote($a_course_id,
'integer') .
"";
264 while ($row =
$ilDB->fetchObject(
$res)) {
272 if (!$this->file_id) {
277 $query =
"SELECT * FROM crs_file WHERE file_id = " . $this->db->quote($this->file_id,
'integer');
279 while ($row = $this->db->fetchObject(
$res)) {
ilFSStorageCourse $fss_storage
setTemporaryName(string $a_name)
setErrorCode(int $a_code)
setFileName(string $a_name)
setFileType(string $a_type)
static _readFilesByCourse(int $a_course_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCourseId(int $a_course_id)
create(bool $a_upload=true)
static _deleteByCourse(int $a_course_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_file_id=0)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static _cloneFiles(int $a_source_id, int $a_target_id)
Error Handling & global info handling uses PEAR error class.