5 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
40 $this->
setLMId($a_content_obj->getId());
60 include_once
'Services/MetaData/classes/class.ilMD.php';
68 $md_gen = $md->getGeneral();
72 foreach($md_gen->getDescriptionIds() as
$id)
74 $md_des = $md_gen->getDescription(
$id);
92 include_once
'Services/MetaData/classes/class.ilMD.php';
94 $md =
new ilMD($a_lm_id, $a_lm_obj_id, $a_type);
95 $md_gen = $md->getGeneral();
96 if (is_object($md_gen))
98 foreach($md_gen->getIdentifierIds() as
$id)
100 $md_id = $md_gen->getIdentifier(
$id);
101 if ($md_id->getCatalog() ==
"ILIAS_NID")
103 return $md_id->getEntry();
117 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
122 $md_creator->setTitle($this->
getTitle());
123 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
125 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
126 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
127 $md_creator->setLanguage($ilUser->getPref(
'language'));
128 $md_creator->create();
138 include_once(
"Services/MetaData/classes/class.ilMD.php");
139 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
140 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
143 $md_gen =& $md->getGeneral();
144 $md_gen->setTitle($this->
getTitle());
147 $md_des_ids =& $md_gen->getDescriptionIds();
148 if (count($md_des_ids) > 0)
150 $md_des =& $md_gen->getDescription($md_des_ids[0]);
165 include_once(
'Services/MetaData/classes/class.ilMD.php');
177 $this->data_record = $a_record;
184 $ilBench->start(
"ContentPresentation",
"ilLMObject_read");
186 if(!isset($this->data_record))
188 $ilBench->start(
"ContentPresentation",
"ilLMObject_read_getData");
189 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
190 $ilDB->quote($this->
id,
"integer");
191 $obj_set = $ilDB->query(
$query);
192 $this->data_record = $ilDB->fetchAssoc($obj_set);
193 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read_getData");
196 $this->type = $this->data_record[
"type"];
197 $this->
setImportId($this->data_record[
"import_id"]);
198 $this->
setTitle($this->data_record[
"title"]);
199 $this->
setLayout($this->data_record[
"layout"]);
202 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read");
212 $this->title = $a_title;
235 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
236 $ilDB->quote($a_obj_id,
"integer");
237 $obj_set = $ilDB->query(
$query);
238 $obj_rec = $ilDB->fetchAssoc($obj_set);
240 return $obj_rec[
"title"];
255 $and =
' AND lm_id = '.$ilDB->quote($a_lm_id,
'integer');
258 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").$and;
259 $obj_set = $ilDB->query(
$query);
260 $obj_rec = $ilDB->fetchAssoc($obj_set);
262 return $obj_rec[
"type"];
270 $query =
"UPDATE lm_data SET ".
271 " title = ".$ilDB->quote($a_title,
"text").
272 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
273 $ilDB->manipulate(
$query);
279 $this->description = $a_description;
289 $this->type = $a_type;
299 $this->lm_id = $a_lm_id;
310 $this->content_object =& $a_content_obj;
330 return $this->import_id;
335 $this->import_id = $a_id;
345 $this->layout = $a_val;
355 return $this->layout;
369 $q =
"UPDATE lm_data ".
371 "import_id = ".$ilDB->quote($a_import_id,
"text").
",".
372 "last_update = ".$ilDB->now().
" ".
373 "WHERE obj_id = ".$ilDB->quote($a_id,
"integer");
375 $ilDB->manipulate($q);
383 $this->
setId($ilDB->nextId(
"lm_data"));
384 $query =
"INSERT INTO lm_data (obj_id, title, type, layout, lm_id, import_id, create_date) ".
386 $ilDB->quote($this->
getId(),
"integer").
",".
387 $ilDB->quote($this->
getTitle(),
"text").
",".
388 $ilDB->quote($this->
getType(),
"text").
", ".
389 $ilDB->quote($this->
getLayout(),
"text").
", ".
390 $ilDB->quote($this->
getLMId(),
"integer").
",".
392 ", ".$ilDB->now().
")";
393 $ilDB->manipulate($query);
396 include_once(
"classes/class.ilHistory.php");
398 $this->content_object->getType().
":".$this->
getType());
416 $query =
"UPDATE lm_data SET ".
417 " lm_id = ".$ilDB->quote($this->
getLMId(),
"integer").
418 " ,title = ".$ilDB->quote($this->
getTitle(),
"text").
419 " ,layout = ".$ilDB->quote($this->
getLayout(),
"text").
420 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
422 $ilDB->manipulate(
$query);
438 if (!is_array($a_pages))
439 {$a_pages = array(0);
446 if (empty($a_cont_obj_id))
448 $message = sprintf(
'ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_cont_obj_id is empty');
449 $ilLog->write($message,$ilLog->WARNING);
450 $ilErr->raiseError($message,$ilErr->MESSAGE);
455 $lm_tree =
new ilTree($a_cont_obj_id);
456 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
457 $lm_tree->setTreeTablePK(
"lm_id");
458 $lm_tree->readRootId();
461 $q =
"SELECT obj_id FROM lm_data " .
462 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
464 $r = $ilDB->query($q);
467 while (
$row = $ilDB->fetchAssoc($r))
469 $childs = $lm_tree->getChilds(
$row[
"obj_id"]);
471 foreach ($childs as $page)
473 if ($page[
"type"] ==
"pg" and in_array($page[
"obj_id"],$a_pages))
475 array_push($a_pages,
$row[
"obj_id"]);
482 $q =
"UPDATE lm_data SET " .
483 "public_access = CASE " .
484 "WHEN ".$ilDB->in(
"obj_id", $a_pages,
false,
"integer").
" ".
485 "THEN ".$ilDB->quote(
"y",
"text").
486 "ELSE ".$ilDB->quote(
"n",
"text").
488 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
489 "AND ".$ilDB->in(
"type", array(
"pg",
"st"),
false,
"text");
490 $ilDB->manipulate($q);
499 if (empty($a_node_id))
501 $message = sprintf(
'ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
502 $ilLog->write($message,$ilLog->WARNING);
506 if ($a_check_public_mode ===
true)
508 $lm_id = ilLMObject::_lookupContObjId($a_node_id);
510 $q =
"SELECT public_access_mode FROM content_object WHERE id = ".
511 $ilDB->quote(
$lm_id,
"integer");
512 $r = $ilDB->query($q);
513 $row = $ilDB->fetchAssoc($r);
515 if (
$row[
"public_access_mode"] ==
"complete")
521 $q =
"SELECT public_access FROM lm_data WHERE obj_id=".
522 $ilDB->quote($a_node_id,
"integer");
523 $r = $ilDB->query($q);
524 $row = $ilDB->fetchAssoc($r);
532 function delete($a_delete_meta_data =
true)
536 $query =
"DELETE FROM lm_data WHERE obj_id = ".
537 $ilDB->quote($this->
getId(),
"integer");
538 $ilDB->manipulate(
$query);
558 $q =
"SELECT obj_id FROM lm_data WHERE import_id = ".
559 $ilDB->quote($a_import_id,
"text").
" ".
560 " ORDER BY create_date DESC";
561 $obj_set = $ilDB->query($q);
562 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
569 return $obj_rec[
"obj_id"];
589 $where = ($a_in_lm > 0)
590 ?
" AND lm_id = ".$ilDB->quote($a_in_lm,
"integer").
" "
593 $q =
"SELECT * FROM lm_data WHERE import_id = ".
594 $ilDB->quote($a_import_id,
"text").
" ".
596 " ORDER BY create_date DESC";
597 $obj_set = $ilDB->query($q);
600 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
623 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
624 if (is_int(strpos($a_id,
"_")))
629 $q =
"SELECT * FROM lm_data WHERE obj_id = ".
630 $ilDB->quote($a_id,
"integer");
631 $obj_set = $ilDB->query($q);
632 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
650 $type_str = (
$type !=
"")
651 ?
"AND type = ".$ilDB->quote(
$type,
"text").
" "
653 $query =
"SELECT * FROM lm_data ".
654 "WHERE lm_id= ".$ilDB->quote(
$lm_id,
"integer").
" ".
657 $obj_set = $ilDB->query(
$query);
659 while($obj_rec = $ilDB->fetchAssoc($obj_set))
661 $obj_list[] = array(
"obj_id" => $obj_rec[
"obj_id"],
662 "title" => $obj_rec[
"title"],
663 "type" => $obj_rec[
"type"]);
676 include_once
'./classes/class.ilNestedSetXML.php';
678 $query =
"SELECT * FROM lm_data ".
679 "WHERE lm_id= ".$ilDB->quote($a_cobj->getId(),
"integer");
680 $obj_set = $ilDB->query(
$query);
682 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
683 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
687 if (is_object($lm_obj))
689 $lm_obj->delete(
true);
703 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
704 $ilDB->quote($a_id,
"integer");
705 $obj_set = $ilDB->query(
$query);
706 $obj_rec = $ilDB->fetchAssoc($obj_set);
708 return $obj_rec[
"lm_id"];
714 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
718 $tree =
new ilTree($a_obj->getContentObject()->getId());
720 $tree->setTreeTablePK(
"lm_id");
723 $parent_id = ($a_parent_id !=
"")
725 : $tree->getRootId();
728 if ($a_target_node_id !=
"")
730 $target = $a_target_node_id;
735 if ($a_obj->getType() ==
"st")
737 $s_types = array(
"st",
"pg");
738 $childs =& $tree->getChildsByTypeFilter($parent_id, $s_types);
743 $childs =& $tree->getChildsByType($parent_id, $s_types);
746 if (count($childs) == 0)
752 $target = $childs[count($childs) - 1][
"obj_id"];
756 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
758 $ilLog->write(
"LMObject::putInTree: insertNode, ID: ".$a_obj->getId().
759 "Parent ID: ".$parent_id.
", Target: ".$target);
761 $tree->insertNode($a_obj->getId(), $parent_id, $target);
774 $tree =
new ilTree($a_cont_obj_id);
775 $tree->setTableNames(
'lm_tree',
'lm_data');
776 $tree->setTreeTablePK(
"lm_id");
789 if (!is_array($a_ids))
796 foreach($a_ids as
$id)
798 $path = $tree->getPathId($id);
800 foreach(
$path as $path_id)
802 if ($path_id != $id && in_array($path_id, $a_ids))
819 foreach ($cut_ids as
$id)
821 $curnode = $tree->getNodeData($id);
822 if ($tree->isInTree($id))
824 $tree->deleteTree($curnode);
839 $ilUser->clipboardDeleteObjectsOfType(
"pg");
840 $ilUser->clipboardDeleteObjectsOfType(
"st");
843 $time = date(
"Y-m-d H:i:s", time());
844 foreach ($a_ids as
$id)
847 if ($tree->isInTree($id))
849 $curnode = $tree->getNodeData($id);
850 $subnodes = $tree->getSubTree($curnode);
851 foreach($subnodes as $subnode)
853 if ($subnode[
"child"] != $id)
855 $ilUser->addObjectToClipboard($subnode[
"child"],
856 $subnode[
"type"], $subnode[
"title"],
857 $subnode[
"parent"], $time, $subnode[
"lft"]);
861 $order = ($curnode[
"lft"] > 0)
863 : (
int) ($order + 1);
864 $ilUser->addObjectToClipboard($id,
873 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
874 &$a_copied_nodes, $a_as_copy =
false, $a_source_lm = null)
878 include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
879 include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
883 $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
884 if ($item_type ==
"st")
888 else if ($item_type ==
"pg")
893 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
894 "Item ID: ".$a_item_id.
", of original LM: ".$item_lm_id);
896 if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
901 include_once(
"Services/MetaData/classes/class.ilMD.php");
902 $md =
new ilMD($item_lm_id, $item->getId(), $item->getType());
903 $new_md = $md->
cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
906 $item->setLMId($a_target_lm->getId());
907 $item->setContentObject($a_target_lm);
913 if ($item_type ==
"pg")
915 $page = $item->getPageObject();
917 $page->setParentId($a_target_lm->getId());
924 $target_item = $item->copy($a_target_lm);
925 $a_copied_nodes[$item->getId()] = $target_item->getId();
929 $target_item = $item;
932 $ilLog->write(
"Putting into tree type ".$target_item->getType().
933 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
934 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
938 if ($a_source_lm == null)
940 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
944 $childs = $a_source_lm->lm_tree->getChilds($item->getId());
945 foreach ($childs as $k => $child)
947 $childs[$k][
"id"] = $childs[$k][
"child"];
951 foreach($childs as $child)
954 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_source_lm);
957 return $target_item->getId();
968 if (is_array($a_titles))
970 include_once(
"./Services/MetaData/classes/class.ilMD.php");
974 if (is_object($lmobj))
977 $md =
new ilMD($a_lm->getId(),
$id, $lmobj->getType());
979 $md_gen->setTitle(
$title);
993 $all_fixes = array();
994 foreach($a_copied_nodes as $original_id => $copied_id)
999 if ($copied_type ==
"pg")
1007 $il = $tpg->getInternalLinks();
1016 foreach($targets as $target)
1018 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
1019 ($target[
"type"] ==
"pg" || $target[
"type"] ==
"st"))
1022 if ($a_copied_nodes[$target[
"id"]] > 0)
1024 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
1032 if ($trg_lm != $copy_lm)
1037 foreach($lm_data as $item)
1039 if (!$found && ($item[
"lm_id"] == $copy_lm))
1041 $fix[$target[
"id"]] = $item[
"obj_id"];
1051 if (count($fix) > 0)
1056 if (is_array($all_fixes[
$t.
":".$copied_id]))
1058 $all_fixes[
$t.
":".$copied_id] += $fix;
1062 $all_fixes[
$t.
":".$copied_id] = $fix;
1070 if ($copied_type ==
"pg" ||
1071 $copied_type ==
"st")
1084 if ($original_lm != $copy_lm)
1099 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1100 foreach(
$mobs as $mob)
1110 foreach($usages as $usage)
1112 if ($usage[
"type"] ==
"lm:pg" | $usage[
"type"] ==
"lm:st")
1114 $sources[] = $usage;
1119 foreach($sources as $source)
1121 $stype = explode(
":", $source[
"type"]);
1122 $source_type = $stype[1];
1124 if ($source_type ==
"pg" || $source_type ==
"st")
1129 if ($src_lm == $original_lm)
1136 foreach ($lm_data as $item)
1140 $fix[$item[
"obj_id"]][$original_id] = $copied_id;
1148 if (count($fix) > 0)
1150 foreach ($fix as $page_id => $fix_array)
1156 if (is_array($all_fixes[
$t.
":".$page_id]))
1158 $all_fixes[
$t.
":".$page_id] += $fix_array;
1162 $all_fixes[
$t.
":".$page_id] = $fix_array;
1174 foreach ($all_fixes as $pg => $fixes)
1178 $pg = explode(
":", $pg);
1180 if ($page->moveIntLinks($fixes))
1182 $page->update(
true,
true,
true);
1193 if (is_array($a_items))
1195 foreach($a_items as $item)
1202 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");
1226 $ilDB->manipulate(
$query);
1228 else if (
$t ==
"st" && is_object($a_lm))
1230 $node = $a_lm->getLMTree()->getNodeData($a_obj_id);
1231 $child_nodes = $a_lm->getLMTree()->getSubTree($node);
1232 if (is_array($child_nodes) && count($child_nodes) > 0)
1234 foreach ($child_nodes as $c)
1236 if ($c[
"type"] ==
"pg")
1238 $query =
"UPDATE lm_data SET ".
1239 " layout = ".$ilDB->quote($a_layout,
"text").
1240 " WHERE obj_id = ".$ilDB->quote($c[
"child"],
"integer");
1241 $ilDB->manipulate(
$query);
1257 $query =
"SELECT layout FROM lm_data WHERE obj_id = ".
1258 $ilDB->quote($a_obj_id,
"integer");
1259 $obj_set = $ilDB->query(
$query);
1260 $obj_rec = $ilDB->fetchAssoc($obj_set);
1262 return $obj_rec[
"layout"];