ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4require_once "./Services/Object/classes/class.ilObject.php";
5
14{
15 //offline default should be true
16 protected $offline = true; // [bool]
17 protected $public_log; // [bool]
18 protected $schedule_type; // [int]
19 protected $overall_limit; // [int]
20
23
29 function __construct($a_id = 0,$a_call_by_reference = true)
30 {
31 $this->type = "book";
32 $this->setScheduleType(self::TYPE_FIX_SCHEDULE);
33 $this->ilObject($a_id,$a_call_by_reference);
34 }
35
39 protected function getDBFields()
40 {
41 $fields = array(
42 "schedule_type" => array("integer", $this->getScheduleType()),
43 "pool_offline" => array("integer", $this->isOffline()),
44 "public_log" => array("integer", $this->hasPublicLog()),
45 "ovlimit" => array("integer", $this->getOverallLimit())
46 );
47
48 return $fields;
49 }
50
55 function create()
56 {
57 global $ilDB;
58
59 $new_id = parent::create();
60
61 $fields = $this->getDBFields();
62 $fields["booking_pool_id"] = array("integer", $new_id);
63
64 $ilDB->insert("booking_settings", $fields);
65
66 return $new_id;
67 }
68
73 function update()
74 {
75 global $ilDB;
76
77 if (!parent::update())
78 {
79 return false;
80 }
81
82 // put here object specific stuff
83 if($this->getId())
84 {
85 $ilDB->update("booking_settings", $this->getDBFields(),
86 array("booking_pool_id" => array("integer", $this->getId())));
87 }
88
89 return true;
90 }
91
92 function read()
93 {
94 global $ilDB;
95
96 parent::read();
97
98 // put here object specific stuff
99 if($this->getId())
100 {
101 $set = $ilDB->query('SELECT * FROM booking_settings'.
102 ' WHERE booking_pool_id = '.$ilDB->quote($this->getId(), 'integer'));
103 $row = $ilDB->fetchAssoc($set);
104 $this->setOffline($row['pool_offline']);
105 $this->setPublicLog($row['public_log']);
106 $this->setScheduleType($row['schedule_type']);
107 $this->setOverallLimit($row['ovlimit']);
108 }
109 }
110
115 function delete()
116 {
117 global $ilDB;
118
119 $id = $this->getId();
120
121 // always call parent delete function first!!
122 if (!parent::delete())
123 {
124 return false;
125 }
126
127 // put here your module specific stuff
128
129 $ilDB->manipulate('DELETE FROM booking_settings'.
130 ' WHERE booking_pool_id = '.$ilDB->quote($id, 'integer'));
131
132 $ilDB->manipulate('DELETE FROM booking_schedule'.
133 ' WHERE pool_id = '.$ilDB->quote($id, 'integer'));
134
135 $objects = array();
136 $set = $ilDB->query('SELECT booking_object_id FROM booking_object'.
137 ' WHERE pool_id = '.$ilDB->quote($id, 'integer'));
138 while($row = $ilDB->fetchAssoc($set))
139 {
140 $objects[] = $row['booking_object_id'];
141 }
142
143 if(sizeof($objects))
144 {
145 $ilDB->manipulate('DELETE FROM booking_reservation'.
146 ' WHERE '.$ilDB->in('object_id', $objects, '', 'integer'));
147 }
148
149 $ilDB->manipulate('DELETE FROM booking_object'.
150 ' WHERE pool_id = '.$ilDB->quote($id, 'integer'));
151
152 return true;
153 }
154
155 public function cloneObject($a_target_id,$a_copy_id = 0,$a_omit_tree = false)
156 {
157 $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
158
159 //copy online status if object is not the root copy object
160 $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
161
162 if(!$cp_options->isRootNode($this->getRefId()))
163 {
164 $new_obj->setOffline($this->isOffline());
165 }
166
167 $new_obj->setScheduleType($this->getScheduleType());
168 $new_obj->setPublicLog($this->hasPublicLog());
169 $new_obj->setOverallLimit($this->getOverallLimit());
170
171 $smap = null;
172 if($this->getScheduleType() == self::TYPE_FIX_SCHEDULE)
173 {
174 // schedules
175 include_once "Modules/BookingManager/classes/class.ilBookingSchedule.php";
176 foreach(ilBookingSchedule::getList($this->getId()) as $item)
177 {
178 $schedule = new ilBookingSchedule($item["booking_schedule_id"]);
179 $smap[$item["booking_schedule_id"]] = $schedule->doClone($new_obj->getId());
180 }
181 }
182
183 // objects
184 include_once "Modules/BookingManager/classes/class.ilBookingObject.php";
185 foreach(ilBookingObject::getList($this->getId()) as $item)
186 {
187 $bobj = new ilBookingObject($item["booking_object_id"]);
188 $bobj->doClone($new_obj->getId(), $smap);
189 }
190
191 $new_obj->update();
192
193 return $new_obj;
194 }
195
196
209 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
210 {
211 global $tree;
212
213 switch ($a_event)
214 {
215 case "link":
216
217 //var_dump("<pre>",$a_params,"</pre>");
218 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
219 //exit;
220 break;
221
222 case "cut":
223
224 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
225 //exit;
226 break;
227
228 case "copy":
229
230 //var_dump("<pre>",$a_params,"</pre>");
231 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
232 //exit;
233 break;
234
235 case "paste":
236
237 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
238 //exit;
239 break;
240
241 case "new":
242
243 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
244 //exit;
245 break;
246 }
247
248 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
249 if ($a_node_id==$_GET["ref_id"])
250 {
251 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
252 $parent_type = $parent_obj->getType();
253 if($parent_type == $this->getType())
254 {
255 $a_node_id = (int) $tree->getParentId($a_node_id);
256 }
257 }
258
259 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
260 }
261
266 function setOffline($a_value = true)
267 {
268 $this->offline = (bool)$a_value;
269 }
270
275 function isOffline()
276 {
277 return (bool)$this->offline;
278 }
279
284 function setPublicLog($a_value = true)
285 {
286 $this->public_log = (bool)$a_value;
287 }
288
293 function hasPublicLog()
294 {
295 return (bool)$this->public_log;
296 }
297
302 function setScheduleType($a_value)
303 {
304 $this->schedule_type = (int)$a_value;
305 }
306
312 {
314 }
315
322 public static function _lookupOnline($a_obj_id)
323 {
324 global $ilDB;
325
326 $set = $ilDB->query("SELECT pool_offline".
327 " FROM booking_settings".
328 " WHERE booking_pool_id = ".$ilDB->quote($a_obj_id, "integer"));
329 $row = $ilDB->fetchAssoc($set);
330 return !(bool)$row["pool_offline"];
331 }
332
338 public function setOverallLimit($a_value = null)
339 {
340 if($a_value !== null)
341 {
342 $a_value = (int)$a_value;
343 }
344 $this->overall_limit = $a_value;
345 }
346
352 public function getOverallLimit()
353 {
355 }
356
357
358 //
359 // advanced metadata
360 //
361
362 public static function getAdvancedMDFields($a_glossary_id)
363 {
364 $fields = array();
365
366 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php');
367 $recs = ilAdvancedMDRecord::_getSelectedRecordsByObject("book", $a_glossary_id, "bobj");
368
369 foreach($recs as $record_obj)
370 {
371 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
372 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($record_obj->getRecordId()) as $def)
373 {
374 $fields[$def->getFieldId()] = array(
375 "id" => $def->getFieldId(),
376 "title" => $def->getTitle(),
377 "type" => $def->getType()
378 );
379 }
380 }
381
382 return $fields;
383 }
384}
385
386?>
$_GET["client_id"]
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
static _getSelectedRecordsByObject($a_obj_type, $a_obj_id, $a_sub_type="")
Get selected records by object.
a bookable ressource
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type
schedule for booking ressource
static getList($a_pool_id)
Get list of booking objects for given pool.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
Class ilObjBookingPool.
setOffline($a_value=true)
Toggle offline property.
setScheduleType($a_value)
Set schedule type.
__construct($a_id=0, $a_call_by_reference=true)
Constructor.
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
getDBFields()
Parse properties for sql statements.
static getAdvancedMDFields($a_glossary_id)
getScheduleType()
Get schedule type.
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)
Clone object permissions, put in tree ...
isOffline()
Get offline property.
update()
update object data
setPublicLog($a_value=true)
Toggle public log property.
hasPublicLog()
Get public log property.
static _lookupOnline($a_obj_id)
Check object status.
getOverallLimit()
Get overall / global booking limit.
setOverallLimit($a_value=null)
Set overall / global booking limit.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
getId()
get object id @access public
redirection script todo: (a better solution should control the processing via a xml file)
global $ilDB