ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSheetFolder.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 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 ilObjStyleSheetFolder($a_id = 0,$a_call_by_reference = true)
46  {
47  $this->type = "styf";
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 WHERE folder_id = ".
116  $ilDB->quote($this->getId()).
117  " AND style_id = obj.obj_id";
118 
119  $style_set = $ilDB->query($q);
120  while ($style_rec = $style_set->fetchRow(DB_FETCHMODE_ASSOC))
121  {
122  $this->styles[$style_rec["style_id"]] =
123  array("id" => $style_rec["style_id"],
124  "title" => $style_rec["title"]);
125  }
126  }
127 
128 
134  function getStyles()
135  {
136  return $this->styles;
137  }
138 
139 
140 
147  function delete()
148  {
149  // always call parent delete function first!!
150  if (!parent::delete())
151  {
152  return false;
153  }
154 
155  //put here your module specific stuff
156 
157  return true;
158  }
159 
169  function initDefaultRoles()
170  {
171  global $rbacadmin;
172 
173  // create a local role folder
174  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
175 
176  // create moderator role and assign role to rolefolder...
177  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
178  //$roles[] = $roleObj->getId();
179 
180  //unset($rfoldObj);
181  //unset($roleObj);
182 
183  return $roles ? $roles : array();
184  }
185 
199  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
200  {
201  global $tree;
202 
203  switch ($a_event)
204  {
205  case "link":
206 
207  //var_dump("<pre>",$a_params,"</pre>");
208  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
209  //exit;
210  break;
211 
212  case "cut":
213 
214  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
215  //exit;
216  break;
217 
218  case "copy":
219 
220  //var_dump("<pre>",$a_params,"</pre>");
221  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
222  //exit;
223  break;
224 
225  case "paste":
226 
227  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
228  //exit;
229  break;
230 
231  case "new":
232 
233  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
234  //exit;
235  break;
236  }
237 
238  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
239  if ($a_node_id==$_GET["ref_id"])
240  {
241  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
242  $parent_type = $parent_obj->getType();
243  if($parent_type == $this->getType())
244  {
245  $a_node_id = (int) $tree->getParentId($a_node_id);
246  }
247  }
248 
249  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
250  }
251 } // END class.ilObjStyleSheetFolder
252 ?>