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();
116 if(!is_object($md_gen))
121 foreach($md_gen->getIdentifierIds() as
$id)
123 $md_id = $md_gen->getIdentifier(
$id);
124 if ($md_id->getCatalog() ==
"ILIAS_NID")
126 return $md_id->getEntry();
139 include_once
'Services/MetaData/classes/class.ilMDCreator.php';
144 $md_creator->setTitle($this->
getTitle());
145 $md_creator->setTitleLanguage($ilUser->getPref(
'language'));
147 $md_creator->setDescriptionLanguage($ilUser->getPref(
'language'));
148 $md_creator->setKeywordLanguage($ilUser->getPref(
'language'));
149 $md_creator->setLanguage($ilUser->getPref(
'language'));
150 $md_creator->create();
160 include_once(
"Services/MetaData/classes/class.ilMD.php");
161 include_once(
"Services/MetaData/classes/class.ilMDGeneral.php");
162 include_once(
"Services/MetaData/classes/class.ilMDDescription.php");
165 $md_gen =& $md->getGeneral();
166 $md_gen->setTitle($this->
getTitle());
169 $md_des_ids =& $md_gen->getDescriptionIds();
170 if (count($md_des_ids) > 0)
172 $md_des =& $md_gen->getDescription($md_des_ids[0]);
187 include_once(
'Services/MetaData/classes/class.ilMD.php');
199 $this->data_record = $a_record;
206 $ilBench->start(
"ContentPresentation",
"ilLMObject_read");
208 if(!isset($this->data_record))
210 $ilBench->start(
"ContentPresentation",
"ilLMObject_read_getData");
211 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($this->
id);
212 $obj_set = $this->ilias->db->query($query);
214 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read_getData");
217 $this->type = $this->data_record[
"type"];
218 $this->
setImportId($this->data_record[
"import_id"]);
219 $this->
setTitle($this->data_record[
"title"]);
222 $ilBench->stop(
"ContentPresentation",
"ilLMObject_read");
232 $this->title = $a_title;
250 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_obj_id);
251 $obj_set = $ilDB->query($query);
254 return $obj_rec[
"title"];
261 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_obj_id);
262 $obj_set = $ilDB->query($query);
265 return $obj_rec[
"type"];
273 $query =
"UPDATE lm_data SET ".
274 " title = ".$ilDB->quote($a_title).
275 " WHERE obj_id = ".$ilDB->quote($a_obj_id);
276 $ilDB->query($query);
282 $this->description = $a_description;
292 $this->type = $a_type;
302 $this->lm_id = $a_lm_id;
313 $this->content_object =& $a_content_obj;
333 return $this->import_id;
338 $this->import_id = $a_id;
348 $this->active = $a_active;
372 $q =
"UPDATE lm_data ".
374 "import_id = ".$ilDB->quote($a_import_id).
",".
375 "last_update = now() ".
376 "WHERE obj_id = ".$ilDB->quote($a_id);
386 $query =
"INSERT INTO lm_data (title, type, lm_id, import_id, create_date, active) ".
387 "VALUES (".$ilDB->quote($this->
getTitle()).
",".$ilDB->quote($this->
getType()).
", ".
390 $this->ilias->db->query($query);
391 $this->
setId($this->ilias->db->getLastInsertId());
394 include_once(
"classes/class.ilHistory.php");
396 $this->content_object->getType().
":".$this->
getType());
414 $query =
"UPDATE lm_data SET ".
415 " lm_id = ".$ilDB->quote($this->
getLMId()).
416 " ,title = ".$ilDB->quote($this->
getTitle()).
418 " WHERE obj_id = ".$ilDB->quote($this->
getId());
420 $ilDB->query($query);
436 if (!is_array($a_pages))
437 {$a_pages = array(0);
444 if (empty($a_cont_obj_id))
446 $message = sprintf(
'ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_cont_obj_id is empty');
447 $ilLog->write($message,$ilLog->WARNING);
448 $ilErr->raiseError($message,$ilErr->MESSAGE);
453 $lm_tree =
new ilTree($a_cont_obj_id);
454 $lm_tree->setTableNames(
'lm_tree',
'lm_data');
455 $lm_tree->setTreeTablePK(
"lm_id");
456 $lm_tree->readRootId();
459 $q =
"SELECT obj_id FROM lm_data " .
460 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id).
" " .
462 $r = $ilDB->query($q);
465 while ($row = $r->fetchRow())
467 $childs = $lm_tree->getChilds($row[0]);
469 foreach ($childs as $page)
471 if ($page[
"type"] ==
"pg" and in_array($page[
"obj_id"],$a_pages))
473 array_push($a_pages, $row[0]);
480 $q =
"UPDATE lm_data SET " .
481 "public_access = CASE " .
486 "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id).
" " .
487 "AND type IN ('pg','st')";
497 if (empty($a_node_id))
499 $message = sprintf(
'ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
500 $ilLog->write($message,$ilLog->WARNING);
504 if ($a_check_public_mode ===
true)
506 $lm_id = ilLMObject::_lookupContObjId($a_node_id);
508 $q =
"SELECT public_access_mode FROM content_object WHERE id=".$ilDB->quote(
$lm_id);
509 $r = $ilDB->query($q);
510 $row = $r->fetchRow();
512 if ($row[0] ==
"complete")
518 $q =
"SELECT public_access FROM lm_data WHERE obj_id=".$ilDB->quote($a_node_id);
519 $r = $ilDB->query($q);
520 $row = $r->fetchRow();
528 function delete($a_delete_meta_data =
true)
532 $query =
"DELETE FROM lm_data WHERE obj_id= ".$ilDB->quote($this->
getId());
533 $this->ilias->db->query($query);
553 $q =
"SELECT * FROM lm_data WHERE import_id = ".$ilDB->quote($a_import_id).
" ".
554 " ORDER BY create_date DESC LIMIT 1";
555 $obj_set = $ilDB->query($q);
563 return $obj_rec[
"obj_id"];
583 $q =
"SELECT * FROM lm_data WHERE import_id = ".$ilDB->quote($a_import_id).
" ".
584 " ORDER BY create_date DESC";
585 $obj_set = $ilDB->query($q);
611 include_once(
"./Services/COPage/classes/class.ilInternalLink.php");
612 if (is_int(strpos($a_id,
"_")))
617 $q =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_id);
618 $obj_set = $ilDB->query($q);
637 $type_str = (
$type !=
"")
638 ?
"AND type = ".$ilDB->quote(
$type).
" "
640 $query =
"SELECT * FROM lm_data ".
641 "WHERE lm_id= ".$ilDB->quote(
$lm_id).
" ".
644 $obj_set = $ilDB->query($query);
648 $obj_list[] = array(
"obj_id" => $obj_rec[
"obj_id"],
649 "title" => $obj_rec[
"title"],
650 "type" => $obj_rec[
"type"]);
663 include_once
'./classes/class.ilNestedSetXML.php';
665 $query =
"SELECT * FROM lm_data ".
666 "WHERE lm_id= ".$ilDB->quote($a_cobj->getId()).
" ";
667 $obj_set = $this->ilias->db->query($query);
669 require_once(
"./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
674 if (is_object($lm_obj))
676 $lm_obj->delete(
true);
690 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_id).
"";
691 $obj_set = $ilDB->query($query);
694 return $obj_rec[
"lm_id"];
704 $query =
"SELECT * FROM lm_data WHERE obj_id = ".$ilDB->quote($a_id);
705 $obj_set = $ilDB->query($query);
718 $query =
"UPDATE lm_data ".
720 " WHERE obj_id = ".$ilDB->quote($a_id);
721 $ilDB->query($query);
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,
886 static function pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time,
887 &$a_copied_nodes, $a_as_copy =
false)
893 $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
894 if ($item_type ==
"st")
898 else if ($item_type ==
"pg")
903 $ilLog->write(
"Getting from clipboard type ".$item_type.
", ".
904 "Item ID: ".$a_item_id.
", of original LM: ".$item_lm_id);
906 if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
911 include_once(
"Services/MetaData/classes/class.ilMD.php");
912 $md =
new ilMD($item_lm_id, $item->getId(), $item->getType());
913 $new_md = $md->
cloneMD($a_target_lm->getId(), $item->getId(), $item->getType());
916 $item->setLMId($a_target_lm->getId());
917 $item->setContentObject($a_target_lm);
923 if ($item_type ==
"pg")
925 $page = $item->getPageObject();
927 $page->setParentId($a_target_lm->getId());
934 $target_item = $item->copy($a_target_lm);
935 $a_copied_nodes[$item->getId()] = $target_item->getId();
939 $target_item = $item;
942 $ilLog->write(
"Putting into tree type ".$target_item->getType().
943 "Item ID: ".$target_item->getId().
", Parent: ".$a_parent_id.
", ".
944 "Target: ".$a_target.
", Item LM:".$target_item->getContentObject()->getId());
948 $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
950 foreach($childs as $child)
953 IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
956 return $target_item->getId();
967 if (is_array($a_titles))
969 include_once(
"./Services/MetaData/classes/class.ilMD.php");
973 if (is_object($lmobj))
976 $md =
new ilMD($a_lm->getId(),
$id, $lmobj->getType());
978 $md_gen->setTitle(
$title);
992 foreach($a_copied_nodes as $original_id => $copied_id)
997 if ($copied_type ==
"pg")
1005 $il = $tpg->getInternalLinks();
1014 foreach($targets as $target)
1016 if (($target[
"inst"] == 0 || $target[
"inst"] = IL_INST_ID) &&
1017 ($target[
"type"] ==
"pg" || $target[
"type"] ==
"st"))
1020 if ($a_copied_nodes[$target[
"id"]] > 0)
1022 $fix[$target[
"id"]] = $a_copied_nodes[$target[
"id"]];
1030 foreach($lm_data as $item)
1032 if (!$found && ($item[
"lm_id"] == $copy_lm))
1034 $fix[$target[
"id"]] = $item[
"obj_id"];
1047 if (count($fix) > 0)
1050 $page->moveIntLinks($fix);
1055 if ($copied_type ==
"pg" ||
1056 $copied_type ==
"st")
1080 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1081 foreach(
$mobs as $mob)
1084 foreach($usages as $usage)
1086 if ($usage[
"type"] ==
"lm:pg" | $usage[
"type"] ==
"lm:st")
1088 $sources[] = $usage;
1093 foreach($sources as $source)
1095 $stype = explode(
":", $source[
"type"]);
1096 $source_type = $stype[1];
1098 if ($source_type ==
"pg" || $source_type ==
"st")
1104 foreach($lm_data as $item)
1106 if (!$found && ($item[
"lm_id"] == $copy_lm))
1108 $fix[$item[
"obj_id"]][$original_id] = $copied_id;
1119 if (count($fix) > 0)
1121 foreach ($fix as $page_id => $fix_array)
1124 $page->moveIntLinks($fix_array);
1138 if (is_array($a_items))
1140 foreach($a_items as $item)
1147 if (count($types) > 1)