ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLMObject Class Reference

Class ilLMObject. More...

+ Inheritance diagram for ilLMObject:
+ Collaboration diagram for ilLMObject:

Public Member Functions

 ilLMObject ($a_content_obj, $a_id=0)
 
 MDUpdateListener ($a_element)
 Meta data update listener. More...
 
 _lookupNID ($a_lm_id, $a_lm_obj_id, $a_type)
 lookup named identifier (ILIAS_NID) More...
 
 createMetaData ()
 create meta data entry More...
 
 updateMetaData ()
 update meta data entry More...
 
 deleteMetaData ()
 delete meta data entry More...
 
 setDataRecord ($a_record)
 this method should only be called by class ilLMObjectFactory More...
 
 read ()
 
 setTitle ($a_title)
 set title of lm object More...
 
 getTitle ()
 get title of lm object More...
 
 _writeTitle ($a_obj_id, $a_title)
 
 setDescription ($a_description)
 
 getDescription ()
 
 setType ($a_type)
 
 getType ()
 
 setLMId ($a_lm_id)
 
 getLMId ()
 
 setContentObject (&$a_content_obj)
 
getContentObject ()
 
 setId ($a_id)
 
 getId ()
 
 getImportId ()
 
 setImportId ($a_id)
 
 setLayout ($a_val)
 Set layout. More...
 
 getLayout ()
 Get layout. More...
 
 _writeImportId ($a_id, $a_import_id)
 write import id to db (static) More...
 
 create ($a_upload=false)
 
 update ()
 update complete object More...
 
 delete ($a_delete_meta_data=true)
 delete lm object data More...
 
 _getIdForImportId ($a_import_id)
 get current object id for import id (static) More...
 
 _getAllObjectsForImportId ($a_import_id, $a_in_lm=0)
 Get all items for an import ID. More...
 
 _exists ($a_id)
 checks wether a lm content object with specified id exists or not More...
 
 getObjectList ($lm_id, $type="")
 static More...
 
 _deleteAllObjectData (&$a_cobj)
 delete all objects of content object (digi book / learning module) More...
 
 _lookupContObjID ($a_id)
 get learning module / digibook id for lm object More...
 
 clipboardCut ($a_cont_obj_id, $a_ids)
 Copy a set of chapters/pages into the clipboard. More...
 
 existsExportID ($a_lm_id, $a_exp_id, $a_type="pg")
 Does export ID exist in lm? More...
 
 getExportIDInfo ($a_lm_id, $a_exp_id, $a_type="pg")
 Does export ID exist in lm? More...
 

Static Public Member Functions

static preloadDataByLM ($a_lm_id)
 Preload data records by lm. More...
 
static _lookupTitle ($a_obj_id)
 Lookup title. More...
 
static _lookupType ($a_obj_id, $a_lm_id=0)
 Lookup type. More...
 
 _writePublicAccessStatus ($a_pages, $a_cont_obj_id)
 update public access flags in lm_data for all pages of a content object More...
 
static _isPagePublic ($a_node_id, $a_check_public_mode=false)
 
static putInTree ($a_obj, $a_parent_id="", $a_target_node_id="")
 put this object into content object tree More...
 
static getTree ($a_cont_obj_id)
 Get learningmodule tree. More...
 
static clipboardCopy ($a_cont_obj_id, $a_ids)
 Copy a set of chapters/pages into the clipboard. More...
 
static pasteTree ($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_source_lm=null)
 Paste item (tree) from clipboard to current lm. More...
 
static saveTitles ($a_lm, $a_titles, $a_lang="-")
 Save titles for lm objects. More...
 
static updateInternalLinks ($a_copied_nodes, $a_parent_type="lm")
 Update internal links, after multiple pages have been copied. More...
 
static uniqueTypesCheck ($a_items)
 Check for unique types (all pages or all chapters) More...
 
static writeLayout ($a_obj_id, $a_layout, $a_lm=null)
 Write layout setting. More...
 
static lookupLayout ($a_obj_id)
 Lookup type. More...
 
static getPagesOfChapter ($a_lm_id, $a_chap_id)
 Get pages of chapter. More...
 
static saveExportId ($a_lm_id, $a_lmobj_id, $a_exp_id, $a_type="pg")
 Save export id. More...
 
static getExportId ($a_lm_id, $a_lmobj_id, $a_type="pg")
 Get export ID. More...
 
static getDuplicateExportIDs ($a_lm_id, $a_type="pg")
 Get duplicate export IDs (count export ID usages) More...
 
static _getPresentationTitle ($a_node, $a_mode=IL_PAGE_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-")
 Get affective title. More...
 

Data Fields

 $ilias
 
 $lm_id
 
 $type
 
 $id
 
 $meta_data
 
 $data_record
 
 $content_object
 
 $title
 
 $description
 
 $active = true
 

Static Protected Attributes

static $data_records = array()
 

Detailed Description

Class ilLMObject.

Base class for ilStructureObjects and ilPageObjects (see ILIAS DTD)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilLMObject.php.

Member Function Documentation

◆ _deleteAllObjectData()

ilLMObject::_deleteAllObjectData ( $a_cobj)

delete all objects of content object (digi book / learning module)

Definition at line 710 of file class.ilLMObject.php.

References $query, and ilLMObjectFactory\getInstance().

Referenced by ilObjContentObject\delete().

711  {
712  global $ilDB;
713 
714  include_once './Services/Xml/classes/class.ilNestedSetXML.php';
715 
716  $query = "SELECT * FROM lm_data ".
717  "WHERE lm_id= ".$ilDB->quote($a_cobj->getId(), "integer");
718  $obj_set = $ilDB->query($query);
719 
720  require_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
721  while ($obj_rec = $ilDB->fetchAssoc($obj_set))
722  {
723  $lm_obj = ilLMObjectFactory::getInstance($a_cobj, $obj_rec["obj_id"],false);
724 
725  if (is_object($lm_obj))
726  {
727  $lm_obj->delete(true);
728  }
729  }
730 
731  return true;
732  }
getInstance(&$a_content_obj, $a_id=0, $a_halt=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _exists()

ilLMObject::_exists (   $a_id)

checks wether a lm content object with specified id exists or not

Parameters
int$idid
Returns
boolean true, if lm content object exists

Definition at line 655 of file class.ilLMObject.php.

References ilInternalLink\_extractObjIdOfTarget().

Referenced by ilInternalLink\_exists(), ilLinksTableGUI\fillRow(), getDuplicateExportIDs(), ilLMPresentationGUI\ilPage(), ilHelpGUI\showHelp(), and ilLMPresentationGUI\showPrintView().

656  {
657  global $ilDB;
658 
659  include_once("./Services/COPage/classes/class.ilInternalLink.php");
660  if (is_int(strpos($a_id, "_")))
661  {
663  }
664 
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))
669  {
670  return true;
671  }
672  else
673  {
674  return false;
675  }
676 
677  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAllObjectsForImportId()

ilLMObject::_getAllObjectsForImportId (   $a_import_id,
  $a_in_lm = 0 
)

Get all items for an import ID.

(only for items notnot in trash)

Parameters
int$a_import_idimport id
Returns
int id

Definition at line 621 of file class.ilLMObject.php.

References ilObject\_hasUntrashedReference().

Referenced by updateInternalLinks().

622  {
623  global $ilDB;
624 
625  $where = ($a_in_lm > 0)
626  ? " AND lm_id = ".$ilDB->quote($a_in_lm, "integer")." "
627  : "";
628 
629  $q = "SELECT * FROM lm_data WHERE import_id = ".
630  $ilDB->quote($a_import_id, "text")." ".
631  $where.
632  " ORDER BY create_date DESC";
633  $obj_set = $ilDB->query($q);
634 
635  $items = array();
636  while ($obj_rec = $ilDB->fetchAssoc($obj_set))
637  {
638  // check, whether lm is not trashed
639  if (ilObject::_hasUntrashedReference($obj_rec["lm_id"]))
640  {
641  $items[] = $obj_rec;
642  }
643  }
644 
645  return $items;
646  }
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getIdForImportId()

ilLMObject::_getIdForImportId (   $a_import_id)

get current object id for import id (static)

import ids can exist multiple times (if the same learning module has been imported multiple times). we get the object id of the last imported object, that is not in trash

Parameters
int$a_import_idimport id
Returns
int id

Definition at line 588 of file class.ilLMObject.php.

References ilObject\_hasUntrashedReference(), _lookupContObjID(), and ilObjHelpSettings\isHelpLM().

Referenced by ilInternalLink\_getIdForImportId(), SurveyQuestion\_resolveInternalLink(), and assQuestion\_resolveInternalLink().

589  {
590  global $ilDB;
591 
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))
597  {
598  $lm_id = ilLMObject::_lookupContObjID($obj_rec["obj_id"]);
599 
600  // link only in learning module, that is not trashed
601  include_once("./Services/Help/classes/class.ilObjHelpSettings.php");
604  {
605  return $obj_rec["obj_id"];
606  }
607  }
608 
609  return 0;
610  }
static isHelpLM($a_lm_id)
Check if LM is a help LM.
_lookupContObjID($a_id)
get learning module / digibook id for lm object
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getPresentationTitle()

static ilLMObject::_getPresentationTitle (   $a_node,
  $a_mode = IL_PAGE_TITLE,
  $a_include_numbers = false,
  $a_time_scheduled_activation = false,
  $a_force_content = false,
  $a_lm_id = 0,
  $a_lang = "-" 
)
static

Get affective title.

Parameters

Definition at line 1475 of file class.ilLMObject.php.

References ilStructureObject\_getPresentationTitle(), and ilLMPageObject\_getPresentationTitle().

Referenced by ilLMExplorerGUI\getNodeContent().

1478  {
1479  if ($a_lang == "")
1480  {
1481  $a_lang = "-";
1482  }
1483 
1484  if ($a_node["type"] == "st")
1485  {
1486  return ilStructureObject::_getPresentationTitle($a_node["child"],
1487  $a_include_numbers, $a_time_scheduled_activation, $a_lm_id, $a_lang);
1488  }
1489  else
1490  {
1491  return ilLMPageObject::_getPresentationTitle($a_node["child"],
1492  $a_mode, $a_include_numbers, $a_time_scheduled_activation,
1493  $a_force_content, $a_lm_id, $a_lang);
1494  }
1495  }
static _getPresentationTitle($a_st_id, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_lm_id=0, $a_lang="-")
get presentation title
static _getPresentationTitle($a_pg_id, $a_mode=IL_CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-")
presentation title doesn't have to be page title, it may be chapter title + page title or chapter tit...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isPagePublic()

static ilLMObject::_isPagePublic (   $a_node_id,
  $a_check_public_mode = false 
)
static

Definition at line 529 of file class.ilLMObject.php.

References $ilLog, $r, $row, and ilUtil\yn2tf().

Referenced by ilLMPresentationGUI\executeCommand(), ilPublicSectionSelector\formatObject(), ilLMPresentationGUI\getCurrentPageId(), ilLMPresentationGUI\ilLMNavigation(), ilLMPresentationGUI\ilPage(), ilLMExplorer\isClickable(), ilShopPublicSectionSelector\isClickable(), ilLMTOCExplorer\isClickable(), ilTableOfContentsExplorer\isClickable(), ilLMTOCExplorerGUI\isNodeClickable(), ilLMPresentationGUI\showPrintView(), and ilLMPresentationGUI\showPrintViewSelection().

530  {
531  global $ilDB,$ilLog;
532 
533  if (empty($a_node_id))
534  {
535  $message = sprintf('ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
536  $ilLog->write($message,$ilLog->WARNING);
537  return false;
538  }
539 
540  if ($a_check_public_mode === true)
541  {
542  $lm_id = ilLMObject::_lookupContObjId($a_node_id);
543 
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);
548 
549  if ($row["public_access_mode"] == "complete")
550  {
551  return true;
552  }
553  }
554 
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);
559 
560  return ilUtil::yn2tf($row["public_access"]);
561  }
static yn2tf($a_yn)
convert "y"/"n" to true/false
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupContObjID()

ilLMObject::_lookupContObjID (   $a_id)

get learning module / digibook id for lm object

Definition at line 737 of file class.ilLMObject.php.

References $query.

Referenced by ilObjContentObjectAccess\_checkGoto(), ilStartUpGUI\_checkGoto(), _getIdForImportId(), ilStructureObject\_getPresentationTitle(), ilLMPageObject\_getPresentationTitle(), ilLMPageObjectGUI\_goto(), ilStructureObjectGUI\_goto(), ilLMPageObject\_splitPage(), ilLMPageObject\_splitPageNext(), SurveyQuestion\addInternalLink(), ilWebAccessChecker\checkAccessGlossaryTerm(), ilLinksTableGUI\fillRow(), ilLMPageObjectGUI\getLinkXML(), ilGlossaryPresentationGUI\getLinkXML(), ilLMPresentationGUI\getLinkXML(), ilObjMediaObject\getParentObjectIdForUsage(), ilGlossaryPresentationGUI\listDefinitions(), ilObjContentObjectGUI\pastePage(), pasteTree(), ilPageObjectGUI\setDefaultLinkXml(), SurveyQuestion\setMaterial(), and updateInternalLinks().

738  {
739  global $ilDB;
740 
741  if (isset(self::$data_records[$a_id]))
742  {
743  return self::$data_records[$a_id]["lm_id"];
744  }
745 
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);
750 
751  return $obj_rec["lm_id"];
752  }
+ Here is the caller graph for this function:

◆ _lookupNID()

ilLMObject::_lookupNID (   $a_lm_id,
  $a_lm_obj_id,
  $a_type 
)

lookup named identifier (ILIAS_NID)

Definition at line 91 of file class.ilLMObject.php.

References $id.

92  {
93  include_once 'Services/MetaData/classes/class.ilMD.php';
94 //echo "-".$a_lm_id."-".$a_lm_obj_id."-".$a_type."-";
95  $md = new ilMD($a_lm_id, $a_lm_obj_id, $a_type);
96  $md_gen = $md->getGeneral();
97  if (is_object($md_gen))
98  {
99  foreach($md_gen->getIdentifierIds() as $id)
100  {
101  $md_id = $md_gen->getIdentifier($id);
102  if ($md_id->getCatalog() == "ILIAS_NID")
103  {
104  return $md_id->getEntry();
105  }
106  }
107  }
108 
109  return false;
110  }

◆ _lookupTitle()

static ilLMObject::_lookupTitle (   $a_obj_id)
static

Lookup title.

Parameters
intlm object id

Definition at line 252 of file class.ilLMObject.php.

References $query.

Referenced by ilShopResultPresentationGUI\__appendChildLinks(), ilCourseObjectivePresentationGUI\__showLearningMaterials(), ilStructureObject\_getPresentationTitle(), ilLMPageObject\_getPresentationTitle(), clipboardCopy(), ilObjContentObjectGUI\confirmedDelete(), ilObjContentObject\executeDragDrop(), ilTermUsagesTableGUI\fillRow(), ilLinksTableGUI\fillRow(), ilMediaPoolPageUsagesTableGUI\fillRow(), ilMediaObjectUsagesTableGUI\fillRow(), ilCourseObjectivesTableGUI\fillRow(), ilCourseObjectiveMaterialAssignmentTableGUI\fillRow(), ilLMQuestionListTableGUI\fillRow(), ilObjLearningModuleSubItemListGUI\getHTML(), ilImageMapEditorGUI\getMapAreaLinkString(), ilLinkInputGUI\getTranslatedValue(), ilLMPresentationGUI\ilPage(), ilCourseObjectiveMaterialAssignmentTableGUI\parse(), ilContainerObjectiveGUI\renderObjective(), ilHelpGUI\showHelp(), ilHelpGUI\showPage(), ilLMPresentationGUI\showPreconditionsOfPage(), and ilObjContentObject\validatePages().

253  {
254  global $ilDB;
255 
256  if (isset(self::$data_records[$a_obj_id]))
257  {
258  return self::$data_records[$a_obj_id]["title"];
259  }
260 
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);
265 
266  return $obj_rec["title"];
267  }
+ Here is the caller graph for this function:

◆ _lookupType()

static ilLMObject::_lookupType (   $a_obj_id,
  $a_lm_id = 0 
)
static

Lookup type.

Parameters
intid of pg st
intid of lm object [optional]

Definition at line 275 of file class.ilLMObject.php.

References $query.

Referenced by ilShopResultPresentationGUI\__appendChildLinks(), ilStructureObjectGUI\activatePages(), clipboardCopy(), ilLMPresentationGUI\getCurrentPageId(), ilObjLearningModuleSubItemListGUI\getHTML(), ilLMPresentationGUI\ilLMNavigation(), ilLMPresentationGUI\ilPage(), ilLMPresentationGUI\ilTOC(), ilPageObject\moveIntLinks(), pasteTree(), ilObjContentObjectGUI\saveExportIds(), ilLMPresentationGUI\showPrintView(), ilLMPresentationGUI\showTableOfContents(), uniqueTypesCheck(), updateInternalLinks(), ilCourseObjectivesGUI\updateMaterialAssignment(), and writeLayout().

276  {
277  global $ilDB;
278 
279  if (isset(self::$data_records[$a_obj_id]))
280  {
281  if ($a_lm_id == 0 || self::$data_records[$a_obj_id]["lm_id"] == $a_lm_id)
282  {
283  return self::$data_records[$a_obj_id]["type"];
284  }
285  }
286 
287  if($a_lm_id)
288  {
289  $and = ' AND lm_id = '.$ilDB->quote($a_lm_id,'integer');
290  }
291 
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);
295 
296  return $obj_rec["type"];
297  }
+ Here is the caller graph for this function:

◆ _writeImportId()

ilLMObject::_writeImportId (   $a_id,
  $a_import_id 
)

write import id to db (static)

Parameters
int$a_idlm object id
string$a_import_idimport id public

Definition at line 399 of file class.ilLMObject.php.

Referenced by ilContObjParser\handlerEndTag().

400  {
401  global $ilDB;
402 
403  $q = "UPDATE lm_data ".
404  "SET ".
405  "import_id = ".$ilDB->quote($a_import_id, "text").",".
406  "last_update = ".$ilDB->now()." ".
407  "WHERE obj_id = ".$ilDB->quote($a_id, "integer");
408 
409  $ilDB->manipulate($q);
410  }
+ Here is the caller graph for this function:

◆ _writePublicAccessStatus()

ilLMObject::_writePublicAccessStatus (   $a_pages,
  $a_cont_obj_id 
)
static

update public access flags in lm_data for all pages of a content object

public

Parameters
arraypage ids
integercontent object id
Returns
of the jedi

Definition at line 468 of file class.ilLMObject.php.

References $ilErr, $ilLog, $r, and $row.

Referenced by ilObjContentObjectGUI\savePublicSection().

469  {
470  global $ilDB,$ilLog,$ilErr,$ilTree;
471 
472  if (!is_array($a_pages))
473  {$a_pages = array(0);
474  /*$message = sprintf('ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_pages must be an array');
475  $ilLog->write($message,$ilLog->WARNING);
476  $ilErr->raiseError($message,$ilErr->MESSAGE);
477  return false;*/
478  }
479 
480  if (empty($a_cont_obj_id))
481  {
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);
485  return false;
486  }
487 
488  // update structure entries: if at least one page of a chapter is public set chapter to public too
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();
493 
494  // get all st entries of cont_obj
495  $q = "SELECT obj_id FROM lm_data " .
496  "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id, "integer")." " .
497  "AND type = 'st'";
498  $r = $ilDB->query($q);
499 
500  // add chapters with a public page to a_pages
501  while ($row = $ilDB->fetchAssoc($r))
502  {
503  $childs = $lm_tree->getChilds($row["obj_id"]);
504 
505  foreach ($childs as $page)
506  {
507  if ($page["type"] == "pg" and in_array($page["obj_id"],$a_pages))
508  {
509  array_push($a_pages, $row["obj_id"]);
510  break;
511  }
512  }
513  }
514 
515  // update public access status of all pages of cont_obj
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").
521  "END " .
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);
525 
526  return true;
527  }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$r
+ Here is the caller graph for this function:

◆ _writeTitle()

ilLMObject::_writeTitle (   $a_obj_id,
  $a_title 
)

Definition at line 300 of file class.ilLMObject.php.

References $query.

Referenced by MDUpdateListener(), and saveTitles().

301  {
302  global $ilDB;
303 
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);
308  }
+ Here is the caller graph for this function:

◆ clipboardCopy()

static ilLMObject::clipboardCopy (   $a_cont_obj_id,
  $a_ids 
)
static

Copy a set of chapters/pages into the clipboard.

Definition at line 876 of file class.ilLMObject.php.

References $ilUser, _lookupTitle(), _lookupType(), and getTree().

Referenced by clipboardCut(), ilStructureObjectGUI\copyItems(), ilObjContentObjectGUI\copyItems(), and ilObjContentObjectGUI\copyPage().

877  {
878  global $ilUser;
879 
880  $tree = ilLMObject::getTree($a_cont_obj_id);
881 
882  $ilUser->clipboardDeleteObjectsOfType("pg");
883  $ilUser->clipboardDeleteObjectsOfType("st");
884 
885  // put them into the clipboard
886  $time = date("Y-m-d H:i:s", time());
887  foreach ($a_ids as $id)
888  {
889  $curnode = "";
890  if ($tree->isInTree($id))
891  {
892  $curnode = $tree->getNodeData($id);
893  $subnodes = $tree->getSubTree($curnode);
894  foreach($subnodes as $subnode)
895  {
896  if ($subnode["child"] != $id)
897  {
898  $ilUser->addObjectToClipboard($subnode["child"],
899  $subnode["type"], $subnode["title"],
900  $subnode["parent"], $time, $subnode["lft"]);
901  }
902  }
903  }
904  $order = ($curnode["lft"] > 0)
905  ? $curnode["lft"]
906  : (int) ($order + 1);
907  $ilUser->addObjectToClipboard($id,
909  $order);
910  }
911  }
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
static _lookupTitle($a_obj_id)
Lookup title.
static getTree($a_cont_obj_id)
Get learningmodule tree.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clipboardCut()

ilLMObject::clipboardCut (   $a_cont_obj_id,
  $a_ids 
)

Copy a set of chapters/pages into the clipboard.

Definition at line 828 of file class.ilLMObject.php.

References $id, $path, clipboardCopy(), and getTree().

Referenced by ilStructureObjectGUI\cutItems(), ilObjContentObjectGUI\cutItems(), and ilObjContentObjectGUI\movePage().

829  {
830  $tree = ilLMObject::getTree($a_cont_obj_id);
831 
832  if (!is_array($a_ids))
833  {
834  return false;
835  }
836  else
837  {
838  // get all "top" ids, i.e. remove ids, that have a selected parent
839  foreach($a_ids as $id)
840  {
841  $path = $tree->getPathId($id);
842  $take = true;
843  foreach($path as $path_id)
844  {
845  if ($path_id != $id && in_array($path_id, $a_ids))
846  {
847  $take = false;
848  }
849  }
850  if ($take)
851  {
852  $cut_ids[] = $id;
853  }
854  }
855  }
856 
857  ilLMObject::clipboardCopy($a_cont_obj_id, $cut_ids);
858 
859  // remove the objects from the tree
860  // note: we are getting chapters which are *not* in the tree
861  // we do not delete any pages/chapters here
862  foreach ($cut_ids as $id)
863  {
864  $curnode = $tree->getNodeData($id);
865  if ($tree->isInTree($id))
866  {
867  $tree->deleteTree($curnode);
868  }
869  }
870 
871  }
static getTree($a_cont_obj_id)
Get learningmodule tree.
static clipboardCopy($a_cont_obj_id, $a_ids)
Copy a set of chapters/pages into the clipboard.
$path
Definition: index.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilLMObject::create (   $a_upload = false)

Definition at line 412 of file class.ilLMObject.php.

References $query, ilHistory\_createEntry(), createMetaData(), getId(), getImportId(), getLayout(), getLMId(), getTitle(), getType(), and setId().

413  {
414  global $ilDB;
415 
416  // insert object data
417  $this->setId($ilDB->nextId("lm_data"));
418  $query = "INSERT INTO lm_data (obj_id, title, type, layout, lm_id, import_id, create_date) ".
419  "VALUES (".
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").",".
425  $ilDB->quote($this->getImportId(), "text").
426  ", ".$ilDB->now().")";
427  $ilDB->manipulate($query);
428 
429  // create history entry
430  include_once("./Services/History/classes/class.ilHistory.php");
431  ilHistory::_createEntry($this->getId(), "create", "",
432  $this->content_object->getType().":".$this->getType());
433 
434  if (!$a_upload)
435  {
436  $this->createMetaData();
437  }
438 
439  }
getLayout()
Get layout.
_createEntry($a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
getTitle()
get title of lm object
createMetaData()
create meta data entry
+ Here is the call graph for this function:

◆ createMetaData()

ilLMObject::createMetaData ( )

create meta data entry

Definition at line 116 of file class.ilLMObject.php.

References $ilUser, getDescription(), getId(), getLMId(), getTitle(), and getType().

Referenced by create().

117  {
118  include_once 'Services/MetaData/classes/class.ilMDCreator.php';
119 
120  global $ilUser;
121 
122  $md_creator = new ilMDCreator($this->getLMId(), $this->getId(), $this->getType());
123  $md_creator->setTitle($this->getTitle());
124  $md_creator->setTitleLanguage($ilUser->getPref('language'));
125  $md_creator->setDescription($this->getDescription());
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();
130 
131  return true;
132  }
getTitle()
get title of lm object
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilLMObject::delete (   $a_delete_meta_data = true)

delete lm object data

Definition at line 566 of file class.ilLMObject.php.

References $query, deleteMetaData(), and getId().

567  {
568  global $ilDB;
569 
570  $query = "DELETE FROM lm_data WHERE obj_id = ".
571  $ilDB->quote($this->getId(), "integer");
572  $ilDB->manipulate($query);
573 
574  $this->deleteMetaData();
575  }
deleteMetaData()
delete meta data entry
+ Here is the call graph for this function:

◆ deleteMetaData()

ilLMObject::deleteMetaData ( )

delete meta data entry

Definition at line 163 of file class.ilLMObject.php.

References getId(), getLMId(), and getType().

Referenced by delete().

164  {
165  // Delete meta data
166  include_once('Services/MetaData/classes/class.ilMD.php');
167  $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
168  $md->deleteAll();
169  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ existsExportID()

ilLMObject::existsExportID (   $a_lm_id,
  $a_exp_id,
  $a_type = "pg" 
)

Does export ID exist in lm?

Parameters

Definition at line 1429 of file class.ilLMObject.php.

References ilMDIdentifier\existsIdInRbacObject().

Referenced by ilLMPageObject\copy().

1430  {
1431  include_once("./Services/MetaData/classes/class.ilMDIdentifier.php");
1432  return ilMDIdentifier::existsIdInRbacObject($a_lm_id, $a_type, "ILIAS_NID", $a_exp_id);
1433  }
static existsIdInRbacObject($a_rbac_id, $a_obj_type, $a_catalog, $a_entry)
Does id entry exist in rbac object?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContentObject()

& ilLMObject::getContentObject ( )

Definition at line 347 of file class.ilLMObject.php.

References $content_object.

Referenced by ilStructureObject\exportFOPageObjects(), ilLMPageObject\exportXMLPageContent(), and ilStructureObject\exportXMLStructureObjects().

348  {
349  return $this->content_object;
350  }
+ Here is the caller graph for this function:

◆ getDescription()

ilLMObject::getDescription ( )

Definition at line 316 of file class.ilLMObject.php.

References $description.

Referenced by ilStructureObject\copy(), ilLMPageObject\copy(), ilLMPageObject\copyToOtherContObject(), and createMetaData().

317  {
318  return $this->description;
319  }
+ Here is the caller graph for this function:

◆ getDuplicateExportIDs()

static ilLMObject::getDuplicateExportIDs (   $a_lm_id,
  $a_type = "pg" 
)
static

Get duplicate export IDs (count export ID usages)

Definition at line 1438 of file class.ilLMObject.php.

References $res, _exists(), and ilMDIdentifier\_getEntriesForRbacObj().

Referenced by ilExportIDTableGUI\__construct().

1439  {
1440  include_once("./Services/MetaData/classes/class.ilMDIdentifier.php");
1441  $entries = ilMDIdentifier::_getEntriesForRbacObj($a_lm_id, $a_type);
1442  $res = array();
1443  foreach ($entries as $e)
1444  {
1445  if ($e["catalog"] == "ILIAS_NID")
1446  {
1447  if (ilLMObject::_exists($e["obj_id"]))
1448  {
1449  $res[trim($e["entry"])]++;
1450  }
1451  }
1452  }
1453  return $res;
1454  }
_exists($a_id)
checks wether a lm content object with specified id exists or not
static _getEntriesForRbacObj($a_rbac_id, $a_obj_type="")
Get IDs for an rbac object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportId()

static ilLMObject::getExportId (   $a_lm_id,
  $a_lmobj_id,
  $a_type = "pg" 
)
static

Get export ID.

Parameters

Definition at line 1407 of file class.ilLMObject.php.

References ilMDIdentifier\_getEntriesForObj().

Referenced by ilTableOfContentsExplorer\buildLinkTarget(), ilLMPageObject\copy(), ilObjContentObject\exportHTMLPages(), ilExportIDTableGUI\fillRow(), ilLMPresentationGUI\getLink(), and ilLMTOCExplorerGUI\getNodeHref().

1408  {
1409  // look for export id
1410  include_once("./Services/MetaData/classes/class.ilMDIdentifier.php");
1412  $a_lm_id, $a_lmobj_id, $a_type);
1413 
1414  foreach ($entries as $e)
1415  {
1416  if ($e["catalog"] == "ILIAS_NID")
1417  {
1418  return $e["entry"];
1419  }
1420  }
1421  }
static _getEntriesForObj($a_rbac_id, $a_obj_id, $a_obj_type)
Get IDs for an object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExportIDInfo()

ilLMObject::getExportIDInfo (   $a_lm_id,
  $a_exp_id,
  $a_type = "pg" 
)

Does export ID exist in lm?

Parameters

Definition at line 1462 of file class.ilLMObject.php.

References $data, and ilMDIdentifier\readIdData().

1463  {
1464  include_once("./Services/MetaData/classes/class.ilMDIdentifier.php");
1465  $data = ilMDIdentifier::readIdData($a_lm_id, $a_type, "ILIAS_NID", $a_exp_id);
1466  return $data;
1467  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
static readIdData($a_rbac_id, $a_obj_type, $a_catalog, $a_entry)
Does id entry exist in rbac object?
+ Here is the call graph for this function:

◆ getId()

◆ getImportId()

ilLMObject::getImportId ( )

Definition at line 362 of file class.ilLMObject.php.

Referenced by create().

363  {
364  return $this->import_id;
365  }
+ Here is the caller graph for this function:

◆ getLayout()

ilLMObject::getLayout ( )

Get layout.

Returns
string layout

Definition at line 387 of file class.ilLMObject.php.

Referenced by ilLMPageObject\copy(), create(), and update().

388  {
389  return $this->layout;
390  }
+ Here is the caller graph for this function:

◆ getLMId()

◆ getObjectList()

ilLMObject::getObjectList (   $lm_id,
  $type = "" 
)

static

Definition at line 682 of file class.ilLMObject.php.

References $query.

Referenced by ilLMPageObject\getPageList(), ilHelpExporter\getXmlExportTailDependencies(), and ilObjContentObject\importFromZipFile().

683  {
684  global $ilDB;
685 
686  $type_str = ($type != "")
687  ? "AND type = ".$ilDB->quote($type, "text")." "
688  : "";
689 
690  $query = "SELECT * FROM lm_data ".
691  "WHERE lm_id= ".$ilDB->quote($lm_id, "integer")." ".
692  $type_str." ".
693  "ORDER BY title";
694  $obj_set = $ilDB->query($query);
695  $obj_list = array();
696  while($obj_rec = $ilDB->fetchAssoc($obj_set))
697  {
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"]);
702  }
703  return $obj_list;
704  }
+ Here is the caller graph for this function:

◆ getPagesOfChapter()

static ilLMObject::getPagesOfChapter (   $a_lm_id,
  $a_chap_id 
)
static

Get pages of chapter.

Parameters

Definition at line 1320 of file class.ilLMObject.php.

Referenced by ilHelpGUI\showHelp().

1321  {
1322  // update structure entries: if at least one page of a chapter is public set chapter to public too
1323  $lm_tree = new ilTree($a_lm_id);
1324  $lm_tree->setTableNames('lm_tree','lm_data');
1325  $lm_tree->setTreeTablePK("lm_id");
1326  $lm_tree->readRootId();
1327 
1328  $childs = $lm_tree->getChildsByType($a_chap_id, "pg");
1329 
1330  return $childs;
1331  }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the caller graph for this function:

◆ getTitle()

ilLMObject::getTitle ( )

get title of lm object

Returns
string title of chapter or page

Definition at line 241 of file class.ilLMObject.php.

References $title.

Referenced by ilStructureObject\copy(), ilLMPageObject\copy(), ilLMPageObject\copyToOtherContObject(), create(), createMetaData(), ilStructureObject\exportFO(), update(), and updateMetaData().

242  {
243  return $this->title;
244  }
+ Here is the caller graph for this function:

◆ getTree()

static ilLMObject::getTree (   $a_cont_obj_id)
static

Get learningmodule tree.

Parameters
intlearning module object id
Returns
object tree object

Definition at line 815 of file class.ilLMObject.php.

Referenced by clipboardCopy(), and clipboardCut().

816  {
817  $tree = new ilTree($a_cont_obj_id);
818  $tree->setTableNames('lm_tree', 'lm_data');
819  $tree->setTreeTablePK("lm_id");
820  $tree->readRootId();
821 
822  return $tree;
823  }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the caller graph for this function:

◆ getType()

◆ ilLMObject()

ilLMObject::ilLMObject (   $a_content_obj,
  $a_id = 0 
)
Parameters
object$a_content_objcontent object (digi book or learning module)

Definition at line 34 of file class.ilLMObject.php.

References $ilias, read(), setContentObject(), and setLMId().

35  {
36  global $ilias;
37 
38  $this->id = $a_id;
39  $this->setContentObject($a_content_obj);
40  $this->setLMId($a_content_obj->getId());
41  if($a_id != 0)
42  {
43  $this->read();
44  }
45  }
setContentObject(&$a_content_obj)
setLMId($a_lm_id)
+ Here is the call graph for this function:

◆ lookupLayout()

static ilLMObject::lookupLayout (   $a_obj_id)
static

Lookup type.

Parameters
intlm object id

Definition at line 1302 of file class.ilLMObject.php.

References $query.

Referenced by ilLMPresentationGUI\determineLayout(), and ilLMPagesTableGUI\fillRow().

1303  {
1304  global $ilDB;
1305 
1306  $query = "SELECT layout FROM lm_data WHERE obj_id = ".
1307  $ilDB->quote($a_obj_id, "integer");
1308  $obj_set = $ilDB->query($query);
1309  $obj_rec = $ilDB->fetchAssoc($obj_set);
1310 
1311  return $obj_rec["layout"];
1312  }
+ Here is the caller graph for this function:

◆ MDUpdateListener()

ilLMObject::MDUpdateListener (   $a_element)

Meta data update listener.

Important note: Do never call create() or update() method of ilObject here. It would result in an endless loop: update object -> update meta -> update object -> ... Use static _writeTitle() ... methods instead.

Parameters
string$a_elementmd element
Returns
boolean success

Definition at line 59 of file class.ilLMObject.php.

References $id, _writeTitle(), getId(), getLMId(), and getType().

60  {
61  include_once 'Services/MetaData/classes/class.ilMD.php';
62 
63  switch($a_element)
64  {
65  case 'General':
66 
67  // Update Title and description
68  $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
69  $md_gen = $md->getGeneral();
70 
71  ilLMObject::_writeTitle($this->getId(),$md_gen->getTitle());
72 
73  foreach($md_gen->getDescriptionIds() as $id)
74  {
75  $md_des = $md_gen->getDescription($id);
76 // ilLMObject::_writeDescription($this->getId(),$md_des->getDescription());
77  break;
78  }
79 
80  break;
81 
82  default:
83  }
84  return true;
85  }
_writeTitle($a_obj_id, $a_title)
+ Here is the call graph for this function:

◆ pasteTree()

static ilLMObject::pasteTree (   $a_target_lm,
  $a_item_id,
  $a_parent_id,
  $a_target,
  $a_insert_time,
$a_copied_nodes,
  $a_as_copy = false,
  $a_source_lm = null 
)
static

Paste item (tree) from clipboard to current lm.

Definition at line 916 of file class.ilLMObject.php.

References $ilias, $ilLog, $ilUser, _lookupContObjID(), _lookupType(), ilMD\cloneMD(), IL_LAST_NODE, and putInTree().

Referenced by ilObjContentObject\copyAllPagesAndChapters(), ilStructureObjectGUI\insertChapterClip(), ilObjContentObjectGUI\insertChapterClip(), and ilStructureObjectGUI\insertPageClip().

918  {
919  global $ilUser, $ilias, $ilLog;
920 
921  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
922  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
923 
924  $item_lm_id = ilLMObject::_lookupContObjID($a_item_id);
925  $item_type = ilLMObject::_lookupType($a_item_id);
926  $lm_obj = $ilias->obj_factory->getInstanceByObjId($item_lm_id);
927  if ($item_type == "st")
928  {
929  $item = new ilStructureObject($lm_obj, $a_item_id);
930  }
931  else if ($item_type == "pg")
932  {
933  $item = new ilLMPageObject($lm_obj, $a_item_id);
934  }
935 
936  $ilLog->write("Getting from clipboard type ".$item_type.", ".
937  "Item ID: ".$a_item_id.", of original LM: ".$item_lm_id);
938 
939  if ($item_lm_id != $a_target_lm->getId() && !$a_as_copy)
940  {
941  // @todo: check whether st is NOT in tree
942 
943  // "move" metadata to new lm
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());
947 
948  // update lm object
949  $item->setLMId($a_target_lm->getId());
950  $item->setContentObject($a_target_lm);
951  $item->update();
952 
953  // delete old meta data set
954  $md->deleteAll();
955 
956  if ($item_type == "pg")
957  {
958  $page = $item->getPageObject();
959  $page->buildDom();
960  $page->setParentId($a_target_lm->getId());
961  $page->update();
962  }
963  }
964 
965  if ($a_as_copy)
966  {
967  $target_item = $item->copy($a_target_lm);
968  $a_copied_nodes[$item->getId()] = $target_item->getId();
969  }
970  else
971  {
972  $target_item = $item;
973  }
974 
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());
978 
979  ilLMObject::putInTree($target_item, $a_parent_id, $a_target);
980 
981  if ($a_source_lm == null)
982  {
983  $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
984  }
985  else
986  {
987  $childs = $a_source_lm->lm_tree->getChilds($item->getId());
988  foreach ($childs as $k => $child)
989  {
990  $childs[$k]["id"] = $childs[$k]["child"];
991  }
992  }
993 
994  foreach($childs as $child)
995  {
996  ilLMObject::pasteTree($a_target_lm, $child["id"], $target_item->getId(),
997  IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy, $a_source_lm);
998  }
999 
1000  return $target_item->getId();
1001  // @todo: write history (see pastePage)
1002  }
& cloneMD($a_rbac_id, $a_obj_id, $a_obj_type)
Definition: class.ilMD.php:361
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
static pasteTree($a_target_lm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_source_lm=null)
Paste item (tree) from clipboard to current lm.
Class ilLMPageObject.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
put this object into content object tree
_lookupContObjID($a_id)
get learning module / digibook id for lm object
const IL_LAST_NODE
Definition: class.ilTree.php:4
Class ilStructreObject.
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preloadDataByLM()

static ilLMObject::preloadDataByLM (   $a_lm_id)
static

Preload data records by lm.

Parameters
integer$a_lm_idlm id
Returns
int number of preloaded records

Definition at line 211 of file class.ilLMObject.php.

Referenced by ilLMExplorerGUI\__construct().

212  {
213  global $ilDB;
214 
215  $set = $ilDB->query("SELECT * FROM lm_data ".
216  " WHERE lm_id = ".$ilDB->quote($a_lm_id, "integer")
217  );
218  while ($rec = $ilDB->fetchAssoc($set))
219  {
220  self::$data_records[$rec["obj_id"]] = $rec;
221  }
222  return count(self::$data_records);
223  }
+ Here is the caller graph for this function:

◆ putInTree()

static ilLMObject::putInTree (   $a_obj,
  $a_parent_id = "",
  $a_target_node_id = "" 
)
static

put this object into content object tree

Definition at line 757 of file class.ilLMObject.php.

References $ilLog, IL_FIRST_NODE, and ilTree\setTableNames().

Referenced by ilObjContentObject\addFirstChapterAndPage(), ilStructureObjectGUI\insertChapter(), ilObjContentObjectGUI\insertChapter(), ilStructureObjectGUI\insertPage(), and pasteTree().

758  {
759  global $ilLog;
760 
761  $tree = new ilTree($a_obj->getContentObject()->getId());
762  $tree->setTableNames('lm_tree', 'lm_data');
763  $tree->setTreeTablePK("lm_id");
764 
765  // determine parent
766  $parent_id = ($a_parent_id != "")
767  ? $a_parent_id
768  : $tree->getRootId();
769 
770  // determine target
771  if ($a_target_node_id != "")
772  {
773  $target = $a_target_node_id;
774  }
775  else
776  {
777  // determine last child that serves as predecessor
778  if ($a_obj->getType() == "st")
779  {
780  $s_types = array("st", "pg");
781  $childs =& $tree->getChildsByTypeFilter($parent_id, $s_types);
782  }
783  else
784  {
785  $s_types = "pg";
786  $childs =& $tree->getChildsByType($parent_id, $s_types);
787  }
788 
789  if (count($childs) == 0)
790  {
791  $target = IL_FIRST_NODE;
792  }
793  else
794  {
795  $target = $childs[count($childs) - 1]["obj_id"];
796  }
797  }
798 
799  if ($tree->isInTree($parent_id) && !$tree->isInTree($a_obj->getId()))
800  {
801  $ilLog->write("LMObject::putInTree: insertNode, ID: ".$a_obj->getId().
802  "Parent ID: ".$parent_id.", Target: ".$target);
803 
804  $tree->insertNode($a_obj->getId(), $parent_id, $target);
805  }
806  }
const IL_FIRST_NODE
Definition: class.ilTree.php:5
setTableNames($a_table_tree, $a_table_obj_data, $a_table_obj_reference="")
set table names The primary key of the table containing your object_data must be 'obj_id' You may use...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilLMObject::read ( )

Definition at line 181 of file class.ilLMObject.php.

References $ilBench, $query, setImportId(), setLayout(), and setTitle().

Referenced by ilLMObject().

182  {
183  global $ilBench, $ilDB;
184 
185  $ilBench->start("ContentPresentation", "ilLMObject_read");
186 
187  if(!isset($this->data_record))
188  {
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  }
194 
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"]);
199  //$this->setActive(ilUtil::yn2tf($this->data_record["active"]));
200 
201  $ilBench->stop("ContentPresentation", "ilLMObject_read");
202  }
setLayout($a_val)
Set layout.
setTitle($a_title)
set title of lm object
global $ilBench
Definition: ilias.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveExportId()

static ilLMObject::saveExportId (   $a_lm_id,
  $a_lmobj_id,
  $a_exp_id,
  $a_type = "pg" 
)
static

Save export id.

Parameters

Definition at line 1344 of file class.ilLMObject.php.

References ilMDIdentifier\_getEntriesForObj().

Referenced by ilLMPageObject\copy(), and ilObjContentObjectGUI\saveExportIds().

1345  {
1346  global $ilDB;
1347 
1348  include_once("Services/MetaData/classes/class.ilMDIdentifier.php");
1349 
1350  if (trim($a_exp_id) == "")
1351  {
1352  // delete export ids, if existing
1354  $a_lm_id, $a_lmobj_id, $a_type);
1355 
1356  foreach ($entries as $id => $e)
1357  {
1358  if ($e["catalog"] == "ILIAS_NID")
1359  {
1360  $identifier = new ilMDIdentifier();
1361  $identifier->setMetaId($id);
1362  $identifier->delete();
1363  }
1364  }
1365  }
1366  else
1367  {
1368  // update existing entry
1370  $a_lm_id, $a_lmobj_id, $a_type);
1371 
1372  $updated = false;
1373  foreach ($entries as $id => $e)
1374  {
1375  if ($e["catalog"] == "ILIAS_NID")
1376  {
1377  $identifier = new ilMDIdentifier();
1378  $identifier->setMetaId($id);
1379  $identifier->read();
1380  $identifier->setEntry($a_exp_id);
1381  $identifier->update();
1382  $updated = true;
1383  }
1384  }
1385 
1386  // nothing updated? create a new one
1387  if (!$updated)
1388  {
1389  include_once("./Services/MetaData/classes/class.ilMD.php");
1390  $md = new ilMD($a_lm_id, $a_lmobj_id, $a_type);
1391  $md_gen = $md->getGeneral();
1392  $identifier = $md_gen->addIdentifier();
1393  $identifier->setEntry($a_exp_id);
1394  $identifier->setCatalog("ILIAS_NID");
1395  $identifier->save();
1396  }
1397  }
1398 
1399  }
static _getEntriesForObj($a_rbac_id, $a_obj_id, $a_obj_type)
Get IDs for an object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveTitles()

static ilLMObject::saveTitles (   $a_lm,
  $a_titles,
  $a_lang = "-" 
)
static

Save titles for lm objects.

Parameters
arraytitles (key is ID, value is title)

Definition at line 1009 of file class.ilLMObject.php.

References $id, _writeTitle(), ilMD\getGeneral(), ilLMObjectFactory\getInstance(), and ilMDBase\update().

Referenced by ilStructureObjectGUI\saveAllTitles(), and ilObjContentObjectGUI\saveAllTitles().

1010  {
1011  include_once("./Modules/LearningModule/classes/class.ilLMObjTranslation.php");
1012 
1013  if ($a_lang == "")
1014  {
1015  $a_lang = "-";
1016  }
1017  if (is_array($a_titles))
1018  {
1019  include_once("./Services/MetaData/classes/class.ilMD.php");
1020  foreach($a_titles as $id => $title)
1021  {
1022  if ($a_lang == "-")
1023  {
1024  $lmobj = ilLMObjectFactory::getInstance($a_lm, $id, false);
1025  if (is_object($lmobj))
1026  {
1027  // Update Title and description
1028  $md = new ilMD($a_lm->getId(), $id, $lmobj->getType());
1029  $md_gen = $md->getGeneral();
1030  $md_gen->setTitle($title);
1031  $md_gen->update();
1032  $md->update();
1034  }
1035  }
1036  else
1037  {
1038  $lmobjtrans = new ilLMObjTranslation($id, $a_lang);
1039  $lmobjtrans->setTitle($title);
1040  $lmobjtrans->save();
1041  }
1042  }
1043  }
1044  }
getInstance(&$a_content_obj, $a_id=0, $a_halt=true)
_writeTitle($a_obj_id, $a_title)
& getGeneral()
Definition: class.ilMD.php:55
Translation information on lm object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContentObject()

ilLMObject::setContentObject ( $a_content_obj)

Definition at line 342 of file class.ilLMObject.php.

Referenced by ilLMObject().

343  {
344  $this->content_object =& $a_content_obj;
345  }
+ Here is the caller graph for this function:

◆ setDataRecord()

ilLMObject::setDataRecord (   $a_record)

this method should only be called by class ilLMObjectFactory

Definition at line 176 of file class.ilLMObject.php.

177  {
178  $this->data_record = $a_record;
179  }

◆ setDescription()

ilLMObject::setDescription (   $a_description)

Definition at line 311 of file class.ilLMObject.php.

312  {
313  $this->description = $a_description;
314  }

◆ setId()

ilLMObject::setId (   $a_id)

Definition at line 352 of file class.ilLMObject.php.

Referenced by create().

353  {
354  $this->id = $a_id;
355  }
+ Here is the caller graph for this function:

◆ setImportId()

ilLMObject::setImportId (   $a_id)

Definition at line 367 of file class.ilLMObject.php.

Referenced by read().

368  {
369  $this->import_id = $a_id;
370  }
+ Here is the caller graph for this function:

◆ setLayout()

ilLMObject::setLayout (   $a_val)

Set layout.

Parameters
stringlayout

Definition at line 377 of file class.ilLMObject.php.

Referenced by read().

378  {
379  $this->layout = $a_val;
380  }
+ Here is the caller graph for this function:

◆ setLMId()

ilLMObject::setLMId (   $a_lm_id)

Definition at line 331 of file class.ilLMObject.php.

Referenced by ilLMObject().

332  {
333  $this->lm_id = $a_lm_id;
334 
335  }
+ Here is the caller graph for this function:

◆ setTitle()

ilLMObject::setTitle (   $a_title)

set title of lm object

Parameters
string$a_titletitle of chapter or page

Definition at line 231 of file class.ilLMObject.php.

Referenced by read().

232  {
233  $this->title = $a_title;
234  }
+ Here is the caller graph for this function:

◆ setType()

ilLMObject::setType (   $a_type)

Definition at line 321 of file class.ilLMObject.php.

Referenced by ilLMPageObject\ilLMPageObject(), and ilStructureObject\ilStructureObject().

322  {
323  $this->type = $a_type;
324  }
+ Here is the caller graph for this function:

◆ uniqueTypesCheck()

static ilLMObject::uniqueTypesCheck (   $a_items)
static

Check for unique types (all pages or all chapters)

Definition at line 1239 of file class.ilLMObject.php.

References $type, and _lookupType().

Referenced by ilStructureObjectGUI\copyItems(), and ilStructureObjectGUI\cutItems().

1240  {
1241  $types = array();
1242  if (is_array($a_items))
1243  {
1244  foreach($a_items as $item)
1245  {
1246  $type = ilLMObject::_lookupType($item);
1247  $types[$type] = $type;
1248  }
1249  }
1250 
1251  if (count($types) > 1)
1252  {
1253  return false;
1254  }
1255  return true;
1256  }
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilLMObject::update ( )

update complete object

Definition at line 444 of file class.ilLMObject.php.

References $query, getId(), getLayout(), getLMId(), getTitle(), and updateMetaData().

445  {
446  global $ilDB;
447 
448  $this->updateMetaData();
449 
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");
455 
456  $ilDB->manipulate($query);
457  }
getLayout()
Get layout.
updateMetaData()
update meta data entry
getTitle()
get title of lm object
+ Here is the call graph for this function:

◆ updateInternalLinks()

static ilLMObject::updateInternalLinks (   $a_copied_nodes,
  $a_parent_type = "lm" 
)
static

Update internal links, after multiple pages have been copied.

Definition at line 1049 of file class.ilLMObject.php.

References $mobs, $t, ilInternalLink\_extractInstOfTarget(), ilInternalLink\_extractObjIdOfTarget(), ilInternalLink\_extractTypeOfTarget(), _getAllObjectsForImportId(), ilMapArea\_getMobsForTarget(), ilInternalLink\_getSourcesOfTarget(), _lookupContObjID(), _lookupType(), ilObject\_lookupType(), ilPageObjectFactory\getInstance(), and ilObjMediaObject\lookupUsages().

Referenced by ilObjContentObject\copyAllPagesAndChapters(), ilStructureObjectGUI\insertChapterClip(), ilObjContentObjectGUI\insertChapterClip(), ilStructureObjectGUI\insertPageClip(), and ilObjContentObjectGUI\pastePage().

1050  {
1051  $all_fixes = array();
1052  foreach($a_copied_nodes as $original_id => $copied_id)
1053  {
1054  $copied_type = ilLMObject::_lookupType($copied_id);
1055  $copy_lm = ilLMObject::_lookupContObjID($copied_id);
1056 
1057  if ($copied_type == "pg")
1058  {
1059  //
1060  // 1. Outgoing links from the copied page.
1061  //
1062  //$targets = ilInternalLink::_getTargetsOfSource($a_parent_type.":pg", $copied_id);
1063  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
1064  $tpg = new ilLMPage($copied_id);
1065  $tpg->buildDom();
1066  $il = $tpg->getInternalLinks();
1067  $targets = array();
1068  foreach($il as $l)
1069  {
1070  $targets[] = array("type" => ilInternalLink::_extractTypeOfTarget($l["Target"]),
1071  "id" => (int) ilInternalLink::_extractObjIdOfTarget($l["Target"]),
1072  "inst" => (int) ilInternalLink::_extractInstOfTarget($l["Target"]));
1073  }
1074  $fix = array();
1075  foreach($targets as $target)
1076  {
1077  if (($target["inst"] == 0 || $target["inst"] = IL_INST_ID) &&
1078  ($target["type"] == "pg" || $target["type"] == "st"))
1079  {
1080  // first check, whether target is also within the copied set
1081  if ($a_copied_nodes[$target["id"]] > 0)
1082  {
1083  $fix[$target["id"]] = $a_copied_nodes[$target["id"]];
1084  }
1085  else
1086  {
1087  // now check, if a copy if the target is already in the same lm
1088 
1089  // only if target is not already in the same lm!
1090  $trg_lm = ilLMObject::_lookupContObjID($target["id"]);
1091  if ($trg_lm != $copy_lm)
1092  {
1093  $lm_data = ilLMObject::_getAllObjectsForImportId("il__".$target["type"]."_".$target["id"]);
1094  $found = false;
1095 
1096  foreach($lm_data as $item)
1097  {
1098  if (!$found && ($item["lm_id"] == $copy_lm))
1099  {
1100  $fix[$target["id"]] = $item["obj_id"];
1101  $found = true;
1102  }
1103  }
1104  }
1105  }
1106  }
1107  }
1108 
1109  // outgoing links to be fixed
1110  if (count($fix) > 0)
1111  {
1112 //echo "<br>--".$copied_id;
1113 //var_dump($fix);
1114  $t = ilObject::_lookupType($copy_lm);
1115  if (is_array($all_fixes[$t.":".$copied_id]))
1116  {
1117  $all_fixes[$t.":".$copied_id] += $fix;
1118  }
1119  else
1120  {
1121  $all_fixes[$t.":".$copied_id] = $fix;
1122  }
1123  }
1124  }
1125 
1126  if ($copied_type == "pg" ||
1127  $copied_type == "st")
1128  {
1129 
1130  //
1131  // 2. Incoming links to the original pages
1132  //
1133  // A->B A2 (A+B currently copied)
1134  // A->C B2
1135  // B->A
1136  // C->A C2->A (C already copied)
1137  $original_lm = ilLMObject::_lookupContObjID($original_id);
1138  $original_type = ilObject::_lookupType($original_lm);
1139 
1140  if ($original_lm != $copy_lm)
1141  {
1142 
1143  // This gets sources that link to A+B (so we have C here)
1144  // (this also does already the trick when instance map areas are given in C)
1145  // int_link, where target_type, target_id, target_inst -> ok
1146  $sources = ilInternalLink::_getSourcesOfTarget($copied_type,
1147  $original_id, 0);
1148 
1149  // mobs linking to $original_id
1150  // map_area, where link_type, target -> ok
1151  $mobs = ilMapArea::_getMobsForTarget("int", "il__".$copied_type.
1152  "_".$original_id);
1153 
1154  // pages using these mobs
1155  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1156  foreach($mobs as $mob)
1157  {
1158  // mob_usage, where id -> ok
1159  // mep_item, where foreign_id, type -> ok
1160  // mep_tree, where child -> already existed
1161  // il_news_item, where mob_id -> ok
1162  // map_area, where link_type, target -> aready existed
1163  // media_item, where id -> already existed
1164  // personal_clipboard, where item_id, type -> ok
1165  $usages = ilObjMediaObject::lookupUsages($mob);
1166  foreach($usages as $usage)
1167  {
1168  if ($usage["type"] == "lm:pg" | $usage["type"] == "lm:st")
1169  {
1170  $sources[] = $usage;
1171  }
1172  }
1173  }
1174  $fix = array();
1175  foreach($sources as $source)
1176  {
1177  $stype = explode(":", $source["type"]);
1178  $source_type = $stype[1];
1179 
1180  if ($source_type == "pg" || $source_type == "st")
1181  {
1182  // first of all: source must be in original lm
1183  $src_lm = ilLMObject::_lookupContObjID($source["id"]);
1184 
1185  if ($src_lm == $original_lm)
1186  {
1187  // check, if a copy if the source is already in the same lm
1188  // now we look for the latest copy of C in LM2
1189  $lm_data = ilLMObject::_getAllObjectsForImportId("il__".$source_type."_".$source["id"],
1190  $copy_lm);
1191  $found = false;
1192  foreach ($lm_data as $item)
1193  {
1194  if (!$found)
1195  {
1196  $fix[$item["obj_id"]][$original_id] = $copied_id;
1197  $found = true;
1198  }
1199  }
1200  }
1201  }
1202  }
1203  // outgoing links to be fixed
1204  if (count($fix) > 0)
1205  {
1206  foreach ($fix as $page_id => $fix_array)
1207  {
1208  $t = ilObject::_lookupType($copy_lm);
1209  if (is_array($all_fixes[$t.":".$page_id]))
1210  {
1211  $all_fixes[$t.":".$page_id] += $fix_array;
1212  }
1213  else
1214  {
1215  $all_fixes[$t.":".$page_id] = $fix_array;
1216  }
1217 
1218  }
1219  }
1220  }
1221  }
1222  }
1223 
1224  foreach ($all_fixes as $pg => $fixes)
1225  {
1226  $pg = explode(":", $pg);
1227  include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
1228  $page = ilPageObjectFactory::getInstance($pg[0], $pg[1]);
1229  if ($page->moveIntLinks($fixes))
1230  {
1231  $page->update(true, true);
1232  }
1233  }
1234  }
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
lookupUsages($a_id, $a_include_history=true)
Lookup usages of media object.
$mobs
_lookupContObjID($a_id)
get learning module / digibook id for lm object
static _getMobsForTarget($a_type, $a_target)
Get areas for a certain target.
_getAllObjectsForImportId($a_import_id, $a_in_lm=0)
Get all items for an import ID.
static _lookupType($a_id, $a_reference=false)
lookup object type
static getInstance($a_parent_type, $a_id=0, $a_old_nr=0, $a_lang="-")
Get page object instance.
Extension of ilPageObject for learning modules.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateMetaData()

ilLMObject::updateMetaData ( )

update meta data entry

Definition at line 137 of file class.ilLMObject.php.

References getId(), getLMId(), getTitle(), and getType().

Referenced by update().

138  {
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");
142 
143  $md =& new ilMD($this->getLMId(), $this->getId(), $this->getType());
144  $md_gen =& $md->getGeneral();
145  $md_gen->setTitle($this->getTitle());
146 
147  // sets first description (maybe not appropriate)
148  $md_des_ids =& $md_gen->getDescriptionIds();
149  if (count($md_des_ids) > 0)
150  {
151  $md_des =& $md_gen->getDescription($md_des_ids[0]);
152 // $md_des->setDescription($this->getDescription());
153  $md_des->update();
154  }
155  $md_gen->update();
156 
157  }
getTitle()
get title of lm object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeLayout()

static ilLMObject::writeLayout (   $a_obj_id,
  $a_layout,
  $a_lm = null 
)
static

Write layout setting.

Parameters
intlm object id
stringlayout

Definition at line 1264 of file class.ilLMObject.php.

References $query, $t, and _lookupType().

Referenced by ilLMPageObjectGUI\saveLayout(), ilStructureObjectGUI\savePageLayout(), and ilObjContentObjectGUI\savePageLayout().

1265  {
1266  global $ilDB;
1267 
1268  $t = ilLMObject::_lookupType($a_obj_id);
1269 
1270  if ($t == "pg")
1271  {
1272  $query = "UPDATE lm_data SET ".
1273  " layout = ".$ilDB->quote($a_layout, "text").
1274  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
1275  $ilDB->manipulate($query);
1276  }
1277  else if ($t == "st" && is_object($a_lm))
1278  {
1279  $node = $a_lm->getLMTree()->getNodeData($a_obj_id);
1280  $child_nodes = $a_lm->getLMTree()->getSubTree($node);
1281  if (is_array($child_nodes) && count($child_nodes) > 0)
1282  {
1283  foreach ($child_nodes as $c)
1284  {
1285  if ($c["type"] == "pg")
1286  {
1287  $query = "UPDATE lm_data SET ".
1288  " layout = ".$ilDB->quote($a_layout, "text").
1289  " WHERE obj_id = ".$ilDB->quote($c["child"], "integer");
1290  $ilDB->manipulate($query);
1291  }
1292  }
1293  }
1294  }
1295  }
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active

ilLMObject::$active = true

Definition at line 28 of file class.ilLMObject.php.

Referenced by ilLMPageObject\_getPresentationTitle().

◆ $content_object

ilLMObject::$content_object

Definition at line 25 of file class.ilLMObject.php.

Referenced by getContentObject().

◆ $data_record

ilLMObject::$data_record

Definition at line 24 of file class.ilLMObject.php.

◆ $data_records

ilLMObject::$data_records = array()
staticprotected

Definition at line 29 of file class.ilLMObject.php.

◆ $description

ilLMObject::$description

Definition at line 27 of file class.ilLMObject.php.

Referenced by getDescription().

◆ $id

ilLMObject::$id

Definition at line 22 of file class.ilLMObject.php.

Referenced by _lookupNID(), clipboardCut(), getId(), MDUpdateListener(), and saveTitles().

◆ $ilias

ilLMObject::$ilias

Definition at line 19 of file class.ilLMObject.php.

Referenced by ilLMObject(), and pasteTree().

◆ $lm_id

◆ $meta_data

ilLMObject::$meta_data

Definition at line 23 of file class.ilLMObject.php.

◆ $title

◆ $type

ilLMObject::$type

The documentation for this class was generated from the following file: