/** * Get pages for list. */ function getGroups() { global $lng; $data = array(); $subitems = ilObjRepositorySettings::getNewItemGroupSubItems(); if ($subitems[0]) { ilUtil::sendInfo(sprintf($lng->txt("rep_new_item_group_unassigned_subitems"), sizeof($subitems[0]))); unset($subitems[0]); } foreach (ilObjRepositorySettings::getNewItemGroups() as $item) { $data[] = array("id" => $item["id"], "pos" => $item["pos"], "title" => $item["title"], "type" => $item["type"], "subitems" => sizeof($subitems[$item["id"]])); } $data = ilUtil::sortArray($data, "pos", "asc", true); $this->setData($data); }
protected function deleteNewItemGroup() { if (!is_array($_POST["grp_id"])) { return $this->listNewItemGroups(); } include_once "Services/Repository/classes/class.ilObjRepositorySettings.php"; foreach ($_POST["grp_id"] as $grp_id) { ilObjRepositorySettings::deleteNewItemGroup($grp_id); } ilUtil::sendSuccess($this->lng->txt("settings_saved"), true); $this->ctrl->redirect($this, "listNewItemGroups"); }
/** * 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); }
/** * Get pages for list. */ function getComponents() { global $objDefinition, $ilSetting, $lng, $ilPluginAdmin; // unassigned objects should be last $this->pos_group_options = array(0 => $lng->txt("rep_new_item_group_unassigned")); $pos_group_map[0] = "9999"; include_once "Services/Repository/classes/class.ilObjRepositorySettings.php"; foreach (ilObjRepositorySettings::getNewItemGroups() as $item) { $this->pos_group_options[$item["id"]] = $item["title"]; $pos_group_map[$item["id"]] = $item["pos"]; } $obj_types = array(); // parse modules include_once "./Services/Component/classes/class.ilModule.php"; foreach (ilModule::getAvailableCoreModules() as $mod) { $has_repo = false; $rep_types = $objDefinition->getRepositoryObjectTypesForComponent(IL_COMP_MODULE, $mod["subdir"]); if (sizeof($rep_types) > 0) { foreach ($rep_types as $ridx => $rt) { // we only want to display repository modules if ($rt["repository"]) { $has_repo = true; } else { unset($rep_types[$ridx]); } } } if ($has_repo) { foreach ($rep_types as $rt) { $obj_types[$rt["id"]] = array("object" => $rt["class_name"], "caption" => $lng->txt("obj_" . $rt["id"]), "subdir" => $mod["subdir"], "grp" => $rt["grp"], "default_pos" => $rt["default_pos"]); } } } // parse plugins include_once "./Services/Component/classes/class.ilPlugin.php"; $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj"); foreach ($pl_names as $pl_name) { $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name); if ($pl_id) { $obj_types[$pl_id] = array("object" => $pl_name, "caption" => ilPlugin::lookupTxt("rep_robj", $pl_id, "obj_" . $pl_id), "subdir" => $lng->txt("cmps_plugin"), "grp" => "", "default_pos" => 2000); } } // parse positions $data = array(); foreach ($obj_types as $obj_type => $item) { $org_pos = $ilSetting->get("obj_add_new_pos_" . $obj_type); if (!(int) $org_pos) { // no setting yet, use default $org_pos = $item["default_pos"]; } if (strlen($org_pos) < 8) { // "old" setting without group part, add "unassigned" group $org_pos = $pos_group_map[0] . str_pad($org_pos, 4, "0", STR_PAD_LEFT); } $pos_grp_id = $ilSetting->get("obj_add_new_pos_grp_" . $obj_type, 0); $group = null; if ($item["grp"] != "") { $group = $objDefinition->getGroup($item["grp"]); $group = $group["name"]; } $data[] = array("id" => $obj_type, "object" => $item["object"], "caption" => $item["caption"], "subdir" => $item["subdir"], "pos" => (int) substr($org_pos, 4), "pos_group" => $pos_grp_id, "creation" => !(bool) $ilSetting->get("obj_dis_creation_" . $obj_type, false), "group_id" => $item["grp"], "group" => $group, "sort_key" => (int) $org_pos); } $data = ilUtil::sortArray($data, "sort_key", "asc", true); $this->setData($data); }