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(
"./Services/History/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 "import_id" => $obj_rec[
"import_id"],
664 "type" => $obj_rec[
"type"]);
677 include_once
'./Services/Xml/classes/class.ilNestedSetXML.php';
679 $query =
"SELECT * FROM lm_data ".
680 "WHERE lm_id= ".$ilDB->quote($a_cobj->getId(),
"integer");
681 $obj_set = $ilDB->query(
$query);
683 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
684 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
688 if (is_object($lm_obj))
690 $lm_obj->delete(
true);
704 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
705 $ilDB->quote($a_id,
"integer");
706 $obj_set = $ilDB->query(
$query);
707 $obj_rec = $ilDB->fetchAssoc($obj_set);
709 return $obj_rec[
"lm_id"];
715 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
719 $tree =
new ilTree($a_obj->getContentObject()->getId());
721 $tree->setTreeTablePK(
"lm_id");
724 $parent_id = ($a_parent_id !=
"")
726 : $tree->getRootId();
729 if ($a_target_node_id !=
"")
731 $target = $a_target_node_id;
736 if ($a_obj->getType() ==
"st")
738 $s_types = array(
"st",
"pg");
739 $childs =& $tree->getChildsByTypeFilter($parent_id, $s_types);
744 $childs =& $tree->getChildsByType($parent_id, $s_types);
747 if (count($childs) == 0)
753 $target = $childs[count($childs) - 1][
"obj_id"];
757 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
759 $ilLog->write(
"LMObject::putInTree: insertNode, ID: ".$a_obj->getId().
760 "Parent ID: ".$parent_id.
", Target: ".$target);
762 $tree->insertNode($a_obj->getId(), $parent_id, $target);
775 $tree =
new ilTree($a_cont_obj_id);
776 $tree->setTableNames(
'lm_tree',
'lm_data');
777 $tree->setTreeTablePK(
"lm_id");
790 if (!is_array($a_ids))
797 foreach($a_ids as
$id)
799 $path = $tree->getPathId($id);
801 foreach(
$path as $path_id)
803 if ($path_id != $id && in_array($path_id, $a_ids))
820 foreach ($cut_ids as
$id)
822 $curnode = $tree->getNodeData($id);
823 if ($tree->isInTree($id))
825 $tree->deleteTree($curnode);
840 $ilUser->clipboardDeleteObjectsOfType(
"pg");
841 $ilUser->clipboardDeleteObjectsOfType(
"st");
844 $time = date(
"Y-m-d H:i:s", time());
845 foreach ($a_ids as
$id)
848 if ($tree->isInTree($id))
850 $curnode = $tree->getNodeData($id);
851 $subnodes = $tree->getSubTree($curnode);
852 foreach($subnodes as $subnode)
854 if ($subnode[
"child"] != $id)
856 $ilUser->addObjectToClipboard($subnode[
"child"],
857 $subnode[
"type"], $subnode[
"title"],
858 $subnode[
"parent"], $time, $subnode[
"lft"]);
862 $order = ($curnode[
"lft"] > 0)
864 : (
int) ($order + 1);
865 $ilUser->addObjectToClipboard($id,
874 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
875 &$a_copied_nodes, $a_as_copy =
false, $a_source_lm = null)
879 include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
880 include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
884 $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
885 if ($item_type ==
"st")
889 else if ($item_type ==
"pg")
894 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
895 "Item ID: ".$a_item_id.
", of original LM: ".$item_lm_id);
897 if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
902 include_once(
"Services/MetaData/classes/class.ilMD.php");
903 $md =
new ilMD($item_lm_id, $item->getId(), $item->getType());
904 $new_md = $md->
cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
907 $item->setLMId($a_target_lm->getId());
908 $item->setContentObject($a_target_lm);
914 if ($item_type ==
"pg")
916 $page = $item->getPageObject();
918 $page->setParentId($a_target_lm->getId());
925 $target_item = $item->copy($a_target_lm);
926 $a_copied_nodes[$item->getId()] = $target_item->getId();
930 $target_item = $item;
933 $ilLog->write(
"Putting into tree type ".$target_item->getType().
934 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
935 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
939 if ($a_source_lm == null)
941 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
945 $childs = $a_source_lm->lm_tree->getChilds($item->getId());
946 foreach ($childs as $k => $child)
948 $childs[$k][
"id"] = $childs[$k][
"child"];
952 foreach($childs as $child)
955 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_source_lm);
958 return $target_item->getId();
969 if (is_array($a_titles))
971 include_once(
"./Services/MetaData/classes/class.ilMD.php");
975 if (is_object($lmobj))
978 $md =
new ilMD($a_lm->getId(),
$id, $lmobj->getType());
980 $md_gen->setTitle(
$title);
994 $all_fixes = array();
995 foreach($a_copied_nodes as $original_id => $copied_id)
1000 if ($copied_type ==
"pg")
1008 $il = $tpg->getInternalLinks();
1017 foreach($targets as $target)
1019 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
1020 ($target[
"type"] ==
"pg" || $target[
"type"] ==
"st"))
1023 if ($a_copied_nodes[$target[
"id"]] > 0)
1025 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
1033 if ($trg_lm != $copy_lm)
1038 foreach($lm_data as $item)
1040 if (!$found && ($item[
"lm_id"] == $copy_lm))
1042 $fix[$target[
"id"]] = $item[
"obj_id"];
1052 if (count($fix) > 0)
1057 if (is_array($all_fixes[
$t.
":".$copied_id]))
1059 $all_fixes[
$t.
":".$copied_id] += $fix;
1063 $all_fixes[
$t.
":".$copied_id] = $fix;
1071 if ($copied_type ==
"pg" ||
1072 $copied_type ==
"st")
1085 if ($original_lm != $copy_lm)
1100 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1101 foreach(
$mobs as $mob)
1111 foreach($usages as $usage)
1113 if ($usage[
"type"] ==
"lm:pg" | $usage[
"type"] ==
"lm:st")
1115 $sources[] = $usage;
1120 foreach($sources as $source)
1122 $stype = explode(
":", $source[
"type"]);
1123 $source_type = $stype[1];
1125 if ($source_type ==
"pg" || $source_type ==
"st")
1130 if ($src_lm == $original_lm)
1137 foreach ($lm_data as $item)
1141 $fix[$item[
"obj_id"]][$original_id] = $copied_id;
1149 if (count($fix) > 0)
1151 foreach ($fix as $page_id => $fix_array)
1157 if (is_array($all_fixes[
$t.
":".$page_id]))
1159 $all_fixes[
$t.
":".$page_id] += $fix_array;
1163 $all_fixes[
$t.
":".$page_id] = $fix_array;
1175 foreach ($all_fixes as $pg => $fixes)
1179 $pg = explode(
":", $pg);
1181 if ($page->moveIntLinks($fixes))
1183 $page->update(
true,
true,
true);
1194 if (is_array($a_items))
1196 foreach($a_items as $item)
1203 if (count($types) > 1)
1224 $query =
"UPDATE lm_data SET ".
1225 " layout = ".$ilDB->quote($a_layout,
"text").
1226 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
1227 $ilDB->manipulate(
$query);
1229 else if (
$t ==
"st" && is_object($a_lm))
1231 $node = $a_lm->getLMTree()->getNodeData($a_obj_id);
1232 $child_nodes = $a_lm->getLMTree()->getSubTree($node);
1233 if (is_array($child_nodes) && count($child_nodes) > 0)
1235 foreach ($child_nodes as $c)
1237 if ($c[
"type"] ==
"pg")
1239 $query =
"UPDATE lm_data SET ".
1240 " layout = ".$ilDB->quote($a_layout,
"text").
1241 " WHERE obj_id = ".$ilDB->quote($c[
"child"],
"integer");
1242 $ilDB->manipulate(
$query);
1258 $query =
"SELECT layout FROM lm_data WHERE obj_id = ".
1259 $ilDB->quote($a_obj_id,
"integer");
1260 $obj_set = $ilDB->query(
$query);
1261 $obj_rec = $ilDB->fetchAssoc($obj_set);
1263 return $obj_rec[
"layout"];
1275 $lm_tree =
new ilTree($a_lm_id);
1276 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
1277 $lm_tree->setTreeTablePK(
"lm_id");
1278 $lm_tree->readRootId();
1280 $childs = $lm_tree->getChildsByType($a_chap_id,
"pg");
1296 public static function saveExportId($a_lm_id, $a_lmobj_id, $a_exp_id, $a_type =
"pg")
1300 include_once(
"Services/MetaData/classes/class.ilMDIdentifier.php");
1302 if (trim($a_exp_id) ==
"")
1306 $a_lm_id, $a_lmobj_id, $a_type);
1308 foreach ($entries as
$id => $e)
1310 if ($e[
"catalog"] ==
"ILIAS_NID")
1313 $identifier->setMetaId(
$id);
1314 $identifier->delete();
1322 $a_lm_id, $a_lmobj_id, $a_type);
1325 foreach ($entries as
$id => $e)
1327 if ($e[
"catalog"] ==
"ILIAS_NID")
1330 $identifier->setMetaId(
$id);
1331 $identifier->read();
1332 $identifier->setEntry($a_exp_id);
1333 $identifier->update();
1341 include_once(
"./Services/MetaData/classes/class.ilMD.php");
1342 $md =
new ilMD($a_lm_id, $a_lmobj_id, $a_type);
1343 $md_gen = $md->getGeneral();
1344 $identifier = $md_gen->addIdentifier();
1345 $identifier->setEntry($a_exp_id);
1346 $identifier->setCatalog(
"ILIAS_NID");
1347 $identifier->save();
1359 public static function getExportId($a_lm_id, $a_lmobj_id, $a_type =
"pg")
1362 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1364 $a_lm_id, $a_lmobj_id, $a_type);
1366 foreach ($entries as $e)
1368 if ($e[
"catalog"] ==
"ILIAS_NID")
1383 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1392 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1395 foreach ($entries as $e)
1397 if ($e[
"catalog"] ==
"ILIAS_NID")
1401 $res[trim($e[
"entry"])]++;
1416 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");