ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObject.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
13 class ilObject
14 {
18  const TITLE_LENGTH = 128;
19 
20 
26  var $ilias;
27 
33  var $lng;
34 
40  var $id; // true object_id!!!!
41  var $ref_id;// reference_id
42  var $type;
43  var $title;
44  // BEGIN WebDAV: WebDAV needs to access the untranslated title of an object
46  // END WebDAV: WebDAV needs to access the untranslated title of an object
47  var $desc;
49  var $owner;
53  var $register = false; // registering required for object? set to true to implement a subscription interface
54 
61 
68 
74 
79  var $max_desc;
80 
85  var $add_dots;
86 
91 
98  function ilObject($a_id = 0, $a_reference = true)
99  {
100  global $ilias, $lng, $ilBench;
101 
102  $ilBench->start("Core", "ilObject_Constructor");
103 
104  if (DEBUG)
105  {
106  echo "<br/><font color=\"red\">type(".$this->type.") id(".$a_id.") referenced(".$a_reference.")</font>";
107  }
108 
109  $this->ilias =& $ilias;
110  $this->lng =& $lng;
111 
112  $this->max_title = MAXLENGTH_OBJ_TITLE;
113  $this->max_desc = MAXLENGTH_OBJ_DESC;
114  $this->add_dots = true;
115 
116  $this->referenced = $a_reference;
117  $this->call_by_reference = $a_reference;
118 
119  if ($a_id == 0)
120  {
121  $this->referenced = false; // newly created objects are never referenced
122  } // they will get referenced if createReference() is called
123 
124  if ($this->referenced)
125  {
126  $this->ref_id = $a_id;
127  }
128  else
129  {
130  $this->id = $a_id;
131  }
132  // read object data
133  if ($a_id != 0)
134  {
135  $this->read();
136  }
137 
138  $ilBench->stop("Core", "ilObject_Constructor");
139  }
140 
144  function withReferences()
145  {
146  // both vars could differ. this method should always return true if one of them is true without changing their status
147  return ($this->call_by_reference) ? true : $this->referenced;
148  }
149 
150 
156  function read($a_force_db = false)
157  {
158  global $objDefinition, $ilBench, $ilDB, $log;
159 
160  $ilBench->start("Core", "ilObject_read");
161 
162  if (isset($this->obj_data_record) && !$a_force_db)
163  {
164  $obj = $this->obj_data_record;
165  }
166  else if ($this->referenced)
167  {
168  // check reference id
169  if (!isset($this->ref_id))
170  {
171  $message = "ilObject::read(): No ref_id given! (".$this->type.")";
172  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
173  }
174 
175  // read object data
176  $ilBench->start("Core", "ilObject_read_readData");
177 
178  $q = "SELECT * FROM object_data, object_reference WHERE object_data.obj_id=object_reference.obj_id ".
179  "AND object_reference.ref_id= ".$ilDB->quote($this->ref_id, "integer");
180  $object_set = $ilDB->query($q);
181  $ilBench->stop("Core", "ilObject_read_readData");
182 
183  // check number of records
184  if ($ilDB->numRows($object_set) == 0)
185  {
186  $message = "ilObject::read(): Object with ref_id ".$this->ref_id." not found! (".$this->type.")";
187  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
188  }
189 
190  $obj = $ilDB->fetchAssoc($object_set);
191  }
192  else
193  {
194  // check object id
195  if (!isset($this->id))
196  {
197  $message = "ilObject::read(): No obj_id given! (".$this->type.")";
198  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
199  }
200 
201  // read object data
202  $q = "SELECT * FROM object_data ".
203  "WHERE obj_id = ".$ilDB->quote($this->id, "integer");
204  $object_set = $ilDB->query($q);
205 
206  // check number of records
207  if ($ilDB->numRows($object_set) == 0)
208  {
209  $message = "ilObject::read(): Object with obj_id: ".$this->id." (".$this->type.") not found!";
210  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
211  }
212 
213  $obj = $ilDB->fetchAssoc($object_set);
214  }
215 
216  $this->id = $obj["obj_id"];
217 
218  // check type match (the "xxx" type is used for the unit test)
219  if ($this->type != $obj["type"] && $obj["type"] != "xxx")
220  {
221  $message = "ilObject::read(): Type mismatch. Object with obj_id: ".$this->id." ".
222  "was instantiated by type '".$this->type."'. DB type is: ".$obj["type"];
223 
224  // write log entry
225  $log->write($message);
226 
227  // raise error
228  $this->ilias->raiseError("ilObject::read(): Type mismatch. (".$this->type."/".$this->id.")",$this->ilias->error_obj->WARNING);
229  }
230 
231  $this->type = $obj["type"];
232  $this->title = $obj["title"];
233  // BEGIN WebDAV: WebDAV needs to access the untranslated title of an object
234  $this->untranslatedTitle = $obj["title"];
235  // END WebDAV: WebDAV needs to access the untranslated title of an object
236  $this->desc = $obj["description"];
237  $this->owner = $obj["owner"];
238  $this->create_date = $obj["create_date"];
239  $this->last_update = $obj["last_update"];
240  $this->import_id = $obj["import_id"];
241 
242  if($objDefinition->isRBACObject($this->getType()))
243  {
244  // Read long description
245  $query = "SELECT * FROM object_description WHERE obj_id = ".$ilDB->quote($this->id,'integer');
246  $res = $this->ilias->db->query($query);
247  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
248  {
249  if(strlen($row->description))
250  {
251  $this->setDescription($row->description);
252  }
253  }
254  }
255 
256  // multilingual support systemobjects (sys) & categories (db)
257  $ilBench->start("Core", "ilObject_Constructor_getTranslation");
258  $translation_type = $objDefinition->getTranslationType($this->type);
259 
260  if ($translation_type == "sys")
261  {
262  $this->title = $this->lng->txt("obj_".$this->type);
263  $this->desc = $this->lng->txt("obj_".$this->type."_desc");
264  }
265  elseif ($translation_type == "db")
266  {
267  $q = "SELECT title,description FROM object_translation ".
268  "WHERE obj_id = ".$ilDB->quote($this->id,'integer')." ".
269  "AND lang_code = ".$ilDB->quote($this->ilias->account->getCurrentLanguage(),'text')." ".
270  "AND NOT lang_default = 1";
271  $r = $this->ilias->db->query($q);
272  $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
273 
274  if ($row)
275  {
276  $this->title = $row->title;
277  $this->setDescription($row->description);
278  #$this->desc = $row->description;
279  }
280  }
281 
282  $ilBench->stop("Core", "ilObject_Constructor_getTranslation");
283 
284  $ilBench->stop("Core", "ilObject_read");
285  }
286 
292  function getId()
293  {
294  return $this->id;
295  }
296 
302  function setId($a_id)
303  {
304  $this->id = $a_id;
305  }
306 
312  function setRefId($a_id)
313  {
314  $this->ref_id = $a_id;
315  $this->referenced = true;
316  }
317 
323  function getRefId()
324  {
325  return $this->ref_id;
326  }
327 
333  function getType()
334  {
335  return $this->type;
336  }
337 
343  function setType($a_type)
344  {
345  $this->type = $a_type;
346  }
347 
357  public function getPresentationTitle()
358  {
359  return $this->getTitle();
360  }
361 
362 
368  function getTitle()
369  {
370  return $this->title;
371  }
372  // BEGIN WebDAV: WebDAV needs to access the untranslated title of an object
379  {
381  }
382  // END WebDAV: WebDAV needs to access the untranslated title of an object
383 
390  function setTitle($a_title)
391  {
392  $this->title = ilUtil::shortenText($a_title, $this->max_title, $this->add_dots);
393  // BEGIN WebDAV: WebDAV needs to access the untranslated title of an object
394  $this->untranslatedTitle = $this->title;
395  // END WebDAV: WebDAV needs to access the untranslated title of an object
396  }
397 
404  function getDescription()
405  {
406  return $this->desc;
407  }
408 
415  function setDescription($a_desc)
416  {
417  // Shortened form is storted in object_data. Long form is stored in object_description
418  $this->desc = ilUtil::shortenText($a_desc, $this->max_desc, $this->add_dots);
419 
420  $this->long_desc = $a_desc;
421 
422  return true;
423  }
424 
432  {
433  return strlen($this->long_desc) ? $this->long_desc : $this->desc;
434  }
435 
442  function getImportId()
443  {
444  return $this->import_id;
445  }
446 
453  function setImportId($a_import_id)
454  {
455  $this->import_id = $a_import_id;
456  }
457 
458  public static function _lookupObjIdByImportId($a_import_id)
459  {
460  global $ilDB;
461 
462  $query = "SELECT * FROM object_data ".
463  "WHERE import_id = ".$ilDB->quote($a_import_id, "text")." ".
464  "ORDER BY create_date DESC";
465  $res = $ilDB->query($query);
466  while($row = $ilDB->fetchObject($res))
467  {
468  return $row->obj_id;
469  }
470  return 0;
471  }
472 
479  function getOwner()
480  {
481  return $this->owner;
482  }
483 
484  /*
485  * get full name of object owner
486  *
487  * @access public
488  * @return string owner name or unknown
489  */
490  function getOwnerName()
491  {
492  return ilObject::_lookupOwnerName($this->getOwner());
493  }
494 
498  function _lookupOwnerName($a_owner_id)
499  {
500  global $lng;
501 
502  if ($a_owner_id != -1)
503  {
504  if (ilObject::_exists($a_owner_id))
505  {
506  $owner = new ilObjUser($a_owner_id);
507  }
508  }
509 
510  if (is_object($owner))
511  {
512  $own_name = $owner->getFullname();
513  }
514  else
515  {
516  $own_name = $lng->txt("unknown");
517  }
518 
519  return $own_name;
520  }
521 
528  function setOwner($a_owner)
529  {
530  $this->owner = $a_owner;
531  }
532 
533 
534 
540  function getCreateDate()
541  {
542  return $this->create_date;
543  }
544 
550  function getLastUpdateDate()
551  {
552  return $this->last_update;
553  }
554 
555 
567  function getDiskUsage()
568  {
569  return null;
570  }
571 
580  function setObjDataRecord($a_record)
581  {
582  $this->obj_data_record = $a_record;
583  }
584 
593  function create()
594  {
595  global $ilDB, $log,$ilUser,$objDefinition;
596 
597  if (!isset($this->type))
598  {
599  $message = get_class($this)."::create(): No object type given!";
600  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
601  }
602 
603  // write log entry
604  $log->write("ilObject::create(), start");
605 
606  $this->title = ilUtil::shortenText($this->getTitle(), $this->max_title, $this->add_dots);
607  $this->desc = ilUtil::shortenText($this->getDescription(), $this->max_desc, $this->add_dots);
608 
609  // determine owner
610  if ($this->getOwner() > 0)
611  {
612  $owner = $this->getOwner();
613  }
614  elseif(is_object($ilUser))
615  {
616  $owner = $ilUser->getId();
617  }
618  else
619  {
620  $owner = 0;
621  }
622  $this->id = $ilDB->nextId("object_data");
623  $q = "INSERT INTO object_data ".
624  "(obj_id,type,title,description,owner,create_date,last_update,import_id) ".
625  "VALUES ".
626  "(".
627  $ilDB->quote($this->id, "integer").",".
628  $ilDB->quote($this->type, "text").",".
629  $ilDB->quote($this->getTitle(), "text").",".
630  $ilDB->quote($this->getDescription(), "text").",".
631  $ilDB->quote($owner, "integer").",".
632  $ilDB->now().",".
633  $ilDB->now().",".
634  $ilDB->quote($this->getImportId(), "text").")";
635 
636  $ilDB->manipulate($q);
637 
638  //$this->id = $ilDB->getLastInsertId();
639 
640 
641  // Save long form of description if is rbac object
642  if($objDefinition->isRBACObject($this->getType()))
643  {
644  $values = array(
645  'obj_id' => array('integer',$this->id),
646  'description' => array('clob', $this->getLongDescription()));
647 //var_dump($values);
648  $ilDB->insert('object_description',$values);
649  }
650 
651 
652  // the line ($this->read();) messes up meta data handling: meta data,
653  // that is not saved at this time, gets lost, so we query for the dates alone
654  //$this->read();
655  $q = "SELECT last_update, create_date FROM object_data".
656  " WHERE obj_id = ".$ilDB->quote($this->id, "integer");
657  $obj_set = $ilDB->query($q);
658  $obj_rec = $ilDB->fetchAssoc($obj_set);
659  $this->last_update = $obj_rec["last_update"];
660  $this->create_date = $obj_rec["create_date"];
661 
662  // set owner for new objects
663  $this->setOwner($owner);
664 
665  // write log entry
666  $log->write("ilObject::create(), finished, obj_id: ".$this->id.", type: ".
667  $this->type.", title: ".$this->getTitle());
668 
669  $GLOBALS['ilAppEventHandler']->raise(
670  'Services/Object',
671  'create',
672  array('obj_id' => $this->id,'obj_type' => $this->type));
673 
674  return $this->id;
675  }
676 
683  function update()
684  {
685  global $objDefinition, $ilDB;
686 
687  $q = "UPDATE object_data ".
688  "SET ".
689  "title = ".$ilDB->quote($this->getTitle(), "text").",".
690  "description = ".$ilDB->quote($this->getDescription(), "text").", ".
691  "import_id = ".$ilDB->quote($this->getImportId(), "text").",".
692  "last_update = ".$ilDB->now()." ".
693  "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
694  $ilDB->manipulate($q);
695 
696  // the line ($this->read();) messes up meta data handling: meta data,
697  // that is not saved at this time, gets lost, so we query for the dates alone
698  //$this->read();
699  $q = "SELECT last_update FROM object_data".
700  " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
701  $obj_set = $ilDB->query($q);
702  $obj_rec = $ilDB->fetchAssoc($obj_set);
703  $this->last_update = $obj_rec["last_update"];
704 
705  if($objDefinition->isRBACObject($this->getType()))
706  {
707  // Update long description
708  $res = $this->ilias->db->query("SELECT * FROM object_description WHERE obj_id = ".
709  $ilDB->quote($this->getId(),'integer'));
710  if($res->numRows())
711  {
712  $values = array(
713  'description' => array('clob',$this->getLongDescription())
714  );
715  $ilDB->update('object_description',$values,array('obj_id' => array('integer',$this->getId())));
716  }
717  else
718  {
719  $values = array(
720  'description' => array('clob',$this->getLongDescription()),
721  'obj_id' => array('integer',$this->getId()));
722  $ilDB->insert('object_description',$values);
723  }
724  }
725  $GLOBALS['ilAppEventHandler']->raise(
726  'Services/Object',
727  'update',
728  array('obj_id' => $this->getId(),
729  'obj_type' => $this->getType(),
730  'ref_id' => $this->getRefId()));
731 
732  return true;
733  }
734 
746  function MDUpdateListener($a_element)
747  {
748  include_once 'Services/MetaData/classes/class.ilMD.php';
749 
750  $GLOBALS['ilAppEventHandler']->raise(
751  'Services/Object',
752  'update',
753  array('obj_id' => $this->getId(),
754  'obj_type' => $this->getType(),
755  'ref_id' => $this->getRefId()));
756 
757  switch($a_element)
758  {
759  case 'General':
760 
761  // Update Title and description
762  $md = new ilMD($this->getId(),0, $this->getType());
763  if(!is_object($md_gen = $md->getGeneral()))
764  {
765  return false;
766  }
767  $this->setTitle($md_gen->getTitle());
768 
769  foreach($md_gen->getDescriptionIds() as $id)
770  {
771  $md_des = $md_gen->getDescription($id);
772  $this->setDescription($md_des->getDescription());
773  break;
774  }
775  $this->update();
776  break;
777 
778  default:
779  }
780 
781  return true;
782  }
783 
787  function createMetaData()
788  {
789  include_once 'Services/MetaData/classes/class.ilMDCreator.php';
790 
791  global $ilUser;
792 
793  $md_creator = new ilMDCreator($this->getId(),0,$this->getType());
794  $md_creator->setTitle($this->getTitle());
795  $md_creator->setTitleLanguage($ilUser->getPref('language'));
796  $md_creator->setDescription($this->getLongDescription());
797  $md_creator->setDescriptionLanguage($ilUser->getPref('language'));
798  $md_creator->setKeywordLanguage($ilUser->getPref('language'));
799  $md_creator->setLanguage($ilUser->getPref('language'));
800  $md_creator->create();
801 
802  return true;
803  }
804 
808  function updateMetaData()
809  {
810  include_once("Services/MetaData/classes/class.ilMD.php");
811  include_once("Services/MetaData/classes/class.ilMDGeneral.php");
812  include_once("Services/MetaData/classes/class.ilMDDescription.php");
813 
814  $md =& new ilMD($this->getId(), 0, $this->getType());
815  $md_gen =& $md->getGeneral();
816  // BEGIN WebDAV: meta data can be missing sometimes.
817  if ($md_gen == null)
818  {
819  $this->createMetaData();
820  $md =& new ilMD($this->getId(), 0, $this->getType());
821  $md_gen =& $md->getGeneral();
822  }
823  // END WebDAV: meta data can be missing sometimes.
824  $md_gen->setTitle($this->getTitle());
825 
826  // sets first description (maybe not appropriate)
827  $md_des_ids =& $md_gen->getDescriptionIds();
828  if (count($md_des_ids) > 0)
829  {
830  $md_des =& $md_gen->getDescription($md_des_ids[0]);
831  $md_des->setDescription($this->getLongDescription());
832  $md_des->update();
833  }
834  $md_gen->update();
835 
836  }
837 
841  function deleteMetaData()
842  {
843  // Delete meta data
844  include_once('Services/MetaData/classes/class.ilMD.php');
845  $md = new ilMD($this->getId(), 0, $this->getType());
846  $md->deleteAll();
847  }
848 
855  function updateOwner()
856  {
857  global $ilDB;
858 
859  $q = "UPDATE object_data ".
860  "SET ".
861  "owner = ".$ilDB->quote($this->getOwner(), "integer").", ".
862  "last_update = ".$ilDB->now()." ".
863  "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
864  $ilDB->manipulate($q);
865 
866  $q = "SELECT last_update FROM object_data".
867  " WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
868  $obj_set = $ilDB->query($q);
869  $obj_rec = $ilDB->fetchAssoc($obj_set);
870  $this->last_update = $obj_rec["last_update"];
871 
872  return true;
873  }
874 
882  function _getIdForImportId($a_import_id)
883  {
884  global $ilDB;
885 
886  $ilDB->setLimit(1,0);
887  $q = "SELECT * FROM object_data WHERE import_id = ".$ilDB->quote($a_import_id, "text").
888  " ORDER BY create_date DESC";
889  $obj_set = $ilDB->query($q);
890 
891  if ($obj_rec = $ilDB->fetchAssoc($obj_set))
892  {
893  return $obj_rec["obj_id"];
894  }
895  else
896  {
897  return 0;
898  }
899  }
900 
906  public static function _getAllReferences($a_id)
907  {
908  global $ilDB;
909 
910  $query = "SELECT * FROM object_reference WHERE obj_id = ".
911  $ilDB->quote($a_id,'integer');
912 
913  $res = $ilDB->query($query);
914  $ref = array();
915  while($obj_rec = $ilDB->fetchAssoc($res))
916  {
917  $ref[$obj_rec["ref_id"]] = $obj_rec["ref_id"];
918  }
919 
920  return $ref;
921  }
922 
928  public static function _lookupTitle($a_id)
929  {
930  global $ilObjDataCache;
931 
932  $tit = $ilObjDataCache->lookupTitle($a_id);
933  return $tit;
934  }
935 
941  function _lookupOwner($a_id)
942  {
943  global $ilObjDataCache;
944 
945  $owner = $ilObjDataCache->lookupOwner($a_id);
946  return $owner;
947  }
948 
949  public static function _getIdsForTitle($title, $type = '', $partialmatch = false)
950  {
951  global $ilDB;
952 
953  $query = (!$partialmatch)
954  ? "SELECT obj_id FROM object_data WHERE title = ".$ilDB->quote($title, "text")
955  : "SELECT obj_id FROM object_data WHERE ".$ilDB->like("title", "text", '%'.$title.'%');
956  if($type != '')
957  {
958  $query .= " AND type = ".$ilDB->quote($type, "text");
959  }
960 
961  $result = $ilDB->query($query);
962 
963  $object_ids = array();
964  while($row = $ilDB->fetchAssoc($result))
965  {
966  $object_ids[] = $row['obj_id'];
967  }
968 
969  return is_array($object_ids) ? $object_ids : array();
970  }
971 
977  public static function _lookupDescription($a_id)
978  {
979  global $ilObjDataCache;
980 
981  return $ilObjDataCache->lookupDescription($a_id);
982  }
983 
989  function _lookupLastUpdate($a_id, $a_as_string = false)
990  {
991  global $ilObjDataCache;
992 
993  if ($a_as_string)
994  {
995  return ilDatePresentation::formatDate(new ilDateTime($ilObjDataCache->lookupLastUpdate($a_id),IL_CAL_DATETIME));
996  }
997  else
998  {
999  return $ilObjDataCache->lookupLastUpdate($a_id);
1000  }
1001  }
1002 
1008  function _getLastUpdateOfObjects($a_objs)
1009  {
1010  global $ilDB;
1011 
1012  if (!is_array($a_objs))
1013  {
1014  $a_objs = array($a_objs);
1015  }
1016  $types = array();
1017  $set = $ilDB->query("SELECT max(last_update) as last_update FROM object_data ".
1018  "WHERE ".$ilDB->in("obj_id", $a_objs, false, "integer")." ");
1019  $rec = $ilDB->fetchAssoc($set);
1020 
1021  return ($rec["last_update"]);
1022  }
1023 
1024  public static function _lookupObjId($a_id)
1025  {
1026  global $ilObjDataCache;
1027 
1028  return (int) $ilObjDataCache->lookupObjId($a_id);
1029  }
1030 
1034  function _setDeletedDate($a_ref_id)
1035  {
1036  global $ilDB;
1037 
1038  $query = "UPDATE object_reference SET deleted= ".$ilDB->now().' '.
1039  "WHERE ref_id = ".$ilDB->quote($a_ref_id,'integer');
1040  $res = $ilDB->manipulate($query);
1041  }
1042 
1046  function _resetDeletedDate($a_ref_id)
1047  {
1048  global $ilDB;
1049 
1050  $query = "UPDATE object_reference SET deleted = ".$ilDB->quote(null,'timestamp').
1051  " WHERE ref_id = ".$ilDB->quote($a_ref_id,'integer');
1052  $res = $ilDB->manipulate($query);
1053  }
1054 
1058  function _lookupDeletedDate($a_ref_id)
1059  {
1060  global $ilDB;
1061 
1062  $query = "SELECT deleted FROM object_reference".
1063  " WHERE ref_id = ".$ilDB->quote($a_ref_id, "integer");
1064  $set = $ilDB->query($query);
1065  $rec = $ilDB->fetchAssoc($set);
1066 
1067  return $rec["deleted"];
1068  }
1069 
1070 
1078  function _writeTitle($a_obj_id, $a_title)
1079  {
1080  global $ilDB;
1081 
1082  $q = "UPDATE object_data ".
1083  "SET ".
1084  "title = ".$ilDB->quote($a_title, "text").",".
1085  "last_update = ".$ilDB->now()." ".
1086  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
1087 
1088  $ilDB->manipulate($q);
1089  }
1090 
1098  function _writeDescription($a_obj_id, $a_desc)
1099  {
1100  global $ilDB,$objDefinition;
1101 
1102 
1103  $desc = ilUtil::shortenText($a_desc,MAXLENGTH_OBJ_DESC,true);
1104 
1105  $q = "UPDATE object_data ".
1106  "SET ".
1107  "description = ".$ilDB->quote($desc, "text").",".
1108  "last_update = ".$ilDB->now()." ".
1109  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
1110 
1111  $ilDB->manipulate($q);
1112 
1113  if($objDefinition->isRBACObject($this->getType()))
1114  {
1115  // Update long description
1116  $res = $ilDB->query("SELECT * FROM object_description WHERE obj_id = ".
1117  $ilDB->quote($a_obj_id,'integer'));
1118 
1119  if($res->numRows())
1120  {
1121  $values = array(
1122  'description' => array('clob',$this->getLongDescription())
1123  );
1124  $ilDB->update('object_description',$values,array('obj_id' => array('integer',$this->getId())));
1125  }
1126  else
1127  {
1128  $values = array(
1129  'description' => array('clob',$this->getLongDescription()),
1130  'obj_id' => array('integer',$this->getId()));
1131  $ilDB->insert('object_description',$values);
1132  }
1133  }
1134  }
1135 
1143  function _writeImportId($a_obj_id, $a_import_id)
1144  {
1145  global $ilDB;
1146 
1147  $q = "UPDATE object_data ".
1148  "SET ".
1149  "import_id = ".$ilDB->quote($a_import_id, "text").",".
1150  "last_update = ".$ilDB->now()." ".
1151  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
1152 
1153  $ilDB->manipulate($q);
1154  }
1155 
1161  public static function _lookupType($a_id,$a_reference = false)
1162  {
1163  global $ilObjDataCache;
1164 
1165  if($a_reference)
1166  {
1167  return $ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_id));
1168  }
1169  return $ilObjDataCache->lookupType($a_id);
1170 
1171  global $ilDB;
1172 
1173  if ($a_reference === true)
1174  {
1175  $q = "SELECT type FROM object_reference obr, object_data obd ".
1176  "WHERE obr.ref_id = ".$ilDB->quote($a_id, "integer")." ".
1177  "AND obr.obj_id = obd.obj_id ";
1178  }
1179  else
1180  {
1181  $q = "SELECT type FROM object_data WHERE obj_id = ".$ilDB->quote($a_id, "integer");
1182  }
1183 
1184  $obj_set = $ilDB->query($q);
1185  $obj_rec = $ilDB->fetchAssoc($obj_set);
1186 
1187  return $obj_rec["type"];
1188  }
1189 
1193  function _isInTrash($a_ref_id)
1194  {
1195  global $tree;
1196 
1197  return $tree->isSaved($a_ref_id);
1198  }
1199 
1203  function _hasUntrashedReference($a_obj_id)
1204  {
1205  $ref_ids = ilObject::_getAllReferences($a_obj_id);
1206  foreach($ref_ids as $ref_id)
1207  {
1208  if(!ilObject::_isInTrash($ref_id))
1209  {
1210  return true;
1211  }
1212  }
1213 
1214  return false;
1215  }
1216 
1222  function _lookupObjectId($a_ref_id)
1223  {
1224  global $ilObjDataCache;
1225 
1226  return (int) $ilObjDataCache->lookupObjId($a_ref_id);
1227  }
1228 
1239  function _getObjectsDataForType($a_type, $a_omit_trash = false)
1240  {
1241  global $ilDB;
1242 
1243  $q = "SELECT * FROM object_data WHERE type = ".$ilDB->quote($a_type, "text");
1244  $obj_set = $ilDB->query($q);
1245 
1246  $objects = array();
1247  while ($obj_rec = $ilDB->fetchAssoc($obj_set))
1248  {
1249  if ((!$a_omit_trash) || ilObject::_hasUntrashedReference($obj_rec["obj_id"]))
1250  {
1251  $objects[$obj_rec["title"].".".$obj_rec["obj_id"]] = array("id" => $obj_rec["obj_id"],
1252  "type" => $obj_rec["type"], "title" => $obj_rec["title"],
1253  "description" => $obj_rec["description"]);
1254  }
1255  }
1256  ksort($objects);
1257  return $objects;
1258  }
1259 
1265  function putInTree($a_parent_ref)
1266  {
1267  global $tree, $log;
1268 
1269  $tree->insertNode($this->getRefId(), $a_parent_ref);
1270 
1271  // write log entry
1272  $log->write("ilObject::putInTree(), parent_ref: $a_parent_ref, ref_id: ".
1273  $this->getRefId().", obj_id: ".$this->getId().", type: ".
1274  $this->getType().", title: ".$this->getTitle());
1275 
1276  }
1277 
1284  function setPermissions($a_parent_ref)
1285  {
1286  global $rbacadmin, $rbacreview;
1287 
1288  $parentRoles = $rbacreview->getParentRoleIds($a_parent_ref);
1289 
1290  foreach ($parentRoles as $parRol)
1291  {
1292  $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $this->getType(), $parRol["parent"]);
1293  $rbacadmin->grantPermission($parRol["obj_id"], $ops, $this->getRefId());
1294  }
1295 
1296  $this->initDefaultRoles();
1297  }
1298 
1305  function createReference()
1306  {
1307  global $ilDB;
1308 
1309  if (!isset($this->id))
1310  {
1311  $message = "ilObject::createNewReference(): No obj_id given!";
1312  $this->raiseError($message,$this->ilias->error_obj->WARNING);
1313  }
1314 
1315  $next_id = $ilDB->nextId('object_reference');
1316  $query = "INSERT INTO object_reference ".
1317  "(ref_id, obj_id) VALUES (".$ilDB->quote($next_id,'integer').','.$ilDB->quote($this->id ,'integer').")";
1318  $this->ilias->db->query($query);
1319 
1320  $this->ref_id = $next_id;
1321  $this->referenced = true;
1322 
1323  return $this->ref_id;
1324  }
1325 
1326 
1333  function countReferences()
1334  {
1335  global $ilDB;
1336 
1337  if (!isset($this->id))
1338  {
1339  $message = "ilObject::countReferences(): No obj_id given!";
1340  $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
1341  }
1342 
1343  $query = "SELECT COUNT(ref_id) num FROM object_reference ".
1344  "WHERE obj_id = ".$ilDB->quote($this->id,'integer')." ";
1345  $res = $ilDB->query($query);
1346  $row = $ilDB->fetchObject($res);
1347 
1348  return $row->num;
1349  }
1350 
1351 
1352 
1353 
1363  function delete()
1364  {
1365  global $rbacadmin, $log, $ilDB;
1366 
1367  $remove = false;
1368 
1369  // delete object_data entry
1370  if ((!$this->referenced) || ($this->countReferences() == 1))
1371  {
1372  // check type match
1373  $db_type = ilObject::_lookupType($this->getId());
1374  if ($this->type != $db_type)
1375  {
1376  $message = "ilObject::delete(): Type mismatch. Object with obj_id: ".$this->id." ".
1377  "was instantiated by type '".$this->type."'. DB type is: ".$db_type;
1378 
1379  // write log entry
1380  $log->write($message);
1381 
1382  // raise error
1383  $this->ilias->raiseError("ilObject::delete(): Type mismatch. (".$this->type."/".$this->id.")",$this->ilias->error_obj->WARNING);
1384  }
1385 
1386  // delete entry in object_data
1387  $q = "DELETE FROM object_data ".
1388  "WHERE obj_id = ".$ilDB->quote($this->getId(), "integer");
1389  $ilDB->manipulate($q);
1390 
1391  // delete long description
1392  $query = "DELETE FROM object_description WHERE obj_id = ".
1393  $ilDB->quote($this->getId(), "integer");
1394  $ilDB->manipulate($query);
1395 
1396  // write log entry
1397  $log->write("ilObject::delete(), deleted object, obj_id: ".$this->getId().", type: ".
1398  $this->getType().", title: ".$this->getTitle());
1399 
1400  // remove news
1401  include_once("./Services/News/classes/class.ilNewsItem.php");
1402  $news_item = new ilNewsItem();
1403  $news_item->deleteNewsOfContext($this->getId(), $this->getType());
1404  include_once("./Services/Block/classes/class.ilBlockSetting.php");
1406 
1407  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
1409 
1410  /* remove notes (see infoscreen gui)
1411  as they can be seen as personal data we are keeping them for now
1412  include_once("Services/Notes/classes/class.ilNote.php");
1413  foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type)
1414  {
1415  foreach(ilNote::_getNotesOfObject($this->id, 0, $this->type, $note_type) as $note)
1416  {
1417  $note->delete();
1418  }
1419  }
1420  */
1421 
1422  // BEGIN WebDAV: Delete WebDAV properties
1423  $query = "DELETE FROM dav_property ".
1424  "WHERE obj_id = ".$ilDB->quote($this->getId(),'integer');
1425  $res = $ilDB->manipulate($query);
1426  // END WebDAV: Delete WebDAV properties
1427 
1428  $remove = true;
1429  }
1430  else
1431  {
1432  // write log entry
1433  $log->write("ilObject::delete(), object not deleted, number of references: ".
1434  $this->countReferences().", obj_id: ".$this->getId().", type: ".
1435  $this->getType().", title: ".$this->getTitle());
1436  }
1437 
1438  // delete object_reference entry
1439  if ($this->referenced)
1440  {
1441  // delete entry in object_reference
1442  $query = "DELETE FROM object_reference ".
1443  "WHERE ref_id = ".$ilDB->quote($this->getRefId(),'integer');
1444  $res = $ilDB->manipulate($query);
1445 
1446  // write log entry
1447  $log->write("ilObject::delete(), reference deleted, ref_id: ".$this->getRefId().
1448  ", obj_id: ".$this->getId().", type: ".
1449  $this->getType().", title: ".$this->getTitle());
1450 
1451  // DELETE PERMISSION ENTRIES IN RBAC_PA
1452  // DONE: method overwritten in ilObjRole & ilObjUser.
1453  // this call only applies for objects in rbac (not usr,role,rolt)
1454  // TODO: Do this for role templates too
1455  $rbacadmin->revokePermission($this->getRefId(),0,false);
1456 
1457  include_once "Services/AccessControl/classes/class.ilRbacLog.php";
1458  ilRbacLog::delete($this->getRefId());
1459 
1460  // Remove applied didactic template setting
1461  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
1463 
1464  // Remove desktop items
1466  }
1467 
1468  // remove conditions
1469  if ($this->referenced)
1470  {
1471  $ch =& new ilConditionHandler();
1472  $ch->delete($this->getRefId());
1473  unset($ch);
1474  }
1475 
1476  return $remove;
1477  }
1478 
1486  function initDefaultRoles()
1487  {
1488  return array();
1489  }
1490 
1500  function createRoleFolder()
1501  {
1502  global $rbacreview;
1503 
1504  // does a role folder already exists?
1505  // (this check is only 'to be sure' that no second role folder is created under one object.
1506  // the if-construct should never return true)
1507  if ($rolf_data = $rbacreview->getRoleFolderofObject($this->getRefId()))
1508  {
1509  $rfoldObj = $this->ilias->obj_factory->getInstanceByRefId($rolf_data["ref_id"]);
1510  }
1511  else
1512  {
1513  include_once ("./Services/AccessControl/classes/class.ilObjRoleFolder.php");
1514  $rfoldObj = new ilObjRoleFolder();
1515  $rfoldObj->setTitle($this->getId());
1516  $rfoldObj->setDescription(" (ref_id ".$this->getRefId().")");
1517  $rfoldObj->create();
1518  $rfoldObj->createReference();
1519  $rfoldObj->putInTree($this->getRefId());
1520  $rfoldObj->setPermissions($this->getRefId());
1521  }
1522 
1523  return $rfoldObj;
1524  }
1525 
1530  public function applyDidacticTemplate($a_tpl_id)
1531  {
1532  if(!$a_tpl_id)
1533  {
1534  return true;
1535  }
1536 
1537  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
1538  ilDidacticTemplateObjSettings::assignTemplate($this->getRefId(), $this->getId(), (int) $a_tpl_id);
1539 
1540  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
1541  foreach(ilDidacticTemplateActionFactory::getActionsByTemplateId($a_tpl_id) as $action)
1542  {
1543  $action->setRefId($this->getRefId());
1544  $action->apply();
1545  }
1546  }
1547 
1556  function _exists($a_id, $a_reference = false)
1557  {
1558  global $ilias, $ilDB;
1559 
1560  if ($a_reference)
1561  {
1562  $q = "SELECT * FROM object_data ".
1563  "LEFT JOIN object_reference ON object_reference.obj_id=object_data.obj_id ".
1564  "WHERE object_reference.ref_id= ".$ilDB->quote($a_id, "integer");
1565  }
1566  else
1567  {
1568  $q = "SELECT * FROM object_data WHERE obj_id=".$ilDB->quote($a_id, "integer");
1569  }
1570 
1571  $r = $ilDB->query($q);
1572 
1573  return $ilDB->numRows($r) ? true : false;
1574  }
1575 
1588  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
1589  {
1590  global $tree;
1591 
1592  $parent_id = (int) $tree->getParentId($a_node_id);
1593 
1594  if ($parent_id != 0)
1595  {
1596  $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
1597  $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
1598  }
1599 
1600  return true;
1601  }
1602 
1603  // toggle subscription interface
1604  function setRegisterMode($a_bool)
1605  {
1606  $this->register = (bool) $a_bool;
1607  }
1608 
1609  // check register status of current user
1610  // abstract method; overwrite in object type class
1611  function isUserRegistered($a_user_id = 0)
1612  {
1613  return false;
1614  }
1615 
1617  {
1618  return $this->register;
1619  }
1620 
1621 
1622  function getXMLZip()
1623  {
1624  return false;
1625  }
1626  function getHTMLDirectory()
1627  {
1628  return false;
1629  }
1630 
1634  static function _getObjectsByType($a_obj_type = "", $a_owner = "")
1635  {
1636  global $ilDB;
1637 
1638  $order = " ORDER BY title";
1639 
1640  // where clause
1641  if ($a_obj_type)
1642  {
1643  $where_clause = "WHERE type = ".
1644  $ilDB->quote($a_obj_type, "text");
1645 
1646  if ($a_owner != "")
1647  {
1648  $where_clause.= " AND owner = ".$ilDB->quote($a_owner, "integer");
1649  }
1650  }
1651 
1652  $q = "SELECT * FROM object_data ".$where_clause.$order;
1653  $r = $ilDB->query($q);
1654 
1655  $arr = array();
1656  if ($ilDB->numRows($r) > 0)
1657  {
1658  while ($row = $ilDB->fetchAssoc($r))
1659  {
1660  $row["desc"] = $row["description"];
1661  $arr[$row["obj_id"]] = $row;
1662  }
1663  }
1664 
1665  return $arr;
1666  }
1667 
1676  public static function _prepareCloneSelection($a_ref_ids,$new_type,$show_path = true)
1677  {
1678  global $ilDB,$lng,$objDefinition;
1679 
1680  $query = "SELECT obj_data.title obj_title,path_data.title path_title,child FROM tree ".
1681  "JOIN object_reference obj_ref ON child = obj_ref.ref_id ".
1682  "JOIN object_data obj_data ON obj_ref.obj_id = obj_data.obj_id ".
1683  "JOIN object_reference path_ref ON parent = path_ref.ref_id ".
1684  "JOIN object_data path_data ON path_ref.obj_id = path_data.obj_id ".
1685  "WHERE ".$ilDB->in("child", $a_ref_ids, false, "integer")." ".
1686  "ORDER BY obj_data.title ";
1687  $res = $ilDB->query($query);
1688 
1689  if (!$objDefinition->isPlugin($new_type))
1690  {
1691  $options[0] = $lng->txt('obj_'.$new_type.'_select');
1692  }
1693  else
1694  {
1695  include_once("./Services/Component/classes/class.ilPlugin.php");
1696  $options[0] = ilPlugin::lookupTxt("rep_robj", $new_type, "obj_".$new_type."_select");
1697  }
1698 
1699  while($row = $ilDB->fetchObject($res))
1700  {
1701  if(strlen($title = $row->obj_title) > 40)
1702  {
1703  $title = substr($title,0,40).'...';
1704  }
1705 
1706  if($show_path)
1707  {
1708  if(strlen($path = $row->path_title) > 40)
1709  {
1710  $path = substr($path,0,40).'...';
1711  }
1712 
1713  $title .= ' ('.$lng->txt('path').': '.$path.')';
1714  }
1715 
1716  $options[$row->child] = $title;
1717  }
1718  return $options ? $options : array();
1719  }
1720 
1730  public function cloneObject($a_target_id,$a_copy_id = 0,$a_omit_tree = false)
1731  {
1732  global $objDefinition,$ilUser,$rbacadmin, $ilDB;
1733 
1734  $location = $objDefinition->getLocation($this->getType());
1735  $class_name = ('ilObj'.$objDefinition->getClassName($this->getType()));
1736 
1737  if(!$a_omit_tree)
1738  {
1739  $title = $this->appendCopyInfo($a_target_id,$a_copy_id);
1740  }
1741  else
1742  {
1743  $title = $this->getTitle();
1744  }
1745 
1746  // create instance
1747  include_once($location."/class.".$class_name.".php");
1748  $new_obj = new $class_name(0, false);
1749  $new_obj->setOwner($ilUser->getId());
1750  $new_obj->setTitle($title);
1751  $new_obj->setDescription($this->getLongDescription());
1752  $new_obj->setType($this->getType());
1753  // Choose upload mode to avoid creation of additional settings, db entries ...
1754  $new_obj->create(true);
1755 
1756  if(!$a_omit_tree)
1757  {
1758  $new_obj->createReference();
1759  $new_obj->putInTree($a_target_id);
1760  $new_obj->setPermissions($a_target_id);
1761 
1762  // when copying from personal workspace we have no current ref id
1763  if($this->getRefId())
1764  {
1765  // copy local roles
1766  $rbacadmin->copyLocalRoles($this->getRefId(),$new_obj->getRefId());
1767  }
1768  }
1769 
1770  include_once('./Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
1771  ilAdvancedMDValues::_cloneValues($this->getId(),$new_obj->getId());
1772 
1773  // BEGIN WebDAV: Clone WebDAV properties
1774  $query = "INSERT INTO dav_property (obj_id,node_id,ns,name,value) ".
1775  "SELECT ".$ilDB->quote($new_obj->getId(),'integer').",node_id,ns,name,value ".
1776  "FROM dav_property ".
1777  "WHERE obj_id = ".$ilDB->quote($this->getId(),'integer');
1778  $res = $ilDB->manipulate($query);
1779  // END WebDAV: Clone WebDAV properties
1780 
1781  return $new_obj;
1782  }
1783 
1791  public function appendCopyInfo($a_target_id,$a_copy_id)
1792  {
1793  global $tree;
1794 
1795  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
1796  $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
1797  if(!$cp_options->isRootNode($this->getRefId()))
1798  {
1799  return $this->getTitle();
1800  }
1801  $nodes = $tree->getChilds($a_target_id);
1802 
1803  $title_unique = false;
1804  require_once 'Modules/File/classes/class.ilObjFileAccess.php';
1805  $numberOfCopy = 1;
1807  while(!$title_unique)
1808  {
1809  $found = 0;
1810  foreach($nodes as $node)
1811  {
1812  if(($title == $node['title']) and ($this->getType() == $node['type']))
1813  {
1814  $found++;
1815  }
1816  }
1817  if($found > 0)
1818  {
1819  $title = ilObjFileAccess::_appendNumberOfCopyToFilename($this->getTitle(), ++$numberOfCopy);
1820  }
1821  else
1822  {
1823  break;
1824  }
1825  }
1826  return $title;
1827  }
1828 
1841  public function cloneDependencies($a_target_id,$a_copy_id)
1842  {
1843  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
1844  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
1845 
1846  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
1847  $mappings = $cwo->getMappings();
1848 
1849  $conditions = ilConditionHandler::_getConditionsOfTarget($this->getRefId(), $this->getId());
1850  foreach($conditions as $con)
1851  {
1852  if($mappings[$con['trigger_ref_id']])
1853  {
1854  $newCondition = new ilConditionHandler();
1855 
1856  $target_obj = ilObject::_lookupObjId($a_target_id);
1857  $target_typ = ilObject::_lookupType($target_obj);
1858 
1859  $newCondition->setTargetRefId($a_target_id);
1860  $newCondition->setTargetObjId($target_obj);
1861  $newCondition->setTargetType($target_typ);
1862 
1863  $trigger_ref = $mappings[$con['trigger_ref_id']];
1864  $trigger_obj = ilObject::_lookupObjId($trigger_ref);
1865  $trigger_typ = ilObject::_lookupType($trigger_obj);
1866 
1867  $newCondition->setTriggerRefId($trigger_ref);
1868  $newCondition->setTriggerObjId($trigger_obj);
1869  $newCondition->setTriggerType($trigger_typ);
1870  $newCondition->setOperator($con['operator']);
1871  $newCondition->setValue($con['value']);
1872  $newCondition->setReferenceHandlingType($con['ref_handling']);
1873  $newCondition->setObligatory($con['obligatory']);
1874  $newCondition->storeCondition();
1875  }
1876  }
1877  return true;
1878  }
1879 
1887  public function cloneMetaData($target_obj)
1888  {
1889  include_once "./Services/MetaData/classes/class.ilMD.php";
1890  $md = new ilMD($this->getId(),0,$this->getType());
1891  $md->cloneMD($target_obj->getId(),0,$target_obj->getType());
1892  return true;
1893  }
1894 
1903  public static function _getIcon($a_obj_id = "", $a_size = "big", $a_type = "",
1904  $a_offline = false)
1905  {
1906  global $ilSetting, $objDefinition;
1907 
1908  if ($a_obj_id == "" && $a_type == "")
1909  {
1910  return "";
1911  }
1912 
1913  if ($a_type == "")
1914  {
1915  $a_type = ilObject::_lookupType($a_obj_id);
1916  }
1917 
1918  if ($a_size == "")
1919  {
1920  $a_size = "big";
1921  }
1922 
1923  if ($ilSetting->get("custom_icons") &&
1924  in_array($a_type, array("cat","grp","crs", "root")))
1925  {
1926  require_once("./Services/Container/classes/class.ilContainer.php");
1927  if (ilContainer::_lookupContainerSetting($a_obj_id, "icon_".$a_size))
1928  {
1929  $cont_dir = ilContainer::_getContainerDirectory($a_obj_id);
1930  $file_name = $cont_dir."/icon_".$a_size.".gif";
1931 
1932  if (is_file($file_name))
1933  {
1934  return $file_name;
1935  }
1936  }
1937  }
1938 
1939  switch($a_size)
1940  {
1941  case "small": $suff = ""; break;
1942  case "tiny": $suff = "_s"; break;
1943  default: $suff = "_b"; break;
1944  }
1945  if (!$a_offline)
1946  {
1947  if ($objDefinition->isRBACObject($a_type))
1948  {
1949  if (!$objDefinition->isPlugin($a_type))
1950  {
1951  return ilUtil::getImagePath("icon_".$a_type.$suff.".gif");
1952  }
1953  else
1954  {
1955  include_once("./Services/Repository/classes/class.ilRepositoryObjectPlugin.php");
1956  return ilRepositoryObjectPlugin::_getIcon($a_type, $a_size);
1957  }
1958  }
1959  return ilUtil::getImagePath("icon_".$a_type.$suff.".gif");
1960  }
1961  else
1962  {
1963  return "./images/icon_".$a_type.$suff.".gif";
1964  }
1965  }
1966 
1973  static final function collectDeletionDependencies(&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth = 0)
1974  {
1975  global $objDefinition, $tree;
1976 
1977  if ($a_depth == 0)
1978  {
1979  $deps["dep"] = array();
1980  }
1981 
1982  $deps["del_ids"][$a_obj_id] = $a_obj_id;
1983 
1984  if (!$objDefinition->isPlugin($type))
1985  {
1986  $class_name = "ilObj".$objDefinition->getClassName($a_type);
1987  $location = $objDefinition->getLocation($a_type);
1988  include_once($location."/class.".$class_name.".php");
1989  $odeps = call_user_func(array($class_name, "getDeletionDependencies"), $a_obj_id);
1990  if (is_array($odeps))
1991  {
1992  foreach ($odeps as $id => $message)
1993  {
1994  $deps["dep"][$id][$a_obj_id][] = $message;
1995  }
1996  }
1997 
1998  // get deletion dependency of childs
1999  foreach ($tree->getChilds($a_ref_id) as $c)
2000  {
2001  ilObject::collectDeletionDependencies($deps, $c["child"], $c["obj_id"], $c["type"], $a_depth + 1);
2002  }
2003  }
2004 
2005  // delete all dependencies to objects that will be deleted, too
2006  if ($a_depth == 0)
2007  {
2008  foreach ($deps["del_ids"] as $obj_id)
2009  {
2010  unset($deps["dep"][$obj_id]);
2011  }
2012  $deps = $deps["dep"];
2013  }
2014  }
2015 
2020  static function getDeletionDependencies($a_obj_id)
2021  {
2022  return false;
2023  }
2024 } // END class.ilObject
2025 ?>