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"];
271 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
272 $ilDB->quote($a_obj_id,
"integer");
273 $obj_set = $ilDB->query(
$query);
274 $obj_rec = $ilDB->fetchAssoc($obj_set);
276 return $obj_rec[
"type"];
284 $query =
"UPDATE lm_data SET ".
285 " title = ".$ilDB->quote($a_title,
"text").
286 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
287 $ilDB->manipulate(
$query);
293 $this->description = $a_description;
303 $this->type = $a_type;
313 $this->lm_id = $a_lm_id;
324 $this->content_object =& $a_content_obj;
344 return $this->import_id;
349 $this->import_id = $a_id;
359 $this->layout = $a_val;
369 return $this->layout;
383 $q =
"UPDATE lm_data ".
385 "import_id = ".$ilDB->quote($a_import_id,
"text").
",".
386 "last_update = ".$ilDB->now().
" ".
387 "WHERE obj_id = ".$ilDB->quote($a_id,
"integer");
389 $ilDB->manipulate(
$q);
397 $this->
setId($ilDB->nextId(
"lm_data"));
398 $query =
"INSERT INTO lm_data (obj_id, title, type, lm_id, import_id, create_date) ".
400 $ilDB->quote($this->
getId(),
"integer").
",".
401 $ilDB->quote($this->
getTitle(),
"text").
",".
402 $ilDB->quote($this->
getType(),
"text").
", ".
403 $ilDB->quote($this->
getLMId(),
"integer").
",".
405 ", ".$ilDB->now().
")";
406 $ilDB->manipulate($query);
409 include_once(
"classes/class.ilHistory.php");
411 $this->content_object->getType().
":".$this->
getType());
429 $query =
"UPDATE lm_data SET ".
430 " lm_id = ".$ilDB->quote($this->
getLMId(),
"integer").
431 " ,title = ".$ilDB->quote($this->
getTitle(),
"text").
432 " ,layout = ".$ilDB->quote($this->
getLayout(),
"text").
433 " WHERE obj_id = ".$ilDB->quote($this->
getId(),
"integer");
435 $ilDB->manipulate(
$query);
451 if (!is_array($a_pages))
452 {$a_pages = array(0);
459 if (empty($a_cont_obj_id))
461 $message = sprintf(
'ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_cont_obj_id is empty');
462 $ilLog->write($message,$ilLog->WARNING);
463 $ilErr->raiseError($message,$ilErr->MESSAGE);
468 $lm_tree =
new ilTree($a_cont_obj_id);
469 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
470 $lm_tree->setTreeTablePK(
"lm_id");
471 $lm_tree->readRootId();
474 $q =
"SELECT obj_id FROM lm_data " .
475 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
477 $r = $ilDB->query(
$q);
480 while (
$row = $ilDB->fetchAssoc($r))
482 $childs = $lm_tree->getChilds(
$row[
"obj_id"]);
484 foreach ($childs as $page)
486 if ($page[
"type"] ==
"pg" and in_array($page[
"obj_id"],$a_pages))
488 array_push($a_pages,
$row[
"obj_id"]);
495 $q =
"UPDATE lm_data SET " .
496 "public_access = CASE " .
497 "WHEN ".$ilDB->in(
"obj_id", $a_pages,
false,
"integer").
" ".
498 "THEN ".$ilDB->quote(
"y",
"text").
499 "ELSE ".$ilDB->quote(
"n",
"text").
501 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id,
"integer").
" " .
502 "AND ".$ilDB->in(
"type", array(
"pg",
"st"),
false,
"text");
503 $ilDB->manipulate(
$q);
512 if (empty($a_node_id))
514 $message = sprintf(
'ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
515 $ilLog->write($message,$ilLog->WARNING);
519 if ($a_check_public_mode ===
true)
521 $lm_id = ilLMObject::_lookupContObjId($a_node_id);
523 $q =
"SELECT public_access_mode FROM content_object WHERE id = ".
524 $ilDB->quote(
$lm_id,
"integer");
525 $r = $ilDB->query(
$q);
526 $row = $ilDB->fetchAssoc($r);
528 if (
$row[
"public_access_mode"] ==
"complete")
534 $q =
"SELECT public_access FROM lm_data WHERE obj_id=".
535 $ilDB->quote($a_node_id,
"integer");
536 $r = $ilDB->query(
$q);
537 $row = $ilDB->fetchAssoc($r);
545 function delete($a_delete_meta_data =
true)
549 $query =
"DELETE FROM lm_data WHERE obj_id = ".
550 $ilDB->quote($this->
getId(),
"integer");
551 $ilDB->manipulate(
$query);
571 $q =
"SELECT obj_id FROM lm_data WHERE import_id = ".
572 $ilDB->quote($a_import_id,
"text").
" ".
573 " ORDER BY create_date DESC";
574 $obj_set = $ilDB->query(
$q);
575 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
582 return $obj_rec[
"obj_id"];
602 $where = ($a_in_lm > 0)
603 ?
" AND lm_id = ".$ilDB->quote($a_in_lm,
"integer").
" "
606 $q =
"SELECT * FROM lm_data WHERE import_id = ".
607 $ilDB->quote($a_import_id,
"text").
" ".
609 " ORDER BY create_date DESC";
610 $obj_set = $ilDB->query(
$q);
613 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
636 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
637 if (is_int(strpos($a_id,
"_")))
642 $q =
"SELECT * FROM lm_data WHERE obj_id = ".
643 $ilDB->quote($a_id,
"integer");
644 $obj_set = $ilDB->query(
$q);
645 if ($obj_rec = $ilDB->fetchAssoc($obj_set))
663 $type_str = (
$type !=
"")
664 ?
"AND type = ".$ilDB->quote(
$type,
"text").
" "
666 $query =
"SELECT * FROM lm_data ".
667 "WHERE lm_id= ".$ilDB->quote(
$lm_id,
"integer").
" ".
670 $obj_set = $ilDB->query(
$query);
672 while($obj_rec = $ilDB->fetchAssoc($obj_set))
674 $obj_list[] = array(
"obj_id" => $obj_rec[
"obj_id"],
675 "title" => $obj_rec[
"title"],
676 "type" => $obj_rec[
"type"]);
689 include_once
'./classes/class.ilNestedSetXML.php';
691 $query =
"SELECT * FROM lm_data ".
692 "WHERE lm_id= ".$ilDB->quote($a_cobj->getId(),
"integer");
693 $obj_set = $ilDB->query(
$query);
695 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
696 while ($obj_rec = $ilDB->fetchAssoc($obj_set))
700 if (is_object($lm_obj))
702 $lm_obj->delete(
true);
716 $query =
"SELECT * FROM lm_data WHERE obj_id = ".
717 $ilDB->quote($a_id,
"integer");
718 $obj_set = $ilDB->query(
$query);
719 $obj_rec = $ilDB->fetchAssoc($obj_set);
721 return $obj_rec[
"lm_id"];
727 static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
731 $tree =
new ilTree($a_obj->getContentObject()->getId());
733 $tree->setTreeTablePK(
"lm_id");
736 $parent_id = ($a_parent_id !=
"")
738 : $tree->getRootId();
741 if ($a_target_node_id !=
"")
743 $target = $a_target_node_id;
748 if ($a_obj->getType() ==
"st")
750 $s_types = array(
"st",
"pg");
751 $childs =& $tree->getChildsByTypeFilter($parent_id, $s_types);
756 $childs =& $tree->getChildsByType($parent_id, $s_types);
759 if (count($childs) == 0)
765 $target = $childs[count($childs) - 1][
"obj_id"];
769 if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
771 $ilLog->write(
"LMObject::putInTree: insertNode, ID: ".$a_obj->getId().
772 "Parent ID: ".$parent_id.
", Target: ".$target);
774 $tree->insertNode($a_obj->getId(), $parent_id, $target);
787 $tree =
new ilTree($a_cont_obj_id);
788 $tree->setTableNames(
'lm_tree',
'lm_data');
789 $tree->setTreeTablePK(
"lm_id");
802 if (!is_array($a_ids))
809 foreach($a_ids as
$id)
811 $path = $tree->getPathId($id);
813 foreach($path as $path_id)
815 if ($path_id != $id && in_array($path_id, $a_ids))
832 foreach ($cut_ids as
$id)
834 $curnode = $tree->getNodeData($id);
835 if ($tree->isInTree($id))
837 $tree->deleteTree($curnode);
852 $ilUser->clipboardDeleteObjectsOfType(
"pg");
853 $ilUser->clipboardDeleteObjectsOfType(
"st");
856 $time = date(
"Y-m-d H:i:s", time());
857 foreach ($a_ids as
$id)
860 if ($tree->isInTree($id))
862 $curnode = $tree->getNodeData($id);
863 $subnodes = $tree->getSubTree($curnode);
864 foreach($subnodes as $subnode)
866 if ($subnode[
"child"] != $id)
868 $ilUser->addObjectToClipboard($subnode[
"child"],
869 $subnode[
"type"], $subnode[
"title"],
870 $subnode[
"parent"], $time, $subnode[
"lft"]);
874 $order = ($curnode[
"lft"] > 0)
876 : (
int) ($order + 1);
877 $ilUser->addObjectToClipboard($id,
889 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
890 &$a_copied_nodes, $a_as_copy =
false)
896 $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
897 if ($item_type ==
"st")
901 else if ($item_type ==
"pg")
906 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
907 "Item ID: ".$a_item_id.
", of original LM: ".$item_lm_id);
909 if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
914 include_once(
"Services/MetaData/classes/class.ilMD.php");
915 $md =
new ilMD($item_lm_id, $item->getId(), $item->getType());
916 $new_md = $md->
cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
919 $item->setLMId($a_target_lm->getId());
920 $item->setContentObject($a_target_lm);
926 if ($item_type ==
"pg")
928 $page = $item->getPageObject();
930 $page->setParentId($a_target_lm->getId());
937 $target_item = $item->copy($a_target_lm);
938 $a_copied_nodes[$item->getId()] = $target_item->getId();
942 $target_item = $item;
945 $ilLog->write(
"Putting into tree type ".$target_item->getType().
946 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
947 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
951 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
953 foreach($childs as $child)
956 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
959 return $target_item->getId();
970 if (is_array($a_titles))
972 include_once(
"./Services/MetaData/classes/class.ilMD.php");
976 if (is_object($lmobj))
979 $md =
new ilMD($a_lm->getId(),
$id, $lmobj->getType());
981 $md_gen->setTitle(
$title);
995 $all_fixes = array();
996 foreach($a_copied_nodes as $original_id => $copied_id)
1001 if ($copied_type ==
"pg")
1009 $il = $tpg->getInternalLinks();
1018 foreach($targets as $target)
1020 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
1021 ($target[
"type"] ==
"pg" || $target[
"type"] ==
"st"))
1024 if ($a_copied_nodes[$target[
"id"]] > 0)
1026 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
1035 if ($trg_lm != $copy_lm)
1040 foreach($lm_data as $item)
1042 if (!$found && ($item[
"lm_id"] == $copy_lm))
1044 $fix[$target[
"id"]] = $item[
"obj_id"];
1054 if (count($fix) > 0)
1059 if (is_array($all_fixes[
$t.
":".$copied_id]))
1061 $all_fixes[
$t.
":".$copied_id] += $fix;
1065 $all_fixes[
$t.
":".$copied_id] = $fix;
1073 if ($copied_type ==
"pg" ||
1074 $copied_type ==
"st")
1087 if ($original_lm != $copy_lm)
1102 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1103 foreach(
$mobs as $mob)
1113 foreach($usages as $usage)
1115 if ($usage[
"type"] ==
"lm:pg" | $usage[
"type"] ==
"lm:st")
1117 $sources[] = $usage;
1122 foreach($sources as $source)
1124 $stype = explode(
":", $source[
"type"]);
1125 $source_type = $stype[1];
1127 if ($source_type ==
"pg" || $source_type ==
"st")
1132 if ($src_lm == $original_lm)
1139 foreach ($lm_data as $item)
1143 $fix[$item[
"obj_id"]][$original_id] = $copied_id;
1151 if (count($fix) > 0)
1153 foreach ($fix as $page_id => $fix_array)
1159 if (is_array($all_fixes[
$t.
":".$page_id]))
1161 $all_fixes[
$t.
":".$page_id] += $fix_array;
1165 $all_fixes[
$t.
":".$page_id] = $fix_array;
1177 foreach ($all_fixes as $pg => $fixes)
1181 $pg = explode(
":", $pg);
1183 if ($page->moveIntLinks($fixes))
1185 $page->update(
true,
true,
true);
1196 if (is_array($a_items))
1198 foreach($a_items as $item)
1205 if (count($types) > 1)
1222 $query =
"UPDATE lm_data SET ".
1223 " layout = ".$ilDB->quote($a_layout,
"text").
1224 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer");
1226 $ilDB->manipulate(
$query);
1238 $query =
"SELECT layout FROM lm_data WHERE obj_id = ".
1239 $ilDB->quote($a_obj_id,
"integer");
1240 $obj_set = $ilDB->query(
$query);
1241 $obj_rec = $ilDB->fetchAssoc($obj_set);
1243 return $obj_rec[
"layout"];