function showMoveCopyQuestion()
 {
     $tempobj = ilObjectFactory::getInstanceByRefId($_GET["ref_id"]);
     $source_obj = ilLMObjectFactory::getInstance($tempobj, $_GET["sourceId"], true);
     $source_obj->setLMId($tempobj->getId());
     $target_obj = ilLMObjectFactory::getInstance($tempobj, $_GET["targetId"], true);
     $target_obj->setLMId($tempobj->getId());
     //vd($source_obj->getType());
     //vd($target_obj->getType());
     $this->tpl = new ilTemplate("tpl.wysiwyg_popup_movecopyquestion.html", false, true, "Services/COPage");
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     if ($source_obj->getType() == "st" && $target_obj->getType() == "pg") {
         $this->tpl->setVariable("TXT_ST_ON_PG", $this->lng->txt("cont_st_on_pg"));
         $this->tpl->setVariable("BTN_CLOSE2", $this->lng->txt("close"));
     } else {
         if ($source_obj->getType() == "pg" && $target_obj->getType() == "pg" || $source_obj->getType() == "st" && $target_obj->getType() == "st") {
             $this->tpl->setVariable("TXT_SET_AFTER", $this->lng->txt("cont_set_after"));
             $this->tpl->setVariable("TXT_SET_BEFORE", $this->lng->txt("cont_set_before"));
         }
         if ($source_obj->getType() == "st" && $target_obj->getType() == "st") {
             $this->tpl->setVariable("TXT_SET_INTO", $this->lng->txt("cont_set_into"));
         }
         $this->tpl->setVariable("TXT_MOVE_OBJECT", $this->lng->txt("cont_move_object"));
         $this->tpl->setVariable("TXT_COPY_OBJECT", $this->lng->txt("cont_copy_object"));
         $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("save"));
         $this->tpl->setVariable("BTN_CLOSE", $this->lng->txt("close"));
     }
 }
 /**
  * Delete sub tree
  */
 private function delete_rec(&$a_tree, $a_delete_meta_data = true)
 {
     $childs = $a_tree->getChilds($this->getId());
     foreach ($childs as $child) {
         $obj =& ilLMObjectFactory::getInstance($this->content_object, $child["obj_id"], false);
         if (is_object($obj)) {
             if ($obj->getType() == "st") {
                 $obj->delete_rec($a_tree, $a_delete_meta_data);
             }
             if ($obj->getType() == "pg") {
                 $obj->delete($a_delete_meta_data);
             }
         }
         unset($obj);
     }
     parent::delete($a_delete_meta_data);
 }
Esempio n. 3
0
 /**
  * Save titles for lm objects
  *
  * @param	array		titles (key is ID, value is title)
  */
 static function saveTitles($a_lm, $a_titles, $a_lang = "-")
 {
     include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
     if ($a_lang == "") {
         $a_lang = "-";
     }
     if (is_array($a_titles)) {
         include_once "./Services/MetaData/classes/class.ilMD.php";
         foreach ($a_titles as $id => $title) {
             if ($a_lang == "-") {
                 $lmobj = ilLMObjectFactory::getInstance($a_lm, $id, false);
                 if (is_object($lmobj)) {
                     // Update Title and description
                     $md = new ilMD($a_lm->getId(), $id, $lmobj->getType());
                     $md_gen = $md->getGeneral();
                     if (is_object($md_gen)) {
                         $md_gen->setTitle($title);
                         $md_gen->update();
                         $md->update();
                     }
                     ilLMObject::_writeTitle($id, $title);
                 }
             } else {
                 $lmobjtrans = new ilLMObjTranslation($id, $a_lang);
                 $lmobjtrans->setTitle($title);
                 $lmobjtrans->save();
             }
         }
     }
 }
 /**
  * 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"]);
     }
 }
 /**
  * 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();
 }
 /**
  * locator
  */
 function ilLocator()
 {
     global $ilLocator, $tree, $ilCtrl;
     require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
     if (empty($_GET["obj_id"])) {
         $a_id = $this->lm_tree->getRootId();
     } else {
         $a_id = $_GET["obj_id"];
     }
     $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
     if (!$this->lm->cleanFrames()) {
         $frame_param = $_GET["frame"];
         $frame_target = "";
     } else {
         if (!$this->offlineMode()) {
             $frame_param = "";
             $frame_target = ilFrameTargetInfo::_getFrame("MainContent");
         } else {
             $frame_param = "";
             $frame_target = "_top";
         }
     }
     if (!$this->offlineMode()) {
         $ilLocator->addItem("...", "");
         $par_id = $tree->getParentId($_GET["ref_id"]);
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $par_id);
         $ilLocator->addItem(ilObject::_lookupTitle(ilObject::_lookupObjId($par_id)), $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"), ilFrameTargetInfo::_getFrame("MainContent"), $par_id);
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
     } else {
         $ilLocator->setOffline(true);
     }
     if ($this->lm_tree->isInTree($a_id)) {
         $path = $this->lm_tree->getPathFull($a_id);
         foreach ($path as $key => $row) {
             if ($row["type"] != "pg") {
                 if ($row["child"] != $this->lm_tree->getRootId()) {
                     $ilLocator->addItem(ilUtil::shortenText(ilStructureObject::_getPresentationTitle($row["child"], $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), 0, $this->lang), 50, true), $this->getLink($_GET["ref_id"], "layout", $row["child"], $frame_param, "StructureObject"), $frame_target);
                 } else {
                     $ilLocator->addItem(ilUtil::shortenText($this->lm->getTitle(), 50, true), $this->getLink($_GET["ref_id"], "layout", "", $frame_param), $frame_target, $_GET["ref_id"]);
                 }
             }
         }
     } else {
         $ilLocator->addItem($this->lm->getTitle(), $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"]));
         require_once "./Modules/LearningModule/classes/class.ilLMObjectFactory.php";
         $lm_obj = ilLMObjectFactory::getInstance($this->lm, $a_id);
         $ilLocator->addItem($lm_obj->getTitle(), $this->getLink($_GET["ref_id"], "layout", $a_id, $frame_param), $frame_target);
     }
     if (DEBUG) {
         $debug = "DEBUG: <font color=\"red\">" . $this->type . "::" . $this->id . "::" . $_GET["cmd"] . "</font><br/>";
     }
     //$prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
     $this->tpl->setLocator();
 }
 /**
  * cut page
  */
 function cutPage()
 {
     $this->cutItems();
     return;
     if (!isset($_POST["id"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["id"]) > 1) {
         $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"), $this->ilias->error_obj->MESSAGE);
     }
     if (count($_POST["id"]) == 1 && $_POST["id"][0] == IL_FIRST_NODE) {
         $this->ilias->raiseError($this->lng->txt("cont_select_item"), $this->ilias->error_obj->MESSAGE);
     }
     // SAVE POST VALUES
     ilEditClipboard::storeContentObject("pg", $_POST["id"][0]);
     $tree = new ilTree($this->content_object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // cut selected object
     $cutted = 0;
     foreach ($_POST["id"] as $id) {
         if ($id == -1) {
             continue;
         }
         $obj =& ilLMObjectFactory::getInstance($this->content_object, $id);
         $obj->setLMId($this->content_object->getId());
         $node_data = $tree->getNodeData($id);
         //$obj->delete();
         if ($tree->isInTree($id)) {
             $parent_id = $tree->getParentId($id);
             $tree->deleteTree($node_data);
             // write history entry
             require_once "./Services/History/classes/class.ilHistory.php";
             ilHistory::_createEntry($id, "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->content_object->getType() . ":pg");
             ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($id), $id), $this->content_object->getType() . ":st");
         }
         $cutted++;
     }
     // tree check
     $this->checkTree();
     if ($cutted > 0) {
         ilUtil::sendInfo($this->lng->txt("msg_cut_clipboard"), true);
     }
     $this->ctrl->redirect($this, "view");
 }
 /**
  * Save titles for lm objects
  *
  * @param	array		titles (key is ID, value is title)
  */
 static function saveTitles($a_lm, $a_titles)
 {
     if (is_array($a_titles)) {
         include_once "./Services/MetaData/classes/class.ilMD.php";
         foreach ($a_titles as $id => $title) {
             $lmobj = ilLMObjectFactory::getInstance($a_lm, $id, false);
             if (is_object($lmobj)) {
                 // Update Title and description
                 $md = new ilMD($a_lm->getId(), $id, $lmobj->getType());
                 $md_gen = $md->getGeneral();
                 $md_gen->setTitle($title);
                 $md_gen->update();
                 $md->update();
                 ilLMObject::_writeTitle($id, $title);
             }
         }
     }
 }