/**
  * delete page object or structure objects
  *
  * @param	int		$a_parent_subobj_id		id of parent object (structure object)
  *											of the objects, that should be deleted
  *											(or no parent object id for top level)
  */
 function confirmedDelete($a_parent_subobj_id = 0)
 {
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // check number of objects
     if (!$_POST["id"]) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     // delete all selected objects
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setLMId($this->object->getId());
                 include_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($this->object->getId(), "delete_" . $obj->getType(), array(ilLMObject::_lookupTitle($id), $id), $this->object->getType());
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     $this->object->checkTree();
     // feedback
     ilUtil::sendSuccess($this->lng->txt("info_deleted"), true);
     if ($a_parent_subobj_id == 0) {
         $this->ctrl->redirect($this, $_GET["backcmd"]);
     }
 }
Exemplo n.º 2
0
 function create($a_upload = false)
 {
     global $ilDB;
     // insert object data
     $this->setId($ilDB->nextId("lm_data"));
     $query = "INSERT INTO lm_data (obj_id, title, type, layout, lm_id, import_id, create_date) " . "VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote($this->getTitle(), "text") . "," . $ilDB->quote($this->getType(), "text") . ", " . $ilDB->quote($this->getLayout(), "text") . ", " . $ilDB->quote($this->getLMId(), "integer") . "," . $ilDB->quote($this->getImportId(), "text") . ", " . $ilDB->now() . ")";
     $ilDB->manipulate($query);
     // create history entry
     include_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->getId(), "create", "", $this->content_object->getType() . ":" . $this->getType());
     if (!$a_upload) {
         $this->createMetaData();
     }
 }
 /**
  * Execute Drag Drop Action
  *
  * @param	string	$source_id		Source element ID
  * @param	string	$target_id		Target element ID
  * @param	string	$first_child	Insert as first child of target
  * @param	string	$movecopy		Position ("move" | "copy")
  */
 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
 {
     $lmtree = new ilTree($this->getId());
     $lmtree->setTableNames('lm_tree', 'lm_data');
     $lmtree->setTreeTablePK("lm_id");
     //echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
     $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
     $source_obj->setLMId($this->getId());
     if (!$first_child) {
         $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
         $target_obj->setLMId($this->getId());
         $target_parent = $lmtree->getParentId($target_id);
     }
     // handle pages
     if ($source_obj->getType() == "pg") {
         //echo "1";
         if ($lmtree->isInTree($source_obj->getId())) {
             $node_data = $lmtree->getNodeData($source_obj->getId());
             // cut on move
             if ($movecopy == "move") {
                 $parent_id = $lmtree->getParentId($source_obj->getId());
                 $lmtree->deleteTree($node_data);
                 // write history entry
                 require_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($source_obj->getId(), "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->getType() . ":pg");
                 ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
             } else {
                 // copy page
                 $new_page =& $source_obj->copy();
                 $source_id = $new_page->getId();
                 $source_obj =& $new_page;
             }
             // paste page
             if (!$lmtree->isInTree($source_obj->getId())) {
                 if ($first_child) {
                     $target_pos = IL_FIRST_NODE;
                     $parent = $target_id;
                 } else {
                     if ($as_subitem) {
                         $parent = $target_id;
                         $target_pos = IL_FIRST_NODE;
                         $pg_childs =& $lmtree->getChildsByType($parent, "pg");
                         if (count($pg_childs) != 0) {
                             $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
                         }
                     } else {
                         $target_pos = $target_id;
                         $parent = $target_parent;
                     }
                 }
                 // insert page into tree
                 $lmtree->insertNode($source_obj->getId(), $parent, $target_pos);
                 // write history entry
                 if ($movecopy == "move") {
                     // write history comments
                     include_once "./Services/History/classes/class.ilHistory.php";
                     ilHistory::_createEntry($source_obj->getId(), "paste", array(ilLMObject::_lookupTitle($parent), $parent), $this->getType() . ":pg");
                     ilHistory::_createEntry($parent, "paste_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
                 }
             }
         }
     }
     // handle chapters
     if ($source_obj->getType() == "st") {
         //echo "2";
         $source_node = $lmtree->getNodeData($source_id);
         $subnodes = $lmtree->getSubtree($source_node);
         // check, if target is within subtree
         foreach ($subnodes as $subnode) {
             if ($subnode["obj_id"] == $target_id) {
                 return;
             }
         }
         $target_pos = $target_id;
         if ($first_child) {
             $target_pos = IL_FIRST_NODE;
             $target_parent = $target_id;
             $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
             if (count($pg_childs) != 0) {
                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
             }
         } else {
             if ($as_subitem) {
                 $target_parent = $target_id;
                 $target_pos = IL_FIRST_NODE;
                 $childs =& $lmtree->getChilds($target_parent);
                 if (count($childs) != 0) {
                     $target_pos = $childs[count($childs) - 1]["obj_id"];
                 }
             }
         }
         // insert into
         /*
         			if ($position == "into")
         			{
         				$target_parent = $target_id;
         				$target_pos = IL_FIRST_NODE;
         
         				// if target_pos is still first node we must skip all pages
         				if ($target_pos == IL_FIRST_NODE)
         				{
         					$pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
         					if (count($pg_childs) != 0)
         					{
         						$target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
         					}
         				}
         			}
         */
         // delete source tree
         if ($movecopy == "move") {
             $lmtree->deleteTree($source_node);
         } else {
             // copy chapter (incl. subcontents)
             $new_chapter =& $source_obj->copy($lmtree, $target_parent, $target_pos);
         }
         if (!$lmtree->isInTree($source_id)) {
             $lmtree->insertNode($source_id, $target_parent, $target_pos);
             // insert moved tree
             if ($movecopy == "move") {
                 foreach ($subnodes as $node) {
                     if ($node["obj_id"] != $source_id) {
                         $lmtree->insertNode($node["obj_id"], $node["parent"]);
                     }
                 }
             }
         }
         // check the tree
         $this->checkTree();
     }
     $this->checkTree();
 }
Exemplo n.º 4
0
 /**
  * add change comment to history
  */
 function addChangeComment()
 {
     include_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->page->getId(), "update", "", $this->page->getParentType() . ":pg", ilUtil::stripSlashes($_POST["change_comment"]), true);
     ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
     $this->ctrl->returnToParent($this);
 }
 function add($a_update_history = true)
 {
     global $ilDB;
     $this->__setLastUpdateDate(time());
     $this->__setCreateDate(time());
     $next_id = $ilDB->nextId('webr_items');
     $query = "INSERT INTO webr_items (link_id,title,description,target,active,disable_check," . "last_update,create_date,webr_id,valid) " . "VALUES( " . $ilDB->quote($next_id, 'integer') . ", " . $ilDB->quote($this->getTitle(), 'text') . ", " . $ilDB->quote($this->getDescription(), 'text') . ", " . $ilDB->quote($this->getTarget(), 'text') . ", " . $ilDB->quote($this->getActiveStatus(), 'integer') . ", " . $ilDB->quote($this->getDisableCheckStatus(), 'integer') . ", " . $ilDB->quote($this->getLastUpdateDate(), 'integer') . ", " . $ilDB->quote($this->getCreateDate(), 'integer') . ", " . $ilDB->quote($this->getLinkResourceId(), 'integer') . ", " . $ilDB->quote($this->getValidStatus(), 'integer') . ' ' . ")";
     $res = $ilDB->manipulate($query);
     $link_id = $next_id;
     $this->setLinkId($link_id);
     if ($a_update_history) {
         include_once "./Services/History/classes/class.ilHistory.php";
         ilHistory::_createEntry($this->getLinkResourceId(), "add", $this->getTitle());
     }
     return $link_id;
 }
 /**
  * update history
  */
 function updateHistory()
 {
     require_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->obj->getId(), "update", "", $this->content_object->getType() . ":pg", "", true);
 }
 /**
  * paste page
  */
 function pastePage()
 {
     global $ilUser;
     if (!$ilUser->clipboardHasObjectsOfType("pg")) {
         $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"), $this->ilias->error_obj->MESSAGE);
     }
     return $this->insertPageClip();
     return;
     $tree = new ilTree($this->content_object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // paste selected object
     $id = ilEditClipboard::getContentObjectId();
     // copy page, if action is copy
     if (ilEditClipboard::getAction() == "copy") {
         // check wether page belongs to lm
         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()) == $this->content_object->getID()) {
             $lm_page = new ilLMPageObject($this->content_object, $id);
             $new_page =& $lm_page->copy();
             $id = $new_page->getId();
         } else {
             // get page from other content object into current content object
             $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
             $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
             $lm_page = new ilLMPageObject($lm_obj, $id);
             $copied_nodes = array();
             $new_page =& $lm_page->copyToOtherContObject($this->content_object, $copied_nodes);
             $id = $new_page->getId();
             ilLMObject::updateInternalLinks($copied_nodes);
         }
     }
     if (ilEditClipboard::getAction() == "cut") {
         // check wether page belongs not to lm
         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()) != $this->content_object->getID()) {
             $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
             $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
             $lm_page = new ilLMPageObject($lm_obj, $id);
             $lm_page->setLMId($this->content_object->getID());
             $lm_page->update();
             $page =& $lm_page->getPageObject();
             $page->buildDom();
             $page->setParentId($this->content_object->getID());
             $page->update();
         }
     }
     if (!$tree->isInTree($id)) {
         if (!isset($_POST["id"])) {
             $target = IL_FIRST_NODE;
         } else {
             $target = $_POST["id"][0];
         }
         $tree->insertNode($id, $this->obj->getId(), $target);
         ilEditClipboard::clear();
     }
     // write history comments
     include_once "./Services/History/classes/class.ilHistory.php";
     $parent_id = $tree->getParentId($id);
     ilHistory::_createEntry($id, "paste", array(ilLMObject::_lookupTitle($this->obj->getId()), $this->obj->getId()), $this->content_object->getType() . ":pg");
     ilHistory::_createEntry($parent_id, "paste_page", array(ilLMObject::_lookupTitle($id), $id), $this->content_object->getType() . ":st");
     // check the tree
     $this->checkTree();
     $this->ctrl->redirect($this, "view");
 }
Exemplo n.º 8
0
 /**
  * Makes the specified version the current one and returns theSummary of rollbackVersion
  * 
  * @param int $version_id The id of the version to make the current one.
  * @return array The new actual version. 
  */
 public function rollback($version_id)
 {
     global $ilDB, $ilUser;
     $source = $this->getSpecificVersion($version_id);
     if ($source === false) {
         $this->ilErr->raiseError($this->lng->txt("obj_not_found"), $this->ilErr->MESSAGE);
     }
     // get the new version number
     $new_version_nr = $this->getVersion() + 1;
     // copy file
     $source_path = $this->getDirectory($source["version"]) . "/" . $source["filename"];
     $dest_dir = $this->getDirectory($new_version_nr);
     if (@(!is_dir($dest_dir))) {
         ilUtil::makeDir($dest_dir);
     }
     copy($source_path, $dest_dir . "/" . $source["filename"]);
     // create new history entry based on the old one
     include_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->getId(), "rollback", $source["filename"] . "," . $new_version_nr . "|" . $source["version"] . "|" . $ilUser->getId());
     // get id of newest entry
     $new_version = $this->getSpecificVersion($ilDB->getLastInsertId());
     // change user back to the original uploader
     ilHistory::_changeUserId($new_version["hist_entry_id"], $source["user_id"]);
     // update this file with the new version
     $this->updateWithVersion($new_version);
     $this->addNewsNotification("file_updated");
     return $new_version;
 }
 public function addFileVersion($a_upload_file, $a_filename)
 {
     $this->getUploadFile($a_upload_file, $a_filename);
     require_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->getId(), "new_version", $a_filename . "," . $this->getVersion());
     $this->setFilename($a_filename);
     $this->addNewsNotification("file_updated");
 }
 /**
  * update file according to filename and version and create history entry
  * has to be called after (!) file save for new objects, since file storage will be initialised with obj id.
  *
  */
 public function updateFileContents()
 {
     if ($this->setFileContents()) {
         require_once "./Services/History/classes/class.ilHistory.php";
         ilHistory::_createEntry($this->file->getId(), "replace", $this->file->getFilename() . "," . $this->file->getVersion());
         $this->file->addNewsNotification("file_updated");
     }
 }
Exemplo n.º 11
0
 /**
  * Creates a new version of the object.
  * Only objects which support versioning need to implement this method.
  */
 function createNewVersion()
 {
     $this->obj->setVersion($this->obj->getVersion() + 1);
     ilHistory::_createEntry($this->obj->getId(), "replace", $this->obj->getFileName() . "," . $this->obj->getVersion());
 }