• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilObject.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00035 class ilObject
00036 {
00042         var $ilias;
00043 
00049         var $lng;
00050 
00056         var $id;        // true object_id!!!!
00057         var $ref_id;// reference_id
00058         var $type;
00059         var $title;
00060         var $desc;
00061         var $owner;
00062         var $create_date;
00063         var $last_update;
00064         var $import_id;
00065         var $register = false;          // registering required for object? set to true to implement a subscription interface
00066 
00072         var $referenced;
00073 
00079         var $objectList;
00080 
00085         var $max_title;
00086 
00091         var $max_desc;
00092 
00097         var $add_dots;
00098 
00102         var $obj_data_record;
00103 
00110         function ilObject($a_id = 0, $a_reference = true)
00111         {
00112                 global $ilias, $lng, $ilBench;
00113 
00114                 $ilBench->start("Core", "ilObject_Constructor");
00115 
00116                 if (DEBUG)
00117                 {
00118                         echo "<br/><font color=\"red\">type(".$this->type.") id(".$a_id.") referenced(".$a_reference.")</font>";
00119                 }
00120 
00121                 $this->ilias =& $ilias;
00122                 $this->lng =& $lng;
00123 
00124                 $this->max_title = MAXLENGTH_OBJ_TITLE;
00125                 $this->max_desc = MAXLENGTH_OBJ_DESC;
00126                 $this->add_dots = true;
00127 
00128                 $this->referenced = $a_reference;
00129                 $this->call_by_reference = $a_reference;
00130 
00131                 if ($a_id == 0)
00132                 {
00133                         $this->referenced = false;              // newly created objects are never referenced
00134                 }                                                                       // they will get referenced if createReference() is called
00135 
00136                 if ($this->referenced)
00137                 {
00138                         $this->ref_id = $a_id;
00139                 }
00140                 else
00141                 {
00142                         $this->id = $a_id;
00143                 }
00144                 // read object data
00145                 if ($a_id != 0)
00146                 {
00147                         $this->read();
00148                 }
00149 
00150                 $ilBench->stop("Core", "ilObject_Constructor");
00151         }
00152 
00156         function withReferences()
00157         {
00158                 // both vars could differ. this method should always return true if one of them is true without changing their status
00159                 return ($this->call_by_reference) ? true : $this->referenced;
00160         }
00161 
00162 
00168         function read($a_force_db = false)
00169         {
00170                 global $objDefinition, $ilBench;
00171 
00172                 $ilBench->start("Core", "ilObject_read");
00173 
00174                 if (isset($this->obj_data_record) && !$a_force_db)
00175                 {
00176                         $obj = $this->obj_data_record;
00177                 }
00178                 else if ($this->referenced)
00179                 {
00180                         // check reference id
00181                         if (!isset($this->ref_id))
00182                         {
00183                                 $message = "ilObject::read(): No ref_id given!";
00184                                 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00185                         }
00186 
00187                         // read object data
00188                         $ilBench->start("Core", "ilObject_read_readData");
00189                         /* old query (very slow)
00190                         $q = "SELECT * FROM object_data ".
00191                                  "LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id ".
00192                                  "WHERE object_reference.ref_id='".$this->ref_id."'"; */
00193                         $q = "SELECT * FROM object_data, object_reference WHERE object_data.obj_id=object_reference.obj_id ".
00194                                  "AND object_reference.ref_id='".$this->ref_id."'";
00195                         $object_set = $this->ilias->db->query($q);
00196                         $ilBench->stop("Core", "ilObject_read_readData");
00197 
00198                         // check number of records
00199                         if ($object_set->numRows() == 0)
00200                         {
00201                                 $message = "ilObject::read(): Object with ref_id ".$this->ref_id." not found!";
00202                                 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00203                         }
00204 
00205                         $obj = $object_set->fetchRow(DB_FETCHMODE_ASSOC);
00206                 }
00207                 else
00208                 {
00209                         // check object id
00210                         if (!isset($this->id))
00211                         {
00212                                 $message = "ilObject::read(): No obj_id given!";
00213                                 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00214                         }
00215 
00216                         // read object data
00217                         $q = "SELECT * FROM object_data ".
00218                                  "WHERE obj_id = '".$this->id."'";
00219                         $object_set = $this->ilias->db->query($q);
00220 
00221                         // check number of records
00222                         if ($object_set->numRows() == 0)
00223                         {
00224                                 $message = "ilObject::read(): Object with obj_id: ".$this->id." not found!";
00225                                 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00226                         }
00227 
00228                         $obj = $object_set->fetchRow(DB_FETCHMODE_ASSOC);
00229                 }
00230 
00231                 $this->id = $obj["obj_id"];
00232                 $this->type = $obj["type"];
00233                 $this->title = $obj["title"];
00234                 $this->desc = $obj["description"];
00235                 $this->owner = $obj["owner"];
00236                 $this->create_date = $obj["create_date"];
00237                 $this->last_update = $obj["last_update"];
00238                 $this->import_id = $obj["import_id"];
00239 
00240                 // multilingual support systemobjects (sys) & categories (db)
00241                 $ilBench->start("Core", "ilObject_Constructor_getTranslation");
00242                 $translation_type = $objDefinition->getTranslationType($this->type);
00243 
00244                 if ($translation_type == "sys")
00245                 {
00246                         $this->title = $this->lng->txt("obj_".$this->type);
00247                         $this->desc = $this->lng->txt("obj_".$this->type."_desc");
00248                 }
00249                 elseif ($translation_type == "db")
00250                 {
00251                         $q = "SELECT title,description FROM object_translation ".
00252                                  "WHERE obj_id = ".$this->id." ".
00253                                  "AND lang_code = '".$this->ilias->account->getCurrentLanguage()."' ".
00254                                  "AND NOT lang_default = 1";
00255                         $r = $this->ilias->db->query($q);
00256                         $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
00257 
00258                         if ($row)
00259                         {
00260                                 $this->title = $row->title;
00261                                 $this->desc = $row->description;
00262                         }
00263                 }
00264 
00265                 $ilBench->stop("Core", "ilObject_Constructor_getTranslation");
00266 
00267                 $ilBench->stop("Core", "ilObject_read");
00268         }
00269 
00275         function getId()
00276         {
00277                 return $this->id;
00278         }
00279 
00285         function setId($a_id)
00286         {
00287                 $this->id = $a_id;
00288         }
00289 
00295         function setRefId($a_id)
00296         {
00297                 $this->ref_id = $a_id;
00298                 $this->referenced = true;
00299         }
00300 
00306         function getRefId()
00307         {
00308                 return $this->ref_id;
00309         }
00310 
00316         function getType()
00317         {
00318                 return $this->type;
00319         }
00320 
00326         function setType($a_type)
00327         {
00328                 $this->type = $a_type;
00329         }
00330 
00336         function getTitle()
00337         {
00338                 return $this->title;
00339         }
00340 
00347         function setTitle($a_title)
00348         {
00349                 if ($a_title == "")
00350                 {
00351                         $a_title = "NO TITLE";
00352                 }
00353 
00354                 $this->title = ilUtil::shortenText($a_title, $this->max_title, $this->add_dots);
00355         }
00356 
00363         function getDescription()
00364         {
00365                 return $this->desc;
00366         }
00367 
00374         function setDescription($a_desc)
00375         {
00376                 $this->desc = ilUtil::shortenText($a_desc, $this->max_desc, $this->add_dots);
00377         }
00378 
00385         function getImportId()
00386         {
00387                 return $this->import_id;
00388         }
00389 
00396         function setImportId($a_import_id)
00397         {
00398                 $this->import_id = $a_import_id;
00399         }
00400 
00407         function getOwner()
00408         {
00409                 return $this->owner;
00410         }
00411 
00412         /*
00413         * get full name of object owner
00414         *
00415         * @access       public
00416         * @return       string  owner name or unknown
00417         */
00418         function getOwnerName()
00419         {
00420                 return ilObject::_lookupOwnerName($this->getOwner());
00421         }
00422         
00426         function _lookupOwnerName($a_owner_id)
00427         {
00428                 global $lng;
00429                 
00430                 if ($a_owner_id != -1)
00431                 {
00432                         if (ilObject::_exists($a_owner_id))
00433                         {
00434                                 $owner = new ilObjUser($a_owner_id);
00435                         }
00436                 }
00437 
00438                 if (is_object($owner))
00439                 {
00440                         $own_name = $owner->getFullname();
00441                 }
00442                 else
00443                 {
00444                         $own_name = $lng->txt("unknown");
00445                 }
00446 
00447                 return $own_name;
00448         }
00449 
00456         function setOwner($a_owner)
00457         {
00458                 $this->owner = $a_owner;
00459         }
00460 
00466         function getCreateDate()
00467         {
00468                 return $this->create_date;
00469         }
00470 
00476         function getLastUpdateDate()
00477         {
00478                 return $this->last_update;
00479         }
00480 
00489         function setObjDataRecord($a_record)
00490         {
00491                 $this->obj_data_record = $a_record;
00492         }
00493 
00502         function create()
00503         {
00504                 global $ilDB, $log,$ilUser;
00505 
00506                 if (!isset($this->type))
00507                 {
00508                         $message = get_class($this)."::create(): No object type given!";
00509                         $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00510                 }
00511                 
00512                 // write log entry
00513                 $log->write("ilObject::create(), start");
00514 
00515                 $this->title = ilUtil::shortenText($this->getTitle(), $this->max_title, $this->add_dots);
00516                 $this->desc = ilUtil::shortenText($this->getDescription(), $this->max_desc, $this->add_dots);
00517 
00518                 $q = "INSERT INTO object_data ".
00519                          "(type,title,description,owner,create_date,last_update,import_id) ".
00520                          "VALUES ".
00521                          "('".$this->type."',".$ilDB->quote($this->getTitle()).",'".ilUtil::prepareDBString($this->getDescription())."',".
00522                          "'".$ilUser->getId()."',now(),now(),'".
00523                         $this->getImportId()."')";
00524 
00525                 $ilDB->query($q);
00526 
00527                 $this->id = $ilDB->getLastInsertId();
00528 
00529                 // the line ($this->read();) messes up meta data handling: meta data,
00530                 // that is not saved at this time, gets lost, so we query for the dates alone
00531                 //$this->read();
00532                 $q = "SELECT last_update, create_date FROM object_data".
00533                          " WHERE obj_id = '".$this->id."'";
00534                 $obj_set = $this->ilias->db->query($q);
00535                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00536                 $this->last_update = $obj_rec["last_update"];
00537                 $this->create_date = $obj_rec["create_date"];
00538 
00539                 // set owner for new objects
00540                 $this->setOwner($ilUser->getId());
00541 
00542                 // write log entry
00543                 $log->write("ilObject::create(), finished, obj_id: ".$this->id.", type: ".
00544                         $this->type.", title: ".$this->getTitle());
00545 
00546                 return $this->id;
00547         }
00548 
00555         function update()
00556         {
00557 
00558                 $q = "UPDATE object_data ".
00559                         "SET ".
00560                         "title = '".ilUtil::prepareDBString($this->getTitle())."',".
00561                         "description = '".ilUtil::prepareDBString($this->getDescription())."', ".
00562                         "import_id = '".$this->getImportId()."', ".
00563                         "last_update = now() ".
00564                         "WHERE obj_id = '".$this->getId()."'";
00565                 $this->ilias->db->query($q);
00566 
00567                 // the line ($this->read();) messes up meta data handling: meta data,
00568                 // that is not saved at this time, gets lost, so we query for the dates alone
00569                 //$this->read();
00570                 $q = "SELECT last_update FROM object_data".
00571                          " WHERE obj_id = '".$this->getId()."'";
00572                 $obj_set = $this->ilias->db->query($q);
00573                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00574                 $this->last_update = $obj_rec["last_update"];
00575 
00576                 return true;
00577         }
00578 
00585     function updateOwner()
00586     {
00587         $q = "UPDATE object_data ".
00588             "SET ".
00589             "owner = '".$this->getOwner()."', ".
00590             "last_update = now() ".
00591             "WHERE obj_id = '".$this->getId()."'";
00592         $this->ilias->db->query($q);
00593 
00594         $q = "SELECT last_update FROM object_data".
00595              " WHERE obj_id = '".$this->getId()."'";
00596         $obj_set = $this->ilias->db->query($q);
00597         $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00598         $this->last_update = $obj_rec["last_update"];
00599 
00600         return true;
00601     }
00602 
00610         function _getIdForImportId($a_import_id)
00611         {
00612                 global $ilDB;
00613                 
00614                 $q = "SELECT * FROM object_data WHERE import_id = '".$a_import_id."'".
00615                         " ORDER BY create_date DESC LIMIT 1";
00616                 $obj_set = $ilDB->query($q);
00617 
00618                 if ($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
00619                 {
00620                         return $obj_rec["obj_id"];
00621                 }
00622                 else
00623                 {
00624                         return 0;
00625                 }
00626         }
00627 
00633         function _getAllReferences($a_id)
00634         {
00635                 global $ilDB;
00636 
00637                 $q = "SELECT * FROM object_reference WHERE obj_id = '".$a_id."'";
00638                 $obj_set = $ilDB->query($q);
00639                 $ref = array();
00640 
00641                 while ($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
00642                 {
00643                         $ref[$obj_rec["ref_id"]] = $obj_rec["ref_id"];
00644                 }
00645 
00646                 return $ref;
00647         }
00648 
00654         function _lookupTitle($a_id)
00655         {
00656                 global $ilDB;
00657 
00658                 $q = "SELECT title FROM object_data WHERE obj_id = '".$a_id."'";
00659                 $obj_set = $ilDB->query($q);
00660                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00661 
00662                 return $obj_rec["title"];
00663         }
00664 
00670         function _lookupDescription($a_id)
00671         {
00672                 global $ilDB;
00673 
00674                 $q = "SELECT description FROM object_data WHERE obj_id = '".$a_id."'";
00675                 $obj_set = $ilDB->query($q);
00676                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00677 
00678                 return $obj_rec["description"];
00679         }
00680 
00681         function _lookupObjId($a_id)
00682         {
00683                 global $ilDB;
00684 
00685                 $query = "SELECT obj_id FROM object_reference ".
00686                         "WHERE ref_id = '".$a_id."'";
00687                 $res = $ilDB->query($query);
00688                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00689                 {
00690                         return $row->obj_id;
00691                 }
00692                 return 0;
00693         }
00694 
00702         function _writeTitle($a_obj_id, $a_title)
00703         {
00704                 global $ilDB;
00705 
00706                 $q = "UPDATE object_data ".
00707                         "SET ".
00708                         "title = ".$ilDB->quote($a_title).",".
00709                         "last_update = now() ".
00710                         "WHERE obj_id = ".$ilDB->quote($a_obj_id);
00711 
00712                 $ilDB->query($q);
00713         }
00714 
00722         function _writeDescription($a_obj_id, $a_desc)
00723         {
00724                 global $ilDB;
00725 
00726                 $q = "UPDATE object_data ".
00727                         "SET ".
00728                         "description = ".$ilDB->quote($a_desc).",".
00729                         "last_update = now() ".
00730                         "WHERE obj_id = ".$ilDB->quote($a_obj_id);
00731 
00732                 $ilDB->query($q);
00733         }
00734 
00740         function _lookupType($a_id,$a_reference = false)
00741         {
00742                 global $ilDB;
00743 
00744                 if ($a_reference === true)
00745                 {
00746                         $q = "SELECT type FROM object_reference as obr, object_data as obd ".
00747                                 "WHERE obr.ref_id = '".$a_id."' ".
00748                                 "AND obr.obj_id = obd.obj_id ";
00749                         
00750                         #$q = "SELECT type FROM object_data as obj ".
00751                         #        "LEFT JOIN object_reference as ref ON ref.obj_id=obj.obj_id ".
00752                         #        "WHERE ref.ref_id = '".$a_id."'";
00753                 }
00754                 else
00755                 {
00756                         $q = "SELECT type FROM object_data WHERE obj_id = '".$a_id."'";
00757                 }
00758 
00759                 $obj_set = $ilDB->query($q);
00760                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00761 
00762                 return $obj_rec["type"];
00763         }
00764 
00768         function _isInTrash($a_ref_id)
00769         {
00770                 global $tree;
00771 
00772                 return $tree->isSaved($a_ref_id);
00773         }
00774 
00778         function _hasUntrashedReference($a_obj_id)
00779         {
00780                 $ref_ids  = ilObject::_getAllReferences($a_obj_id);
00781                 foreach($ref_ids as $ref_id)
00782                 {
00783                         if(!ilObject::_isInTrash($ref_id))
00784                         {
00785                                 return true;
00786                         }
00787                 }
00788 
00789                 return false;
00790         }
00791 
00797         function _lookupObjectId($a_ref_id)
00798         {
00799                 global $ilDB;
00800 
00801                 $q = "SELECT obj_id FROM object_reference WHERE ref_id = '".$a_ref_id."'";
00802                 $obj_set = $ilDB->query($q);
00803                 $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
00804 
00805                 return $obj_rec["obj_id"];
00806         }
00807 
00818         function _getObjectsDataForType($a_type, $a_omit_trash = false)
00819         {
00820                 global $ilDB;
00821 
00822                 $q = "SELECT * FROM object_data WHERE type = ".$ilDB->quote($a_type);
00823                 $obj_set = $ilDB->query($q);
00824 
00825                 $objects = array();
00826                 while ($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
00827                 {
00828                         if ((!$a_omit_trash) || ilObject::_hasUntrashedReference($obj_rec["obj_id"]))
00829                         {
00830                                 $objects[$obj_rec["title"].".".$obj_rec["obj_id"]] = array("id" => $obj_rec["obj_id"],
00831                                         "type" => $obj_rec["type"], "title" => $obj_rec["title"],
00832                                         "description" => $obj_rec["description"]);
00833                         }
00834                 }
00835                 ksort($objects);
00836                 return $objects;
00837         }
00838 
00844         function putInTree($a_parent_ref)
00845         {
00846                 global $tree, $log;
00847 
00848                 $tree->insertNode($this->getRefId(), $a_parent_ref);
00849                 
00850                 // write log entry
00851                 $log->write("ilObject::putInTree(), parent_ref: $a_parent_ref, ref_id: ".
00852                         $this->getRefId().", obj_id: ".$this->getId().", type: ".
00853                         $this->getType().", title: ".$this->getTitle());
00854 
00855         }
00856 
00863         function setPermissions($a_parent_ref)
00864         {
00865                 global $rbacadmin, $rbacreview;
00866 
00867                 $parentRoles = $rbacreview->getParentRoleIds($a_parent_ref);
00868 
00869                 foreach ($parentRoles as $parRol)
00870                 {
00871                         $ops = $rbacreview->getOperationsOfRole($parRol["obj_id"], $this->getType(), $parRol["parent"]);
00872                         $rbacadmin->grantPermission($parRol["obj_id"], $ops, $this->getRefId());
00873                 }
00874         }
00875 
00882         function createReference()
00883         {
00884                 global $ilDB;
00885 
00886                 if (!isset($this->id))
00887                 {
00888                         $message = "ilObject::createNewReference(): No obj_id given!";
00889                         $this->raiseError($message,$this->ilias->error_obj->WARNING);
00890                 }
00891 
00892                 $q = "INSERT INTO object_reference ".
00893                          "(obj_id) VALUES ('".$this->id."')";
00894                 $this->ilias->db->query($q);
00895 
00896                 $this->ref_id = $ilDB->getLastInsertId();
00897 
00898                 return $this->ref_id;
00899         }
00900 
00901 
00908         function countReferences()
00909         {
00910                 if (!isset($this->id))
00911                 {
00912                         $message = "ilObject::countReferences(): No obj_id given!";
00913                         $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
00914                 }
00915 
00916                 $q = "SELECT COUNT(ref_id) AS num FROM object_reference ".
00917                         "WHERE obj_id = '".$this->id."'";
00918                 $row = $this->ilias->db->getRow($q);
00919 
00920                 return $row->num;
00921         }
00922 
00923 
00934         function ilClone($a_parent_ref)
00935         {
00936                 global $log;
00937                 
00938                 $new_obj = new ilObject();
00939                 $new_obj->setTitle($this->getTitle());
00940                 $new_obj->setType($this->getType());
00941                 $new_obj->setDescription($this->getDescription());
00942                 $new_obj->create();
00943                 $new_ref_id = $new_obj->createReference();
00944                 $new_obj->putInTree($a_parent_ref);
00945                 $new_obj->setPermissions($a_parent_ref);
00946 
00947                 unset($new_obj);
00948                 
00949                 // write log entry
00950                 $log->write("ilObject::ilClone(), ref_id: ".$this->getRefId().",obj_id: ".$this->getId().", type: ".
00951                         $this->getType().", title: ".$this->getTitle().
00952                         ", new ref_id: ".$new_obj->getRefId().", new obj_id:".$new_obj->getId());
00953         
00954                 // ... and finally always return new reference ID!!
00955                 return $new_ref_id;
00956         }
00957 
00958 
00968         function delete()
00969         {
00970                 global $rbacadmin, $log;
00971 
00972                 $remove = false;
00973 
00974                 // delete object_data entry
00975                 if ((!$this->referenced) || ($this->countReferences() == 1))
00976                 {
00977                         // delete entry in object_data
00978                         $q = "DELETE FROM object_data ".
00979                                 "WHERE obj_id = '".$this->getId()."'";
00980                         $this->ilias->db->query($q);
00981 
00982                         // write log entry
00983                         $log->write("ilObject::delete(), deleted object, obj_id: ".$this->getId().", type: ".
00984                                 $this->getType().", title: ".$this->getTitle());
00985                         
00986                         $remove = true;
00987                 }
00988                 else
00989                 {
00990                         // write log entry
00991                         $log->write("ilObject::delete(), object not deleted, number of references: ".
00992                                 $this->countReferences().", obj_id: ".$this->getId().", type: ".
00993                                 $this->getType().", title: ".$this->getTitle());
00994                 }
00995 
00996                 // delete object_reference entry
00997                 if ($this->referenced)
00998                 {
00999                         // delete entry in object_reference
01000                         $q = "DELETE FROM object_reference ".
01001                                 "WHERE ref_id = '".$this->getRefId()."'";
01002                         $this->ilias->db->query($q);
01003 
01004                         // write log entry
01005                         $log->write("ilObject::delete(), reference deleted, ref_id: ".$this->getRefId().
01006                                 ", obj_id: ".$this->getId().", type: ".
01007                                 $this->getType().", title: ".$this->getTitle());
01008 
01009                         // DELETE PERMISSION ENTRIES IN RBAC_PA
01010                         // DONE: method overwritten in ilObjRole & ilObjUser.
01011                         // this call only applies for objects in rbac (not usr,role,rolt)
01012                         // TODO: Do this for role templates too
01013                         $rbacadmin->revokePermission($this->getRefId());
01014                 }
01015 
01016                 // remove conditions
01017                 if ($this->referenced)
01018                 {
01019                         $ch =& new ilConditionHandler();
01020                         $ch->delete($this->getRefId());
01021                         unset($ch);
01022                 }
01023 
01024                 return $remove;
01025         }
01026 
01034         function initDefaultRoles()
01035         {
01036                 return array();
01037         }
01038         
01048         function createRoleFolder()
01049         {
01050                 global $rbacreview;
01051                 
01052                 // does a role folder already exists?
01053                 // (this check is only 'to be sure' that no second role folder is created under one object.
01054                 // the if-construct should never return true)
01055                 if ($rolf_data = $rbacreview->getRoleFolderofObject($this->getRefId()))
01056                 {
01057                         $rfoldObj = $this->ilias->obj_factory->getInstanceByRefId($rolf_data["ref_id"]);
01058                 }
01059                 else
01060                 {
01061                         include_once ("classes/class.ilObjRoleFolder.php");
01062                         $rfoldObj = new ilObjRoleFolder();
01063                         $rfoldObj->setTitle($this->getId());
01064                         $rfoldObj->setDescription(" (ref_id ".$this->getRefId().")");
01065                         $rfoldObj->create();
01066                         $rfoldObj->createReference();
01067                         $rfoldObj->putInTree($this->getRefId());
01068                         $rfoldObj->setPermissions($this->getRefId());
01069                 }
01070                 
01071                 return $rfoldObj;
01072         }
01073 
01082         function _exists($a_id, $a_reference = false)
01083         {
01084                 global $ilias;
01085                 
01086                 if ($a_reference)
01087                 {
01088                         $q = "SELECT * FROM object_data ".
01089                                  "LEFT JOIN object_reference ON object_reference.obj_id=object_data.obj_id ".
01090                                  "WHERE object_reference.ref_id='".$a_id."'";
01091                 }
01092                 else
01093                 {
01094                         $q = "SELECT * FROM object_data WHERE obj_id='".$a_id."'";
01095                 }
01096                 
01097                 $r = $ilias->db->query($q);
01098 
01099                 return $r->numRows() ? true : false;
01100         }
01101 
01114         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
01115         { 
01116                 global $tree;
01117                 
01118                 $parent_id = (int) $tree->getParentId($a_node_id);
01119                 
01120                 if ($parent_id != 0)
01121                 {
01122                         $obj_data =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
01123                         $obj_data->notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$parent_id,$a_params);
01124                 }
01125                                 
01126                 return true;
01127         }
01128         
01129         // toggle subscription interface
01130         function setRegisterMode($a_bool)
01131         {
01132                 $this->register = (bool) $a_bool;
01133         }
01134         
01135         // check register status of current user
01136         // abstract method; overwrite in object type class
01137         function isUserRegistered($a_user_id = 0)
01138         {
01139                 return false;
01140         }
01141 
01142         function requireRegistration()
01143         {
01144                 return $this->register;
01145         }
01146 
01147 
01148         function getXMLZip()
01149         {
01150                 return false;
01151         }
01152         function getHTMLDirectory()
01153         {
01154                 return false;
01155         }
01156 
01157         // static method for condition handler
01158         function _checkCondition($a_obj_id,$a_operator,$a_value)
01159         {
01160                 switch($a_operator)
01161                 {
01162                         default:
01163                                 return true;
01164                 }
01165         }
01166 
01167 
01168 } // END class.ilObject
01169 ?>

Generated on Fri Dec 13 2013 09:06:34 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1