ILIAS  Release_4_1_x_branch Revision 61804
 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 "./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  while ($style_rec = $ilDB->fetchAssoc($style_set))
101  {
102  $this->styles[$style_rec["style_id"]] =
103  array("id" => $style_rec["style_id"],
104  "title" => ilObject::_lookupTitle($style_rec["style_id"]),
105  "category" => $style_rec["category"]);
106 //echo "<br>-".$style_rec["category"]."-";
107  }
108  }
109 
113  function _lookupActivatedStyle($a_skin, $a_style)
114  {
115  global $ilDB;
116 
117  $q = "SELECT count(*) cnt FROM settings_deactivated_s".
118  " WHERE skin = ".$ilDB->quote($a_skin, "text").
119  " AND style = ".$ilDB->quote($a_style, "text")." ";
120 
121  $cnt_set = $ilDB->query($q);
122  $cnt_rec = $ilDB->fetchAssoc($cnt_set);
123 
124  if ($cnt_rec["cnt"] > 0)
125  {
126  return false;
127  }
128  else
129  {
130  return true;
131  }
132  }
133 
137  function _deactivateStyle($a_skin, $a_style)
138  {
139  global $ilDB;
140 
141  ilObjStyleSettings::_activateStyle($a_skin, $a_style);
142  $q = "INSERT into settings_deactivated_s".
143  " (skin, style) VALUES ".
144  " (".$ilDB->quote($a_skin, "text").",".
145  " ".$ilDB->quote($a_style, "text").")";
146 
147  $ilDB->manipulate($q);
148  }
149 
153  function _activateStyle($a_skin, $a_style)
154  {
155  global $ilDB;
156 
157  $q = "DELETE FROM settings_deactivated_s".
158  " WHERE skin = ".$ilDB->quote($a_skin, "text").
159  " AND style = ".$ilDB->quote($a_style, "text");
160 
161  $ilDB->manipulate($q);
162  }
163 
169  function getStyles()
170  {
171  return $this->styles;
172  }
173 
174 
181  function delete()
182  {
183  // always call parent delete function first!!
184  if (!parent::delete())
185  {
186  return false;
187  }
188 
189  //put here your module specific stuff
190 
191  return true;
192  }
193 
203  function initDefaultRoles()
204  {
205  global $rbacadmin;
206 
207  // create a local role folder
208  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
209 
210  // create moderator role and assign role to rolefolder...
211  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
212  //$roles[] = $roleObj->getId();
213 
214  //unset($rfoldObj);
215  //unset($roleObj);
216 
217  return $roles ? $roles : array();
218  }
219 
233  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
234  {
235  global $tree;
236 
237  switch ($a_event)
238  {
239  case "link":
240 
241  //var_dump("<pre>",$a_params,"</pre>");
242  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
243  //exit;
244  break;
245 
246  case "cut":
247 
248  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
249  //exit;
250  break;
251 
252  case "copy":
253 
254  //var_dump("<pre>",$a_params,"</pre>");
255  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
256  //exit;
257  break;
258 
259  case "paste":
260 
261  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
262  //exit;
263  break;
264 
265  case "new":
266 
267  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
268  //exit;
269  break;
270  }
271 
272  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
273  if ($a_node_id==$_GET["ref_id"])
274  {
275  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
276  $parent_type = $parent_obj->getType();
277  if($parent_type == $this->getType())
278  {
279  $a_node_id = (int) $tree->getParentId($a_node_id);
280  }
281  }
282 
283  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
284  }
285 } // END class.ilObjStyleSettings
286 ?>