24 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
59 $this->
setLMId($a_content_obj->getId());
79 include_once
'Services/MetaData/classes/class.ilMD.php';
87 $md_gen = $md->getGeneral();
91 foreach($md_gen->getDescriptionIds() as
$id)
93 $md_des = $md_gen->getDescription(
$id);
111 include_once
'Services/MetaData/classes/class.ilMD.php';
113 $md =
new ilMD($a_lm_id, $a_lm_obj_id, $a_type);
114 $md_gen = $md->getGeneral();
115 if (is_object($md_gen))
117 foreach($md_gen->getIdentifierIds() as
$id)
119 $md_id = $md_gen->getIdentifier(
$id);
120 if ($md_id->getCatalog() ==
"ILIAS_NID")
122 return $md_id->getEntry();
136 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
141 $md_creator->setTitle($this->
getTitle());
142 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
144 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
145 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
146 $md_creator->setLanguage($ilUser->getPref(
'language'));
147 $md_creator->create();
157 include_once(
"Services/MetaData/classes/class.ilMD.php");
158 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
159 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
162 $md_gen =& $md->getGeneral();
163 $md_gen->setTitle($this->
getTitle());
166 $md_des_ids =& $md_gen->getDescriptionIds();
167 if (count($md_des_ids) > 0)
169 $md_des =& $md_gen->getDescription($md_des_ids[0]);
184 include_once(
'Services/MetaData/classes/class.ilMD.php');
196 $this->data_record = $a_record;
203 $ilBench->start(
"ContentPresentation",
"ilLMObject_read");
205 if(!isset($this->data_record))
207 $ilBench->start(
"ContentPresentation",
"ilLMObject_read_getData");
208 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
209 $ilDB->quote($this->
id,
"integer");
210 $obj_set = $ilDB->query(
$query);
211 $this->data_record = $ilDB->fetchAssoc($obj_set);
212 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read_getData");
215 $this->type = $this->data_record[
"type"];
216 $this->
setImportId($this->data_record[
"import_id"]);
217 $this->
setTitle($this->data_record[
"title"]);
218 $this->
setLayout($this->data_record[
"layout"]);
221 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read");
231 $this->title = $a_title;
254 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
255 $ilDB->quote($a_obj_id,
"integer");
256 $obj_set = $ilDB->query(
$query);
257 $obj_rec = $ilDB->fetchAssoc($obj_set);
259 return $obj_rec[
"title"];
274 $and =
' AND lm_id = '.$ilDB->quote($a_lm_id,
'integer');
277 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").$and;
278 $obj_set = $ilDB->query(
$query);
279 $obj_rec = $ilDB->fetchAssoc($obj_set);
281 return $obj_rec[
"type"];
289 $query =
"UPDATE lm_data SET ".
290 " title = ".$ilDB->quote($a_title,
"text").
291 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
292 $ilDB->manipulate(
$query);
298 $this->description = $a_description;
308 $this->type = $a_type;
318 $this->lm_id = $a_lm_id;
329 $this->content_object =& $a_content_obj;
349 return $this->import_id;
354 $this->import_id = $a_id;
364 $this->layout = $a_val;
374 return $this->layout;
388 $q =
"UPDATE lm_data ".
390 "import_id = ".$ilDB->quote($a_import_id,
"text").
",".
391 "last_update = ".$ilDB->now().
" ".
392 "WHERE obj_id = ".$ilDB->quote($a_id,
"integer");
394 $ilDB->manipulate($q);
402 $this->
setId($ilDB->nextId(
"lm_data"));
403 $query =
"INSERT INTO lm_data (obj_id, title, type, lm_id, import_id, create_date) ".
405 $ilDB->quote($this->
getId(),
"integer").
",".
406 $ilDB->quote($this->
getTitle(),
"text").
",".
407 $ilDB->quote($this->
getType(),
"text").
", ".
408 $ilDB->quote($this->
getLMId(),
"integer").
",".
410 ", ".$ilDB->now().
")";
411 $ilDB->manipulate($query);
414 include_once(
"classes/class.ilHistory.php");
416 $this->content_object->getType().
":".$this->
getType());
434 $query =
"UPDATE lm_data SET ".
435 " lm_id = ".$ilDB->quote($this->
getLMId(),
"integer").
436 " ,title = ".$ilDB->quote($this->
getTitle(),
"text").
437 " ,layout = ".$ilDB->quote($this->
getLayout(),
"text").
438 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
440 $ilDB->manipulate(
$query);
456 if (!is_array($a_pages))
457 {$a_pages = array(0);
464 if (empty($a_cont_obj_id))
466 $message = sprintf(
'ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_cont_obj_id is empty');
467 $ilLog->write($message,$ilLog->WARNING);
468 $ilErr->raiseError($message,$ilErr->MESSAGE);
473 $lm_tree =
new ilTree($a_cont_obj_id);
474 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
475 $lm_tree->setTreeTablePK(
"lm_id");
476 $lm_tree->readRootId();
479 $q =
"SELECT obj_id FROM lm_data " .
480 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
482 $r = $ilDB->query($q);
485 while (
$row = $ilDB->fetchAssoc($r))
487 $childs = $lm_tree->getChilds(
$row[
"obj_id"]);
489 foreach ($childs as $page)
491 if ($page[
"type"] ==
"pg" and in_array($page[
"obj_id"],$a_pages))
493 array_push($a_pages,
$row[
"obj_id"]);
500 $q =
"UPDATE lm_data SET " .
501 "public_access = CASE " .
502 "WHEN ".$ilDB->in(
"obj_id", $a_pages,
false,
"integer").
" ".
503 "THEN ".$ilDB->quote(
"y",
"text").
504 "ELSE ".$ilDB->quote(
"n",
"text").
506 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
507 "AND ".$ilDB->in(
"type", array(
"pg",
"st"),
false,
"text");
508 $ilDB->manipulate($q);
517 if (empty($a_node_id))
519 $message = sprintf(
'ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
520 $ilLog->write($message,$ilLog->WARNING);
524 if ($a_check_public_mode ===
true)
526 $lm_id = ilLMObject::_lookupContObjId($a_node_id);
528 $q =
"SELECT public_access_mode FROM content_object WHERE id = ".
529 $ilDB->quote(
$lm_id,
"integer");
530 $r = $ilDB->query($q);
531 $row = $ilDB->fetchAssoc($r);
533 if (
$row[
"public_access_mode"] ==
"complete")
539 $q =
"SELECT public_access FROM lm_data WHERE obj_id=".
540 $ilDB->quote($a_node_id,
"integer");
541 $r = $ilDB->query($q);
542 $row = $ilDB->fetchAssoc($r);
550 function delete($a_delete_meta_data =
true)
554 $query =
"DELETE FROM lm_data WHERE obj_id = ".
555 $ilDB->quote($this->
getId(),
"integer");
556 $ilDB->manipulate(
$query);
576 $q =
"SELECT obj_id FROM lm_data WHERE import_id = ".
577 $ilDB->quote($a_import_id,
"text").
" ".
578 " ORDER BY create_date DESC";
579 $obj_set = $ilDB->query($q);
580 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
587 return $obj_rec[
"obj_id"];
607 $where = ($a_in_lm > 0)
608 ?
" AND lm_id = ".$ilDB->quote($a_in_lm,
"integer").
" "
611 $q =
"SELECT * FROM lm_data WHERE import_id = ".
612 $ilDB->quote($a_import_id,
"text").
" ".
614 " ORDER BY create_date DESC";
615 $obj_set = $ilDB->query($q);
618 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
641 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
642 if (is_int(strpos($a_id,
"_")))
647 $q =
"SELECT * FROM lm_data WHERE obj_id = ".
648 $ilDB->quote($a_id,
"integer");
649 $obj_set = $ilDB->query($q);
650 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
668 $type_str = (
$type !=
"")
669 ?
"AND type = ".$ilDB->quote(
$type,
"text").
" "
671 $query =
"SELECT * FROM lm_data ".
672 "WHERE lm_id= ".$ilDB->quote(
$lm_id,
"integer").
" ".
675 $obj_set = $ilDB->query(
$query);
677 while($obj_rec = $ilDB->fetchAssoc($obj_set))
679 $obj_list[] = array(
"obj_id" => $obj_rec[
"obj_id"],
680 "title" => $obj_rec[
"title"],
681 "type" => $obj_rec[
"type"]);
694 include_once
'./classes/class.ilNestedSetXML.php';
696 $query =
"SELECT * FROM lm_data ".
697 "WHERE lm_id= ".$ilDB->quote($a_cobj->getId(),
"integer");
698 $obj_set = $ilDB->query(
$query);
700 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
701 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
705 if (is_object($lm_obj))
707 $lm_obj->delete(
true);
721 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
722 $ilDB->quote($a_id,
"integer");
723 $obj_set = $ilDB->query(
$query);
724 $obj_rec = $ilDB->fetchAssoc($obj_set);
726 return $obj_rec[
"lm_id"];
732 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
736 $tree =
new ilTree($a_obj->getContentObject()->getId());
738 $tree->setTreeTablePK(
"lm_id");
741 $parent_id = ($a_parent_id !=
"")
743 : $tree->getRootId();
746 if ($a_target_node_id !=
"")
748 $target = $a_target_node_id;
753 if ($a_obj->getType() ==
"st")
755 $s_types = array(
"st",
"pg");
756 $childs =& $tree->getChildsByTypeFilter($parent_id, $s_types);
761 $childs =& $tree->getChildsByType($parent_id, $s_types);
764 if (count($childs) == 0)
770 $target = $childs[count($childs) - 1][
"obj_id"];
774 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
776 $ilLog->write(
"LMObject::putInTree: insertNode, ID: ".$a_obj->getId().
777 "Parent ID: ".$parent_id.
", Target: ".$target);
779 $tree->insertNode($a_obj->getId(), $parent_id, $target);
792 $tree =
new ilTree($a_cont_obj_id);
793 $tree->setTableNames(
'lm_tree',
'lm_data');
794 $tree->setTreeTablePK(
"lm_id");
807 if (!is_array($a_ids))
814 foreach($a_ids as
$id)
816 $path = $tree->getPathId($id);
818 foreach(
$path as $path_id)
820 if ($path_id != $id && in_array($path_id, $a_ids))
837 foreach ($cut_ids as
$id)
839 $curnode = $tree->getNodeData($id);
840 if ($tree->isInTree($id))
842 $tree->deleteTree($curnode);
857 $ilUser->clipboardDeleteObjectsOfType(
"pg");
858 $ilUser->clipboardDeleteObjectsOfType(
"st");
861 $time = date(
"Y-m-d H:i:s", time());
862 foreach ($a_ids as
$id)
865 if ($tree->isInTree($id))
867 $curnode = $tree->getNodeData($id);
868 $subnodes = $tree->getSubTree($curnode);
869 foreach($subnodes as $subnode)
871 if ($subnode[
"child"] != $id)
873 $ilUser->addObjectToClipboard($subnode[
"child"],
874 $subnode[
"type"], $subnode[
"title"],
875 $subnode[
"parent"], $time, $subnode[
"lft"]);
879 $order = ($curnode[
"lft"] > 0)
881 : (
int) ($order + 1);
882 $ilUser->addObjectToClipboard($id,
891 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
892 &$a_copied_nodes, $a_as_copy =
false)
898 $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
899 if ($item_type ==
"st")
903 else if ($item_type ==
"pg")
908 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
909 "Item ID: ".$a_item_id.
", of original LM: ".$item_lm_id);
911 if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
916 include_once(
"Services/MetaData/classes/class.ilMD.php");
917 $md =
new ilMD($item_lm_id, $item->getId(), $item->getType());
918 $new_md = $md->
cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
921 $item->setLMId($a_target_lm->getId());
922 $item->setContentObject($a_target_lm);
928 if ($item_type ==
"pg")
930 $page = $item->getPageObject();
932 $page->setParentId($a_target_lm->getId());
939 $target_item = $item->copy($a_target_lm);
940 $a_copied_nodes[$item->getId()] = $target_item->getId();
944 $target_item = $item;
947 $ilLog->write(
"Putting into tree type ".$target_item->getType().
948 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
949 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
953 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
955 foreach($childs as $child)
958 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
961 return $target_item->getId();
972 if (is_array($a_titles))
974 include_once(
"./Services/MetaData/classes/class.ilMD.php");
978 if (is_object($lmobj))
981 $md =
new ilMD($a_lm->getId(),
$id, $lmobj->getType());
983 $md_gen->setTitle(
$title);
997 $all_fixes = array();
998 foreach($a_copied_nodes as $original_id => $copied_id)
1003 if ($copied_type ==
"pg")
1011 $il = $tpg->getInternalLinks();
1020 foreach($targets as $target)
1022 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
1023 ($target[
"type"] ==
"pg" || $target[
"type"] ==
"st"))
1026 if ($a_copied_nodes[$target[
"id"]] > 0)
1028 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
1036 if ($trg_lm != $copy_lm)
1041 foreach($lm_data as $item)
1043 if (!$found && ($item[
"lm_id"] == $copy_lm))
1045 $fix[$target[
"id"]] = $item[
"obj_id"];
1055 if (count($fix) > 0)
1060 if (is_array($all_fixes[
$t.
":".$copied_id]))
1062 $all_fixes[
$t.
":".$copied_id] += $fix;
1066 $all_fixes[
$t.
":".$copied_id] = $fix;
1074 if ($copied_type ==
"pg" ||
1075 $copied_type ==
"st")
1088 if ($original_lm != $copy_lm)
1103 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1104 foreach(
$mobs as $mob)
1114 foreach($usages as $usage)
1116 if ($usage[
"type"] ==
"lm:pg" | $usage[
"type"] ==
"lm:st")
1118 $sources[] = $usage;
1123 foreach($sources as $source)
1125 $stype = explode(
":", $source[
"type"]);
1126 $source_type = $stype[1];
1128 if ($source_type ==
"pg" || $source_type ==
"st")
1133 if ($src_lm == $original_lm)
1140 foreach ($lm_data as $item)
1144 $fix[$item[
"obj_id"]][$original_id] = $copied_id;
1152 if (count($fix) > 0)
1154 foreach ($fix as $page_id => $fix_array)
1160 if (is_array($all_fixes[
$t.
":".$page_id]))
1162 $all_fixes[
$t.
":".$page_id] += $fix_array;
1166 $all_fixes[
$t.
":".$page_id] = $fix_array;
1178 foreach ($all_fixes as $pg => $fixes)
1182 $pg = explode(
":", $pg);
1184 if ($page->moveIntLinks($fixes))
1186 $page->update(
true,
true,
true);
1197 if (is_array($a_items))
1199 foreach($a_items as $item)
1206 if (count($types) > 1)
1223 $query =
"UPDATE lm_data SET ".
1224 " layout = ".$ilDB->quote($a_layout,
"text").
1225 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
1227 $ilDB->manipulate(
$query);
1239 $query =
"SELECT layout FROM lm_data WHERE obj_id = ".
1240 $ilDB->quote($a_obj_id,
"integer");
1241 $obj_set = $ilDB->query(
$query);
1242 $obj_rec = $ilDB->fetchAssoc($obj_set);
1244 return $obj_rec[
"layout"];