1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Object/classes/class.ilObject.php");
5
6/**
7* Class ilObject2
8* This is an intermediate progress of ilObject class. Please do not ust it yet.
9*
10* @author Stefan Meyer <meyer@leifos.com>
11* @author Alex Killing <alex.killing@gmx.de>
12* @version $Id$
13*/
14abstract class ilObject2 extends ilObject
15{
16    /**
17    * Constructor
18    * @access	public
19    * @param	integer	reference_id or object_id
20    * @param	boolean	treat the id as reference_id (true) or object_id (false)
21    */
22    public function __construct($a_id = 0, $a_reference = true)
23    {
24        $this->initType();
25        parent::__construct($a_id, $a_reference);
26    }
27
28    abstract protected function initType();
29
30    final public function withReferences()
31    {
32        return parent::withReferences();
33    }
34
35    /**
36    * Read data from db
37    */
38    final public function read()
39    {
40        parent::read();
41        $this->doRead();
42    }
43    protected function doRead()
44    {
45    }
46
47    public function getId()
48    {
49        return parent::getId();
50    }
51    public function setId($a_id)
52    {
53        return parent::setId($a_id);
54    }
55    final public function setRefId($a_id)
56    {
57        return parent::setRefId($a_id);
58    }
59    final public function getRefId()
60    {
61        return parent::getRefId();
62    }
63    final public function getType()
64    {
65        return parent::getType();
66    }
67    final public function setType($a_type)
68    {
69        return parent::setType($a_type);
70    }
71    final public function getPresentationTitle()
72    {
73        return parent::getPresentationTitle();
74    }
75    final public function getTitle()
76    {
77        return parent::getTitle();
78    }
79    final public function getUntranslatedTitle()
80    {
81        return parent::getUntranslatedTitle();
82    }
83    final public function setTitle($a_title)
84    {
85        return parent::setTitle($a_title);
86    }
87    final public function getDescription()
88    {
89        return parent::getDescription();
90    }
91    final public function setDescription($a_desc)
92    {
93        return parent::setDescription($a_desc);
94    }
95    final public function getLongDescription()
96    {
97        return parent::getLongDescription();
98    }
99    final public function getImportId()
100    {
101        return parent::getImportId();
102    }
103    final public function setImportId($a_import_id)
104    {
105        return parent::setImportId($a_import_id);
106    }
107    final public static function _lookupObjIdByImportId($a_import_id)
108    {
109        return parent::_lookupObjIdByImportId($a_import_id);
110    }
111    final public function getOwner()
112    {
113        return parent::getOwner();
114    }
115    final public function getOwnerName()
116    {
117        return parent::getOwnerName();
118    }
119    final public static function _lookupOwnerName($a_owner_id)
120    {
121        return parent::_lookupOwnerName($a_owner_id);
122    }
123    final public function setOwner($a_owner)
124    {
125        return parent::setOwner($a_owner);
126    }
127    final public function getCreateDate()
128    {
129        return parent::getCreateDate();
130    }
131    final public function getLastUpdateDate()
132    {
133        return parent::getLastUpdateDate();
134    }
135
136    final public function create($a_clone_mode = false)
137    {
138        if ($this->beforeCreate()) {
139            $id = parent::create();
140            if ($id) {
141                $this->doCreate($a_clone_mode);
142                return $id;
143            }
144        }
145    }
146
147    protected function doCreate()
148    {
149    }
150
151    protected function beforeCreate()
152    {
153        return true;
154    }
155
156    final public function update()
157    {
158        if ($this->beforeUpdate()) {
159            if (!parent::update()) {
160                return false;
161            }
162            $this->doUpdate();
163
164            return true;
165        }
166
167        return false;
168    }
169
170    protected function doUpdate()
171    {
172    }
173
174    protected function beforeUpdate()
175    {
176        return true;
177    }
178
179    final public function MDUpdateListener($a_element)
180    {
181        if ($this->beforeMDUpdateListener($a_element)) {
182            if (parent::MDUpdateListener($a_element)) {
183                $this->doMDUpdateListener($a_element);
184                return true;
185            }
186        }
187        return false;
188    }
189
190    protected function doMDUpdateListener($a_element)
191    {
192    }
193
194    protected function beforeMDUpdateListener($a_element)
195    {
196        return true;
197    }
198
199    final public function createMetaData()
200    {
201        if ($this->beforeCreateMetaData()) {
202            if (parent::createMetaData()) {
203                $this->doCreateMetaData();
204                return true;
205            }
206        }
207        return false;
208    }
209
210    protected function doCreateMetaData()
211    {
212    }
213
214    protected function beforeCreateMetaData()
215    {
216        return true;
217    }
218
219    final public function updateMetaData()
220    {
221        if ($this->beforeUpdateMetaData()) {
222            if (parent::updateMetaData()) {
223                $this->doUpdateMetaData();
224                return true;
225            }
226        }
227        return false;
228    }
229
230    protected function doUpdateMetaData()
231    {
232    }
233
234    protected function beforeUpdateMetaData()
235    {
236        return true;
237    }
238
239    final public function deleteMetaData()
240    {
241        return parent::deleteMetaData();
242    }
243    final public function updateOwner()
244    {
245        return parent::updateOwner();
246    }
247    final public static function _getIdForImportId($a_import_id)
248    {
249        return parent::_getIdForImportId($a_import_id);
250    }
251    final public static function _getAllReferences($a_id)
252    {
253        return parent::_getAllReferences($a_id);
254    }
255    final public static function _lookupTitle($a_id)
256    {
257        return parent::_lookupTitle($a_id);
258    }
259    final public static function _lookupOwner($a_id)
260    {
261        return parent::_lookupOwner($a_id);
262    }
263    final public static function _getIdsForTitle($title, $type = '', $partialmatch = false)
264    {
265        return parent::_getIdsForTitle($title, $type, $partialmatch);
266    }
267    final public static function _lookupDescription($a_id)
268    {
269        return parent::_lookupDescription($a_id);
270    }
271    final public static function _lookupLastUpdate($a_id, $a_as_string = false)
272    {
273        return parent::_lookupLastUpdate($a_id, $a_as_string);
274    }
275    final public static function _getLastUpdateOfObjects($a_objs)
276    {
277        return parent::_getLastUpdateOfObjects($a_objs);
278    }
279    final public static function _lookupObjId($a_id)
280    {
281        return parent::_lookupObjId($a_id);
282    }
283    final public static function _setDeletedDate($a_ref_id)
284    {
285        return parent::_setDeletedDate($a_ref_id);
286    }
287    final public static function _resetDeletedDate($a_ref_id)
288    {
289        return parent::_resetDeletedDate($a_ref_id);
290    }
291    final public static function _lookupDeletedDate($a_ref_id)
292    {
293        return parent::_lookupDeletedDate($a_ref_id);
294    }
295    final public static function _writeTitle($a_obj_id, $a_title)
296    {
297        return parent::_writeTitle($a_obj_id, $a_title);
298    }
299    final public static function _writeDescription($a_obj_id, $a_desc)
300    {
301        return parent::_writeDescription($a_obj_id, $a_desc);
302    }
303    final public static function _writeImportId($a_obj_id, $a_import_id)
304    {
305        return parent::_writeImportId($a_obj_id, $a_import_id);
306    }
307    final public static function _lookupType($a_id, $a_reference = false)
308    {
309        return parent::_lookupType($a_id, $a_reference);
310    }
311    final public static function _isInTrash($a_ref_id)
312    {
313        return parent::_isInTrash($a_ref_id);
314    }
315    final public static function _hasUntrashedReference($a_obj_id)
316    {
317        return parent::_hasUntrashedReference($a_obj_id);
318    }
319    final public static function _lookupObjectId($a_ref_id)
320    {
321        return parent::_lookupObjectId($a_ref_id);
322    }
323    final public static function _getObjectsDataForType($a_type, $a_omit_trash = false)
324    {
325        return parent::_getObjectsDataForType($a_type, $a_omit_trash);
326    }
327    final public function putInTree($a_parent_ref)
328    {
329        return parent::putInTree($a_parent_ref);
330    }
331    final public function setPermissions($a_parent_ref)
332    {
333        return parent::setPermissions($a_parent_ref);
334    }
335    final public function createReference()
336    {
337        return parent::createReference();
338    }
339    final public function countReferences()
340    {
341        return parent::countReferences();
342    }
343
344    final public function delete()
345    {
346        if ($this->beforeDelete()) {
347            if (parent::delete()) {
348                $this->doDelete();
349                $this->id = null;
350                return true;
351            }
352        }
353        return false;
354    }
355
356    protected function doDelete()
357    {
358    }
359
360    protected function beforeDelete()
361    {
362        return true;
363    }
364
365    public function initDefaultRoles()
366    {
367        return array();
368    }
369
370    final public static function _exists($a_id, $a_reference = false, $a_type = null)
371    {
372        return parent::_exists($a_id, $a_reference, $a_type);
373    }
374    final public function setRegisterMode($a_bool)
375    {
376        return parent::setRegisterMode($a_bool);
377    }
378    final public function isUserRegistered($a_user_id = 0)
379    {
380        return parent::isUserRegistered($a_user_id);
381    }
382    final public function requireRegistration()
383    {
384        return parent::requireRegistration();
385    }
386    //final function getXMLZip() { return parent::getXMLZip(); }
387    //final function getHTMLDirectory() { return parent::getHTMLDirectory(); }
388    final public static function _getObjectsByType($a_obj_type = "", $a_owner = "")
389    {
390        return parent::_getObjectsByType($a_obj_type, $a_owner);
391    }
392
393    final public static function _prepareCloneSelection($a_ref_ids, $new_type, $a_show_path = true)
394    {
395        return parent::_prepareCloneSelection($a_ref_ids, $new_type, $a_show_path);
396    }
397    final public function appendCopyInfo($a_target_id, $a_copy_id)
398    {
399        return parent::appendCopyInfo($a_target_id, $a_copy_id);
400    }
401    final public function cloneMetaData($target_obj)
402    {
403        return parent::cloneMetaData($target_obj);
404    }
405
406    final public function cloneObject($a_target_id, $a_copy_id = null, $a_omit_tree = false)
407    {
408        if ($this->beforeCloneObject()) {
409            $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
410            if ($new_obj) {
411                $this->doCloneObject($new_obj, $a_target_id, $a_copy_id);
412                return $new_obj;
413            }
414        }
415    }
416
417    protected function doCloneObject($new_obj, $a_target_id, $a_copy_id = null)
418    {
419    }
420
421    protected function beforeCloneObject()
422    {
423        return true;
424    }
425
426    public function cloneDependencies($a_target_id, $a_copy_id)
427    {
428        return parent::cloneDependencies($a_target_id, $a_copy_id);
429    }
430
431    final public static function _getIcon($a_obj_id = "", $a_size = "big", $a_type = "", $a_offline = false)
432    {
433        return parent::_getIcon($a_obj_id, $a_size, $a_type, $a_offline);
434    }
435}
436