19declare(strict_types=1);
48 $this->component_repository =
$DIC[
"component.repository"];
59 foreach ($global_cache->getIlObjectDef() as $rec) {
60 $this->obj_data[$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),
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']
85 $this->obj_data[$rec[
"id"]][
"subobjects"] = [];
87 $defIds[] = $rec[
"id"];
90 $subobj = $global_cache->lookupSubObjForParent($defIds);
92 foreach ($subobj as $rec2) {
97 $this->obj_data[$rec2[
"parent"]][
"subobjects"][$rec2[
"subobj"]] = [
98 "name" => $rec2[
"subobj"],
100 "lng" => $rec2[
"subobj"]
104 $this->obj_group = $global_cache->getIlObjectGroup();
106 $this->sub_types = $global_cache->getIlObjectSubType();
115 $this->obj_data = [];
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
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),
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']
153 $this->obj_data[$rec[
"id"]][
"subobjects"] = [];
155 $defIds[] = $rec[
"id"];
160 "SELECT parent, subobj, mmax" . PHP_EOL
161 .
"FROM il_object_subobj" . PHP_EOL
162 .
"WHERE " .
$ilDB->in(
'parent', $defIds,
false,
'text') . PHP_EOL
164 $result =
$ilDB->query($sql);
165 while ($rec2 =
$ilDB->fetchAssoc($result)) {
166 $max = $rec2[
"mmax"];
170 $this->obj_data[$rec2[
"parent"]][
"subobjects"][$rec2[
"subobj"]] = [
171 "name" => $rec2[
"subobj"],
173 "lng" => $rec2[
"subobj"]
178 "SELECT id, name, default_pres_pos" . PHP_EOL
179 .
"FROM il_object_group" . PHP_EOL
181 $result =
$ilDB->query($sql);
182 $this->obj_group = array();
183 while ($rec =
$ilDB->fetchAssoc($result)) {
184 $this->obj_group[$rec[
"id"]] = $rec;
190 "SELECT obj_type, sub_type, amet" . PHP_EOL
191 .
"FROM il_object_sub_type" . PHP_EOL
193 $result =
$ilDB->query($sql);
194 $this->sub_types = array();
195 while ($rec =
$ilDB->fetchAssoc($result)) {
196 $this->sub_types[$rec[
"obj_type"]][] = $rec;
218 foreach ($plugins as
$plugin) {
220 if (!isset($grouped_obj[$pl_id])) {
221 $grouped_obj[$pl_id] = array(
223 "objs" => array(0 => $pl_id)
232 return $this->obj_data[$obj_name][
"class_name"] ??
'';
237 return $this->obj_data[$obj_name][
"location"] ??
'';
245 return $this->obj_group[
$id];
253 return $this->obj_data[$obj_name][
"group"] ??
null;
261 return (
bool) ($this->obj_data[$obj_name][
"checkbox"] ??
false);
272 if ($obj_name ==
"root") {
273 if (!isset($this->root_trans_type)) {
275 "SELECT count(obj_id) cnt" . PHP_EOL
276 .
"FROM object_translation" . PHP_EOL
279 $set =
$ilDB->query($sql);
281 if ($rec[
"cnt"] > 0) {
282 $this->root_trans_type =
"db";
284 $this->root_trans_type = $this->obj_data[$obj_name][
"translate"];
287 return $this->root_trans_type;
290 if (isset($this->obj_data[$obj_name])) {
291 return $this->obj_data[$obj_name][
"translate"];
302 return (
bool) $this->obj_data[$obj_name][
"inherit"];
310 return (
bool) ($this->obj_data[$obj_name][
"devmode"] ??
false);
320 $types = array_keys($this->obj_data);
323 foreach ($types as
$type) {
325 $dev_types[] =
$type;
338 return (
bool) ($this->obj_data[$obj_name][
"rbac"] ??
false);
347 return isset($this->obj_data[$obj_name][
"plugin"]);
355 return (substr($str, 0, 1) ==
"x");
363 if (!$this->component_repository->hasPluginId(
$type)) {
366 $plugin_slot = $this->component_repository->getPluginById(
$type)->getPluginSlot();
367 return $plugin_slot->getId() ===
"robj" || $plugin_slot->getId() ===
"orguext";
372 $types = array_keys($this->obj_data);
375 foreach ($types as
$type) {
377 $rbac_types[] =
$type;
389 return array_keys($this->obj_data);
397 return (
bool) $this->obj_data[$obj_name][
"allow_link"];
405 return (
bool) $this->obj_data[$obj_name][
"allow_copy"];
410 return (
bool) $this->obj_data[$obj_name][
'export'];
434 if ($subobjects = ($this->obj_data[$obj_type][
"subobjects"] ??
false)) {
439 foreach ($subobjects as
$data => $sub) {
440 if (!isset($sub[
"module"]) || $sub[
"module"] !=
"n") {
445 $pos = (
int) $this->obj_data[
$data][
"default_pos"];
449 $subs[
$data][
"pos"] = $pos;
470 bool $include_source_obj =
true,
471 bool $add_admin_objects =
false
475 $recursive_subs = [];
479 $to_do = [$obj_type];
487 while (count($to_do) > 0) {
488 $type = array_pop($to_do);
492 if (
$type ==
'recf') {
497 if (!$add_admin_objects and
$type ==
'adm') {
502 foreach ($subs as $subtype =>
$data) {
507 if ($subtype ==
'rolt') {
510 if (!$add_admin_objects and $subtype ==
'adm') {
514 $recursive_subs[$subtype] =
$data;
515 if (!in_array($subtype, $done) && !in_array($subtype, $to_do)) {
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;
540 foreach ($this->obj_data[$obj_type][
"subobjects"] as
$key => $value) {
558 int $context = self::MODE_REPOSITORY,
559 int $parent_ref_id =
null
561 $sub_objects = $this->getSubObjects($obj_type);
564 unset($sub_objects[
"rolf"]);
566 $sub_types = array_keys($sub_objects);
569 foreach ($sub_types as
$type) {
570 if ($this->getDevMode(
$type) || $this->isSystemObject(
$type)) {
571 unset($sub_objects[
$type]);
573 if (
$context == self::MODE_REPOSITORY && !$this->isAllowedInRepository(
$type)) {
574 unset($sub_objects[
$type]);
576 if (
$context == self::MODE_WORKSPACE && !$this->isAllowedInWorkspace(
$type)) {
577 unset($sub_objects[
$type]);
579 if (
$context == self::MODE_ADMINISTRATION && !$this->isAdministrationObject(
$type)) {
580 unset($sub_objects[
$type]);
584 if ($obj_type ==
"prg") {
598 if (is_array($this->obj_data[$obj_type][
"subobjects"])) {
599 $data = array_keys($this->obj_data[$obj_type][
"subobjects"]);
600 $string =
"'" . implode(
"','",
$data) .
"'";
611 return (
bool) ($this->obj_data[$obj_name][
'subobjects'] ??
false);
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');
625 $this->parent_tag_name = $attribs[
"name"];
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"];
641 $this->current_tag =
'';
642 $this->current_tag_name =
'';
662 return (
bool) ($this->obj_data[$obj_name][
"system"] ??
false);
670 return (
bool) ($this->obj_data[$obj_name][
"sideblock"] ??
false);
675 $side_block_types = [];
676 foreach (array_keys($this->obj_data) as
$type) {
678 $filter_repository_types &&
679 !$this->isAllowedInRepository(
$type)
683 if ($this->isSideBlock(
$type)) {
684 $side_block_types[] =
$type;
687 return $side_block_types;
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
710 $result =
$ilDB->queryF($sql, [
"text"], [$component_type .
"/" . $component_name]);
713 while ($rec =
$ilDB->fetchAssoc($result)) {
714 if ($rec[
"system"] != 1) {
730 $result =
$ilDB->queryF(
"SELECT component FROM il_object_def WHERE id = %s", [
"text"], [$obj_type]);
732 if ($rec =
$ilDB->fetchAssoc($result)) {
733 return $rec[
"component"];
747 $set =
$ilDB->query(
"SELECT * FROM il_object_group");
750 $groups[$gr_rec[
"id"]] = $gr_rec;
755 $recs = $global_cache->lookupGroupedRepObj($parent_obj_type);
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"];
763 $grouped_obj[$rec[
"id"]][
"pos"] = (
int) $rec[
"default_pres_pos"];
764 $grouped_obj[$rec[
"id"]][
"objs"][] = $rec[
"id"];
768 $grouped_obj = self::getGroupedPluginObjectTypes($grouped_obj,
"robj");
769 $grouped_obj = self::getGroupedPluginObjectTypes($grouped_obj,
"orguext");
779 return (
bool) ($this->obj_data[$obj_name][
"repository"] ??
false);
787 $types = array_keys($this->obj_data);
790 foreach ($types as
$type) {
791 if ($this->isAllowedInRepository(
$type) && (!$this->isAdministrationObject(
$type) || $incl_adm)) {
792 $rbac_types[] =
$type;
804 return (
bool) ($this->obj_data[$obj_name][
"workspace"] ??
false);
812 return (
bool) ($this->obj_data[$obj_name][
'administration'] ??
false);
820 if (substr(
$type, 0, 1) ==
"x" && !$this->isPlugin(
$type)) {
832 foreach ($this->obj_data as $k => $v) {
833 if ($v[
"amet"] ??
false) {
834 $amet[] = [
"obj_type" => $k,
"sub_type" =>
""];
838 foreach ($this->sub_types as
$type => $sub_types) {
839 foreach ($sub_types as $t) {
841 $amet[] = [
"obj_type" =>
$type,
"sub_type" => $t[
"sub_type"]];
857 foreach ($this->obj_data as
$type => $object_info) {
858 if ($object_info[
'orgunit_permissions']) {
872 foreach ($this->obj_data as
$type => $object_info) {
873 if (array_key_exists(
'lti_provider', $object_info) && $object_info[
'lti_provider']) {
885 return in_array($obj_type, $this->getOrgUnitPermissionTypes());
893 if ($this->
settings->get(
"obj_add_new_pos_" . $type) > 0) {
894 return (
int) $this->
settings->get(
"obj_add_new_pos_" . $type);
896 return (
int) $this->obj_data[
$type][
"default_pos"];
905 foreach ($this->obj_data as
$type => $pl_data) {
906 if ($this->isPlugin(
$type)) {
907 $plugins[
$type] = $pl_data;
918 $res = $grp_map = $cnt_grp = [];
921 foreach ($this->getSubObjectsRecursively(
"root") as $rtype) {
922 $type = $rtype[
"name"];
924 if (
$type ==
"rolf") {
929 $type_grp = $this->getGroupOfObj(
$type);
931 $grp_map[$type_grp][] =
$type;
935 if ($this->isContainer(
$type)) {
937 $cnt_grp[] = $type_grp;
945 foreach ($cnt_grp as $grp) {
946 $res = array_merge(
$res, $grp_map[$grp]);
950 return array_unique(
$res);
958 return (
bool) ($this->obj_data[$obj_type][
'offline_handling'] ??
false);
968 $this->parsePluginData(
"robj",
false);
969 $this->parsePluginData(
"orguext",
true);
979 $plugins = $this->component_repository->getPluginSlotById($slotId)->getActivePlugins();
980 foreach ($plugins as
$plugin) {
982 if ($pl_id !=
"" && !isset($this->obj_data[$pl_id])) {
983 $loc =
$plugin->getPath() .
"/classes";
987 $this->obj_data[$pl_id] = [
989 "class_name" => $pl->getPluginName(),
998 "allow_copy" => $pl->allowCopy() ?
'1' :
'0',
1002 "default_pos" =>
"99992000",
1003 'repository' =>
'1',
1005 'administration' => $isInAdministration ?
'1' :
'0',
1007 'export' =>
$plugin->supportsExport(),
1008 'offline_handling' =>
'0',
1009 'orgunit_permissions' => $pl->useOrguPermissions() ?
'1' :
'0'
1012 $parent_types = $pl->getParentTypes();
1013 foreach ($parent_types as $parent_type) {
1014 $this->obj_data[$parent_type][
"subobjects"][$pl_id] = [
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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
readDefinitionDataFromCache()
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
readDefinitionDataFromDB()
allowExport(string $obj_name)
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.
getLocation(string $obj_name)
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)
const MODE_ADMINISTRATION
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...
Readable part of repository interface to ilComponentDataDB.
getPluginSlotById(string $id)
Get pluginslot by id.