ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjBookingPool.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./classes/class.ilObject.php";
5 
14 {
15  protected $offline; // bool
16  protected $public_log; // bool
17  protected $slots_no; // int
18 
24  function __construct($a_id = 0,$a_call_by_reference = true)
25  {
26  $this->type = "book";
27  $this->ilObject($a_id,$a_call_by_reference);
28  }
29 
30 
35  function create()
36  {
37  global $ilDB;
38 
39  $new_id = parent::create();
40 
41  $ilDB->manipulate('INSERT INTO booking_settings (booking_pool_id)'.
42  ' VALUES ('.$ilDB->quote($new_id, 'integer').')');
43 
44  return $new_id;
45  }
46 
51  function update()
52  {
53  global $ilDB;
54 
55  if (!parent::update())
56  {
57  return false;
58  }
59 
60  // put here object specific stuff
61  if($this->getId())
62  {
63  $ilDB->manipulate('UPDATE booking_settings'.
64  ' SET pool_offline = '.$ilDB->quote($this->isOffline(), 'integer').
65  ', public_log = '.$ilDB->quote($this->hasPublicLog(), 'integer').
66  ', slots_no = '.$ilDB->quote($this->getNumberOfSlots(), 'integer').
67  ' WHERE booking_pool_id = '.$ilDB->quote($this->getId(), 'integer'));
68  }
69 
70  return true;
71  }
72 
73  function read()
74  {
75  global $ilDB;
76 
77  parent::read();
78 
79  // put here object specific stuff
80  if($this->getId())
81  {
82  $set = $ilDB->query('SELECT * FROM booking_settings'.
83  ' WHERE booking_pool_id = '.$ilDB->quote($this->getId(), 'integer'));
84  $row = $ilDB->fetchAssoc($set);
85  $this->setOffline($row['pool_offline']);
86  $this->setPublicLog($row['public_log']);
87  $this->setNumberOfSlots($row['slots_no']);
88  }
89  }
90 
95  function delete()
96  {
97  global $ilDB;
98 
99  $id = $this->getId();
100 
101  // always call parent delete function first!!
102  if (!parent::delete())
103  {
104  return false;
105  }
106 
107  // put here your module specific stuff
108 
109  $ilDB->manipulate('DELETE FROM booking_settings'.
110  ' WHERE booking_pool_id = '.$ilDB->quote($id, 'integer'));
111 
112  $ilDB->manipulate('DELETE FROM booking_schedule'.
113  ' WHERE pool_id = '.$ilDB->quote($id, 'integer'));
114 
115  $types = array();
116  $set = $ilDB->query('SELECT booking_type_id FROM booking_type'.
117  ' WHERE pool_id = '.$ilDB->quote($id, 'integer'));
118  while($row = $ilDB->fetchAssoc($set))
119  {
120  $types[] = $row['booking_type_id'];
121  }
122 
123  if(sizeof($types))
124  {
125  $objects = array();
126  $set = $ilDB->query('SELECT booking_object_id FROM booking_object'.
127  ' WHERE '.$ilDB->in('type_id', $types, '', 'integer'));
128  while($row = $ilDB->fetchAssoc($set))
129  {
130  $objects[] = $row['booking_object_id'];
131  }
132 
133  if(sizeof($objects))
134  {
135  $ilDB->manipulate('DELETE FROM booking_reservation'.
136  ' WHERE '.$ilDB->in('object_id', $objects, '', 'integer'));
137  }
138 
139  $ilDB->manipulate('DELETE FROM booking_object'.
140  ' WHERE '.$ilDB->in('type_id', $types, '', 'integer'));
141 
142  $ilDB->manipulate('DELETE FROM booking_type'.
143  ' WHERE pool_id = '.$ilDB->quote($id, 'integer'));
144  }
145 
146  return true;
147  }
148 
157  function initDefaultRoles()
158  {
159  global $rbacadmin;
160 
161  // create a local role folder
162  //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
163 
164  // create moderator role and assign role to rolefolder...
165  //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
166  //$roles[] = $roleObj->getId();
167 
168  //unset($rfoldObj);
169  //unset($roleObj);
170 
171  return $roles ? $roles : array();
172  }
173 
186  function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
187  {
188  global $tree;
189 
190  switch ($a_event)
191  {
192  case "link":
193 
194  //var_dump("<pre>",$a_params,"</pre>");
195  //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
196  //exit;
197  break;
198 
199  case "cut":
200 
201  //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
202  //exit;
203  break;
204 
205  case "copy":
206 
207  //var_dump("<pre>",$a_params,"</pre>");
208  //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
209  //exit;
210  break;
211 
212  case "paste":
213 
214  //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
215  //exit;
216  break;
217 
218  case "new":
219 
220  //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
221  //exit;
222  break;
223  }
224 
225  // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
226  if ($a_node_id==$_GET["ref_id"])
227  {
228  $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
229  $parent_type = $parent_obj->getType();
230  if($parent_type == $this->getType())
231  {
232  $a_node_id = (int) $tree->getParentId($a_node_id);
233  }
234  }
235 
236  parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
237  }
238 
243  function setOffline($a_value = true)
244  {
245  $this->offline = (bool)$a_value;
246  }
247 
252  function isOffline()
253  {
254  return (bool)$this->offline;
255  }
256 
261  function setPublicLog($a_value = true)
262  {
263  $this->public_log = (bool)$a_value;
264  }
265 
270  function hasPublicLog()
271  {
272  return (bool)$this->public_log;
273  }
274 
279  function setNumberOfSlots($a_value = true)
280  {
281  $this->slots_no = (int)$a_value;
282  }
283 
288  function getNumberOfSlots()
289  {
290  return (int)$this->slots_no;
291  }
292 }
293 
294 ?>