ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
716 function getCreatableSubObjects($a_obj_type, $a_context = self::MODE_REPOSITORY)
717 {
718 $subobjects = $this->getSubObjects($a_obj_type);
719
720 // remove role folder object from list
721 unset($subobjects["rolf"]);
722
723 $sub_types = array_keys($subobjects);
724
725 // remove object types in development from list
726 foreach ($sub_types as $type)
727 {
728 if ($this->getDevMode($type) || $this->isSystemObject($type))
729 {
730 unset($subobjects[$type]);
731 }
732 if ($a_context == self::MODE_REPOSITORY && !$this->isAllowedInRepository($type))
733 {
734 unset($subobjects[$type]);
735 }
736 if ($a_context == self::MODE_WORKSPACE && !$this->isAllowedInWorkspace($type))
737 {
738 unset($subobjects[$type]);
739 }
740 if ($a_context == self::MODE_ADMINISTRATION && !$this->isAdministrationObject($type))
741 {
742 unset($subobjects[$type]);
743 }
744 // Filter for iLinc: Delete the following lines after we completely removed the iLinc object in ILIAS 4.5.x
745 if(in_array($type, array('icrs', 'icla')))
746 {
747 unset($subobjects[$type]);
748 }
749 }
750
751 return $subobjects;
752 }
753
760 function getSubObjectsAsString($a_obj_type)
761 {
762 $string = "";
763
764 if (is_array($this->obj_data[$a_obj_type]["subobjects"]))
765 {
766 $data = array_keys($this->obj_data[$a_obj_type]["subobjects"]);
767
768 $string = "'".implode("','", $data)."'";
769 }
770
771 return $string;
772 }
773
782 public function isContainer($a_obj_name)
783 {
784 if(!is_array($this->obj_data[$a_obj_name]['subobjects']))
785 {
786 return false;
787 }
788 return count($this->obj_data[$a_obj_name]['subobjects']) >= 1 ? true : false;
789 }
790
791// PRIVATE METHODS
792
799 function setHandlers($a_xml_parser)
800 {
801 xml_set_object($a_xml_parser,$this);
802 xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
803 xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
804 }
805
814 function handlerBeginTag($a_xml_parser,$a_name,$a_attribs)
815 {
816 switch ($a_name)
817 {
818 case 'object':
819 $this->parent_tag_name = $a_attribs["name"];
820 break;
821 case 'property':
822 $this->current_tag = "property";
823 $this->current_tag_name = $a_attribs["name"];
824// $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["name"] = $a_attribs["name"];
825 $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["module"] = $a_attribs["module"];
826//echo '<br>$this->obj_data["'.$this->parent_tag_name.'"]["properties"]["'.$this->current_tag_name.'"]["module"] = "'.$a_attribs["module"].'";';
827 break;
828 }
829 }
830
838 function handlerCharacterData($a_xml_parser,$a_data)
839 {
840 }
841
849 function handlerEndTag($a_xml_parser,$a_name)
850 {
851 $this->current_tag = '';
852 $this->current_tag_name = '';
853 }
854
855
856 function __filterObjects(&$subobjects)
857 {
858 foreach($subobjects as $type => $data)
859 {
860 switch($type)
861 {
862 case "chat":
863 if(!$this->ilias->getSetting("chat_active"))
864 {
865 unset($subobjects[$type]);
866 }
867 break;
868
869 case "icrs":
870 if(!$this->ilias->getSetting("ilinc_active"))
871 {
872 unset($subobjects[$type]);
873 }
874 break;
875
876 default:
877 // DO NOTHING
878 }
879 }
880 }
881
895 function isSystemObject($a_obj_name)
896 {
897 return (bool) $this->obj_data[$a_obj_name]["system"];
898 }
899
906 function isSideBlock($a_obj_name)
907 {
908 return (bool) $this->obj_data[$a_obj_name]["sideblock"];
909 }
910
914 static function getRepositoryObjectTypesForComponent($a_component_type,
915 $a_component_name)
916 {
917 global $ilDB;
918
919 $set = $ilDB->queryF("SELECT * FROM il_object_def WHERE component = %s",
920 array("text"), array($a_component_type."/".$a_component_name));
921
922 $types = array();
923 while($rec = $ilDB->fetchAssoc($set))
924 {
925 if ($rec["system"] != 1)
926 {
927 $types[] = $rec;
928 }
929 }
930
931 return $types;
932 }
933
937 static function getComponentForType($a_obj_type)
938 {
939 global $ilDB;
940
941 $set = $ilDB->queryF("SELECT component FROM il_object_def WHERE id = %s",
942 array("text"), array($a_obj_type));
943
944 if ($rec = $ilDB->fetchAssoc($set))
945 {
946 return $rec["component"];
947 }
948
949 return "";
950 }
951
955 static function getGroupedRepositoryObjectTypes($a_parent_obj_type)
956 {
957 global $ilDB, $ilPluginAdmin;
958
959 $set = $ilDB->query("SELECT * FROM il_object_group");
960 $groups = array();
961 while ($gr_rec = $set->fetchRow(DB_FETCHMODE_ASSOC))
962 {
963 $groups[$gr_rec["id"]] = $gr_rec;
964 }
965
966 $global_cache = ilCachedComponentData::getInstance();
967
968
969// if (!is_array($a_parent_obj_type))
970// {
971// $set = $ilDB->queryF("SELECT il_object_def.* FROM il_object_def, il_object_subobj ".
972// " WHERE NOT (system = 1) AND NOT (sideblock = 1) AND ".
973// " parent = %s ".
974// " AND subobj = id ", array("text"), array($a_parent_obj_type));
975// }
976// else
977// {
978// $q = "SELECT DISTINCT (id) as sid, il_object_def.* FROM il_object_def, il_object_subobj ".
979// " WHERE NOT (system = 1) AND NOT (sideblock = 1) AND ".
980// $ilDB->in("parent", $a_parent_obj_type, false, "text").
981// " AND subobj = id ";
982// $set = $ilDB->query($q);
983// }
984
985 $recs = $global_cache->lookupGroupedRepObj($a_parent_obj_type);
986
987 $grouped_obj = array();
988// while($rec = $ilDB->fetchAssoc($set))
989 foreach((array)$recs as $rec)
990 {
991 if ($rec["grp"] != "")
992 {
993 $grouped_obj[$rec["grp"]]["pos"] = (int) $groups[$rec["grp"]]["default_pres_pos"];
994 $grouped_obj[$rec["grp"]]["objs"][] = $rec["id"];
995 }
996 else
997 {
998 $grouped_obj[$rec["id"]]["pos"] = (int) $rec["default_pres_pos"];
999 $grouped_obj[$rec["id"]]["objs"][] = $rec["id"];
1000 }
1001 }
1002//var_dump($grouped_obj);
1003 // now get objects from repository plugin
1004 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
1005 foreach ($pl_names as $pl_name)
1006 {
1007 include_once("./Services/Component/classes/class.ilPlugin.php");
1008 $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name);
1009 if (!isset($grouped_obj[$pl_id]))
1010 {
1011 $grouped_obj[$pl_id] = array(
1012 "pos" => "99992000", // "unassigned" group
1013 "objs" => array(0 => $pl_id)
1014 );
1015 }
1016 }
1017
1018//var_dump($grouped_obj);
1019
1020 $ret = ilUtil::sortArray($grouped_obj, "pos", "asc", true, true);
1021//var_dump($ret);
1022 return $ret;
1023 }
1024
1032 function isAllowedInRepository($a_obj_name)
1033 {
1034 return (bool) $this->obj_data[$a_obj_name]["repository"];
1035 }
1036
1043 function getAllRepositoryTypes($a_incl_adm = false)
1044 {
1045 $types = array_keys($this->obj_data);
1046
1047 foreach ($types as $type)
1048 {
1049 if ($this->isAllowedInRepository($type) &&
1050 (!$this->isAdministrationObject($type) || $a_incl_adm))
1051 {
1052 $rbactypes[] = $type;
1053 }
1054 }
1055
1056 return $rbactypes ? $rbactypes : array();
1057 }
1058
1059
1067 function isAllowedInWorkspace($a_obj_name)
1068 {
1069 return (bool) $this->obj_data[$a_obj_name]["workspace"];
1070 }
1071
1077 public function isAdministrationObject($a_obj_name)
1078 {
1079 return (bool) $this->obj_data[$a_obj_name]['administration'];
1080 }
1081
1088 public function isInactivePlugin($a_type)
1089 {
1090 if (substr($a_type, 0, 1) == "x" && !$this->isPlugin($a_type))
1091 {
1092 return true;
1093 }
1094 return false;
1095 }
1096
1104 {
1105 $amet = array();
1106 foreach ($this->obj_data as $k => $v)
1107 {
1108 if ($v["amet"])
1109 {
1110 $amet[] = array("obj_type" => $k, "sub_type" => "");
1111 }
1112 }
1113
1114 foreach ($this->sub_types as $type => $sub_types)
1115 {
1116 foreach ($sub_types as $t)
1117 {
1118 if ($t["amet"])
1119 {
1120 $amet[] = array("obj_type" => $type, "sub_type" => $t["sub_type"]);
1121 }
1122 }
1123 }
1124
1125 return $amet;
1126 }
1127
1134 function getPositionByType($a_type)
1135 {
1136 global $ilSetting;
1137
1138 return ($ilSetting->get("obj_add_new_pos_".$a_type) > 0)
1139 ? (int) $ilSetting->get("obj_add_new_pos_".$a_type)
1140 : (int) $this->obj_data[$a_type]["default_pos"];
1141 }
1142
1147 public function getPlugins()
1148 {
1149 $plugins = array();
1150 foreach((array) $this->obj_data as $type => $pl_data)
1151 {
1152 if($this->isPlugin($type))
1153 {
1154 $plugins[$type] = $pl_data;
1155 }
1156 }
1157 return $plugins;
1158 }
1159
1160}
1161?>
const IL_COMP_SERVICE
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10
static getInstance($component)
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.
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
getCreatableSubObjects($a_obj_type, $a_context=self::MODE_REPOSITORY)
get only creatable subobjects 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
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
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
global $ilDB