/**
  * Parse creatable sub objects for repository incl. grouping
  * 
  * @return bool
  */
 protected function parseRepository()
 {
     global $objDefinition, $lng, $ilAccess;
     $this->sub_objects = array();
     if (!is_array($this->disabled_object_types)) {
         $this->disabled_object_types = array();
     }
     $this->disabled_object_types[] = "rolf";
     $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
     $subtypes = $objDefinition->getCreatableSubObjects($parent_type, $this->mode);
     if (count($subtypes) > 0) {
         // grouping of object types
         $grp_map = $pos_group_map = array();
         include_once "Services/Repository/classes/class.ilObjRepositorySettings.php";
         $groups = ilObjRepositorySettings::getNewItemGroups();
         // no groups => use default
         if (!$groups) {
             $default = ilObjRepositorySettings::getDefaultNewItemGrouping();
             $groups = $default["groups"];
             $grp_map = $default["items"];
             // reset positions (9999 = "other"/unassigned)
             $pos = 0;
             foreach ($subtypes as $item_type => $item) {
                 // see ilObjectDefinition
                 if (substr($item_type, 0, 1) == "x") {
                     $subtypes[$item_type]["pos"] = "99992000";
                 } else {
                     $subtypes[$item_type]["pos"] = "9999" . str_pad(++$pos, 4, "0", STR_PAD_LEFT);
                 }
             }
             // assign default positions
             foreach ($default["sort"] as $item_type => $pos) {
                 if (array_key_exists($item_type, $subtypes)) {
                     $subtypes[$item_type]["pos"] = $pos;
                 }
             }
             // sort by default positions
             $subtypes = ilUtil::sortArray($subtypes, "pos", "asc", true, true);
         } else {
             foreach (ilObjRepositorySettings::getNewItemGroupSubItems() as $grp_id => $subitems) {
                 foreach ($subitems as $subitem) {
                     $grp_map[$subitem] = $grp_id;
                 }
             }
         }
         $group_separators = array();
         $pos_group_map[0] = $lng->txt("rep_new_item_group_other");
         $old_grp_ids = array();
         foreach ($groups as $item) {
             if ($item["type"] == ilObjRepositorySettings::NEW_ITEM_GROUP_TYPE_GROUP) {
                 $pos_group_map[$item["id"]] = $item["title"];
             } else {
                 if (sizeof($old_grp_ids)) {
                     $group_separators[$item["id"]] = $old_grp_ids;
                 }
             }
             $old_grp_ids[] = $item["id"];
         }
         $current_grp = null;
         foreach ($subtypes as $type => $subitem) {
             if (!in_array($type, $this->disabled_object_types)) {
                 // #9950
                 if ($ilAccess->checkAccess("create_" . $type, "", $this->parent_ref_id, $parent_type)) {
                     // if only assigned - do not add groups
                     if (sizeof($pos_group_map) > 1) {
                         $obj_grp_id = (int) $grp_map[$type];
                         if ($obj_grp_id !== $current_grp) {
                             // add seperator after last group?
                             $sdone = false;
                             foreach ($group_separators as $idx => $spath) {
                                 // #11986 - all separators up to next group
                                 if ($current_grp && !in_array($obj_grp_id, $spath)) {
                                     // 1 only separator between groups
                                     if (!$sdone) {
                                         $this->sub_objects[] = array("type" => "column_separator");
                                         $sdone = true;
                                     }
                                     unset($group_separators[$idx]);
                                 }
                             }
                             $title = $pos_group_map[$obj_grp_id];
                             $this->sub_objects[] = array("type" => "group", "title" => $title);
                             $current_grp = $obj_grp_id;
                         }
                     }
                     if ($subitem["plugin"]) {
                         include_once "./Services/Component/classes/class.ilPlugin.php";
                         $title = ilPlugin::lookupTxt("rep_robj", $type, "obj_" . $type);
                     } else {
                         // #13088
                         $title = $lng->txt("obj_" . $type);
                     }
                     $this->sub_objects[] = array("type" => "object", "value" => $type, "title" => $title);
                 }
             }
         }
     }
     return (bool) sizeof($this->sub_objects);
 }