ILIAS  release_8 Revision v8.24
class.ilObjectDefinition.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
30 public const MODE_REPOSITORY = 1;
31 public const MODE_WORKSPACE = 2;
32 public const MODE_ADMINISTRATION = 3;
33
36
37 protected array $obj_data = [];
38 protected array $obj_group = [];
39 protected array $sub_types = [];
40 protected string $parent_tag_name;
41 protected string $current_tag;
42 protected string $current_tag_name;
43
44 public function __construct()
45 {
46 global $DIC;
47
48 $this->component_repository = $DIC["component.repository"];
49 $this->settings = $DIC->settings();
50 $this->readDefinitionData();
51 }
52
53 protected function readDefinitionDataFromCache(): void
54 {
55 $this->obj_data = [];
56 $defIds = [];
57
59 foreach ($global_cache->getIlObjectDef() as $rec) {
60 $this->obj_data[$rec["id"]] = [
61 "name" => $rec["id"],
62 "class_name" => $rec["class_name"],
63 "location" => $rec["location"],
64 "checkbox" => $rec["checkbox"],
65 "inherit" => $rec["inherit"],
66 "component" => $rec["component"],
67 "translate" => $rec["translate"],
68 "devmode" => $rec["devmode"],
69 "allow_link" => $rec["allow_link"],
70 "allow_copy" => $rec["allow_copy"],
71 "rbac" => $rec["rbac"],
72 "group" => $rec["grp"],
73 "system" => $rec["system"],
74 "default_pos" => "9999" . str_pad((string) $rec["default_pos"], 4, "0", STR_PAD_LEFT), // "unassigned" group
75 "sideblock" => $rec["sideblock"],
76 'export' => $rec['export'],
77 'repository' => $rec['repository'],
78 'workspace' => $rec['workspace'],
79 'administration' => $rec['administration'],
80 'amet' => $rec['amet'],
81 'orgunit_permissions' => $rec['orgunit_permissions'],
82 'lti_provider' => $rec['lti_provider'],
83 'offline_handling' => $rec['offline_handling']
84 ];
85 $this->obj_data[$rec["id"]]["subobjects"] = [];
86
87 $defIds[] = $rec["id"];
88 }
89
90 $subobj = $global_cache->lookupSubObjForParent($defIds);
91
92 foreach ($subobj as $rec2) {
93 $max = $rec2["mmax"];
94 if ($max <= 0) {
95 $max = "";
96 }
97 $this->obj_data[$rec2["parent"]]["subobjects"][$rec2["subobj"]] = [
98 "name" => $rec2["subobj"],
99 "max" => $max,
100 "lng" => $rec2["subobj"]
101 ];
102 }
103
104 $this->obj_group = $global_cache->getIlObjectGroup();
105 $this->readPluginData();
106 $this->sub_types = $global_cache->getIlObjectSubType();
107 }
108
109
110 protected function readDefinitionDataFromDB(): void
111 {
112 global $DIC;
113 $ilDB = $DIC->database();
114
115 $this->obj_data = [];
116
117 // Select all object_definitions and collect the definition id's in this array.
118 $defIds = [];
119
120 $sql =
121 "SELECT id, class_name, component, location, checkbox, inherit, translate, devmode, allow_link," . PHP_EOL
122 . "allow_copy, rbac, `system`, sideblock, default_pos, grp, default_pres_pos, `export`, repository," . PHP_EOL
123 . "workspace, administration, amet, orgunit_permissions, lti_provider, offline_handling" . PHP_EOL
124 . "FROM il_object_def" . PHP_EOL
125 ;
126 $result = $ilDB->query($sql);
127 while ($rec = $ilDB->fetchAssoc($result)) {
128 $this->obj_data[$rec["id"]] = [
129 "name" => $rec["id"],
130 "class_name" => $rec["class_name"],
131 "location" => $rec["location"],
132 "checkbox" => $rec["checkbox"],
133 "inherit" => $rec["inherit"],
134 "component" => $rec["component"],
135 "translate" => $rec["translate"],
136 "devmode" => $rec["devmode"],
137 "allow_link" => $rec["allow_link"],
138 "allow_copy" => $rec["allow_copy"],
139 "rbac" => $rec["rbac"],
140 "group" => $rec["grp"],
141 "system" => $rec["system"],
142 "default_pos" => "9999" . str_pad((string) $rec["default_pos"], 4, "0", STR_PAD_LEFT), // "unassigned" group
143 "sideblock" => $rec["sideblock"],
144 'export' => $rec['export'],
145 'repository' => $rec['repository'],
146 'workspace' => $rec['workspace'],
147 'administration' => $rec['administration'],
148 'amet' => $rec['amet'],
149 'orgunit_permissions' => $rec['orgunit_permissions'],
150 'lti_provider' => $rec['lti_provider'],
151 'offline_handling' => $rec['offline_handling']
152 ];
153 $this->obj_data[$rec["id"]]["subobjects"] = [];
154
155 $defIds[] = $rec["id"];
156 }
157
158 // get all sub object definitions in a single query
159 $sql =
160 "SELECT parent, subobj, mmax" . PHP_EOL
161 . "FROM il_object_subobj" . PHP_EOL
162 . "WHERE " . $ilDB->in('parent', $defIds, false, 'text') . PHP_EOL
163 ;
164 $result = $ilDB->query($sql);
165 while ($rec2 = $ilDB->fetchAssoc($result)) {
166 $max = $rec2["mmax"];
167 if ($max <= 0) { // for backward compliance
168 $max = "";
169 }
170 $this->obj_data[$rec2["parent"]]["subobjects"][$rec2["subobj"]] = [
171 "name" => $rec2["subobj"],
172 "max" => $max,
173 "lng" => $rec2["subobj"]
174 ];
175 }
176
177 $sql =
178 "SELECT id, name, default_pres_pos" . PHP_EOL
179 . "FROM il_object_group" . PHP_EOL
180 ;
181 $result = $ilDB->query($sql);
182 $this->obj_group = array();
183 while ($rec = $ilDB->fetchAssoc($result)) {
184 $this->obj_group[$rec["id"]] = $rec;
185 }
186
187 $this->readPluginData();
188
189 $sql =
190 "SELECT obj_type, sub_type, amet" . PHP_EOL
191 . "FROM il_object_sub_type" . PHP_EOL
192 ;
193 $result = $ilDB->query($sql);
194 $this->sub_types = array();
195 while ($rec = $ilDB->fetchAssoc($result)) {
196 $this->sub_types[$rec["obj_type"]][] = $rec;
197 }
198 }
199
203 public function readDefinitionData(): void
204 {
207 } else {
209 }
210 }
211
212 protected static function getGroupedPluginObjectTypes(array $grouped_obj, string $slotId): array
213 {
214 global $DIC;
215
216 $component_repository = $DIC["component.repository"];
217 $plugins = $component_repository->getPluginSlotById($slotId)->getActivePlugins();
218 foreach ($plugins as $plugin) {
219 $pl_id = $plugin->getId();
220 if (!isset($grouped_obj[$pl_id])) {
221 $grouped_obj[$pl_id] = array(
222 "pos" => "99992000", // "unassigned" group
223 "objs" => array(0 => $pl_id)
224 );
225 }
226 }
227 return $grouped_obj;
228 }
229
230 public function getClassName(string $obj_name): string
231 {
232 return $this->obj_data[$obj_name]["class_name"] ?? '';
233 }
234
235 public function getLocation(string $obj_name): string
236 {
237 return $this->obj_data[$obj_name]["location"] ?? '';
238 }
239
243 public function getGroup(string $id): array
244 {
245 return $this->obj_group[$id];
246 }
247
251 public function getGroupOfObj(string $obj_name): ?string
252 {
253 return $this->obj_data[$obj_name]["group"] ?? null;
254 }
255
259 public function hasCheckbox(string $obj_name): bool
260 {
261 return (bool) ($this->obj_data[$obj_name]["checkbox"] ?? false);
262 }
263
267 public function getTranslationType(string $obj_name): ?string
268 {
269 global $DIC;
270 $ilDB = $DIC->database();
271
272 if ($obj_name == "root") {
273 if (!isset($this->root_trans_type)) {
274 $sql =
275 "SELECT count(obj_id) cnt" . PHP_EOL
276 . "FROM object_translation" . PHP_EOL
277 . "WHERE obj_id = " . $ilDB->quote(ROOT_FOLDER_ID, 'integer') . PHP_EOL
278 ;
279 $set = $ilDB->query($sql);
280 $rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
281 if ($rec["cnt"] > 0) {
282 $this->root_trans_type = "db";
283 } else {
284 $this->root_trans_type = $this->obj_data[$obj_name]["translate"];
285 }
286 }
287 return $this->root_trans_type;
288 }
289
290 if (isset($this->obj_data[$obj_name])) {
291 return $this->obj_data[$obj_name]["translate"];
292 }
293
294 return "";
295 }
296
300 public function stopInheritance(string $obj_name): bool
301 {
302 return (bool) $this->obj_data[$obj_name]["inherit"];
303 }
304
308 public function getDevMode(string $obj_name): bool
309 {
310 return (bool) ($this->obj_data[$obj_name]["devmode"] ?? false);
311 }
312
318 public function getDevModeAll(): array
319 {
320 $types = array_keys($this->obj_data);
321
322 $dev_types = [];
323 foreach ($types as $type) {
324 if ($this->getDevMode($type)) {
325 $dev_types[] = $type;
326 }
327 }
328
329 return $dev_types;
330 }
331
336 public function isRBACObject(string $obj_name): bool
337 {
338 return (bool) ($this->obj_data[$obj_name]["rbac"] ?? false);
339 }
340
345 public function isPlugin(string $obj_name): bool
346 {
347 return isset($this->obj_data[$obj_name]["plugin"]);
348 }
349
353 public function isPluginTypeName(string $str): bool
354 {
355 return (substr($str, 0, 1) == "x");
356 }
357
361 public function isActivePluginType(string $type): bool
362 {
363 if (!$this->component_repository->hasPluginId($type)) {
364 return false;
365 }
366 $plugin_slot = $this->component_repository->getPluginById($type)->getPluginSlot();
367 return $plugin_slot->getId() === "robj" || $plugin_slot->getId() === "orguext";
368 }
369
370 public function getAllRBACObjects(): array
371 {
372 $types = array_keys($this->obj_data);
373
374 $rbac_types = [];
375 foreach ($types as $type) {
376 if ($this->isRBACObject($type)) {
377 $rbac_types[] = $type;
378 }
379 }
380
381 return $rbac_types;
382 }
383
387 public function getAllObjects(): array
388 {
389 return array_keys($this->obj_data);
390 }
391
395 public function allowLink(string $obj_name): bool
396 {
397 return (bool) $this->obj_data[$obj_name]["allow_link"];
398 }
399
403 public function allowCopy(string $obj_name): bool
404 {
405 return (bool) $this->obj_data[$obj_name]["allow_copy"];
406 }
407
408 public function allowExport(string $obj_name): bool
409 {
410 return (bool) $this->obj_data[$obj_name]['export'];
411 }
412
417 public function hasLocalRoles(string $obj_type): bool
418 {
419 switch ($obj_type) {
420 case 'root':
421 return false;
422
423 default:
424 return true;
425 }
426 }
427
431 public function getSubObjects(string $obj_type, bool $filter = true): array
432 {
433 $subs = [];
434 if ($subobjects = ($this->obj_data[$obj_type]["subobjects"] ?? false)) {
435 // Filter some objects e.g. chat object are creatable if chat is active
436 if ($filter) {
437 $this->__filterObjects($subobjects);
438 }
439 foreach ($subobjects as $data => $sub) {
440 if (!isset($sub["module"]) || $sub["module"] != "n") {
441 if (!($this->settings->get("obj_dis_creation_" . $data))) {
442 $subs[$data] = $sub;
443
444 // determine position
445 $pos = (int) $this->obj_data[$data]["default_pos"];
446 if ($this->settings->get("obj_add_new_pos_" . $data) > 0) {
447 $pos = (int) $this->settings->get("obj_add_new_pos_" . $data);
448 }
449 $subs[$data]["pos"] = $pos;
450 }
451 }
452 }
453
454 return ilArrayUtil::sortArray($subs, "pos", 'ASC', true, true);
455 }
456
457 return $subs;
458 }
459
469 string $obj_type,
470 bool $include_source_obj = true,
471 bool $add_admin_objects = false
472 ): array {
473 // This associative array is used to collect all sub object types.
474 // key=>type, value=data
475 $recursive_subs = [];
476
477 // This array is used to keep track of the object types, we
478 // need to call function getSubobjects() for.
479 $to_do = [$obj_type];
480
481 // This array is used to keep track of the object types, we
482 // have called function getSubobjects() already. This is to
483 // prevent endless loops, for object types that support
484 // themselves as subobject types either directly or indirectly.
485 $done = [];
486
487 while (count($to_do) > 0) {
488 $type = array_pop($to_do);
489 $done[] = $type;
490
491 // no recovery folder subitems
492 if ($type == 'recf') {
493 continue;
494 }
495
496 // Hide administration if desired
497 if (!$add_admin_objects and $type == 'adm') {
498 $subs = [];
499 } else {
500 $subs = $this->getSubObjects($type);
501 }
502 foreach ($subs as $subtype => $data) {
503 // Hide role templates and folder from view
504 if ($this->getDevMode($subtype) or !$this->isRBACObject($subtype)) {
505 continue;
506 }
507 if ($subtype == 'rolt') {
508 continue;
509 }
510 if (!$add_admin_objects and $subtype == 'adm') {
511 continue;
512 }
513
514 $recursive_subs[$subtype] = $data;
515 if (!in_array($subtype, $done) && !in_array($subtype, $to_do)) {
516 $to_do[] = $subtype;
517 }
518 }
519 }
520
521 if ($include_source_obj) {
522 if (!isset($recursive_subs[$obj_type])) {
523 $recursive_subs[$obj_type]['name'] = $obj_type;
524 $recursive_subs[$obj_type]['lng'] = $obj_type;
525 $recursive_subs[$obj_type]['max'] = 0;
526 $recursive_subs[$obj_type]['pos'] = -1;
527 }
528 }
529 return ilArrayUtil::sortArray($recursive_subs, "pos", 'ASC', true, true);
530 }
531
532
538 public function getSubobjectsToFilter(string $obj_type = "adm"): array
539 {
540 foreach ($this->obj_data[$obj_type]["subobjects"] as $key => $value) {
541 switch ($key) {
542 case "rolf":
543 case "orgu":
544 // DO NOTHING
545 break;
546
547 default:
548 $tmp_subs[] = $key;
549 }
550 }
551 $tmp_subs[] = "adm";
552
553 return $tmp_subs;
554 }
555
556 public function getCreatableSubObjects(
557 string $obj_type,
558 int $context = self::MODE_REPOSITORY,
559 int $parent_ref_id = null
560 ): array {
561 $sub_objects = $this->getSubObjects($obj_type);
562
563 // remove role folder object from list
564 unset($sub_objects["rolf"]);
565
566 $sub_types = array_keys($sub_objects);
567
568 // remove object types in development from list
569 foreach ($sub_types as $type) {
570 if ($this->getDevMode($type) || $this->isSystemObject($type)) {
571 unset($sub_objects[$type]);
572 }
573 if ($context == self::MODE_REPOSITORY && !$this->isAllowedInRepository($type)) {
574 unset($sub_objects[$type]);
575 }
576 if ($context == self::MODE_WORKSPACE && !$this->isAllowedInWorkspace($type)) {
577 unset($sub_objects[$type]);
578 }
579 if ($context == self::MODE_ADMINISTRATION && !$this->isAdministrationObject($type)) {
580 unset($sub_objects[$type]);
581 }
582 }
583
584 if ($obj_type == "prg") {
585 // ask study program which objects are allowed to create on the concrete node.
586 return ilObjStudyProgramme::getCreatableSubObjects($sub_objects, $parent_ref_id);
587 }
588
589 return $sub_objects;
590 }
591
595 public function getSubObjectsAsString(string $obj_type): string
596 {
597 $string = "";
598 if (is_array($this->obj_data[$obj_type]["subobjects"])) {
599 $data = array_keys($this->obj_data[$obj_type]["subobjects"]);
600 $string = "'" . implode("','", $data) . "'";
601 }
602
603 return $string;
604 }
605
609 public function isContainer(string $obj_name): bool
610 {
611 return (bool) ($this->obj_data[$obj_name]['subobjects'] ?? false);
612 }
613
614 public function setHandlers($xml_parser): void
615 {
616 xml_set_object($xml_parser, $this);
617 xml_set_element_handler($xml_parser, 'handlerBeginTag', 'handlerEndTag');
618 xml_set_character_data_handler($xml_parser, 'handlerCharacterData');
619 }
620
621 public function handlerBeginTag($xml_parser, string $name, array $attribs): void
622 {
623 switch ($name) {
624 case 'object':
625 $this->parent_tag_name = $attribs["name"];
626 break;
627 case 'property':
628 $this->current_tag = "property";
629 $this->current_tag_name = $attribs["name"];
630 $this->obj_data[$this->parent_tag_name]["properties"][$this->current_tag_name]["module"] = $attribs["module"];
631 break;
632 }
633 }
634
635 public function handlerCharacterData($xml_parser, string $data): void
636 {
637 }
638
639 public function handlerEndTag($xml_parser, string $name): void
640 {
641 $this->current_tag = '';
642 $this->current_tag_name = '';
643 }
644
645 public function __filterObjects(array &$sub_objects): void
646 {
647 // DO NOTHING
648 }
649
660 public function isSystemObject(string $obj_name): bool
661 {
662 return (bool) ($this->obj_data[$obj_name]["system"] ?? false);
663 }
664
668 public function isSideBlock(string $obj_name): bool
669 {
670 return (bool) ($this->obj_data[$obj_name]["sideblock"] ?? false);
671 }
672
673 public function getSideBlockTypes(bool $filter_repository_types = true): array
674 {
675 $side_block_types = [];
676 foreach (array_keys($this->obj_data) as $type) {
677 if (
678 $filter_repository_types &&
679 !$this->isAllowedInRepository($type)
680 ) {
681 continue;
682 }
683 if ($this->isSideBlock($type)) {
684 $side_block_types[] = $type;
685 }
686 }
687 return $side_block_types;
688 }
689
698 public static function getRepositoryObjectTypesForComponent(string $component_type, string $component_name): array
699 {
700 global $DIC;
701 $ilDB = $DIC->database();
702
703 $sql =
704 "SELECT id, class_name, component, location, checkbox, inherit, translate, devmode, allow_link," . PHP_EOL
705 . "allow_copy, rbac, `system`, sideblock, default_pos, grp, default_pres_pos, `export`, repository," . PHP_EOL
706 . "workspace, administration, amet, orgunit_permissions, lti_provider, offline_handling" . PHP_EOL
707 . "FROM il_object_def" . PHP_EOL
708 . "WHERE component = %s" . PHP_EOL
709 ;
710 $result = $ilDB->queryF($sql, ["text"], [$component_type . "/" . $component_name]);
711
712 $types = [];
713 while ($rec = $ilDB->fetchAssoc($result)) {
714 if ($rec["system"] != 1) {
715 $types[] = $rec;
716 }
717 }
718
719 return $types;
720 }
721
725 public static function getComponentForType(string $obj_type): string
726 {
727 global $DIC;
728 $ilDB = $DIC->database();
729
730 $result = $ilDB->queryF("SELECT component FROM il_object_def WHERE id = %s", ["text"], [$obj_type]);
731
732 if ($rec = $ilDB->fetchAssoc($result)) {
733 return $rec["component"];
734 }
735
736 return "";
737 }
738
742 public static function getGroupedRepositoryObjectTypes($parent_obj_type): array
743 {
744 global $DIC;
745 $ilDB = $DIC->database();
746
747 $set = $ilDB->query("SELECT * FROM il_object_group");
748 $groups = array();
749 while ($gr_rec = $set->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
750 $groups[$gr_rec["id"]] = $gr_rec;
751 }
752
754
755 $recs = $global_cache->lookupGroupedRepObj($parent_obj_type);
756
757 $grouped_obj = array();
758 foreach ((array) $recs as $rec) {
759 if ($rec["grp"] != "") {
760 $grouped_obj[$rec["grp"]]["pos"] = (int) $groups[$rec["grp"]]["default_pres_pos"];
761 $grouped_obj[$rec["grp"]]["objs"][] = $rec["id"];
762 } else {
763 $grouped_obj[$rec["id"]]["pos"] = (int) $rec["default_pres_pos"];
764 $grouped_obj[$rec["id"]]["objs"][] = $rec["id"];
765 }
766 }
767 // now get objects from repository plugin
768 $grouped_obj = self::getGroupedPluginObjectTypes($grouped_obj, "robj");
769 $grouped_obj = self::getGroupedPluginObjectTypes($grouped_obj, "orguext");
770
771 return ilArrayUtil::sortArray($grouped_obj, "pos", "asc", true, true);
772 }
773
777 public function isAllowedInRepository(string $obj_name): bool
778 {
779 return (bool) ($this->obj_data[$obj_name]["repository"] ?? false);
780 }
781
785 public function getAllRepositoryTypes(bool $incl_adm = false): array
786 {
787 $types = array_keys($this->obj_data);
788
789 $rbac_types = [];
790 foreach ($types as $type) {
791 if ($this->isAllowedInRepository($type) && (!$this->isAdministrationObject($type) || $incl_adm)) {
792 $rbac_types[] = $type;
793 }
794 }
795
796 return $rbac_types;
797 }
798
802 public function isAllowedInWorkspace(string $obj_name): bool
803 {
804 return (bool) ($this->obj_data[$obj_name]["workspace"] ?? false);
805 }
806
810 public function isAdministrationObject(string $obj_name): bool
811 {
812 return (bool) ($this->obj_data[$obj_name]['administration'] ?? false);
813 }
814
818 public function isInactivePlugin(string $type): bool
819 {
820 if (substr($type, 0, 1) == "x" && !$this->isPlugin($type)) {
821 return true;
822 }
823 return false;
824 }
825
829 public function getAdvancedMetaDataTypes(): array
830 {
831 $amet = [];
832 foreach ($this->obj_data as $k => $v) {
833 if ($v["amet"] ?? false) {
834 $amet[] = ["obj_type" => $k, "sub_type" => ""];
835 }
836 }
837
838 foreach ($this->sub_types as $type => $sub_types) {
839 foreach ($sub_types as $t) {
840 if ($t["amet"]) {
841 $amet[] = ["obj_type" => $type, "sub_type" => $t["sub_type"]];
842 }
843 }
844 }
845
846 return $amet;
847 }
848
854 public function getOrgUnitPermissionTypes(): array
855 {
856 $types = [];
857 foreach ($this->obj_data as $type => $object_info) {
858 if ($object_info['orgunit_permissions']) {
859 $types[] = $type;
860 }
861 }
862 return $types;
863 }
864
869 public function getLTIProviderTypes(): array
870 {
871 $types = [];
872 foreach ($this->obj_data as $type => $object_info) {
873 if (array_key_exists('lti_provider', $object_info) && $object_info['lti_provider']) {
874 $types[] = $type;
875 }
876 }
877 return $types;
878 }
879
883 public function isOrgUnitPermissionType(string $obj_type): bool
884 {
885 return in_array($obj_type, $this->getOrgUnitPermissionTypes());
886 }
887
891 public function getPositionByType(string $type): int
892 {
893 if ($this->settings->get("obj_add_new_pos_" . $type) > 0) {
894 return (int) $this->settings->get("obj_add_new_pos_" . $type);
895 }
896 return (int) $this->obj_data[$type]["default_pos"];
897 }
898
902 public function getPlugins(): array
903 {
904 $plugins = [];
905 foreach ($this->obj_data as $type => $pl_data) {
906 if ($this->isPlugin($type)) {
907 $plugins[$type] = $pl_data;
908 }
909 }
910 return $plugins;
911 }
912
916 public function getExplorerContainerTypes(): array
917 {
918 $res = $grp_map = $cnt_grp = [];
919
920 // all repository object types
921 foreach ($this->getSubObjectsRecursively("root") as $rtype) {
922 $type = $rtype["name"];
923
924 if ($type == "rolf") {
925 continue;
926 }
927
928 // gather group data
929 $type_grp = $this->getGroupOfObj($type);
930 if ($type_grp) {
931 $grp_map[$type_grp][] = $type;
932 }
933
934 // add basic container types
935 if ($this->isContainer($type)) {
936 if ($type_grp) {
937 $cnt_grp[] = $type_grp;
938 }
939
940 $res[] = $type;
941 }
942 }
943
944 // add complete groups (cat => rcat, catr; crs => rcrs, crsr; ...)
945 foreach ($cnt_grp as $grp) {
946 $res = array_merge($res, $grp_map[$grp]);
947 }
948 $res[] = "itgr";
949
950 return array_unique($res);
951 }
952
956 public function supportsOfflineHandling(string $obj_type): bool
957 {
958 return (bool) ($this->obj_data[$obj_type]['offline_handling'] ?? false);
959 }
960
961
966 protected function readPluginData(): void
967 {
968 $this->parsePluginData("robj", false);
969 $this->parsePluginData("orguext", true);
970 }
971
977 protected function parsePluginData(string $slotId, bool $isInAdministration): void
978 {
979 $plugins = $this->component_repository->getPluginSlotById($slotId)->getActivePlugins();
980 foreach ($plugins as $plugin) {
981 $pl_id = $plugin->getId();
982 if ($pl_id != "" && !isset($this->obj_data[$pl_id])) {
983 $loc = $plugin->getPath() . "/classes";
984 // The plugin_id is the same as the type_id in repository object plugins.
986
987 $this->obj_data[$pl_id] = [
988 "name" => $pl_id,
989 "class_name" => $pl->getPluginName(),
990 "plugin" => "1",
991 "location" => $loc,
992 "checkbox" => "1",
993 "inherit" => "0",
994 "component" => "",
995 "translate" => "0",
996 "devmode" => "0",
997 "allow_link" => "1",
998 "allow_copy" => $pl->allowCopy() ? '1' : '0',
999 "rbac" => "1",
1000 "group" => null,
1001 "system" => "0",
1002 "default_pos" => "99992000", // "unassigned" group
1003 'repository' => '1',
1004 'workspace' => '0',
1005 'administration' => $isInAdministration ? '1' : '0',
1006 "sideblock" => "0",
1007 'export' => $plugin->supportsExport(),
1008 'offline_handling' => '0',
1009 'orgunit_permissions' => $pl->useOrguPermissions() ? '1' : '0'
1010 ];
1011
1012 $parent_types = $pl->getParentTypes();
1013 foreach ($parent_types as $parent_type) {
1014 $this->obj_data[$parent_type]["subobjects"][$pl_id] = [
1015 "name" => $pl_id,
1016 "max" => "",
1017 "lng" => $pl_id,
1018 "plugin" => true
1019 ];
1020 }
1021 }
1022 }
1023 }
1024}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
return true
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static getInstance(?string $component)
static getCreatableSubObjects(array $subobjects, $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
isSideBlock(string $obj_name)
Check, whether object type is a side block.
isPlugin(string $obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type
allowLink(string $obj_name)
checks if linking of an object type is allowed
static getGroupedRepositoryObjectTypes($parent_obj_type)
getOrgUnitPermissionTypes()
Get object type with org unit position permission support.
isSystemObject(string $obj_name)
checks if object type is a system object
isAllowedInRepository(string $obj_name)
checks if object type can be used in repository context
static getComponentForType(string $obj_type)
Get component for object type.
readDefinitionData()
Read object definition data.
getDevModeAll()
get all object types in dev mode
getGroup(string $id)
Get Group information.
isActivePluginType(string $type)
Returns true if the given type is an active type of repositoryObject or Organisation Unit Extension p...
supportsOfflineHandling(string $obj_type)
check whether obj_type supports centralised offline handling
isInactivePlugin(string $type)
Check whether type belongs to inactive plugin.
handlerBeginTag($xml_parser, string $name, array $attribs)
isAllowedInWorkspace(string $obj_name)
checks if object type can be used in workspace context
getLTIProviderTypes()
Get object types which offer lti provider support.
readPluginData()
Loads the different plugins into the object definition.
getSubObjects(string $obj_type, bool $filter=true)
get all sub objects by type
getTranslationType(string $obj_name)
get translation type (sys, db or null)
static getGroupedPluginObjectTypes(array $grouped_obj, string $slotId)
getCreatableSubObjects(string $obj_type, int $context=self::MODE_REPOSITORY, int $parent_ref_id=null)
__filterObjects(array &$sub_objects)
stopInheritance(string $obj_name)
Does object permits stopping inheritance?
hasLocalRoles(string $obj_type)
Check whether the creation of local roles is allowed Currently disabled for type "root" and "adm".
getGroupOfObj(string $obj_name)
Get Group of object type.
ilComponentRepository $component_repository
hasCheckbox(string $obj_name)
should the object get a checkbox (needed for 'cut','copy' ...)
getSubobjectsToFilter(string $obj_type="adm")
get all subjects except (rolf) of the adm object This is necessary for filtering these objects in rol...
getDevMode(string $obj_name)
get dev mode status by type
isContainer(string $obj_name)
Check if object type is container ('crs','fold','grp' ...)
isAdministrationObject(string $obj_name)
Check if administration object.
isRBACObject(string $obj_name)
get RBAC status by type returns true if object type is a RBAC object type
static getRepositoryObjectTypesForComponent(string $component_type, string $component_name)
Get all repository object types of component.
isPluginTypeName(string $str)
Check if given type is a plugin type name (starts with an "x")
getAllRepositoryTypes(bool $incl_adm=false)
get all RBAC object types
getPlugins()
Get plugin object info.
getAdvancedMetaDataTypes()
Get advanced meta data objects.
getAllObjects()
get all object types
getPositionByType(string $type)
Get Position By Object Type.
getExplorerContainerTypes()
Get all object types which are defined as container in an explorer context.
handlerEndTag($xml_parser, string $name)
getClassName(string $obj_name)
allowCopy(string $obj_name)
checks if copying of an object type is allowed
isOrgUnitPermissionType(string $obj_type)
Check if object type offers org unit position support.
getSideBlockTypes(bool $filter_repository_types=true)
handlerCharacterData($xml_parser, string $data)
parsePluginData(string $slotId, bool $isInAdministration)
loads a single plugin definition into the object definition
getSubObjectsRecursively(string $obj_type, bool $include_source_obj=true, bool $add_admin_objects=false)
Get all sub objects by type.
getSubObjectsAsString(string $obj_type)
get a string of all sub objects by type
static getPluginObjectByType(string $type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
Readable part of repository interface to ilComponentDataDB.
getPluginSlotById(string $id)
Get pluginslot by id.
$res
Definition: ltiservices.php:69
if($format !==null) $name
Definition: metadata.php:247
string $key
Consumer key/client ID value.
Definition: System.php:193
$type
$context
Definition: webdav.php:29