Public Member Functions | Static Public Member Functions | Data Fields

ilLMObject Class Reference

Inheritance diagram for ilLMObject:

Public Member Functions

 ilLMObject (&$a_content_obj, $a_id=0)
 setDataRecord ($a_record)
 this method should only be called by class ilLMObjectFactory
 read ()
 setTitle ($a_title)
 getTitle ()
 _lookupTitle ($a_obj_id)
 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)
 create ($a_upload=false)
 assignMetaData (&$a_meta_data)
getMetaData ()
 updateMetaData ()
 update meta data of object and lm_data table
 update ()
 update complete object
 _isPagePublic ($a_node_id, $a_check_public_mode=false)
 delete ($a_delete_meta_data=true)
 delete lm object data
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _exists ($a_id)
 checks wether a lm content object with specified id exists or not
 getObjectList ($lm_id, $type="")
 static
 _deleteAllObjectData (&$a_cobj)
 delete all objects of content object (digi book / learning module)
 _lookupContObjID ($a_id)
 get learning module / digibook id for lm object

Static Public Member Functions

 _writePublicAccessStatus ($a_pages, $a_cont_obj_id)
 update public access flags in lm_data for all pages of a content object

Data Fields

 $ilias
 $lm_id
 $type
 $id
 $meta_data
 $data_record
 $content_object
 $title
 $description

Detailed Description

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


Member Function Documentation

ilLMObject::_deleteAllObjectData ( &$  a_cobj  ) 

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

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

References $query, ilNestedSetXML::_deleteAllChildMetaData(), ilNestedSetXML::_getAllChildIds(), and ilLMObjectFactory::getInstance().

Referenced by ilObjContentObject::delete().

        {
                include_once './classes/class.ilNestedSetXML.php';

                $page_ids = ilNestedSetXML::_getAllChildIds($a_cobj->getId());

                $query = "SELECT * FROM lm_data ".
                        "WHERE lm_id= '".$a_cobj->getId()."'";
                $obj_set = $this->ilias->db->query($query);

                require_once("content/classes/class.ilLMObjectFactory.php");
                while($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $lm_obj =& ilLMObjectFactory::getInstance($a_cobj, $obj_rec["obj_id"],false);

                        if (is_object($lm_obj))
                        {
                                $lm_obj->delete(false);
                        }
                }
                ilNestedSetXML::_deleteAllChildMetaData($page_ids);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLMObject::_exists ( a_id  ) 

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

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

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

References $q, and ilInternalLink::_extractObjIdOfTarget().

        {
                global $ilDB;
                
                include_once("content/classes/Pages/class.ilInternalLink.php");
                if (is_int(strpos($a_id, "_")))
                {
                        $a_id = ilInternalLink::_extractObjIdOfTarget($a_id);
                }
                
                $q = "SELECT * FROM lm_data WHERE obj_id = '".$a_id."'";
                $obj_set = $ilDB->query($q);
                if ($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        return true;
                }
                else
                {
                        return false;
                }

        }

Here is the call graph for this function:

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_id import id
Returns:
int id

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

References $lm_id, $q, ilObject::_hasUntrashedReference(), and _lookupContObjID().

Referenced by SurveyQuestion::_resolveInternalLink(), and ASS_Question::_resolveInternalLink().

        {
                global $ilDB;
                
                $q = "SELECT * FROM lm_data WHERE import_id = '".$a_import_id."'".
                        " ORDER BY create_date DESC LIMIT 1";
                $obj_set = $ilDB->query($q);
                while ($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $lm_id = ilLMObject::_lookupContObjID($obj_rec["obj_id"]);

                        // link only in learning module, that is not trashed
                        if (ilObject::_hasUntrashedReference($lm_id))
                        {
                                return $obj_rec["obj_id"];
                        }
                }

                return 0;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLMObject::_isPagePublic ( a_node_id,
a_check_public_mode = false 
)

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

References $ilLog, $lm_id, $q, $row, and ilUtil::yn2tf().

Referenced by ilPublicSectionSelector::formatObject(), ilLMPresentationGUI::getCurrentPageId(), ilLMPresentationGUI::ilLMNavigation(), ilLMPresentationGUI::ilPage(), ilLMExplorer::isClickable(), ilLMPresentationGUI::showPrintView(), and ilLMPresentationGUI::showPrintViewSelection().

        {
                global $ilDB,$ilLog;

                if (empty($a_node_id))
                {
                        $message = sprintf('ilLMObject::_isPagePublic(): Invalid parameter! $a_node_id is empty');
                        $ilLog->write($message,$ilLog->WARNING);
                        return false;
                }
                
                if ($a_check_public_mode === true)
                {
                        $lm_id = ilLMObject::_lookupContObjId($a_node_id);

                        $q = "SELECT public_access_mode FROM content_object WHERE id=".$ilDB->quote($lm_id);
                        $r = $ilDB->query($q);
                        $row = $r->fetchRow();
                        
                        if ($row[0] == "complete")
                        {
                                return true;
                        }
                }

                $q = "SELECT public_access FROM lm_data WHERE obj_id=".$ilDB->quote($a_node_id);
                $r = $ilDB->query($q);
                $row = $r->fetchRow();
                
                return ilUtil::yn2tf($row[0]);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLMObject::_lookupContObjID ( a_id  ) 

get learning module / digibook id for lm object

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

References $query.

Referenced by _getIdForImportId(), ilStructureObject::_goto(), ilLMPageObject::_goto(), ilLMPageObject::_splitPage(), ilLMPageObject::_splitPageNext(), ilLMPresentationGUI::getLinkXML(), ilLMPageObjectGUI::getLinkXML(), ilGlossaryPresentationGUI::getLinkXML(), ilStructureObjectGUI::pastePage(), ilObjContentObjectGUI::pastePage(), and SurveyQuestion::setMaterial().

        {
                global $ilDB;

                $query = "SELECT * FROM lm_data WHERE obj_id = '".$a_id."'";
                $obj_set = $ilDB->query($query);
                $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);

                return $obj_rec["lm_id"];
        }

Here is the caller graph for this function:

ilLMObject::_lookupTitle ( a_obj_id  ) 

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

References $query.

Referenced by ilStructureObjectGUI::cutPage(), ilObjMediaObjectGUI::getMapAreaLinkString(), ilStructureObjectGUI::pastePage(), ilObjContentObjectGUI::proceedDragDrop(), ilLMPresentationGUI::showPreconditionsOfPage(), and ilObjMediaObjectGUI::showUsagesObject().

        {
                global $ilDB;

                $query = "SELECT * FROM lm_data WHERE obj_id = '".$a_obj_id."'";
                $obj_set = $ilDB->query($query);
                $obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);

                return $obj_rec["title"];
        }

Here is the caller graph for this function:

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:
array page ids
integer content object id
Returns:
of the jedi

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

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

Referenced by ilObjContentObjectGUI::savePublicSection().

        {
                global $ilDB,$ilLog,$ilErr,$ilTree;
                
                if (!is_array($a_pages))
                {$a_pages = array(0);
                        /*$message = sprintf('ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_pages must be an array');
                        $ilLog->write($message,$ilLog->WARNING);
                        $ilErr->raiseError($message,$ilErr->MESSAGE);
                        return false;*/
                }
                
                if (empty($a_cont_obj_id))
                {
                        $message = sprintf('ilLMObject::_writePublicAccessStatus(): Invalid parameter! $a_cont_obj_id is empty');
                        $ilLog->write($message,$ilLog->WARNING);
                        $ilErr->raiseError($message,$ilErr->MESSAGE);
                        return false;
                }
                
                // update structure entries: if at least one page of a chapter is public set chapter to public too
                $lm_tree = new ilTree($a_cont_obj_id);
                $lm_tree->setTableNames('lm_tree','lm_data');
                $lm_tree->setTreeTablePK("lm_id");
                $lm_tree->readRootId();
                
                // get all st entries of cont_obj
                $q = "SELECT obj_id FROM lm_data " . 
                         "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id)." " .
                         "AND type = 'st'";
                $r = $ilDB->query($q);
                
                // add chapters with a public page to a_pages
                while ($row = $r->fetchRow())
                {
                        $childs = $lm_tree->getChilds($row[0]);
                        
                        foreach ($childs as $page)
                        {
                                if ($page["type"] == "pg" and in_array($page["obj_id"],$a_pages))
                                {
                                        array_push($a_pages, $row[0]);
                                        break;
                                }
                        }
                }
                
                // update public access status of all pages of cont_obj
                $q = "UPDATE lm_data SET " .
                         "public_access = CASE " .
                         "WHEN obj_id IN (".implode(',',$a_pages).") " .
                         "THEN 'y' ".
                         "ELSE 'n' ".
                         "END " .
                         "WHERE lm_id = ".$ilDB->quote($a_cont_obj_id)." " .
                         "AND type IN ('pg','st')";
                $ilDB->query($q);
                
                return true;
        }

Here is the caller graph for this function:

ilLMObject::assignMetaData ( &$  a_meta_data  ) 

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

        {
                $this->meta_data =& $a_meta_data;
        }

ilLMObject::create ( a_upload = false  ) 

Reimplemented in ilLMPageObject, and ilStructureObject.

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

References $query, ilHistory::_createEntry(), getDescription(), getId(), getImportId(), getLMId(), getTitle(), getType(), and setId().

        {
                // insert object data
                $query = "INSERT INTO lm_data (title, type, lm_id, import_id, create_date) ".
                        "VALUES ('".ilUtil::prepareDBString($this->getTitle())."','".$this->getType()."', ".$this->getLMId().",'".$this->getImportId().
                        "', now())";
                $this->ilias->db->query($query);
                $this->setId($this->ilias->db->getLastInsertId());
                
                // create history entry
                include_once("classes/class.ilHistory.php");
                ilHistory::_createEntry($this->getId(), "create", "",
                        $this->content_object->getType().":pg");

                if (!$a_upload)
                {
                        // create meta data
                        $this->meta_data->setId($this->getId());
                        $this->meta_data->setType($this->getType());
                        $this->meta_data->setTitle($this->getTitle());
                        $this->meta_data->setDescription($this->getDescription());
                        $this->meta_data->setObject($this);
                        $this->meta_data->create();
                }
        }

Here is the call graph for this function:

ilLMObject::delete ( a_delete_meta_data = true  ) 

delete lm object data

Reimplemented in ilLMPageObject, and ilStructureObject.

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

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

        {
                if ($a_delete_meta_data)
                {
                        /* Delete meta data in nested set table for given object and type */
                        $nested = new ilNestedSetXML();
                        $nested->init($this->getId(), $this->getType());
                        $nested->deleteAllDBData();
                }
                $query = "DELETE FROM lm_data WHERE obj_id= '".$this->getId()."'";
                $this->ilias->db->query($query);
        }

Here is the call graph for this function:

& ilLMObject::getContentObject (  ) 

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

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

        {
                return $this->content_object;
        }

Here is the caller graph for this function:

ilLMObject::getDescription (  ) 

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

Referenced by ilStructureObject::copy(), ilLMPageObject::copy(), ilLMPageObject::copyToOtherContObject(), and create().

        {
                return $this->description ? $this->description : $this->meta_data->getDescription();
        }

Here is the caller graph for this function:

ilLMObject::getId (  ) 
ilLMObject::getImportId (  ) 

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

Referenced by create().

        {
                return $this->meta_data->getImportIdentifierEntryID();
        }

Here is the caller graph for this function:

ilLMObject::getLMId (  ) 

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

Referenced by ilStructureObject::copy(), ilLMPageObject::copy(), ilLMPageObject::create(), create(), and update().

        {
                return $this->lm_id;
        }

Here is the caller graph for this function:

& ilLMObject::getMetaData (  ) 

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

        {
                return $this->meta_data;
        }

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

static

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

References $query, and $type.

Referenced by ilLMPageObject::getPageList().

        {
                $type_str = ($type != "")
                        ? "AND type = '$type' "
                        : "";
                $query = "SELECT * FROM lm_data ".
                        "WHERE lm_id= '".$lm_id."'".
                        $type_str." ".
                        "ORDER BY title";
                $obj_set = $this->ilias->db->query($query);
                $obj_list = array();
                while($obj_rec = $obj_set->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $obj_list[] = array("obj_id" => $obj_rec["obj_id"],
                                                                "title" => $obj_rec["title"],
                                                                "type" => $obj_rec["type"]);
                }
                return $obj_list;
        }

Here is the caller graph for this function:

ilLMObject::getTitle (  ) 

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

Referenced by ilStructureObject::copy(), ilLMPageObject::copy(), ilLMPageObject::copyToOtherContObject(), create(), ilStructureObject::exportFO(), and updateMetaData().

        {
                return $this->title ? $this->title : $this->meta_data->getTitle();
        }

Here is the caller graph for this function:

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

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

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

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

        {
                global $ilias;

                $this->ilias =& $ilias;
                $this->id = $a_id;
                $this->setContentObject($a_content_obj);
                $this->setLMId($a_content_obj->getId());
                if($a_id != 0)
                {
                        $this->read();
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLMObject::read (  ) 

Reimplemented in ilLMPageObject.

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

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

Referenced by ilLMObject().

        {
                global $ilBench;

                $ilBench->start("ContentPresentation", "ilLMObject_read");

                if(!isset($this->data_record))
                {
                        $ilBench->start("ContentPresentation", "ilLMObject_read_getData");
                        $query = "SELECT * FROM lm_data WHERE obj_id = '".$this->id."'";
                        $obj_set = $this->ilias->db->query($query);
                        $this->data_record = $obj_set->fetchRow(DB_FETCHMODE_ASSOC);
                        $ilBench->stop("ContentPresentation", "ilLMObject_read_getData");
                }

                $this->type = $this->data_record["type"];
                $ilBench->start("ContentPresentation", "ilLMObject_read_getMeta");
                $this->meta_data =& new ilMetaData($this->type, $this->id);
                $ilBench->stop("ContentPresentation", "ilLMObject_read_getMeta");
                $this->setImportId($this->data_record["import_id"]);
                $this->setTitle($this->data_record["title"]);

                $ilBench->stop("ContentPresentation", "ilLMObject_read");
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLMObject::setContentObject ( &$  a_content_obj  ) 

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

Referenced by ilLMObject().

        {
                $this->content_object =& $a_content_obj;
        }

Here is the caller graph for this function:

ilLMObject::setDataRecord ( a_record  ) 

this method should only be called by class ilLMObjectFactory

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

        {
                $this->data_record = $a_record;
        }

ilLMObject::setDescription ( a_description  ) 

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

Referenced by updateMetaData().

        {
                $this->meta_data->setDescription($a_description);
                $this->description = $a_description;
        }

Here is the caller graph for this function:

ilLMObject::setId ( a_id  ) 

Reimplemented in ilLMPageObject.

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

Referenced by create().

        {
                $this->id = $a_id;
        }

Here is the caller graph for this function:

ilLMObject::setImportId ( a_id  ) 

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

Referenced by read().

        {
                $this->meta_data->setImportIdentifierEntryID($a_id);
        }

Here is the caller graph for this function:

ilLMObject::setLMId ( a_lm_id  ) 

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

Referenced by ilLMObject().

        {
                $this->lm_id = $a_lm_id;

        }

Here is the caller graph for this function:

ilLMObject::setTitle ( a_title  ) 

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

Referenced by read(), and updateMetaData().

        {
                $this->meta_data->setTitle($a_title);
                $this->title = $a_title;
        }

Here is the caller graph for this function:

ilLMObject::setType ( a_type  ) 

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

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

        {
                $this->type = $a_type;
        }

Here is the caller graph for this function:

ilLMObject::update (  ) 

update complete object

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

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

        {
                global $ilDB;

                $query = "UPDATE lm_data SET ".
                        " lm_id = ".$ilDB->quote($this->getLMId()).
                        " WHERE obj_id = ".$ilDB->quote($this->getId());
                $ilDB->query($query);

                $this->updateMetaData();

        }

Here is the call graph for this function:

ilLMObject::updateMetaData (  ) 

update meta data of object and lm_data table

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

References $query, getId(), getTitle(), setDescription(), and setTitle().

Referenced by update().

        {
                global $ilDB;

//$f = fopen("/opt/iliasdata/bb.txt", "a"); fwrite($f, "LMObject::updateMetaData(), start\n"); fclose($f);

                //$this->meta_data->update();
                if ($this->meta_data->section != "General")
                {
                        $meta = $this->meta_data->getElement("Title", "General");
                        $this->title = $meta[0]["Value"];
                        $meta = $this->meta_data->getElement("Description", "General");
                        $this->description = $meta[0]["Value"];
                }
                else
                {
                        $this->setTitle($this->meta_data->getTitle());
                        $this->setDescription($this->meta_data->getDescription());
                }
                $query = "UPDATE lm_data SET ".
                        " title = ".$ilDB->quote($this->getTitle()).
                        ", last_update = now() WHERE obj_id = ".$ilDB->quote($this->getId());

                $this->ilias->db->query($query);
                $this->meta_data->update();
//$f = fopen("/opt/iliasdata/bb.txt", "a"); fwrite($f, "LMObject::updateMetaData(), end\n"); fclose($f);
        }

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

ilLMObject::$content_object

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

ilLMObject::$data_record

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

ilLMObject::$description

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

ilLMObject::$id

Reimplemented in ilLMPageObject.

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

ilLMObject::$ilias

Reimplemented in ilLMPageObject.

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

Referenced by ilLMObject().

ilLMObject::$lm_id
ilLMObject::$meta_data

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

ilLMObject::$title

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

Referenced by ilLMPageObject::exportFO().

ilLMObject::$type

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