Public Member Functions | Data Fields

ilObjectDefinition Class Reference

parses the objects.xml it handles the xml-description of all ilias objects More...

Inheritance diagram for ilObjectDefinition:
Collaboration diagram for ilObjectDefinition:

Public Member Functions

 ilObjectDefinition ()
 Constructor.
 getDefinition ($a_obj_name)
 get object definition by type
 getClassName ($a_obj_name)
 get class name by type
 getLocation ($a_obj_name)
 get location by type
 getModule ($a_obj_name)
 get module by type
 hasCheckbox ($a_obj_name)
 should the object get a checkbox (needed for 'cut','copy' ...)
 getTranslationType ($a_obj_name)
 get translation type (sys, db or 0)s
 stopInheritance ($a_obj_name)
 Does object permits stopping inheritance?
 getProperties ($a_obj_name)
 get properties by type
 getDevMode ($a_obj_name)
 get devmode status by type
 getDevModeAll ()
 get all object types in devmode
 isRBACObject ($a_obj_name)
 get RBAC status by type returns true if object type is a RBAC object type
 getAllRBACObjects ()
 get all RBAC object types
 getAllObjects ()
 get all object types
 allowLink ($a_obj_name)
 checks if linking of an object type is allowed
 allowCopy ($a_obj_name)
 checks if copying of an object type is allowed
 getContentItemSortingModes ($a_obj_name)
 get content item sorting modes
 getSubObjects ($a_obj_type, $a_filter=true)
 get all subobjects by type
 getSubObjectsRecursively ($a_obj_type)
 Get all subobjects by type.
 getSubobjectsToFilter ($a_obj_type="adm")
 get all subjects except (rolf) of the adm object This is neceesary for filtering these objects in role perm view.
 getCreatableSubObjects ($a_obj_type)
 get only creatable subobjects by type
 getActions ($a_obj_name)
 get possible actions by type
 getFirstProperty ($a_obj_name)
 get default property by type
 getPropertyName ($a_cmd, $a_obj_name)
 get name of property by type
 getSubObjectsAsString ($a_obj_type)
 get a string of all subobjects by type
 getImportObjects ($a_obj_type)
 get all subobjects that may be imported
 isContainer ($a_obj_name)
 Check if object type is container ('crs','fold','grp' ...).
 setHandlers ($a_xml_parser)
 set event handler
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 start tag handler
 handlerCharacterData ($a_xml_parser, $a_data)
 end tag handler
 handlerEndTag ($a_xml_parser, $a_name)
 end tag handler
 __filterObjects (&$subobjects)
 isSystemObject ($a_obj_name)
 checks if object type is a system object
 isSideBlock ($a_obj_name)
 Check, whether object type is a side block.

Data Fields

 $obj_id
 $parent
 $obj_data

Detailed Description

parses the objects.xml it handles the xml-description of all ilias objects

Author:
Stefan Meyer <smeyer>
Version:
Id:
class.ilObjectDefinition.php 15634 2007-12-21 08:54:08Z smeyer

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


Member Function Documentation

ilObjectDefinition::__filterObjects ( &$  subobjects  ) 

Definition at line 707 of file class.ilObjectDefinition.php.

References $data.

Referenced by getSubObjects().

        {
                foreach($subobjects as $type => $data)
                {
                        switch($type)
                        {
                                case "chat":
                                        if(!$this->ilias->getSetting("chat_active"))
                                        {
                                                unset($subobjects[$type]);
                                        }
                                        break;

                                case "icrs":
                                        if(!$this->ilias->getSetting("ilinc_active"))
                                        {
                                                unset($subobjects[$type]);
                                        }
                                        break;                                  

                                default:
                                        // DO NOTHING
                        }
                }
        }

Here is the caller graph for this function:

ilObjectDefinition::allowCopy ( a_obj_name  ) 

checks if copying of an object type is allowed

Parameters:
string object type public

Definition at line 309 of file class.ilObjectDefinition.php.

        {
                return (bool) $this->obj_data[$a_obj_name]["allow_copy"];
        }

ilObjectDefinition::allowLink ( a_obj_name  ) 

checks if linking of an object type is allowed

Parameters:
string object type public

Definition at line 298 of file class.ilObjectDefinition.php.

        {
                return (bool) $this->obj_data[$a_obj_name]["allow_link"];
        }

ilObjectDefinition::getActions ( a_obj_name  ) 

get possible actions by type

Parameters:
string object type public

Definition at line 476 of file class.ilObjectDefinition.php.

References $ret.

        {
                $ret = (is_array($this->obj_data[$a_obj_name]["actions"])) ?
                        $this->obj_data[$a_obj_name]["actions"] :
                        array();
                return $ret;
        }

ilObjectDefinition::getAllObjects (  ) 

get all object types

public

Returns:
array object types

Definition at line 287 of file class.ilObjectDefinition.php.

        {
                return array_keys($this->obj_data);
        }

ilObjectDefinition::getAllRBACObjects (  ) 

get all RBAC object types

public

Returns:
array object types set to development

Definition at line 266 of file class.ilObjectDefinition.php.

References isRBACObject().

        {
                $types = array_keys($this->obj_data);
                
                foreach ($types as $type)
                {
                        if ($this->isRBACObject($type))
                        {
                                $rbactypes[] = $type;
                        }
                }

                return $rbactypes ? $rbactypes : array();
        }

Here is the call graph for this function:

ilObjectDefinition::getClassName ( a_obj_name  ) 

get class name by type

Parameters:
string object type public

Definition at line 88 of file class.ilObjectDefinition.php.

        {
                return $this->obj_data[$a_obj_name]["class_name"];
        }

ilObjectDefinition::getContentItemSortingModes ( a_obj_name  ) 

get content item sorting modes

public

Parameters:
 

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

        {
                if(isset($this->obj_data[$a_obj_name]['sorting']))
                {
                        return $this->obj_data[$a_obj_name]['sorting']['modes'] ? $this->obj_data[$a_obj_name]['sorting']['modes'] : array(); 
                }
                return array();
        }

ilObjectDefinition::getCreatableSubObjects ( a_obj_type  ) 

get only creatable subobjects by type

Parameters:
string object type public
Returns:
array list of createable object types

Definition at line 449 of file class.ilObjectDefinition.php.

References getDevMode(), and getSubObjects().

        {
                $subobjects = $this->getSubObjects($a_obj_type);

                // remove role folder object from list 
                unset($subobjects["rolf"]);
                
                $sub_types = array_keys($subobjects);

                // remove object types in development from list
                foreach ($sub_types as $type)
                {
                        if ($this->getDevMode($type))
                        {
                                unset($subobjects[$type]);
                        }
                }

                return $subobjects;
        }

Here is the call graph for this function:

ilObjectDefinition::getDefinition ( a_obj_name  ) 

get object definition by type

Parameters:
string object type public

Definition at line 77 of file class.ilObjectDefinition.php.

        {
                return $this->obj_data[$a_obj_name];
        }

ilObjectDefinition::getDevMode ( a_obj_name  ) 

get devmode status by type

Parameters:
string object type public

Definition at line 222 of file class.ilObjectDefinition.php.

Referenced by getCreatableSubObjects(), and getDevModeAll().

        {
                return (bool) $this->obj_data[$a_obj_name]["devmode"];
        }

Here is the caller graph for this function:

ilObjectDefinition::getDevModeAll (  ) 

get all object types in devmode

public

Returns:
array object types set to development

Definition at line 233 of file class.ilObjectDefinition.php.

References getDevMode().

        {
                $types = array_keys($this->obj_data);
                
                foreach ($types as $type)
                {
                        if ($this->getDevMode($type))
                        {
                                $devtypes[] = $type;
                        }
                }

                return $devtypes ? $devtypes : array();
        }

Here is the call graph for this function:

ilObjectDefinition::getFirstProperty ( a_obj_name  ) 

get default property by type

Parameters:
string object type public

Definition at line 490 of file class.ilObjectDefinition.php.

References $data.

        {
                if (defined("ILIAS_MODULE"))
                {
                        foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
                        {
                                if($prop["module"] != "n")
                                {
                                        return $data;
                                }
                        }
                }
                else
                {
                        foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
                        {
                                if ($prop["module"] != 1)
                                {
                                        return $data;
                                }
                        }
                }
        }

ilObjectDefinition::getImportObjects ( a_obj_type  ) 

get all subobjects that may be imported

Parameters:
string object type public

Definition at line 551 of file class.ilObjectDefinition.php.

        {
                $imp = array();

                if (is_array($this->obj_data[$a_obj_type]["subobjects"]))
                {
                        foreach ($this->obj_data[$a_obj_type]["subobjects"] as $sub)
                        {
                                if ($sub["import"] == 1)
                                {
                                        $imp[] = $sub["name"];
                                }
                        }
                }

                return $imp;
        }

ilObjectDefinition::getLocation ( a_obj_name  ) 

get location by type

Parameters:
string object type public

Definition at line 100 of file class.ilObjectDefinition.php.

        {
                return $this->obj_data[$a_obj_name]["location"];
        }

ilObjectDefinition::getModule ( a_obj_name  ) 

get module by type

Parameters:
string object type public

Definition at line 112 of file class.ilObjectDefinition.php.

        {
                return $this->obj_data[$a_obj_name]["module"];
        }

ilObjectDefinition::getProperties ( a_obj_name  ) 

get properties by type

Parameters:
string object type public

Definition at line 180 of file class.ilObjectDefinition.php.

References $_GET, and $data.

        {
                // dirty hack, has to be implemented better, if ilias.php
                // is established
                if (defined("ILIAS_MODULE") || $_GET["baseClass"] != "")
                {
                        $props = array();
                        if (is_array($this->obj_data[$a_obj_name]["properties"]))
                        {
                                foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
                                {
                                        if ($prop["module"] != "n")
                                        {
                                                $props[$data] = $prop;
                                        }
                                }
                        }
                        return $props;
                }
                else
                {
                        $props = array();
                        if (is_array($this->obj_data[$a_obj_name]["properties"]))
                        {
                                foreach ($this->obj_data[$a_obj_name]["properties"] as $data => $prop)
                                {
                                        if ($prop["module"] != 1)
                                        {
                                                $props[$data] = $prop;
                                        }
                                }
                        }
                        return $props;
                }
        }

ilObjectDefinition::getPropertyName ( a_cmd,
a_obj_name 
)

get name of property by type

Parameters:
string object type public

Definition at line 520 of file class.ilObjectDefinition.php.

        {
                return $this->obj_data[$a_obj_name]["properties"][$a_cmd]["lng"];
        }

ilObjectDefinition::getSubObjects ( a_obj_type,
a_filter = true 
)

get all subobjects by type

Parameters:
string object type
boolean filter disabled objects? (default: true) public
Returns:
array list of allowed object types

Definition at line 338 of file class.ilObjectDefinition.php.

References $data, and __filterObjects().

Referenced by getCreatableSubObjects(), and getSubObjectsRecursively().

        {
                $subs = array();

                if ($subobjects = $this->obj_data[$a_obj_type]["subobjects"])
                {
                        // Filter some objects e.g chat object are creatable if chat is active
                        if ($a_filter)
                        {
                                $this->__filterObjects($subobjects);
                        }

                        foreach ($subobjects as $data => $sub)
                        {
                                if ($sub["module"] != "n")
                                {
                                        $subs[$data] = $sub;
                                }
                        }

                        return $subs;
                }

                return $subs;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjectDefinition::getSubObjectsAsString ( a_obj_type  ) 

get a string of all subobjects by type

Parameters:
string object type public

Definition at line 531 of file class.ilObjectDefinition.php.

References $data.

        {
                $string = "";

                if (is_array($this->obj_data[$a_obj_type]["subobjects"]))
                {
                        $data = array_keys($this->obj_data[$a_obj_type]["subobjects"]);

                        $string = "'".implode("','", $data)."'";
                }
                
                return $string;
        }

ilObjectDefinition::getSubObjectsRecursively ( a_obj_type  ) 

Get all subobjects by type.

This function returns all subobjects allowed by the provided object type and all its subobject types recursively.

This function is used to create local role templates. It is important, that we do not filter out any objects here!

Parameters:
string object type public
Returns:
array list of allowed object types

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

References $data, and getSubObjects().

        {
                // This associative array is used to collect all subobject types.
                // key=>type, value=data
                $recursivesubs = array();

                // This array is used to keep track of the object types, we
                // need to call function getSubobjects() for.
                $to_do = array($a_obj_type);

                // This array is used to keep track of the object types, we
                // have called function getSubobjects() already. This is to
                // prevent endless loops, for object types that support 
                // themselves as subobject types either directly or indirectly.
                $done = array();

                while (count($to_do) > 0)
                {
                        $type = array_pop($to_do);
                        $done[] = $type;
                        $subs = $this->getSubObjects($type);
                        foreach ($subs as $subtype => $data)
                        {
                                $recursivesubs[$subtype] = $data;
                                if (! in_array($subtype, $done)
                                && ! in_array($subtype, $to_do))
                                {
                                        $to_do[] = $subtype;
                                }
                        }
                }

                return $recursivesubs;
        }

Here is the call graph for this function:

ilObjectDefinition::getSubobjectsToFilter ( a_obj_type = "adm"  ) 

get all subjects except (rolf) of the adm object This is neceesary for filtering these objects in role perm view.

e.g It it not necessary to view/edit role permission for the usrf object since it's not possible to create a new one

Parameters:
string object type public
Returns:
array list of object types to filter

Definition at line 421 of file class.ilObjectDefinition.php.

        {
                foreach($this->obj_data[$a_obj_type]["subobjects"] as $key => $value)
                {
                        switch($key)
                        {
                                case "rolf":
                                        // DO NOTHING
                                        break;

                                default:
                                        $tmp_subs[] = $key;
                        }
                }
                // ADD adm and root object
                $tmp_subs[] = "adm";
                #$tmp_subs[] = "root";

                return $tmp_subs ? $tmp_subs : array();
        }

ilObjectDefinition::getTranslationType ( a_obj_name  ) 

get translation type (sys, db or 0)s

Parameters:
string object type public

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

        {
                global $ilDB;
                
                if ($a_obj_name == "root")
                {
                        if (!isset($this->root_trans_type))
                        {
                                $q = "SELECT count(*) as cnt FROM object_translation WHERE obj_id = ".
                                        $ilDB->quote(ROOT_FOLDER_ID);
                                $set = $ilDB->query($q);
                                $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
                                if($rec["cnt"] > 0)
                                {
                                        $this->root_trans_type = "db";
                                }
                                else
                                {
                                        $this->root_trans_type = $this->obj_data[$a_obj_name]["translate"];
                                }
                        }
                        return $this->root_trans_type;
                }
                
                return $this->obj_data[$a_obj_name]["translate"];
        }

ilObjectDefinition::handlerBeginTag ( a_xml_parser,
a_name,
a_attribs 
)

start tag handler

Parameters:
ressouce internal xml_parser_handler
string element tag name
array element attributes private

Definition at line 609 of file class.ilObjectDefinition.php.

        {
                switch ($a_name)
                {
                        case 'objects':
                                $this->current_tag = '';
                                break;
                        case 'object':
                                $this->parent_tag_name = $a_attribs["name"];
                                $this->current_tag = '';
                                $this->obj_data["$a_attribs[name]"]["name"] = $a_attribs["name"];
                                $this->obj_data["$a_attribs[name]"]["class_name"] = $a_attribs["class_name"];
                                $this->obj_data["$a_attribs[name]"]["location"] = $a_attribs["location"];
                                $this->obj_data["$a_attribs[name]"]["checkbox"] = $a_attribs["checkbox"];
                                $this->obj_data["$a_attribs[name]"]["inherit"] = $a_attribs["inherit"];
                                $this->obj_data["$a_attribs[name]"]["module"] = $a_attribs["module"];
                                $this->obj_data["$a_attribs[name]"]["translate"] = $a_attribs["translate"];
                                $this->obj_data["$a_attribs[name]"]["devmode"] = $a_attribs["devmode"];
                                $this->obj_data["$a_attribs[name]"]["allow_link"] = $a_attribs["allow_link"];
                                $this->obj_data["$a_attribs[name]"]["allow_copy"] = $a_attribs["allow_copy"];
                                $this->obj_data["$a_attribs[name]"]["rbac"] = $a_attribs["rbac"];
                                $this->obj_data["$a_attribs[name]"]["system"] = $a_attribs["system"];
                                $this->obj_data["$a_attribs[name]"]["sideblock"] = $a_attribs["sideblock"];
                                break;
                        case 'subobj':
                                $this->current_tag = "subobj";
                                $this->current_tag_name = $a_attribs["name"];
                                $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["name"] = $a_attribs["name"];
                                // NUMBER OF ALLOWED SUBOBJECTS (NULL means no limit)
                                $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["max"] = $a_attribs["max"];
                                // also allow import ("1" means yes)
                                $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["import"] = $a_attribs["import"];
                                $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["module"] = $a_attribs["module"];
                                break;
                        case 'property':
                                $this->current_tag = "property";
                                $this->current_tag_name = $a_attribs["name"];
                                $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["name"] = $a_attribs["name"];
                                $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["module"] = $a_attribs["module"];
                                break;
                        case 'action':
                                $this->current_tag = "action";
                                $this->current_tag_name = $a_attribs["name"];
                                $this->obj_data[$this->parent_tag_name]["actions"][$this->current_tag_name]["name"] = $a_attribs["name"];
                                break;
                                
                        case 'sorting':
                                $this->current_tag = 'sorting';
                                $this->obj_data[$this->parent_tag_name]['sorting']['modes'][] = $a_attribs['mode'];
                                break;
                }
        }

ilObjectDefinition::handlerCharacterData ( a_xml_parser,
a_data 
)

end tag handler

Parameters:
ressouce internal xml_parser_handler
string data private

Definition at line 669 of file class.ilObjectDefinition.php.

        {
                // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
                $a_data = preg_replace("/\n/","",$a_data);
                $a_data = preg_replace("/\t+/","",$a_data);

                if (!empty($a_data))
                {
                        switch ($this->current_tag)
                        {
                                case "subobj":
                                        $this->obj_data[$this->parent_tag_name]["subobjects"][$this->current_tag_name]["lng"] .= $a_data;
                                        break;
                                case "action" :
                                        $this->obj_data[$this->parent_tag_name]["actions"][$this->current_tag_name]["lng"] .= $a_data;
                                        break;
                                case "property" :
                                        $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["lng"] .= $a_data;
                                        break;
                                default:
                                        break;
                        }
                }
        }

ilObjectDefinition::handlerEndTag ( a_xml_parser,
a_name 
)

end tag handler

Parameters:
ressouce internal xml_parser_handler
string element tag name private

Definition at line 701 of file class.ilObjectDefinition.php.

        {
                $this->current_tag = '';
                $this->current_tag_name = '';
        }

ilObjectDefinition::hasCheckbox ( a_obj_name  ) 

should the object get a checkbox (needed for 'cut','copy' ...)

Parameters:
string object type public

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

        {
                return (bool) $this->obj_data[$a_obj_name]["checkbox"];
        }

ilObjectDefinition::ilObjectDefinition (  ) 

Constructor.

setup ILIAS global object public

Definition at line 64 of file class.ilObjectDefinition.php.

References ilSaxParser::ilSaxParser().

Here is the call graph for this function:

ilObjectDefinition::isContainer ( a_obj_name  ) 

Check if object type is container ('crs','fold','grp' ...).

public

Parameters:
string object type
Returns:
bool

Definition at line 577 of file class.ilObjectDefinition.php.

        {
                if(!is_array($this->obj_data[$a_obj_name]['subobjects']))
                {
                        return false;
                }
                return count($this->obj_data[$a_obj_name]['subobjects']) > 1 ? true : false;
        }

ilObjectDefinition::isRBACObject ( a_obj_name  ) 

get RBAC status by type returns true if object type is a RBAC object type

Parameters:
string object type public

Definition at line 255 of file class.ilObjectDefinition.php.

Referenced by getAllRBACObjects().

        {
                return (bool) $this->obj_data[$a_obj_name]["rbac"];
        }

Here is the caller graph for this function:

ilObjectDefinition::isSideBlock ( a_obj_name  ) 

Check, whether object type is a side block.

Parameters:
string object type
Returns:
boolean side block true/false

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

        {
                return (bool) $this->obj_data[$a_obj_name]["sideblock"];
        }

ilObjectDefinition::isSystemObject ( a_obj_name  ) 

checks if object type is a system object

system objects are those object types that are only used for internal purposes and to keep the object type model consistent. Typically they are used in the administation, exist only once and may contain only specific object types. To mark an object type as a system object type, use 'system=1' in the object definition in objects.xml

Parameters:
string object type public

Definition at line 746 of file class.ilObjectDefinition.php.

        {
                return (bool) $this->obj_data[$a_obj_name]["system"];
        }

ilObjectDefinition::setHandlers ( a_xml_parser  ) 

set event handler

Parameters:
ressouce internal xml_parser_handler private

Reimplemented from ilSaxParser.

Definition at line 594 of file class.ilObjectDefinition.php.

        {
                xml_set_object($a_xml_parser,$this);
                xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
                xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
        }

ilObjectDefinition::stopInheritance ( a_obj_name  ) 

Does object permits stopping inheritance?

Parameters:
string object type public

Definition at line 169 of file class.ilObjectDefinition.php.

        {
                return (bool) $this->obj_data[$a_obj_name]["inherit"];
        }


Field Documentation

ilObjectDefinition::$obj_data

Definition at line 56 of file class.ilObjectDefinition.php.

ilObjectDefinition::$obj_id

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

ilObjectDefinition::$parent

Definition at line 49 of file class.ilObjectDefinition.php.


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