예제 #1
0
 /**
  * delete page object
  */
 function delete()
 {
     global $ilDB;
     $mobs = array();
     $files = array();
     if (!$this->page_not_found) {
         $this->buildDom();
         $mobs = $this->collectMediaObjects(false);
     }
     $this->__beforeDelete();
     // delete style usages
     $this->deleteStyleUsages(false);
     // delete internal links
     $this->deleteInternalLinks();
     // delete all mob usages
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     ilObjMediaObject::_deleteAllUsages($this->getParentType() . ":pg", $this->getId());
     // delete news
     include_once "./Services/News/classes/class.ilNewsItem.php";
     ilNewsItem::deleteNewsOfContext($this->getParentId(), $this->getParentType(), $this->getId(), "pg");
     // delete page_object entry
     $ilDB->manipulate("DELETE FROM page_object " . "WHERE page_id = " . $ilDB->quote($this->getId(), "integer") . " AND parent_type= " . $ilDB->quote($this->getParentType(), "text"));
     //$this->ilias->db->query($query);
     // delete media objects
     foreach ($mobs as $mob_id) {
         if (ilObject::_lookupType($mob_id) != 'mob') {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Type mismatch. Ignoring mob with id: ' . $mob_id);
             continue;
         }
         if (ilObject::_exists($mob_id)) {
             $mob_obj =& new ilObjMediaObject($mob_id);
             $mob_obj->delete();
         }
     }
     /* delete public and private notes (see PageObjectGUI->getNotesHTML())
     		  as they can be seen as personal data we are keeping them for now
     		include_once("Services/Notes/classes/class.ilNote.php");
     		foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type)
     		{
     			foreach(ilNote::_getNotesOfObject($this->getParentId(), $this->getId(),
     				$this->getParentType(), $note_type) as $note)
     			{
     				$note->delete();
     			}
     		}
     		*/
 }
예제 #2
0
 /**
  * delete object or referenced object
  * (in the case of a referenced object, object data is only deleted
  * if last reference is deleted)
  * This function removes an object entirely from system!!
  *
  * @access	public
  * @return	boolean	true if object was removed completely; false if only a references was removed
  */
 function delete()
 {
     global $rbacadmin, $log, $ilDB;
     $remove = false;
     // delete object_data entry
     if (!$this->referenced || $this->countReferences() == 1) {
         // check type match
         $db_type = ilObject::_lookupType($this->getId());
         if ($this->type != $db_type) {
             $message = "ilObject::delete(): Type mismatch. Object with obj_id: " . $this->id . " " . "was instantiated by type '" . $this->type . "'. DB type is: " . $db_type;
             // write log entry
             $log->write($message);
             // raise error
             $this->ilias->raiseError("ilObject::delete(): Type mismatch. (" . $this->type . "/" . $this->id . ")", $this->ilias->error_obj->WARNING);
         }
         // delete entry in object_data
         $q = "DELETE FROM object_data " . "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
         $ilDB->manipulate($q);
         // delete long description
         $query = "DELETE FROM object_description WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
         $ilDB->manipulate($query);
         // write log entry
         $log->write("ilObject::delete(), deleted object, obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
         // remove news
         include_once "./Services/News/classes/class.ilNewsItem.php";
         $news_item = new ilNewsItem();
         $news_item->deleteNewsOfContext($this->getId(), $this->getType());
         include_once "./Services/Block/classes/class.ilBlockSetting.php";
         ilBlockSetting::_deleteSettingsOfBlock($this->getId(), "news");
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
         ilDidacticTemplateObjSettings::deleteByObjId($this->getId());
         /* remove notes (see infoscreen gui)
         			   as they can be seen as personal data we are keeping them for now
         			include_once("Services/Notes/classes/class.ilNote.php");
         			foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type)
         			{
         				foreach(ilNote::_getNotesOfObject($this->id, 0, $this->type, $note_type) as $note)
         				{
         					$note->delete();
         				}
         			}
         		    */
         // BEGIN WebDAV: Delete WebDAV properties
         $query = "DELETE FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer');
         $res = $ilDB->manipulate($query);
         // END WebDAV: Delete WebDAV properties
         include_once './Services/Tracking/classes/class.ilChangeEvent.php';
         ilChangeEvent::_delete($this->getId());
         include_once './Services/Tracking/classes/class.ilLPCollections.php';
         ilLPCollections::_deleteAll($this->getId());
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         ilECSImport::_deleteByObjId($this->getId());
         $remove = true;
     } else {
         // write log entry
         $log->write("ilObject::delete(), object not deleted, number of references: " . $this->countReferences() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
     }
     // delete object_reference entry
     if ($this->referenced) {
         include_once "Services/Object/classes/class.ilObjectActivation.php";
         ilObjectActivation::deleteAllEntries($this->getRefId());
         // delete entry in object_reference
         $query = "DELETE FROM object_reference " . "WHERE ref_id = " . $ilDB->quote($this->getRefId(), 'integer');
         $res = $ilDB->manipulate($query);
         // write log entry
         $log->write("ilObject::delete(), reference deleted, ref_id: " . $this->getRefId() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle());
         // DELETE PERMISSION ENTRIES IN RBAC_PA
         // DONE: method overwritten in ilObjRole & ilObjUser.
         // this call only applies for objects in rbac (not usr,role,rolt)
         // TODO: Do this for role templates too
         $rbacadmin->revokePermission($this->getRefId(), 0, false);
         include_once "Services/AccessControl/classes/class.ilRbacLog.php";
         ilRbacLog::delete($this->getRefId());
         // Remove applied didactic template setting
         include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
         ilDidacticTemplateObjSettings::deleteByRefId($this->getRefId());
         // Remove desktop items
         ilUtil::removeItemFromDesktops($this->getRefId());
     }
     // remove conditions
     if ($this->referenced) {
         $ch =& new ilConditionHandler();
         $ch->delete($this->getRefId());
         unset($ch);
     }
     return $remove;
 }