5 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
40 $this->
setLMId($a_content_obj->getId());
61 include_once
'Services/MetaData/classes/class.ilMD.php';
69 $md_gen = $md->getGeneral();
73 foreach($md_gen->getDescriptionIds() as
$id)
75 $md_des = $md_gen->getDescription(
$id);
93 include_once
'Services/MetaData/classes/class.ilMD.php';
95 $md =
new ilMD($a_lm_id, $a_lm_obj_id, $a_type);
96 $md_gen = $md->getGeneral();
97 if (is_object($md_gen))
99 foreach($md_gen->getIdentifierIds() as
$id)
101 $md_id = $md_gen->getIdentifier(
$id);
102 if ($md_id->getCatalog() ==
"ILIAS_NID")
104 return $md_id->getEntry();
118 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
123 $md_creator->setTitle($this->
getTitle());
124 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
126 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
127 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
128 $md_creator->setLanguage($ilUser->getPref(
'language'));
129 $md_creator->create();
139 include_once(
"Services/MetaData/classes/class.ilMD.php");
140 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
141 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
144 $md_gen =& $md->getGeneral();
145 $md_gen->setTitle($this->
getTitle());
148 $md_des_ids =& $md_gen->getDescriptionIds();
149 if (count($md_des_ids) > 0)
151 $md_des =& $md_gen->getDescription($md_des_ids[0]);
166 include_once(
'Services/MetaData/classes/class.ilMD.php');
178 $this->data_record = $a_record;
185 $ilBench->start(
"ContentPresentation",
"ilLMObject_read");
187 if(!isset($this->data_record))
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);
195 $this->type = $this->data_record[
"type"];
196 $this->
setImportId($this->data_record[
"import_id"]);
197 $this->
setTitle($this->data_record[
"title"]);
198 $this->
setLayout($this->data_record[
"layout"]);
201 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read");
215 $set = $ilDB->query(
"SELECT * FROM lm_data ".
216 " WHERE lm_id = ".$ilDB->quote($a_lm_id,
"integer")
218 while ($rec = $ilDB->fetchAssoc($set))
220 self::$data_records[$rec[
"obj_id"]] = $rec;
222 return count(self::$data_records);
233 $this->title = $a_title;
256 if (isset(self::$data_records[$a_obj_id]))
258 return self::$data_records[$a_obj_id][
"title"];
261 $query =
"SELECT title FROM lm_data WHERE obj_id = ".
262 $ilDB->quote($a_obj_id,
"integer");
263 $obj_set = $ilDB->query(
$query);
264 $obj_rec = $ilDB->fetchAssoc($obj_set);
266 return $obj_rec[
"title"];
279 if (isset(self::$data_records[$a_obj_id]))
281 if ($a_lm_id == 0 || self::$data_records[$a_obj_id][
"lm_id"] == $a_lm_id)
283 return self::$data_records[$a_obj_id][
"type"];
289 $and =
' AND lm_id = '.$ilDB->quote($a_lm_id,
'integer');
292 $query =
"SELECT type FROM lm_data WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").$and;
293 $obj_set = $ilDB->query(
$query);
294 $obj_rec = $ilDB->fetchAssoc($obj_set);
296 return $obj_rec[
"type"];
304 $query =
"UPDATE lm_data SET ".
305 " title = ".$ilDB->quote($a_title,
"text").
306 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
307 $ilDB->manipulate(
$query);
313 $this->description = $a_description;
323 $this->type = $a_type;
333 $this->lm_id = $a_lm_id;
344 $this->content_object =& $a_content_obj;
364 return $this->import_id;
369 $this->import_id = $a_id;
379 $this->layout = $a_val;
389 return $this->layout;
403 $q =
"UPDATE lm_data ".
405 "import_id = ".$ilDB->quote($a_import_id,
"text").
",".
406 "last_update = ".$ilDB->now().
" ".
407 "WHERE obj_id = ".$ilDB->quote($a_id,
"integer");
409 $ilDB->manipulate($q);
417 $this->
setId($ilDB->nextId(
"lm_data"));
418 $query =
"INSERT INTO lm_data (obj_id, title, type, layout, lm_id, import_id, create_date) ".
420 $ilDB->quote($this->
getId(),
"integer").
",".
421 $ilDB->quote($this->
getTitle(),
"text").
",".
422 $ilDB->quote($this->
getType(),
"text").
", ".
423 $ilDB->quote($this->
getLayout(),
"text").
", ".
424 $ilDB->quote($this->
getLMId(),
"integer").
",".
426 ", ".$ilDB->now().
")";
427 $ilDB->manipulate($query);
430 include_once(
"./Services/History/classes/class.ilHistory.php");
432 $this->content_object->getType().
":".$this->
getType());
450 $query =
"UPDATE lm_data SET ".
451 " lm_id = ".$ilDB->quote($this->
getLMId(),
"integer").
452 " ,title = ".$ilDB->quote($this->
getTitle(),
"text").
453 " ,layout = ".$ilDB->quote($this->
getLayout(),
"text").
454 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
456 $ilDB->manipulate(
$query);
472 if (!is_array($a_pages))
473 {$a_pages = array(0);
480 if (empty($a_cont_obj_id))
482 $message = sprintf(
'ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_cont_obj_id is empty');
483 $ilLog->write($message,$ilLog->WARNING);
484 $ilErr->raiseError($message,$ilErr->MESSAGE);
489 $lm_tree =
new ilTree($a_cont_obj_id);
490 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
491 $lm_tree->setTreeTablePK(
"lm_id");
492 $lm_tree->readRootId();
495 $q =
"SELECT obj_id FROM lm_data " .
496 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
498 $r = $ilDB->query($q);
501 while (
$row = $ilDB->fetchAssoc($r))
503 $childs = $lm_tree->getChilds(
$row[
"obj_id"]);
505 foreach ($childs as $page)
507 if ($page[
"type"] ==
"pg" and in_array($page[
"obj_id"],$a_pages))
509 array_push($a_pages,
$row[
"obj_id"]);
516 $q =
"UPDATE lm_data SET " .
517 "public_access = CASE " .
518 "WHEN ".$ilDB->in(
"obj_id", $a_pages,
false,
"integer").
" ".
519 "THEN ".$ilDB->quote(
"y",
"text").
520 "ELSE ".$ilDB->quote(
"n",
"text").
522 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
523 "AND ".$ilDB->in(
"type", array(
"pg",
"st"),
false,
"text");
524 $ilDB->manipulate($q);
533 if (empty($a_node_id))
535 $message = sprintf(
'ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
536 $ilLog->write($message,$ilLog->WARNING);
540 if ($a_check_public_mode ===
true)
542 $lm_id = ilLMObject::_lookupContObjId($a_node_id);
544 $q =
"SELECT public_access_mode FROM content_object WHERE id = ".
545 $ilDB->quote(
$lm_id,
"integer");
546 $r = $ilDB->query($q);
547 $row = $ilDB->fetchAssoc($r);
549 if (
$row[
"public_access_mode"] ==
"complete")
555 $q =
"SELECT public_access FROM lm_data WHERE obj_id=".
556 $ilDB->quote($a_node_id,
"integer");
557 $r = $ilDB->query($q);
558 $row = $ilDB->fetchAssoc($r);
566 function delete($a_delete_meta_data =
true)
570 $query =
"DELETE FROM lm_data WHERE obj_id = ".
571 $ilDB->quote($this->
getId(),
"integer");
572 $ilDB->manipulate(
$query);
592 $q =
"SELECT obj_id FROM lm_data WHERE import_id = ".
593 $ilDB->quote($a_import_id,
"text").
" ".
594 " ORDER BY create_date DESC";
595 $obj_set = $ilDB->query($q);
596 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
601 include_once(
"./Services/Help/classes/class.ilObjHelpSettings.php");
605 return $obj_rec[
"obj_id"];
625 $where = ($a_in_lm > 0)
626 ?
" AND lm_id = ".$ilDB->quote($a_in_lm,
"integer").
" "
629 $q =
"SELECT * FROM lm_data WHERE import_id = ".
630 $ilDB->quote($a_import_id,
"text").
" ".
632 " ORDER BY create_date DESC";
633 $obj_set = $ilDB->query($q);
636 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
659 include_once(
"./Services/Link/classes/class.ilInternalLink.php");
660 if (is_int(strpos($a_id,
"_")))
665 $q =
"SELECT * FROM lm_data WHERE obj_id = ".
666 $ilDB->quote($a_id,
"integer");
667 $obj_set = $ilDB->query($q);
668 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
686 $type_str = (
$type !=
"")
687 ?
"AND type = ".$ilDB->quote(
$type,
"text").
" "
690 $query =
"SELECT * FROM lm_data ".
691 "WHERE lm_id= ".$ilDB->quote(
$lm_id,
"integer").
" ".
694 $obj_set = $ilDB->query(
$query);
696 while($obj_rec = $ilDB->fetchAssoc($obj_set))
698 $obj_list[] = array(
"obj_id" => $obj_rec[
"obj_id"],
699 "title" => $obj_rec[
"title"],
700 "import_id" => $obj_rec[
"import_id"],
701 "type" => $obj_rec[
"type"]);
714 include_once
'./Services/Xml/classes/class.ilNestedSetXML.php';
716 $query =
"SELECT * FROM lm_data ".
717 "WHERE lm_id= ".$ilDB->quote($a_cobj->getId(),
"integer");
718 $obj_set = $ilDB->query(
$query);
720 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
721 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
725 if (is_object($lm_obj))
727 $lm_obj->delete(
true);
741 if (isset(self::$data_records[$a_id]))
743 return self::$data_records[$a_id][
"lm_id"];
746 $query =
"SELECT lm_id FROM lm_data WHERE obj_id = ".
747 $ilDB->quote($a_id,
"integer");
748 $obj_set = $ilDB->query(
$query);
749 $obj_rec = $ilDB->fetchAssoc($obj_set);
751 return $obj_rec[
"lm_id"];
757 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
761 $tree =
new ilTree($a_obj->getContentObject()->getId());
763 $tree->setTreeTablePK(
"lm_id");
766 $parent_id = ($a_parent_id !=
"")
768 : $tree->getRootId();
771 if ($a_target_node_id !=
"")
773 $target = $a_target_node_id;
778 if ($a_obj->getType() ==
"st")
780 $s_types = array(
"st",
"pg");
781 $childs =& $tree->getChildsByTypeFilter($parent_id, $s_types);
786 $childs =& $tree->getChildsByType($parent_id, $s_types);
789 if (count($childs) == 0)
795 $target = $childs[count($childs) - 1][
"obj_id"];
799 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
801 $ilLog->write(
"LMObject::putInTree: insertNode, ID: ".$a_obj->getId().
802 "Parent ID: ".$parent_id.
", Target: ".$target);
804 $tree->insertNode($a_obj->getId(), $parent_id, $target);
817 $tree =
new ilTree($a_cont_obj_id);
818 $tree->setTableNames(
'lm_tree',
'lm_data');
819 $tree->setTreeTablePK(
"lm_id");
832 if (!is_array($a_ids))
839 foreach($a_ids as
$id)
841 $path = $tree->getPathId($id);
843 foreach(
$path as $path_id)
845 if ($path_id != $id && in_array($path_id, $a_ids))
862 foreach ($cut_ids as
$id)
864 $curnode = $tree->getNodeData($id);
865 if ($tree->isInTree($id))
867 $tree->deleteTree($curnode);
882 $ilUser->clipboardDeleteObjectsOfType(
"pg");
883 $ilUser->clipboardDeleteObjectsOfType(
"st");
886 $time = date(
"Y-m-d H:i:s", time());
887 foreach ($a_ids as
$id)
890 if ($tree->isInTree($id))
892 $curnode = $tree->getNodeData($id);
893 $subnodes = $tree->getSubTree($curnode);
894 foreach($subnodes as $subnode)
896 if ($subnode[
"child"] != $id)
898 $ilUser->addObjectToClipboard($subnode[
"child"],
899 $subnode[
"type"], $subnode[
"title"],
900 $subnode[
"parent"], $time, $subnode[
"lft"]);
904 $order = ($curnode[
"lft"] > 0)
906 : (
int) ($order + 1);
907 $ilUser->addObjectToClipboard($id,
916 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
917 &$a_copied_nodes, $a_as_copy =
false, $a_source_lm = null)
921 include_once(
"./Modules/LearningModule/classes/class.ilStructureObject.php");
922 include_once(
"./Modules/LearningModule/classes/class.ilLMPageObject.php");
926 $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
927 if ($item_type ==
"st")
931 else if ($item_type ==
"pg")
936 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
937 "Item ID: ".$a_item_id.
", of original LM: ".$item_lm_id);
939 if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
944 include_once(
"Services/MetaData/classes/class.ilMD.php");
945 $md =
new ilMD($item_lm_id, $item->getId(), $item->getType());
946 $new_md = $md->
cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
949 $item->setLMId($a_target_lm->getId());
950 $item->setContentObject($a_target_lm);
956 if ($item_type ==
"pg")
958 $page = $item->getPageObject();
960 $page->setParentId($a_target_lm->getId());
967 $target_item = $item->copy($a_target_lm);
968 $a_copied_nodes[$item->getId()] = $target_item->getId();
972 $target_item = $item;
975 $ilLog->write(
"Putting into tree type ".$target_item->getType().
976 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
977 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
981 if ($a_source_lm == null)
983 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
987 $childs = $a_source_lm->lm_tree->getChilds($item->getId());
988 foreach ($childs as $k => $child)
990 $childs[$k][
"id"] = $childs[$k][
"child"];
994 foreach($childs as $child)
997 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_source_lm);
1000 return $target_item->getId();
1011 include_once(
"./Modules/LearningModule/classes/class.ilLMObjTranslation.php");
1017 if (is_array($a_titles))
1019 include_once(
"./Services/MetaData/classes/class.ilMD.php");
1025 if (is_object($lmobj))
1028 $md =
new ilMD($a_lm->getId(),
$id, $lmobj->getType());
1030 if (is_object($md_gen))
1032 $md_gen->setTitle(
$title);
1042 $lmobjtrans->setTitle(
$title);
1043 $lmobjtrans->save();
1054 $all_fixes = array();
1055 foreach($a_copied_nodes as $original_id => $copied_id)
1060 if ($copied_type ==
"pg")
1066 include_once(
"./Modules/LearningModule/classes/class.ilLMPage.php");
1069 $il = $tpg->getInternalLinks();
1078 foreach($targets as $target)
1080 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
1081 ($target[
"type"] ==
"pg" || $target[
"type"] ==
"st"))
1084 if ($a_copied_nodes[$target[
"id"]] > 0)
1086 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
1094 if ($trg_lm != $copy_lm)
1099 foreach($lm_data as $item)
1101 if (!$found && ($item[
"lm_id"] == $copy_lm))
1103 $fix[$target[
"id"]] = $item[
"obj_id"];
1113 if (count($fix) > 0)
1118 if (is_array($all_fixes[
$t.
":".$copied_id]))
1120 $all_fixes[
$t.
":".$copied_id] += $fix;
1124 $all_fixes[
$t.
":".$copied_id] = $fix;
1129 if ($copied_type ==
"pg" ||
1130 $copied_type ==
"st")
1143 if ($original_lm != $copy_lm)
1158 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1159 foreach(
$mobs as $mob)
1169 foreach($usages as $usage)
1171 if ($usage[
"type"] ==
"lm:pg" | $usage[
"type"] ==
"lm:st")
1173 $sources[] = $usage;
1178 foreach($sources as $source)
1180 $stype = explode(
":", $source[
"type"]);
1181 $source_type = $stype[1];
1183 if ($source_type ==
"pg" || $source_type ==
"st")
1188 if ($src_lm == $original_lm)
1195 foreach ($lm_data as $item)
1199 $fix[$item[
"obj_id"]][$original_id] = $copied_id;
1207 if (count($fix) > 0)
1209 foreach ($fix as $page_id => $fix_array)
1212 if (is_array($all_fixes[
$t.
":".$page_id]))
1214 $all_fixes[
$t.
":".$page_id] += $fix_array;
1218 $all_fixes[
$t.
":".$page_id] = $fix_array;
1227 foreach ($all_fixes as $pg => $fixes)
1229 $pg = explode(
":", $pg);
1230 include_once(
"./Services/COPage/classes/class.ilPageObjectFactory.php");
1232 if ($page->moveIntLinks($fixes))
1234 $page->update(
true,
true);
1245 if (is_array($a_items))
1247 foreach($a_items as $item)
1254 if (count($types) > 1)
1275 $query =
"UPDATE lm_data SET ".
1276 " layout = ".$ilDB->quote($a_layout,
"text").
1277 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
1278 $ilDB->manipulate(
$query);
1280 else if (
$t ==
"st" && is_object($a_lm))
1282 $node = $a_lm->getLMTree()->getNodeData($a_obj_id);
1283 $child_nodes = $a_lm->getLMTree()->getSubTree($node);
1284 if (is_array($child_nodes) && count($child_nodes) > 0)
1286 foreach ($child_nodes as $c)
1288 if ($c[
"type"] ==
"pg")
1290 $query =
"UPDATE lm_data SET ".
1291 " layout = ".$ilDB->quote($a_layout,
"text").
1292 " WHERE obj_id = ".$ilDB->quote($c[
"child"],
"integer");
1293 $ilDB->manipulate(
$query);
1309 $query =
"SELECT layout FROM lm_data WHERE obj_id = ".
1310 $ilDB->quote($a_obj_id,
"integer");
1311 $obj_set = $ilDB->query(
$query);
1312 $obj_rec = $ilDB->fetchAssoc($obj_set);
1314 return $obj_rec[
"layout"];
1326 $lm_tree =
new ilTree($a_lm_id);
1327 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
1328 $lm_tree->setTreeTablePK(
"lm_id");
1329 $lm_tree->readRootId();
1331 $childs = $lm_tree->getChildsByType($a_chap_id,
"pg");
1346 $and = ($a_type !=
"")
1347 ?
" AND type = ".$ilDB->quote($a_type,
"text")
1350 $set = $ilDB->query(
"SELECT obj_id FROM lm_data ".
1351 " WHERE lm_id = ".$ilDB->quote($a_lm_id,
"integer").$and);
1353 while ($rec = $ilDB->fetchAssoc($set))
1355 $obj_ids[] = $rec[
"obj_id"];
1372 public static function saveExportId($a_lm_id, $a_lmobj_id, $a_exp_id, $a_type =
"pg")
1376 include_once(
"Services/MetaData/classes/class.ilMDIdentifier.php");
1378 if (trim($a_exp_id) ==
"")
1382 $a_lm_id, $a_lmobj_id, $a_type);
1384 foreach ($entries as
$id => $e)
1386 if ($e[
"catalog"] ==
"ILIAS_NID")
1389 $identifier->setMetaId(
$id);
1390 $identifier->delete();
1398 $a_lm_id, $a_lmobj_id, $a_type);
1401 foreach ($entries as
$id => $e)
1403 if ($e[
"catalog"] ==
"ILIAS_NID")
1406 $identifier->setMetaId(
$id);
1407 $identifier->read();
1408 $identifier->setEntry($a_exp_id);
1409 $identifier->update();
1417 include_once(
"./Services/MetaData/classes/class.ilMD.php");
1418 $md =
new ilMD($a_lm_id, $a_lmobj_id, $a_type);
1419 $md_gen = $md->getGeneral();
1420 $identifier = $md_gen->addIdentifier();
1421 $identifier->setEntry($a_exp_id);
1422 $identifier->setCatalog(
"ILIAS_NID");
1423 $identifier->save();
1435 public static function getExportId($a_lm_id, $a_lmobj_id, $a_type =
"pg")
1438 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1440 $a_lm_id, $a_lmobj_id, $a_type);
1442 foreach ($entries as $e)
1444 if ($e[
"catalog"] ==
"ILIAS_NID")
1459 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1468 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1471 foreach ($entries as $e)
1473 if ($e[
"catalog"] ==
"ILIAS_NID")
1477 $res[trim($e[
"entry"])]++;
1492 include_once(
"./Services/MetaData/classes/class.ilMDIdentifier.php");
1504 $a_include_numbers =
false, $a_time_scheduled_activation =
false,
1505 $a_force_content =
false, $a_lm_id = 0, $a_lang =
"-")
1512 if ($a_node[
"type"] ==
"st")
1515 $a_include_numbers, $a_time_scheduled_activation, $a_lm_id, $a_lang);
1520 $a_mode, $a_include_numbers, $a_time_scheduled_activation,
1521 $a_force_content, $a_lm_id, $a_lang);