ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
33 require_once "./classes/class.ilObject.php";
34 
36 {
37  var $styles;
38 
45  function ilObjStyleSettings($a_id = 0,$a_call_by_reference = true)
46  {
47  $this->type = "stys";
48  $this->ilObject($a_id,$a_call_by_reference);
49 
50  $this->styles = array();
51  }
52 
58  function addStyle($a_style_id)
59  {
60  $this->styles[$a_style_id] =
61  array("id" => $a_style_id,
62  "title" => ilObject::_lookupTitle($a_style_id));
63  }
64 
65 
69  function removeStyle($a_id)
70  {
71  unset($a_id);
72  }
73 
74 
81  function update()
82  {
83  global $ilDB;
84 
85  if (!parent::update())
86  {
87  return false;
88  }
89 
90  // save styles of style folder
91  $q = "DELETE FROM style_folder_styles WHERE folder_id = ".
92  $ilDB->quote($this->getId());
93  $ilDB->query($q);
94  foreach($this->styles as $style)
95  {
96  $q = "INSERT INTO style_folder_styles (folder_id, style_id) VALUES".
97  "(".$ilDB->quote($this->getId()).", ".
98  $ilDB->quote($style["id"]).")";
99  $ilDB->query($q);
100  }
101 
102  return true;
103  }
104 
108  function read()
109  {
110  global $ilDB;
111 
112  parent::read();
113 
114  // get styles of style folder
115  $q = "SELECT * FROM style_folder_styles, object_data as obj, style_data WHERE folder_id = ".
116  $ilDB->quote($this->getId()).
117  " AND style_id = obj.obj_id".
118  " AND style_data.id = obj.obj_id";
119 
120  $style_set = $ilDB->query($q);
121  while ($style_rec = $style_set->fetchRow(DB_FETCHMODE_ASSOC))
122  {
123  $this->styles[$style_rec["style_id"]] =
124  array("id" => $style_rec["style_id"],
125  "title" => $style_rec["title"],
126  "category" => $style_rec["category"]);
127 //echo "<br>-".$style_rec["category"]."-";
128  }
129  }
130 
134  function _lookupActivatedStyle($a_skin, $a_style)
135  {
136  global $ilDB;
137 
138  $q = "SELECT count(*) AS cnt FROM settings_deactivated_styles".
139  " WHERE skin = ".$ilDB->quote($a_skin).
140  " AND style = ".$ilDB->quote($a_style);
141 
142  $cnt_set = $ilDB->query($q);
143  $cnt_rec = $cnt_set->fetchRow(DB_FETCHMODE_ASSOC);
144 
145  if ($cnt_rec["cnt"] > 0)
146  {
147  return false;
148  }
149  else
150  {
151  return true;
152  }
153  }
154 
158  function _deactivateStyle($a_skin, $a_style)
159  {
160  global $ilDB;
161 
162  $q = "REPLACE into settings_deactivated_styles".
163  " (skin, style) VALUES ".
164  " (".$ilDB->quote($a_skin).",".
165  " ".$ilDB->quote($a_style).")";
166 
167  $ilDB->query($q);
168  }
169 
173  function _activateStyle($a_skin, $a_style)
174  {
175  global $ilDB;
176 
177  $q = "DELETE FROM settings_deactivated_styles".
178  " WHERE skin = ".$ilDB->quote($a_skin).
179  " AND style = ".$ilDB->quote($a_style);
180 
181  $ilDB->query($q);
182  }
183 
189  function getStyles()
190  {
191  return $this->styles;
192  }
193 
194 
201  function delete()
202  {
203  // always call parent delete function first!!
204  if (!parent::delete())
205  {
206  return false;
207  }
208 
209  //put here your module specific stuff
210 
211  return true;
212  }
213 
223  function initDefaultRoles()
224  {
225  global $rbacadmin;
226 
227  // create a local role folder
228  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
229 
230  // create moderator role and assign role to rolefolder...
231  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
232  //$roles[] = $roleObj->getId();
233 
234  //unset($rfoldObj);
235  //unset($roleObj);
236 
237  return $roles ? $roles : array();
238  }
239 
253  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
254  {
255  global $tree;
256 
257  switch ($a_event)
258  {
259  case "link":
260 
261  //var_dump("<pre>",$a_params,"</pre>");
262  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
263  //exit;
264  break;
265 
266  case "cut":
267 
268  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
269  //exit;
270  break;
271 
272  case "copy":
273 
274  //var_dump("<pre>",$a_params,"</pre>");
275  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
276  //exit;
277  break;
278 
279  case "paste":
280 
281  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
282  //exit;
283  break;
284 
285  case "new":
286 
287  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
288  //exit;
289  break;
290  }
291 
292  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
293  if ($a_node_id==$_GET["ref_id"])
294  {
295  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
296  $parent_type = $parent_obj->getType();
297  if($parent_type == $this->getType())
298  {
299  $a_node_id = (int) $tree->getParentId($a_node_id);
300  }
301  }
302 
303  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
304  }
305 } // END class.ilObjStyleSettings
306 ?>