ILIAS  eassessment Revision 61809
 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 
202  function initDefaultRoles()
203  {
204  global $rbacadmin;
205 
206  return $roles ? $roles : array();
207  }
208 
222  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
223  {
224  global $tree;
225 
226  switch ($a_event)
227  {
228  case "link":
229 
230  //var_dump("<pre>",$a_params,"</pre>");
231  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
232  //exit;
233  break;
234 
235  case "cut":
236 
237  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
238  //exit;
239  break;
240 
241  case "copy":
242 
243  //var_dump("<pre>",$a_params,"</pre>");
244  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
245  //exit;
246  break;
247 
248  case "paste":
249 
250  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
251  //exit;
252  break;
253 
254  case "new":
255 
256  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
257  //exit;
258  break;
259  }
260 
261  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
262  if ($a_node_id==$_GET["ref_id"])
263  {
264  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
265  $parent_type = $parent_obj->getType();
266  if($parent_type == $this->getType())
267  {
268  $a_node_id = (int) $tree->getParentId($a_node_id);
269  }
270  }
271 
272  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
273  }
274 } // END class.ilObjStyleSettings
275 ?>