ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 require_once "./Services/Object/classes/class.ilObject.php";
14 
16 {
17  var $styles;
18 
25  function ilObjStyleSettings($a_id = 0,$a_call_by_reference = true)
26  {
27  $this->type = "stys";
28  $this->ilObject($a_id,$a_call_by_reference);
29 
30  $this->styles = array();
31  }
32 
38  function addStyle($a_style_id)
39  {
40  $this->styles[$a_style_id] =
41  array("id" => $a_style_id,
42  "title" => ilObject::_lookupTitle($a_style_id));
43  }
44 
45 
49  function removeStyle($a_id)
50  {
51  unset($a_id);
52  }
53 
54 
61  function update()
62  {
63  global $ilDB;
64 
65  if (!parent::update())
66  {
67  return false;
68  }
69 
70  // save styles of style folder
71  $q = "DELETE FROM style_folder_styles WHERE folder_id = ".
72  $ilDB->quote($this->getId(), "integer");
73  $ilDB->manipulate($q);
74  foreach($this->styles as $style)
75  {
76  $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES".
77  "(".$ilDB->quote((int) $this->getId(), "integer").", ".
78  $ilDB->quote((int) $style["id"], "integer").")";
79  $ilDB->manipulate($q);
80  }
81 
82  return true;
83  }
84 
88  function read()
89  {
90  global $ilDB;
91 
92  parent::read();
93 
94  // get styles of style folder
95  $q = "SELECT * FROM style_folder_styles, style_data WHERE folder_id = ".
96  $ilDB->quote($this->getId(), "integer").
97  " AND style_id = style_data.id";
98 
99  $style_set = $ilDB->query($q);
100  $this->styles = array();
101  while ($style_rec = $ilDB->fetchAssoc($style_set))
102  {
103  $this->styles[$style_rec["style_id"]] =
104  array("id" => $style_rec["style_id"],
105  "title" => ilObject::_lookupTitle($style_rec["style_id"]),
106  "category" => $style_rec["category"]);
107  }
108  $this->styles =
109  ilUtil::sortArray($this->styles, "title", "asc", false, true);
110  }
111 
115  function _lookupActivatedStyle($a_skin, $a_style)
116  {
117  global $ilDB;
118 
119  $q = "SELECT count(*) cnt FROM settings_deactivated_s".
120  " WHERE skin = ".$ilDB->quote($a_skin, "text").
121  " AND style = ".$ilDB->quote($a_style, "text")." ";
122 
123  $cnt_set = $ilDB->query($q);
124  $cnt_rec = $ilDB->fetchAssoc($cnt_set);
125 
126  if ($cnt_rec["cnt"] > 0)
127  {
128  return false;
129  }
130  else
131  {
132  return true;
133  }
134  }
135 
139  function _deactivateStyle($a_skin, $a_style)
140  {
141  global $ilDB;
142 
143  ilObjStyleSettings::_activateStyle($a_skin, $a_style);
144  $q = "INSERT into settings_deactivated_s".
145  " (skin, style) VALUES ".
146  " (".$ilDB->quote($a_skin, "text").",".
147  " ".$ilDB->quote($a_style, "text").")";
148 
149  $ilDB->manipulate($q);
150  }
151 
155  function _activateStyle($a_skin, $a_style)
156  {
157  global $ilDB;
158 
159  $q = "DELETE FROM settings_deactivated_s".
160  " WHERE skin = ".$ilDB->quote($a_skin, "text").
161  " AND style = ".$ilDB->quote($a_style, "text");
162 
163  $ilDB->manipulate($q);
164  }
165 
171  function getStyles()
172  {
173  return $this->styles;
174  }
175 
176 
183  function delete()
184  {
185  // always call parent delete function first!!
186  if (!parent::delete())
187  {
188  return false;
189  }
190 
191  //put here your module specific stuff
192 
193  return true;
194  }
195 
205  function initDefaultRoles()
206  {
207  global $rbacadmin;
208 
209  // create a local role folder
210  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
211 
212  // create moderator role and assign role to rolefolder...
213  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
214  //$roles[] = $roleObj->getId();
215 
216  //unset($rfoldObj);
217  //unset($roleObj);
218 
219  return $roles ? $roles : array();
220  }
221 
235  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
236  {
237  global $tree;
238 
239  switch ($a_event)
240  {
241  case "link":
242 
243  //var_dump("<pre>",$a_params,"</pre>");
244  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
245  //exit;
246  break;
247 
248  case "cut":
249 
250  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
251  //exit;
252  break;
253 
254  case "copy":
255 
256  //var_dump("<pre>",$a_params,"</pre>");
257  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
258  //exit;
259  break;
260 
261  case "paste":
262 
263  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
264  //exit;
265  break;
266 
267  case "new":
268 
269  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
270  //exit;
271  break;
272  }
273 
274  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
275  if ($a_node_id==$_GET["ref_id"])
276  {
277  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
278  $parent_type = $parent_obj->getType();
279  if($parent_type == $this->getType())
280  {
281  $a_node_id = (int) $tree->getParentId($a_node_id);
282  }
283  }
284 
285  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
286  }
287 } // END class.ilObjStyleSettings
288 ?>