ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjectDefinition.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
14class ilObjectDefinition// extends ilSaxParser
15{
23
30
37
38 var $sub_types = array();
39
40 const MODE_REPOSITORY = 1;
41 const MODE_WORKSPACE = 2;
43
51 {
52 global $ilias;
53
54 $this->readDefinitionData();
55 $this->ilias = $ilias;
56
57 //parent::ilSaxParser(ILIAS_ABSOLUTE_PATH."/objects.xml");
58
59 // removing this line leads to segmentation faults in
60 // learning module editor with
61 // - PHP 5.2.1, libxml 2.6.22, libxslt 1.1.15 (MacOsX)
62 // - PHP 5.2.1, libxml 2.6.31, libxslt 1.1.22 (MacOsX)
63 // - PHP 5.2.5, libxml 2.6.31, libxslt 1.1.22 (MacOsX)
64 // - PHP 5.2.0-8+etch7, libxml 2.6.27, libxslt 1.1.19
65 // - PHP 5.2.0, libxml, libxml 2.6.26, libxslt 1.1.17 (OpenSuse 10.2)
66 // (needs further investigation)
67 // OK with:
68 // - PHP 5.1.2, libxml 2.6.24, libxslt 1.1.15
69
70 //
71 // Replacing all "=&" with "=" in xml5compliance seems to solve the problem
72 //
73
74// $this->startParsing();
75 }
76
77
78 protected function readDefinitionDataFromCache() {
79 global $ilPluginAdmin;
80
81 $this->obj_data = array();
82 $defIds = array();
83 $global_cache = ilCachedComponentData::getInstance();
84 foreach ($global_cache->getIlobjectDef() as $rec) {
85 $this->obj_data[$rec["id"]] = array(
86 "name" => $rec["id"],
87 "class_name" => $rec["class_name"],
88 "location" => $rec["location"],
89 "checkbox" => $rec["checkbox"],
90 "inherit" => $rec["inherit"],
91 "component" => $rec["component"],
92 "translate" => $rec["translate"],
93 "devmode" => $rec["devmode"],
94 "allow_link" => $rec["allow_link"],
95 "allow_copy" => $rec["allow_copy"],
96 "rbac" => $rec["rbac"],
97 "group" => $rec["grp"],
98 "system" => $rec["system"],
99 "default_pos" => "9999" . str_pad($rec["default_pos"], 4, "0", STR_PAD_LEFT), // "unassigned" group
100 "sideblock" => $rec["sideblock"],
101 'export' => $rec['export'],
102 'repository' => $rec['repository'],
103 'workspace' => $rec['workspace'],
104 'administration' => $rec['administration'],
105 'amet' => $rec['amet']
106 );
107 $this->obj_data[$rec["id"]]["subobjects"] = array();
108
109 $defIds[] = $rec["id"];
110 }
111
112 $subobj = $global_cache->lookupSubObjForParent($defIds);
113
114 foreach ($subobj as $rec2) {
115
116 $max = $rec2["mmax"];
117 if ($max <= 0) {
118 $max = "";
119 }
120 $this->obj_data[$rec2["parent"]]["subobjects"][$rec2["subobj"]] = array(
121 "name" => $rec2["subobj"],
122 "max" => $max,
123 "lng" => $rec2["subobj"]
124 );
125 }
126 $this->obj_group = $global_cache->getIlObjectGroup();
127
128 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
129 foreach ($pl_names as $pl_name) {
130 include_once("./Services/Component/classes/class.ilPlugin.php");
131 $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name);
132 if ($pl_id != "" && ! isset($this->obj_data[$pl_id])) {
133 include_once("./Services/Repository/classes/class.ilRepositoryObjectPlugin.php");
134 $loc = ilPlugin::_getDirectory(IL_COMP_SERVICE, "Repository", "robj", $pl_name) . "/classes";
135
136 $this->obj_data[$pl_id] = array(
137 "name" => $pl_id,
138 "class_name" => $pl_name,
139 "plugin" => "1",
140 "location" => $loc,
141 "checkbox" => "1",
142 "inherit" => "0",
143 "component" => "",
144 "translate" => "0",
145 "devmode" => "0",
146 "allow_link" => "1",
147 "allow_copy" => "0",
148 "rbac" => "1",
149 "group" => NULL,
150 "system" => "0",
151 "default_pos" => "99992000", // "unassigned" group
152 'repository' => '1',
153 'workspace' => '0',
154 'administration' => '0',
155 "sideblock" => "0"
156 );
157 $this->obj_data[$rec["id"]]["subobjects"] = array();
158
159 // plugins have to be marked as such - see ilContainerGUI::showPossibleSubObjects()
160 $this->obj_data["crs"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
161 $this->obj_data["fold"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
162 $this->obj_data["grp"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
163 $this->obj_data["cat"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
164 $this->obj_data["root"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
165 }
166 }
167
168 $this->sub_types = $global_cache->getIlObjectSubType();
169 }
170
171
172 protected function readDefinitionDataFromDB() {
173 global $ilDB, $ilPluginAdmin;
174
175 $this->obj_data = array();
176
177 // Select all object_definitions and collect the definition id's in
178 // this array.
179 $defIds = array();
180 $set = $ilDB->query("SELECT * FROM il_object_def");
181 while ($rec = $ilDB->fetchAssoc($set)) {
182 $this->obj_data[$rec["id"]] = array(
183 "name" => $rec["id"],
184 "class_name" => $rec["class_name"],
185 "location" => $rec["location"],
186 "checkbox" => $rec["checkbox"],
187 "inherit" => $rec["inherit"],
188 "component" => $rec["component"],
189 "translate" => $rec["translate"],
190 "devmode" => $rec["devmode"],
191 "allow_link" => $rec["allow_link"],
192 "allow_copy" => $rec["allow_copy"],
193 "rbac" => $rec["rbac"],
194 "group" => $rec["grp"],
195 "system" => $rec["system"],
196 "default_pos" => "9999" . str_pad($rec["default_pos"], 4, "0", STR_PAD_LEFT), // "unassigned" group
197 "sideblock" => $rec["sideblock"],
198 'export' => $rec['export'],
199 'repository' => $rec['repository'],
200 'workspace' => $rec['workspace'],
201 'administration' => $rec['administration'],
202 'amet' => $rec['amet']
203 );
204 $this->obj_data[$rec["id"]]["subobjects"] = array();
205
206 $defIds[] = $rec["id"];
207 }
208
209 // get all subobject definitions in a single query
210 $set2 = $ilDB->query("SELECT * FROM il_object_subobj WHERE " . $ilDB->in('parent', $defIds, false, 'text'));
211 while ($rec2 = $ilDB->fetchAssoc($set2)) {
212 $max = $rec2["mmax"];
213 if ($max <= 0) // for backward compliance
214 {
215 $max = "";
216 }
217 $this->obj_data[$rec2["parent"]]["subobjects"][$rec2["subobj"]] = array(
218 "name" => $rec2["subobj"],
219 "max" => $max,
220 "lng" => $rec2["subobj"]
221 );
222 }
223
224 $set = $ilDB->query("SELECT * FROM il_object_group");
225 $this->obj_group = array();
226 while ($rec = $ilDB->fetchAssoc($set)) {
227 $this->obj_group[$rec["id"]] = $rec;
228 }
229
230 // now get objects from repository plugin
231 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
232 foreach ($pl_names as $pl_name) {
233 include_once("./Services/Component/classes/class.ilPlugin.php");
234 $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name);
235 if ($pl_id != "" && ! isset($this->obj_data[$pl_id])) {
236 include_once("./Services/Repository/classes/class.ilRepositoryObjectPlugin.php");
237 $loc = ilPlugin::_getDirectory(IL_COMP_SERVICE, "Repository", "robj", $pl_name) . "/classes";
238
239 $this->obj_data[$pl_id] = array(
240 "name" => $pl_id,
241 "class_name" => $pl_name,
242 "plugin" => "1",
243 "location" => $loc,
244 "checkbox" => "1",
245 "inherit" => "0",
246 "component" => "",
247 "translate" => "0",
248 "devmode" => "0",
249 "allow_link" => "1",
250 "allow_copy" => "0",
251 "rbac" => "1",
252 "group" => NULL,
253 "system" => "0",
254 "default_pos" => "99992000", // "unassigned" group
255 'repository' => '1',
256 'workspace' => '0',
257 'administration' => '0',
258 "sideblock" => "0"
259 );
260 $this->obj_data[$rec["id"]]["subobjects"] = array();
261
262 // plugins have to be marked as such - see ilContainerGUI::showPossibleSubObjects()
263 $this->obj_data["crs"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
264 $this->obj_data["fold"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
265 $this->obj_data["grp"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
266 $this->obj_data["cat"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
267 $this->obj_data["root"]["subobjects"][$pl_id] = array( "name" => $pl_id, "max" => "", "lng" => $pl_id, "plugin" => true );
268 }
269 }
270 //var_dump($this->obj_data["root"]["subobjects"]);
271 //var_dump($this->obj_data2["root"]);
272
273 $set = $ilDB->query("SELECT * FROM il_object_sub_type ");
274 $this->sub_types = array();
275 while ($rec = $ilDB->fetchAssoc($set)) {
276 $this->sub_types[$rec["obj_type"]][] = $rec;
277 }
278 }
279
280
285 {
288 } else {
290 }
291 }
292
293
294// PUBLIC METHODS
295
302 function getClassName($a_obj_name)
303 {
304 return $this->obj_data[$a_obj_name]["class_name"];
305 }
306
307
314 function getLocation($a_obj_name)
315 {
316 return $this->obj_data[$a_obj_name]["location"];
317 }
318
322 function getGroup($a_id)
323 {
324 return $this->obj_group[$a_id];
325 }
326
330 function getGroupOfObj($a_obj_name)
331 {
332 return $this->obj_data[$a_obj_name]["group"];
333 }
334
341 function hasCheckbox($a_obj_name)
342 {
343 return (bool) $this->obj_data[$a_obj_name]["checkbox"];
344 }
345
352 function getTranslationType($a_obj_name)
353 {
354 global $ilDB;
355
356 if ($a_obj_name == "root")
357 {
358 if (!isset($this->root_trans_type))
359 {
360 $q = "SELECT count(obj_id) cnt FROM object_translation WHERE obj_id = ".
361 $ilDB->quote(ROOT_FOLDER_ID,'integer')." ";
362 $set = $ilDB->query($q);
363 $rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
364 if($rec["cnt"] > 0)
365 {
366 $this->root_trans_type = "db";
367 }
368 else
369 {
370 $this->root_trans_type = $this->obj_data[$a_obj_name]["translate"];
371 }
372 }
373 return $this->root_trans_type;
374 }
375
376 if (isset($this->obj_data[$a_obj_name]))
377 {
378 return $this->obj_data[$a_obj_name]["translate"];
379 }
380
381 return "";
382 }
383
384
391 function stopInheritance($a_obj_name)
392 {
393 return (bool) $this->obj_data[$a_obj_name]["inherit"];
394 }
395
402 function getDevMode($a_obj_name)
403 {
404 return (bool) $this->obj_data[$a_obj_name]["devmode"];
405 }
406
413 function getDevModeAll()
414 {
415 $types = array_keys($this->obj_data);
416
417 foreach ($types as $type)
418 {
419 if ($this->getDevMode($type))
420 {
421 $devtypes[] = $type;
422 }
423 }
424
425 return $devtypes ? $devtypes : array();
426 }
427
435 function isRBACObject($a_obj_name)
436 {
437 return (bool) $this->obj_data[$a_obj_name]["rbac"];
438 }
439
447 function isPlugin($a_obj_name)
448 {
449 return (bool) isset($this->obj_data[$a_obj_name]["plugin"]);
450 }
451
458 function isPluginTypeName($a_str)
459 {
460 return (substr($a_str, 0, 1) == "x");
461 }
462
470 {
471 $types = array_keys($this->obj_data);
472
473 foreach ($types as $type)
474 {
475 if ($this->isRBACObject($type))
476 {
477 $rbactypes[] = $type;
478 }
479 }
480
481 return $rbactypes ? $rbactypes : array();
482 }
483
490 function getAllObjects()
491 {
492 return array_keys($this->obj_data);
493 }
494
501 public function allowLink($a_obj_name)
502 {
503 return (bool) $this->obj_data[$a_obj_name]["allow_link"];
504 }
505
512 public function allowCopy($a_obj_name)
513 {
514 return (bool) $this->obj_data[$a_obj_name]["allow_copy"];
515 }
516
517 public function allowExport($a_obj_name)
518 {
519 return (bool) $this->obj_data[$a_obj_name]['export'];
520 }
521
527 public function hasLocalRoles($a_obj_type)
528 {
529 switch($a_obj_type)
530 {
531 case 'root':
532 return FALSE;
533
534 default:
535 return TRUE;
536 }
537 }
538
547 function getSubObjects($a_obj_type,$a_filter = true)
548 {
549 global $ilSetting;
550
551 $subs = array();
552
553 if ($subobjects = $this->obj_data[$a_obj_type]["subobjects"])
554 {
555 // Filter some objects e.g chat object are creatable if chat is active
556 if ($a_filter)
557 {
558 $this->__filterObjects($subobjects);
559 }
560 foreach ($subobjects as $data => $sub)
561 {
562 if ($sub["module"] != "n")
563 {
564 if (!($ilSetting->get("obj_dis_creation_".$data)))
565 {
566 $subs[$data] = $sub;
567
568 // determine position
569 $pos = ($ilSetting->get("obj_add_new_pos_".$data) > 0)
570 ? (int) $ilSetting->get("obj_add_new_pos_".$data)
571 : (int) $this->obj_data[$data]["default_pos"];
572 $subs[$data]["pos"] = $pos;
573 }
574 }
575 }
576
577 $subs2 = ilUtil::sortArray($subs, "pos", ASC, true, true);
578
579 return $subs2;
580 }
581
582 return $subs;
583 }
584
598 function getSubObjectsRecursively($a_obj_type,$a_include_source_obj = true, $a_add_admin_objects = false)
599 {
600 global $ilSetting;
601
602 // This associative array is used to collect all subobject types.
603 // key=>type, value=data
604 $recursivesubs = array();
605
606 // This array is used to keep track of the object types, we
607 // need to call function getSubobjects() for.
608 $to_do = array($a_obj_type);
609
610 // This array is used to keep track of the object types, we
611 // have called function getSubobjects() already. This is to
612 // prevent endless loops, for object types that support
613 // themselves as subobject types either directly or indirectly.
614 $done = array();
615
616 while (count($to_do) > 0)
617 {
618 $type = array_pop($to_do);
619 $done[] = $type;
620
621 // no recovery folder subitems
622 if($type == 'recf')
623 {
624 continue;
625 }
626
627 // Hide administration if desired
628 if(!$a_add_admin_objects and $type == 'adm')
629 {
630 $subs = array();
631 }
632 else
633 {
634 $subs = $this->getSubObjects($type);
635 }
636 #vd('xxxxxxxxxxxxx'.$type);
637 foreach ($subs as $subtype => $data)
638 {
639 #vd('------------------------->'.$subtype);
640
641 // Hide role templates and folder from view
642 if($this->getDevMode($subtype) or !$this->isRBACObject($subtype))
643 {
644 continue;
645 }
646 if($subtype == 'rolt')
647 {
648 continue;
649 }
650 if(!$a_add_admin_objects and $subtype == 'adm')
651 {
652 continue;
653 }
654
655 $recursivesubs[$subtype] = $data;
656 if (! in_array($subtype, $done)
657 && ! in_array($subtype, $to_do))
658 {
659 $to_do[] = $subtype;
660 }
661 }
662 }
663
664 if($a_include_source_obj)
665 {
666 if(!isset($recursivesubs[$a_obj_type]))
667 {
668 $recursivesubs[$a_obj_type]['name'] = $a_obj_type;
669 $recursivesubs[$a_obj_type]['lng'] = $a_obj_type;
670 $recursivesubs[$a_obj_type]['max'] = 0;
671 $recursivesubs[$a_obj_type]['pos'] = -1;
672 }
673 }
674 return ilUtil::sortArray($recursivesubs, "pos", ASC, true, true);
675 }
676
677
687 function getSubobjectsToFilter($a_obj_type = "adm")
688 {
689 foreach($this->obj_data[$a_obj_type]["subobjects"] as $key => $value)
690 {
691 switch($key)
692 {
693 case "rolf":
694 // DO NOTHING
695 break;
696
697 default:
698 $tmp_subs[] = $key;
699 }
700 }
701 // ADD adm and root object
702 $tmp_subs[] = "adm";
703 #$tmp_subs[] = "root";
704
705 return $tmp_subs ? $tmp_subs : array();
706 }
707
717 function getCreatableSubObjects($a_obj_type, $a_context = self::MODE_REPOSITORY, $a_parent_ref_id = null)
718 {
719 $subobjects = $this->getSubObjects($a_obj_type);
720
721 // remove role folder object from list
722 unset($subobjects["rolf"]);
723
724 $sub_types = array_keys($subobjects);
725
726 // remove object types in development from list
727 foreach ($sub_types as $type)
728 {
729 if ($this->getDevMode($type) || $this->isSystemObject($type))
730 {
731 unset($subobjects[$type]);
732 }
733 if ($a_context == self::MODE_REPOSITORY && !$this->isAllowedInRepository($type))
734 {
735 unset($subobjects[$type]);
736 }
737 if ($a_context == self::MODE_WORKSPACE && !$this->isAllowedInWorkspace($type))
738 {
739 unset($subobjects[$type]);
740 }
741 if ($a_context == self::MODE_ADMINISTRATION && !$this->isAdministrationObject($type))
742 {
743 unset($subobjects[$type]);
744 }
745 }
746
747 if ($a_obj_type == "prg") {
748 // ask study program which objects are allowed to create on the concrete node.
749 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
750 return ilObjStudyProgramme::getCreatableSubObjects($subobjects, $a_parent_ref_id);
751 }
752
753 return $subobjects;
754 }
755
762 function getSubObjectsAsString($a_obj_type)
763 {
764 $string = "";
765
766 if (is_array($this->obj_data[$a_obj_type]["subobjects"]))
767 {
768 $data = array_keys($this->obj_data[$a_obj_type]["subobjects"]);
769
770 $string = "'".implode("','", $data)."'";
771 }
772
773 return $string;
774 }
775
784 public function isContainer($a_obj_name)
785 {
786 if(!is_array($this->obj_data[$a_obj_name]['subobjects']))
787 {
788 return false;
789 }
790 return count($this->obj_data[$a_obj_name]['subobjects']) >= 1 ? true : false;
791 }
792
793// PRIVATE METHODS
794
801 function setHandlers($a_xml_parser)
802 {
803 xml_set_object($a_xml_parser,$this);
804 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
805 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
806 }
807
816 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
817 {
818 switch ($a_name)
819 {
820 case 'object':
821 $this->parent_tag_name = $a_attribs["name"];
822 break;
823 case 'property':
824 $this->current_tag = "property";
825 $this->current_tag_name = $a_attribs["name"];
826// $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["name"] = $a_attribs["name"];
827 $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["module"] = $a_attribs["module"];
828//echo '<br>$this->obj_data["'.$this->parent_tag_name.'"]["properties"]["'.$this->current_tag_name.'"]["module"] = "'.$a_attribs["module"].'";';
829 break;
830 }
831 }
832
840 function handlerCharacterData($a_xml_parser,$a_data)
841 {
842 }
843
851 function handlerEndTag($a_xml_parser,$a_name)
852 {
853 $this->current_tag = '';
854 $this->current_tag_name = '';
855 }
856
857
858 function __filterObjects(&$subobjects)
859 {
860 foreach($subobjects as $type => $data)
861 {
862 switch($type)
863 {
864 default:
865 // DO NOTHING
866 }
867 }
868 }
869
883 function isSystemObject($a_obj_name)
884 {
885 return (bool) $this->obj_data[$a_obj_name]["system"];
886 }
887
894 function isSideBlock($a_obj_name)
895 {
896 return (bool) $this->obj_data[$a_obj_name]["sideblock"];
897 }
898
902 static function getRepositoryObjectTypesForComponent($a_component_type,
903 $a_component_name)
904 {
905 global $ilDB;
906
907 $set = $ilDB->queryF("SELECT * FROM il_object_def WHERE component = %s",
908 array("text"), array($a_component_type."/".$a_component_name));
909
910 $types = array();
911 while($rec = $ilDB->fetchAssoc($set))
912 {
913 if ($rec["system"] != 1)
914 {
915 $types[] = $rec;
916 }
917 }
918
919 return $types;
920 }
921
925 static function getComponentForType($a_obj_type)
926 {
927 global $ilDB;
928
929 $set = $ilDB->queryF("SELECT component FROM il_object_def WHERE id = %s",
930 array("text"), array($a_obj_type));
931
932 if ($rec = $ilDB->fetchAssoc($set))
933 {
934 return $rec["component"];
935 }
936
937 return "";
938 }
939
943 static function getGroupedRepositoryObjectTypes($a_parent_obj_type)
944 {
945 global $ilDB, $ilPluginAdmin;
946
947 $set = $ilDB->query("SELECT * FROM il_object_group");
948 $groups = array();
949 while ($gr_rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
950 {
951 $groups[$gr_rec["id"]] = $gr_rec;
952 }
953
954 $global_cache = ilCachedComponentData::getInstance();
955
956
957// if (!is_array($a_parent_obj_type))
958// {
959// $set = $ilDB->queryF("SELECT il_object_def.* FROM il_object_def, il_object_subobj ".
960// " WHERE NOT (system = 1) AND NOT (sideblock = 1) AND ".
961// " parent = %s ".
962// " AND subobj = id ", array("text"), array($a_parent_obj_type));
963// }
964// else
965// {
966// $q = "SELECT DISTINCT (id) as sid, il_object_def.* FROM il_object_def, il_object_subobj ".
967// " WHERE NOT (system = 1) AND NOT (sideblock = 1) AND ".
968// $ilDB->in("parent", $a_parent_obj_type, false, "text").
969// " AND subobj = id ";
970// $set = $ilDB->query($q);
971// }
972
973 $recs = $global_cache->lookupGroupedRepObj($a_parent_obj_type);
974
975 $grouped_obj = array();
976// while($rec = $ilDB->fetchAssoc($set))
977 foreach((array)$recs as $rec)
978 {
979 if ($rec["grp"] != "")
980 {
981 $grouped_obj[$rec["grp"]]["pos"] = (int) $groups[$rec["grp"]]["default_pres_pos"];
982 $grouped_obj[$rec["grp"]]["objs"][] = $rec["id"];
983 }
984 else
985 {
986 $grouped_obj[$rec["id"]]["pos"] = (int) $rec["default_pres_pos"];
987 $grouped_obj[$rec["id"]]["objs"][] = $rec["id"];
988 }
989 }
990//var_dump($grouped_obj);
991 // now get objects from repository plugin
992 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
993 foreach ($pl_names as $pl_name)
994 {
995 include_once("./Services/Component/classes/class.ilPlugin.php");
996 $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name);
997 if (!isset($grouped_obj[$pl_id]))
998 {
999 $grouped_obj[$pl_id] = array(
1000 "pos" => "99992000", // "unassigned" group
1001 "objs" => array(0 => $pl_id)
1002 );
1003 }
1004 }
1005
1006//var_dump($grouped_obj);
1007
1008 $ret = ilUtil::sortArray($grouped_obj, "pos", "asc", true, true);
1009//var_dump($ret);
1010 return $ret;
1011 }
1012
1020 function isAllowedInRepository($a_obj_name)
1021 {
1022 return (bool) $this->obj_data[$a_obj_name]["repository"];
1023 }
1024
1031 function getAllRepositoryTypes($a_incl_adm = false)
1032 {
1033 $types = array_keys($this->obj_data);
1034
1035 foreach ($types as $type)
1036 {
1037 if ($this->isAllowedInRepository($type) &&
1038 (!$this->isAdministrationObject($type) || $a_incl_adm))
1039 {
1040 $rbactypes[] = $type;
1041 }
1042 }
1043
1044 return $rbactypes ? $rbactypes : array();
1045 }
1046
1047
1055 function isAllowedInWorkspace($a_obj_name)
1056 {
1057 return (bool) $this->obj_data[$a_obj_name]["workspace"];
1058 }
1059
1065 public function isAdministrationObject($a_obj_name)
1066 {
1067 return (bool) $this->obj_data[$a_obj_name]['administration'];
1068 }
1069
1076 public function isInactivePlugin($a_type)
1077 {
1078 if (substr($a_type, 0, 1) == "x" && !$this->isPlugin($a_type))
1079 {
1080 return true;
1081 }
1082 return false;
1083 }
1084
1092 {
1093 $amet = array();
1094 foreach ($this->obj_data as $k => $v)
1095 {
1096 if ($v["amet"])
1097 {
1098 $amet[] = array("obj_type" => $k, "sub_type" => "");
1099 }
1100 }
1101
1102 foreach ($this->sub_types as $type => $sub_types)
1103 {
1104 foreach ($sub_types as $t)
1105 {
1106 if ($t["amet"])
1107 {
1108 $amet[] = array("obj_type" => $type, "sub_type" => $t["sub_type"]);
1109 }
1110 }
1111 }
1112
1113 return $amet;
1114 }
1115
1122 function getPositionByType($a_type)
1123 {
1124 global $ilSetting;
1125
1126 return ($ilSetting->get("obj_add_new_pos_".$a_type) > 0)
1127 ? (int) $ilSetting->get("obj_add_new_pos_".$a_type)
1128 : (int) $this->obj_data[$a_type]["default_pos"];
1129 }
1130
1135 public function getPlugins()
1136 {
1137 $plugins = array();
1138 foreach((array) $this->obj_data as $type => $pl_data)
1139 {
1140 if($this->isPlugin($type))
1141 {
1142 $plugins[$type] = $pl_data;
1143 }
1144 }
1145 return $plugins;
1146 }
1147
1154 {
1155 $res = $grp_map = $cnt_grp = array();
1156
1157 // all repository object types
1158 foreach ($this->getSubObjectsRecursively("root") as $rtype)
1159 {
1160 $type = $rtype["name"];
1161
1162 // obsolete
1163 if($type == "rolf")
1164 {
1165 continue;
1166 }
1167
1168 // gather group data
1169 $type_grp = $this->getGroupOfObj($type);
1170 if($type_grp)
1171 {
1172 $grp_map[$type_grp][] = $type;
1173 }
1174
1175 // add basic container types
1176 if($this->isContainer($type))
1177 {
1178 // add to cnt_grp
1179 if($type_grp)
1180 {
1181 $cnt_grp[] = $type_grp;
1182 }
1183
1184 $res[] = $type;
1185 }
1186 }
1187
1188 // add complete groups (cat => rcat, catr; crs => rcrs, crsr; ...)
1189 foreach($cnt_grp as $grp)
1190 {
1191 $res = array_merge($res, $grp_map[$grp]);
1192 }
1193
1194 // add very special case
1195 $res[] = "itgr";
1196
1197 return array_unique($res);
1198 }
1199
1200}
1201?>
const IL_COMP_SERVICE
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
static getInstance($component)
static getCreatableSubObjects($a_subobjects, $a_ref_id)
Filter the list of possible subobjects for the objects that actually could be created on a concrete n...
parses the objects.xml it handles the xml-description of all ilias objects
getTranslationType($a_obj_name)
get translation type (sys, db or 0)s
getSubobjectsToFilter($a_obj_type="adm")
get all subjects except (rolf) of the adm object This is neceesary for filtering these objects in rol...
getSubObjectsRecursively($a_obj_type, $a_include_source_obj=true, $a_add_admin_objects=false)
Get all subobjects by type.
getCreatableSubObjects($a_obj_type, $a_context=self::MODE_REPOSITORY, $a_parent_ref_id=null)
get only creatable subobjects by type
static getComponentForType($a_obj_type)
Get component for object type.
getAllRepositoryTypes($a_incl_adm=false)
get all RBAC object types
getAllRBACObjects()
get all RBAC object types
isPlugin($a_obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type
getGroupOfObj($a_obj_name)
Get Group of object type.
readDefinitionData()
Read object definition data.
getDevModeAll()
get all object types in devmode
handlerCharacterData($a_xml_parser, $a_data)
end tag handler
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
start tag handler
getDevMode($a_obj_name)
get devmode status by type
static getGroupedRepositoryObjectTypes($a_parent_obj_type)
Get grouped repository object types.
hasLocalRoles($a_obj_type)
Check whether the creation of local roles is allowed Currently disabled for type "root" and "adm".
getLocation($a_obj_name)
get location by type
isAllowedInRepository($a_obj_name)
checks if object type can be used in repository context
allowLink($a_obj_name)
checks if linking of an object type is allowed
stopInheritance($a_obj_name)
Does object permits stopping inheritance?
allowCopy($a_obj_name)
checks if copying of an object type is allowed
isSystemObject($a_obj_name)
checks if object type is a system object
isAllowedInWorkspace($a_obj_name)
checks if object type can be used in workspace context
isInactivePlugin($a_type)
Check whether type belongs to inactive plugin.
static getRepositoryObjectTypesForComponent($a_component_type, $a_component_name)
Get all repository object types of component.
isSideBlock($a_obj_name)
Check, whether object type is a side block.
getClassName($a_obj_name)
get class name by type
getSubObjectsAsString($a_obj_type)
get a string of all subobjects by type
getPlugins()
Get plugin object info.
getAdvancedMetaDataTypes()
Get advanced meta data objects.
getAllObjects()
get all object types
getGroup($a_id)
Get Group information.
getSubObjects($a_obj_type, $a_filter=true)
get all subobjects by type
getExplorerContainerTypes()
Get all object types which are defined as container in an explorer context.
isPluginTypeName($a_str)
Check if given type is a plugin type name (starts with an "x")
hasCheckbox($a_obj_name)
should the object get a checkbox (needed for 'cut','copy' ...)
isContainer($a_obj_name)
Check if object type is container ('crs','fold','grp' ...)
setHandlers($a_xml_parser)
set event handler
isAdministrationObject($a_obj_name)
Check if administration object.
getPositionByType($a_type)
Get Position By Object Type.
handlerEndTag($a_xml_parser, $a_name)
end tag handler
isRBACObject($a_obj_name)
get RBAC status by type returns true if object type is a RBAC object type
lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
static _getDirectory($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin directory.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
$data
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
global $ilDB