ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilExportFileInfo.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
14{
15 const CURRENT_VERSION = "4.1.0";
16
17
18 private $obj_id = 0;
20 private $export_type = '';
21 private $file_name = '';
22 private $create_date = null;
23
27 public function __construct($a_obj_id, $a_export_type = '',$a_filename = '')
28 {
29 $this->obj_id = $a_obj_id;
30 $this->export_type = $a_export_type;
31 $this->file_name = $a_filename;
32 if($this->getObjId() and $this->getExportType() and $this->getFilename())
33 {
34 $this->read();
35 }
36 }
37
45 public static function lookupLastExport($a_obj_id,$a_type,$a_version = '')
46 {
47 global $ilDB;
48
49 $query = "SELECT * FROM export_file_info ".
50 "WHERE obj_id = ".$ilDB->quote($a_obj_id,'integer').' '.
51 "AND export_type = ".$ilDB->quote($a_type,'text').' '.
52 "ORDER BY create_date DESC";
53 $res = $ilDB->query($query);
54 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
55 {
56 if(!$a_version or $row->version == $a_version)
57 {
58 return new ilExportFileInfo($row->obj_id,$row->export_type,$row->filename);
59 }
60 }
61 return null;
62 }
63
64
70 public static function deleteByObjId($a_obj_id)
71 {
72 global $ilDB;
73
74 $ilDB->manipulate("DELETE FROM export_file_info WHERE obj_id = ".$ilDB->quote($a_obj_id));
75 return true;
76 }
77
78
79
85 public function setExportType($a_type)
86 {
87 $this->export_type = $a_type;
88 }
89
94 public function getExportType()
95 {
96 return $this->export_type;
97 }
98
104 public function setFilename($a_name)
105 {
106 $this->file_name = $a_name;
107 }
108
113 public function getFilename()
114 {
115 return $this->file_name;
116 }
117
118 public function getBasename($a_ext = '.zip')
119 {
120 return basename($this->getFilename(),$a_ext);
121 }
122
128 public function setObjId($a_id)
129 {
130 $this->obj_id = $a_id;
131 }
132
137 public function getObjId()
138 {
139 return $this->obj_id;
140 }
141
146 public function setVersion($a_version)
147 {
148 $this->version = $a_version;
149 }
150
155 public function getVersion()
156 {
157 return $this->version;
158 }
159
164 public function getCreationDate()
165 {
166 return $this->create_date instanceof ilDateTime ? $this->create_date : new ilDateTime(time(),IL_CAL_UNIX);
167 }
168
174 public function setCreationDate(ilDateTime $dt = null)
175 {
176 $this->create_date = $dt;
177 }
178
183 public function create()
184 {
185 global $ilDB;
186
187 $query = "INSERT INTO export_file_info (obj_id, export_type, filename, version, create_date) ".
188 "VALUES ( ".
189 $ilDB->quote($this->getObjId(),'integer').', '.
190 $ilDB->quote($this->getExportType(),'text').', '.
191 $ilDB->quote($this->getFilename(),'text').', '.
192 $ilDB->quote($this->getVersion(),'text').', '.
193 $ilDB->quote($this->getCreationDate()->get(IL_CAL_DATETIME,'',ilTimeZone::UTC),'timestamp').' '.
194 ")";
195 $ilDB->manipulate($query);
196 }
197
202 public function delete()
203 {
204 global $ilDB;
205
206 $ilDB->manipulate('DELETE FROM export_file_info '.
207 'WHERE obj_id = '.$ilDB->quote($this->getObjId(),'integer').' '.
208 'AND filename = '.$ilDB->quote($this->getFilename(),'text')
209 );
210 return true;
211 }
212
217 protected function read()
218 {
219 global $ilDB;
220
221 $query = "SELECT * FROM export_file_info ".
222 "WHERE obj_id = ".$ilDB->quote($this->getObjId(),'integer').' '.
223 "AND export_type = ".$ilDB->quote($this->getExportType(),'text').' '.
224 "AND filename = ".$ilDB->quote($this->getFilename(),'text');
225
226 $res = $ilDB->query($query);
227 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
228 {
229 $this->setVersion($row->version);
231 }
232 return true;
233 }
234}
235?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
@classDescription Stores information of creation date and versions of export files
setExportType($a_type)
set export type
setCreationDate(ilDateTime $dt=null)
set creation date
static deleteByObjId($a_obj_id)
Delete all export entries by obj_id.
create()
Create new export entry.
getExportType()
get export type
setFilename($a_name)
set filename
static lookupLastExport($a_obj_id, $a_type, $a_version='')
Lookup last export.
__construct($a_obj_id, $a_export_type='', $a_filename='')
Constructor.
getCreationDate()
get creation date
setVersion($a_version)
set version
setObjId($a_id)
Set obj id.
global $ilDB