4 require_once
"Services/Object/classes/class.ilObject2.php";
5 include_once(
'Modules/File/classes/class.ilFSStorageFile.php');
38 $this->raise_upload_error =
true;
57 protected function doCreate($a_upload =
false, $a_prevent_meta_data_creation =
false)
78 $this->file_storage->create();
86 require_once(
"./Services/History/classes/class.ilHistory.php");
91 require_once(
"./Services/News/classes/class.ilNewsItem.php");
93 if ($default_visibility ==
"public")
96 1, 0, $this->
getId());
99 $q =
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) "
100 .
"VALUES (".$ilDB->quote($this->
getId() ,
'integer').
","
103 .$ilDB->quote((
int) $this->
getFileSize() ,
'integer').
","
104 .$ilDB->quote(1 ,
'integer').
",".$ilDB->quote($this->
getMode() ,
'text').
")";
105 $res = $ilDB->manipulate($q);
108 if ($this->
getMode() !=
"filelist" && !$a_prevent_meta_data_creation)
122 $technical = $md_obj->addTechnical();
125 $format = $technical->addFormat();
128 $technical->update();
135 include_once
'Services/MetaData/classes/class.ilMD.php';
137 if(!is_object($md_gen = $md->getGeneral()))
142 $md_gen->setTitle(
$title);
150 include_once
'Services/MetaData/classes/class.ilMD.php';
158 if(!is_object($md_technical = $md->getTechnical()))
163 foreach($md_technical->getFormatIds() as
$id)
165 $md_format = $md_technical->getFormat(
$id);
179 $version_subdir =
"";
184 $version_subdir = sprintf(
"%03d", $a_version);
188 if(!is_object($this->file_storage))
193 return $this->file_storage->getAbsolutePath().
'/'.$version_subdir;
203 $this->raise_upload_error = $a_raise;
227 require_once(
"./Services/History/classes/class.ilHistory.php");
231 $a_filename.
",".$this->getVersion()
233 $this->setFilename($a_filename);
242 require_once(
"./Services/History/classes/class.ilHistory.php");
246 $a_filename.
",".$this->getVersion()
248 $this->setFilename($a_filename);
257 function copy($a_source,$a_destination)
275 $ilDB->manipulate(
"UPDATE file_data SET version = 1 WHERE file_id = ".$ilDB->quote($this->getId() ,
'integer'));
279 require_once(
"./Services/History/classes/class.ilHistory.php");
291 $q =
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
292 $r = $this->ilias->db->query($q);
307 if ($this->
getMode() !=
"filelist")
324 $q =
"UPDATE file_data SET file_name = ".$ilDB->quote($this->
getFileName() ,
'text').
325 ", file_type = ".$ilDB->quote($this->getFiletype() ,
'text').
" ".
326 ", file_size = ".$ilDB->quote((
int) $this->
getFileSize() ,
'integer').
" ".
327 ", version = ".$ilDB->quote($this->
getVersion() ,
'integer').
" ".
328 ", f_mode = ".$ilDB->quote($this->
getMode() ,
'text').
" ".
329 "WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
330 $res = $ilDB->manipulate($q);
342 if(!is_object($technical = $md_obj->getTechnical()))
344 $technical = $md_obj->addTechnical();
349 $format_ids = $technical->getFormatIds();
350 if (count($format_ids) > 0)
352 $format = $technical->getFormat($format_ids[0]);
358 $format = $technical->addFormat();
362 $technical->update();
370 $this->filename = $a_name;
383 $this->filetype = $a_type;
393 $this->filesize = $a_size;
398 return $this->filesize;
408 require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
416 if (is_null($a_hist_entry_id))
422 require_once(
"./Services/History/classes/class.ilHistory.php");
425 if ($entry ===
false)
430 $data = explode(
",",$entry[
"info_params"]);
447 $this->version = $a_version;
452 return $this->version;
462 $this->mode = $a_mode;
479 $q =
"UPDATE file_data SET ".
480 " file_type = ".$ilDB->quote($a_format ,
'text').
481 " WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
482 $res = $ilDB->manipulate($q);
490 $q =
"SELECT * FROM file_data WHERE file_id = ".$ilDB->quote($a_id ,
'integer');
491 $r = $ilDB->query($q);
501 require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
510 require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
519 if (is_null($a_hist_entry_id))
525 require_once(
"./Services/History/classes/class.ilHistory.php");
528 if ($entry ===
false)
533 $data = explode(
",",$entry[
"info_params"]);
548 if (is_null($a_hist_entry_id))
553 if (@!is_file(
$file))
560 require_once(
"./Services/History/classes/class.ilHistory.php");
563 if ($entry ===
false)
565 echo
"3";
return false;
568 $data = explode(
",",$entry[
"info_params"]);
580 if (@!is_file(
$file))
591 global $ilClientIniFile;
592 if ($ilClientIniFile->readVariable(
'file_access',
'download_with_uploaded_filename') !=
'1')
612 require_once
'Modules/File/classes/class.ilObjFileAccess.php';
621 require_once
'Modules/File/classes/class.ilObjFileAccess.php';
628 require_once
'Modules/File/classes/class.ilObjFileAccess.php';
641 $path = pathinfo($a_file);
642 if (
$path[
"extension"] !=
"")
648 $filename =
"dummy.".$this->getFileExtension();
650 include_once(
"./Services/Utilities/classes/class.ilMimeTypeUtil.php");
705 $a_new_obj->createDirectory();
712 $query =
"INSERT INTO file_data (file_id,file_name,file_type,file_size,version,f_mode) VALUES (".
713 $ilDB->quote($a_new_obj->getId() ,
'integer').
",".
714 $ilDB->quote($this->getFileName() ,
'text').
",".
715 $ilDB->quote($this->getFileType() ,
'text').
",".
716 $ilDB->quote((
int) $this->getFileSize() ,
'integer').
", ".
717 $ilDB->quote($this->getVersion() ,
'integer').
", ".
718 $ilDB->quote($this->getMode() ,
'text').
")";
719 $res = $ilDB->manipulate($query);
722 require_once(
"./Services/History/classes/class.ilHistory.php");
726 $a_new_obj->addNewsNotification(
"file_created");
737 if (count($usages) == 0)
749 $q =
"DELETE FROM file_data WHERE file_id = ".$ilDB->quote($this->
getId() ,
'integer');
750 $this->ilias->db->query($q);
753 require_once(
"./Services/History/classes/class.ilHistory.php");
763 if ($this->
getMode() !=
"filelist")
778 $subdir =
"il_".IL_INST_ID.
"_file_".$this->
getId();
783 if (@!is_dir($filedir))
798 $ilDB->manipulate(
"DELETE FROM file_usage WHERE usage_type = ".
799 $ilDB->quote($a_type,
"text").
800 " AND usage_id = ".$ilDB->quote((
int) $a_id,
"integer").
801 " AND usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr,
"integer"));
807 function _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr = 0)
811 $ilDB->manipulate(
"DELETE FROM file_usage WHERE usage_type = ".
812 $ilDB->quote((
string) $a_type,
"text").
813 " AND usage_id = ".$ilDB->quote((
int) $a_id,
"integer").
814 " AND usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr,
"integer").
815 " AND id = ".$ilDB->quote((
int) $a_mob_id,
"integer"));
817 $ilDB->manipulate(
"INSERT INTO file_usage (id, usage_type, usage_id, usage_hist_nr) VALUES".
818 " (".$ilDB->quote((
int) $a_mob_id,
"integer").
",".
819 $ilDB->quote((
string) $a_type,
"text").
",".
820 $ilDB->quote((
int) $a_id,
"integer").
",".
821 $ilDB->quote((
int) $a_usage_hist_nr,
"integer").
")");
832 $q =
"SELECT * FROM file_usage WHERE id = ".$ilDB->quote($this->
getId(),
"integer");
833 $us_set = $ilDB->query($q);
835 while($us_rec = $ilDB->fetchAssoc($us_set))
837 $ret[] = array(
"type" => $us_rec[
"usage_type"],
838 "id" => $us_rec[
"usage_id"],
839 "hist_nr" => $us_rec[
"usage_hist_nr"]);
858 $q =
"SELECT * FROM file_usage WHERE ".
859 "usage_id = ".$ilDB->quote((
int) $a_id,
"integer").
" AND ".
860 "usage_type = ".$ilDB->quote((
string) $a_type,
"text").
" AND ".
861 "usage_hist_nr = ".$ilDB->quote((
int) $a_usage_hist_nr,
"integer");
862 $file_set = $ilDB->query($q);
864 while($file_rec = $ilDB->fetchAssoc($file_set))
866 $ret[$file_rec[
"id"]] = $file_rec[
"id"];
896 include_once(
"./Services/News/classes/class.ilNewsItem.php");
897 include_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
899 $news_item->setContext($this->
getId(), $this->
getType());
901 $news_item->setTitle($a_lang_var);
902 $news_item->setContentIsLangVar(
true);
905 $news_item->setContent(
909 $news_item->setUserId($ilUser->getId());
911 $news_item->create();
945 rename($a_upload_file,
$file);
956 $version_subdir =
"";
958 if (!is_numeric($a_version))
962 $version_subdir = DIRECTORY_SEPARATOR.sprintf(
"%03d", $a_version);
963 return $file_storage->getAbsolutePath().$version_subdir.DIRECTORY_SEPARATOR.$filename;
972 include_once
'./Modules/File/classes/class.ilObjFileAccess.php';
975 if ($titleExtension != $fileExtension && strlen($fileExtension) > 0)
979 $suffix = $pi[
"extension"];
982 if (substr($new_title,
983 strlen($new_title) - strlen($suffix) - 1)
986 $new_title = substr($new_title, 0, strlen($new_title) - strlen($suffix) - 1);
989 $new_title .=
'.'.$fileExtension;