ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjRepositorySettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObject.php");
5 
15 {
18 
25  function __construct($a_id,$a_call_by_reference = true)
26  {
27  $this->type = "reps";
28  parent::__construct($a_id,$a_call_by_reference);
29  }
30 
31  function delete()
32  {
33  // DISABLED
34  return false;
35  }
36 
37  public static function addNewItemGroupSeparator()
38  {
39  global $ilDB;
40 
41  // append
42  $pos = $ilDB->query("SELECT max(pos) mpos FROM il_new_item_grp");
43  $pos = $ilDB->fetchAssoc($pos);
44  $pos = (int)$pos["mpos"];
45  $pos += 10;
46 
47  $seq = $ilDB->nextID("il_new_item_grp");
48 
49  $ilDB->manipulate("INSERT INTO il_new_item_grp".
50  " (id, pos, type) VALUES (".
51  $ilDB->quote($seq, "integer").
52  ", ".$ilDB->quote($pos, "integer").
53  ", ".$ilDB->quote(self::NEW_ITEM_GROUP_TYPE_SEPARATOR, "integer").
54  ")");
55  return true;
56  }
57 
58  public static function addNewItemGroup(array $a_titles)
59  {
60  global $ilDB;
61 
62  // append
63  $pos = $ilDB->query("SELECT max(pos) mpos FROM il_new_item_grp");
64  $pos = $ilDB->fetchAssoc($pos);
65  $pos = (int)$pos["mpos"];
66  $pos += 10;
67 
68  $seq = $ilDB->nextID("il_new_item_grp");
69 
70  $ilDB->manipulate("INSERT INTO il_new_item_grp".
71  " (id, titles, pos, type) VALUES (".
72  $ilDB->quote($seq, "integer").
73  ", ".$ilDB->quote(serialize($a_titles), "text").
74  ", ".$ilDB->quote($pos, "integer").
75  ", ".$ilDB->quote(self::NEW_ITEM_GROUP_TYPE_GROUP, "integer").
76  ")");
77  return true;
78  }
79 
80  public static function updateNewItemGroup($a_id, array $a_titles)
81  {
82  global $ilDB;
83 
84  $ilDB->manipulate("UPDATE il_new_item_grp".
85  " SET titles = ".$ilDB->quote(serialize($a_titles), "text").
86  " WHERE id = ".$ilDB->quote($a_id, "integer"));
87  return true;
88  }
89 
90  public static function deleteNewItemGroup($a_id)
91  {
92  global $ilDB, $ilSetting;
93 
94  // move subitems to unassigned
95  $sub_items = self::getNewItemGroupSubItems();
96  $sub_items = $sub_items[$a_id];
97  if($sub_items)
98  {
99  foreach($sub_items as $obj_type)
100  {
101  $old_pos = $ilSetting->get("obj_add_new_pos_".$obj_type);
102  if(strlen($old_pos) == 8)
103  {
104  $new_pos = "9999".substr($old_pos, 4);
105  $ilSetting->set("obj_add_new_pos_".$obj_type, $new_pos);
106  $ilSetting->set("obj_add_new_pos_grp_".$obj_type, 0);
107  }
108  }
109  }
110 
111  $ilDB->manipulate("DELETE FROM il_new_item_grp".
112  " WHERE id = ".$ilDB->quote($a_id, "integer"));
113  return true;
114  }
115 
116  public static function getNewItemGroups()
117  {
118  global $ilDB, $lng, $ilUser;
119 
120  $def_lng = $lng->getDefaultLanguage();
121  $usr_lng = $ilUser->getLanguage();
122 
123  $res = array();
124 
125  $set = $ilDB->query("SELECT * FROM il_new_item_grp ORDER BY pos");
126  while($row = $ilDB->fetchAssoc($set))
127  {
128  if($row["type"] == self::NEW_ITEM_GROUP_TYPE_GROUP)
129  {
130  $row["titles"] = unserialize($row["titles"]);
131 
132  $title = $row["titles"][$usr_lng];
133  if(!$title)
134  {
135  $title = $row["titles"][$def_lng];
136  }
137  if(!$title)
138  {
139  $title = array_shift($row["titles"]);
140  }
141  $row["title"] = $title;
142  }
143  else
144  {
145  $row["title"] = $lng->txt("rep_new_item_group_separator");
146  }
147 
148  $res[$row["id"]] = $row;
149  }
150 
151  return $res;
152  }
153 
154  public static function updateNewItemGroupOrder(array $a_order)
155  {
156  global $ilDB;
157 
158  asort($a_order);
159  $pos = 0;
160  foreach(array_keys($a_order) as $id)
161  {
162  $pos += 10;
163 
164  $ilDB->manipulate("UPDATE il_new_item_grp".
165  " SET pos = ".$ilDB->quote($pos, "integer").
166  " WHERE id = ".$ilDB->quote($id, "integer"));
167  }
168  }
169 
170  protected static function getAllObjTypes()
171  {
172  global $ilPluginAdmin, $objDefinition;
173 
174  $res = array();
175 
176  // parse modules
177  include_once("./Services/Component/classes/class.ilModule.php");
178  foreach(ilModule::getAvailableCoreModules() as $mod)
179  {
180  $has_repo = false;
181  $rep_types = $objDefinition->getRepositoryObjectTypesForComponent(IL_COMP_MODULE, $mod["subdir"]);
182  if(sizeof($rep_types) > 0)
183  {
184  foreach($rep_types as $ridx => $rt)
185  {
186  // we only want to display repository modules
187  if($rt["repository"])
188  {
189  $has_repo = true;
190  }
191  else
192  {
193  unset($rep_types[$ridx]);
194  }
195  }
196  }
197  if($has_repo)
198  {
199  foreach($rep_types as $rt)
200  {
201  $res[] = $rt["id"];
202  }
203  }
204  }
205 
206  // parse plugins
207  include_once("./Services/Component/classes/class.ilPlugin.php");
208  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj");
209  foreach ($pl_names as $pl_name)
210  {
211  $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name);
212  if($pl_id)
213  {
214  $res[] = $pl_id;
215  }
216  }
217 
218  return $res;
219  }
220 
221  public static function getNewItemGroupSubItems()
222  {
223  global $ilSetting;
224 
225  $res = array();
226 
227  foreach(self::getAllObjTypes() as $type)
228  {
229  $pos_grp = $ilSetting->get("obj_add_new_pos_grp_".$type, 0);
230  $res[$pos_grp][] = $type;
231  }
232 
233  return $res;
234  }
235 
236  public static function getDefaultNewItemGrouping()
237  {
238  global $lng;
239 
240  $res = array();
241 
242  $groups = array(
243  "organisation" => array("fold", "sess", "cat", "catr", "crs", "crsr", "grp", "grpr", "itgr", "book", "prg"),
244  "communication" => array("frm", "chtr"),
245  "breaker1" => null,
246  "content" => array("file", "webr", "feed", "wiki", "blog", "lm", "htlm", "sahs", "glo", "dcl", "bibl", "mcst", "mep"),
247  "breaker2" => null,
248  "assessment" => array("exc", "tst", "qpl", "iass"),
249  "feedback" => array("poll", "svy", "spl"),
250  "templates" => array("prtt")
251  );
252 
253  $pos = 0;
254  foreach($groups as $group => $items)
255  {
256  $pos += 10;
257  $grp_id = $pos/10;
258 
259  if(is_array($items))
260  {
261  $title = $lng->txt("rep_add_new_def_grp_".$group);
262 
263  $res["groups"][$grp_id] = array("id" => $grp_id,
264  "titles" => array($lng->getUserLanguage() => $title),
265  "pos" => $pos,
266  "type" => self::NEW_ITEM_GROUP_TYPE_GROUP,
267  "title" => $title);
268 
269  foreach($items as $idx => $item)
270  {
271  $res["items"][$item] = $grp_id;
272  $res["sort"][$item] = str_pad($pos, 4, "0", STR_PAD_LEFT).
273  str_pad($idx+1, 4, "0", STR_PAD_LEFT);
274  }
275  }
276  else
277  {
278  $title = "COL_SEP";
279 
280  $res["groups"][$grp_id] = array("id" => $grp_id,
281  "titles" => array($lng->getUserLanguage() => $title),
282  "pos" => $pos,
283  "type" => self::NEW_ITEM_GROUP_TYPE_SEPARATOR,
284  "title" => $title);
285  }
286  }
287 
288  return $res;
289  }
290 
291  public static function deleteObjectType($a_type)
292  {
293  global $ilSetting;
294 
295  // see ilObjRepositorySettingsGUI::saveModules()
296  $ilSetting->delete("obj_dis_creation_".$a_type);
297  $ilSetting->delete("obj_add_new_pos_".$a_type);
298  $ilSetting->delete("obj_add_new_pos_grp_".$a_type);
299  }
300 }
301 
302 ?>
__construct($a_id, $a_call_by_reference=true)
Constructor public.
Class ilObject Basic functions for all objects.
static lookupIdForName($a_ctype, $a_cname, $a_slot_id, $a_plugin_name)
Lookup id for name.
$a_type
Definition: workflow.php:93
const IL_COMP_MODULE
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
static updateNewItemGroupOrder(array $a_order)
static addNewItemGroup(array $a_titles)
global $ilSetting
Definition: privfeed.php:17
global $ilDB
static updateNewItemGroup($a_id, array $a_titles)
const IL_COMP_SERVICE
Class ilObjRepositorySettings.
static getAvailableCoreModules()
Get all available core modules.