ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilBookingObject Class Reference

a bookable ressource More...

+ Collaboration diagram for ilBookingObject:

Public Member Functions

 __construct ($a_id=NULL)
 Constructor. More...
 
 getId ()
 Get id. More...
 
 setTitle ($a_title)
 Set object title. More...
 
 getTitle ()
 Get object title. More...
 
 setDescription ($a_value)
 Set object description. More...
 
 getDescription ()
 Get object description. More...
 
 setPoolId ($a_pool_id)
 Set booking pool id. More...
 
 getPoolId ()
 Get booking pool id. More...
 
 setScheduleId ($a_schedule_id)
 Set booking schedule id. More...
 
 getScheduleId ()
 Get booking schedule id. More...
 
 setNrOfItems ($a_value)
 Set number of items. More...
 
 getNrOfItems ()
 Get number of items. More...
 
 setFile ($a_value)
 Set info file. More...
 
 getFile ()
 Get info file. More...
 
 getFileFullPath ()
 Get path to info file. More...
 
 uploadFile (array $a_upload)
 Upload new info file. More...
 
 deleteFile ()
 remove existing info file More...
 
 setPostText ($a_value)
 Set post text. More...
 
 getPostText ()
 Get post text. More...
 
 setPostFile ($a_value)
 Set post file. More...
 
 getPostFile ()
 Get post file. More...
 
 getPostFileFullPath ()
 Get path to post file. More...
 
 uploadPostFile (array $a_upload)
 Upload new post file. More...
 
 deletePostFile ()
 remove existing post file More...
 
 deleteFiles ()
 remove existing files More...
 
 save ()
 Create new entry in db. More...
 
 update ()
 Update entry in db. More...
 
 delete ()
 Delete single entry. More...
 
 doClone ($a_pool_id, $a_schedule_map=null)
 

Static Public Member Functions

static initStorage ($a_id, $a_subdir=null)
 Init file system storage. More...
 
static getList ($a_pool_id, $a_title=null)
 Get list of booking objects for given type
More...
 
static getNrOfItemsForObjects (array $a_obj_ids)
 Get nr of available items
More...
 

Protected Member Functions

 read ()
 Get dataset from db. More...
 
 getDBFields ()
 Parse properties for sql statements. More...
 

Protected Attributes

 $id
 
 $pool_id
 
 $title
 
 $description
 
 $nr_of_items
 
 $schedule_id
 
 $info_file
 
 $post_text
 
 $post_file
 

Detailed Description

a bookable ressource

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilBookingObject.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookingObject::__construct (   $a_id = NULL)

Constructor.

if id is given will read dataset from db

Parameters
int$a_id

Definition at line 31 of file class.ilBookingObject.php.

32 {
33 $this->id = (int)$a_id;
34 $this->read();
35 }
read()
Get dataset from db.

References read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingObject::delete ( )

Delete single entry.

Returns
bool

Definition at line 464 of file class.ilBookingObject.php.

465 {
466 global $ilDB;
467
468 if($this->id)
469 {
470 $this->deleteFiles();
471
472 return $ilDB->manipulate('DELETE FROM booking_object'.
473 ' WHERE booking_object_id = '.$ilDB->quote($this->id, 'integer'));
474 }
475 }
deleteFiles()
remove existing files
global $ilDB

References $ilDB, and deleteFiles().

+ Here is the call graph for this function:

◆ deleteFile()

ilBookingObject::deleteFile ( )

remove existing info file

Definition at line 196 of file class.ilBookingObject.php.

197 {
198 if($this->id)
199 {
200 $path = $this->getFileFullPath();
201 if($path)
202 {
203 @unlink($path);
204 $this->setFile(null);
205 }
206 }
207 }
setFile($a_value)
Set info file.
getFileFullPath()
Get path to info file.
$path
Definition: index.php:22

References $path, getFileFullPath(), and setFile().

Referenced by uploadFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteFiles()

ilBookingObject::deleteFiles ( )

remove existing files

Definition at line 304 of file class.ilBookingObject.php.

305 {
306 if($this->id)
307 {
308 include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
309 $storage = new ilFSStorageBooking($this->id);
310 $storage->delete();
311
312 $this->setFile(null);
313 $this->setPostFile(null);
314 }
315 }
setPostFile($a_value)
Set post file.

References setFile(), and setPostFile().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deletePostFile()

ilBookingObject::deletePostFile ( )

remove existing post file

Definition at line 288 of file class.ilBookingObject.php.

289 {
290 if($this->id)
291 {
292 $path = $this->getPostFileFullPath();
293 if($path)
294 {
295 @unlink($path);
296 $this->setPostFile(null);
297 }
298 }
299 }
getPostFileFullPath()
Get path to post file.

References $path, getPostFileFullPath(), and setPostFile().

Referenced by uploadPostFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doClone()

ilBookingObject::doClone (   $a_pool_id,
  $a_schedule_map = null 
)

Definition at line 499 of file class.ilBookingObject.php.

500 {
501 $new_obj = new self();
502 $new_obj->setPoolId($a_pool_id);
503 $new_obj->setTitle($this->getTitle());
504 $new_obj->setDescription($this->getDescription());
505 $new_obj->setNrOfItems($this->getNrOfItems());
506 $new_obj->setFile($this->getFile());
507 $new_obj->setPostText($this->getPostText());
508 $new_obj->setPostFile($this->getPostFile());
509
510 if($a_schedule_map)
511 {
512 $schedule_id = $this->getScheduleId();
513 if($schedule_id)
514 {
515 $new_obj->setScheduleId($a_schedule_map[$schedule_id]);
516 }
517 }
518
519 $new_obj->save();
520
521 // files
522 $source = $this->initStorage($this->getId());
523 $target = $new_obj->initStorage($new_obj->getId());
524 ilUtil::rCopy($source, $target);
525 }
getFile()
Get info file.
getScheduleId()
Get booking schedule id.
getPostText()
Get post text.
getPostFile()
Get post file.
getTitle()
Get object title.
getNrOfItems()
Get number of items.
getDescription()
Get object description.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.

References $schedule_id, getDescription(), getFile(), getId(), getNrOfItems(), getPostFile(), getPostText(), getScheduleId(), getTitle(), initStorage(), and ilUtil\rCopy().

+ Here is the call graph for this function:

◆ getDBFields()

ilBookingObject::getDBFields ( )
protected

Parse properties for sql statements.

Returns
array

Definition at line 373 of file class.ilBookingObject.php.

374 {
375 $fields = array(
376 'title' => array('text', $this->getTitle()),
377 'description' => array('text', $this->getDescription()),
378 'schedule_id' => array('text', $this->getScheduleId()),
379 'nr_items' => array('text', $this->getNrOfItems()),
380 'info_file' => array('text', $this->getFile()),
381 'post_text' => array('text', $this->getPostText()),
382 'post_file' => array('text', $this->getPostFile())
383 );
384
385 return $fields;
386 }

References getDescription(), getFile(), getNrOfItems(), getPostFile(), getPostText(), getScheduleId(), and getTitle().

Referenced by save(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilBookingObject::getDescription ( )

Get object description.

Returns
string

Definition at line 77 of file class.ilBookingObject.php.

References $description.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ getFile()

ilBookingObject::getFile ( )

Get info file.

Returns
string

Definition at line 149 of file class.ilBookingObject.php.

150 {
151 return $this->info_file;
152 }

References $info_file.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ getFileFullPath()

ilBookingObject::getFileFullPath ( )

Get path to info file.

Definition at line 157 of file class.ilBookingObject.php.

158 {
159 if($this->id && $this->info_file)
160 {
161 $path = $this->initStorage($this->id, "file");
162 return $path.$this->info_file;
163 }
164 }

References $path, and initStorage().

Referenced by deleteFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilBookingObject::getId ( )

Get id.

Returns
int

Definition at line 41 of file class.ilBookingObject.php.

42 {
43 return $this->id;
44 }

References $id.

Referenced by doClone().

+ Here is the caller graph for this function:

◆ getList()

static ilBookingObject::getList (   $a_pool_id,
  $a_title = null 
)
static

Get list of booking objects for given type

Parameters
int$a_pool_id
string$a_title
Returns
array

Definition at line 435 of file class.ilBookingObject.php.

436 {
437 global $ilDB;
438
439 $sql = 'SELECT *'.
440 ' FROM booking_object'.
441 ' WHERE pool_id = '.$ilDB->quote($a_pool_id, 'integer');
442
443 if($a_title)
444 {
445 $sql .= ' AND ('.$ilDB->like('title', 'text', '%'.$a_title.'%').
446 ' OR '.$ilDB->like('description', 'text', '%'.$a_title.'%').')';
447 }
448
449 $sql .= ' ORDER BY title';
450
451 $set = $ilDB->query($sql);
452 $res = array();
453 while($row = $ilDB->fetchAssoc($set))
454 {
455 $res[] = $row;
456 }
457 return $res;
458 }

References $ilDB, $res, and $row.

Referenced by ilObjBookingPool\cloneObject(), ilBookingObjectsTableGUI\getItems(), ilObjBookingPoolGUI\initEditCustomForm(), ilBookingReservationsTableGUI\initFilter(), ilBookingScheduleGUI\render(), and ilObjBookingPoolGUI\rsvConfirmCancelObject().

+ Here is the caller graph for this function:

◆ getNrOfItems()

ilBookingObject::getNrOfItems ( )

Get number of items.

Returns
int

Definition at line 131 of file class.ilBookingObject.php.

132 {
133 return $this->nr_of_items;
134 }

References $nr_of_items.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ getNrOfItemsForObjects()

static ilBookingObject::getNrOfItemsForObjects ( array  $a_obj_ids)
static

Get nr of available items

Parameters
array$a_obj_ids
Returns
array

Definition at line 482 of file class.ilBookingObject.php.

483 {
484 global $ilDB;
485
486 $map = array();
487
488 $set = $ilDB->query("SELECT booking_object_id,nr_items".
489 " FROM booking_object".
490 " WHERE ".$ilDB->in("booking_object_id", $a_obj_ids, "", "integer"));
491 while($row = $ilDB->fetchAssoc($set))
492 {
493 $map[$row["booking_object_id"]] = $row["nr_items"];
494 }
495
496 return $map;
497 }

References $ilDB, and $row.

Referenced by ilObjBookingPoolGUI\confirmedBookingObject(), ilBookingReservation\getAvailableObject(), ilBookingReservation\isObjectAvailableInPeriod(), and ilBookingReservation\isObjectAvailableNoSchedule().

+ Here is the caller graph for this function:

◆ getPoolId()

ilBookingObject::getPoolId ( )

Get booking pool id.

Returns
int

Definition at line 95 of file class.ilBookingObject.php.

96 {
97 return $this->pool_id;
98 }

References $pool_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ getPostFile()

ilBookingObject::getPostFile ( )

Get post file.

Returns
string

Definition at line 240 of file class.ilBookingObject.php.

241 {
242 return $this->post_file;
243 }

References $post_file.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ getPostFileFullPath()

ilBookingObject::getPostFileFullPath ( )

Get path to post file.

Definition at line 248 of file class.ilBookingObject.php.

249 {
250 if($this->id && $this->post_file)
251 {
252 $path = $this->initStorage($this->id, "post");
253 return $path.$this->post_file;
254 }
255 }

References $path, and initStorage().

Referenced by deletePostFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPostText()

ilBookingObject::getPostText ( )

Get post text.

Returns
string

Definition at line 222 of file class.ilBookingObject.php.

223 {
224 return $this->post_text;
225 }

References $post_text.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ getScheduleId()

ilBookingObject::getScheduleId ( )

Get booking schedule id.

Returns
int

Definition at line 113 of file class.ilBookingObject.php.

114 {
115 return $this->schedule_id;
116 }

References $schedule_id.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ getTitle()

ilBookingObject::getTitle ( )

Get object title.

Returns
string

Definition at line 59 of file class.ilBookingObject.php.

60 {
61 return $this->title;
62 }

References $title.

Referenced by doClone(), and getDBFields().

+ Here is the caller graph for this function:

◆ initStorage()

static ilBookingObject::initStorage (   $a_id,
  $a_subdir = null 
)
static

Init file system storage.

Parameters
type$a_id
type$a_subdir
Returns
string

Definition at line 324 of file class.ilBookingObject.php.

325 {
326 include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
327 $storage = new ilFSStorageBooking($a_id);
328 $storage->create();
329
330 $path = $storage->getAbsolutePath()."/";
331
332 if($a_subdir)
333 {
334 $path .= $a_subdir."/";
335
336 if(!is_dir($path))
337 {
338 mkdir($path);
339 }
340 }
341
342 return $path;
343 }

References $path.

Referenced by doClone(), getFileFullPath(), getPostFileFullPath(), uploadFile(), and uploadPostFile().

+ Here is the caller graph for this function:

◆ read()

ilBookingObject::read ( )
protected

Get dataset from db.

Definition at line 348 of file class.ilBookingObject.php.

349 {
350 global $ilDB;
351
352 if($this->id)
353 {
354 $set = $ilDB->query('SELECT *'.
355 ' FROM booking_object'.
356 ' WHERE booking_object_id = '.$ilDB->quote($this->id, 'integer'));
357 $row = $ilDB->fetchAssoc($set);
358 $this->setTitle($row['title']);
359 $this->setDescription($row['description']);
360 $this->setPoolId($row['pool_id']);
361 $this->setScheduleId($row['schedule_id']);
362 $this->setNrOfItems($row['nr_items']);
363 $this->setFile($row['info_file']);
364 $this->setPostText($row['post_text']);
365 $this->setPostFile($row['post_file']);
366 }
367 }
setScheduleId($a_schedule_id)
Set booking schedule id.
setTitle($a_title)
Set object title.
setPoolId($a_pool_id)
Set booking pool id.
setDescription($a_value)
Set object description.
setNrOfItems($a_value)
Set number of items.
setPostText($a_value)
Set post text.

References $ilDB, $row, setDescription(), setFile(), setNrOfItems(), setPoolId(), setPostFile(), setPostText(), setScheduleId(), and setTitle().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilBookingObject::save ( )

Create new entry in db.

Returns
bool

Definition at line 392 of file class.ilBookingObject.php.

393 {
394 global $ilDB;
395
396 if($this->id)
397 {
398 return false;
399 }
400
401 $this->id = $ilDB->nextId('booking_object');
402
403 $fields = $this->getDBFields();
404 $fields['booking_object_id'] = array('integer', $this->id);
405 $fields['pool_id'] = array('integer', $this->getPoolId());
406
407 return $ilDB->insert('booking_object', $fields);
408 }
getPoolId()
Get booking pool id.
getDBFields()
Parse properties for sql statements.

References $ilDB, getDBFields(), and getPoolId().

+ Here is the call graph for this function:

◆ setDescription()

ilBookingObject::setDescription (   $a_value)

Set object description.

Parameters
string$a_value

Definition at line 68 of file class.ilBookingObject.php.

69 {
70 $this->description = $a_value;
71 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setFile()

ilBookingObject::setFile (   $a_value)

Set info file.

Parameters
string$a_value

Definition at line 140 of file class.ilBookingObject.php.

141 {
142 $this->info_file = $a_value;
143 }

Referenced by deleteFile(), deleteFiles(), read(), and uploadFile().

+ Here is the caller graph for this function:

◆ setNrOfItems()

ilBookingObject::setNrOfItems (   $a_value)

Set number of items.

Parameters
int$a_value

Definition at line 122 of file class.ilBookingObject.php.

123 {
124 $this->nr_of_items = (int)$a_value;
125 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPoolId()

ilBookingObject::setPoolId (   $a_pool_id)

Set booking pool id.

Parameters
int$a_pool_id

Definition at line 86 of file class.ilBookingObject.php.

87 {
88 $this->pool_id = (int)$a_pool_id;
89 }

Referenced by read(), and ilBookingObjectGUI\save().

+ Here is the caller graph for this function:

◆ setPostFile()

ilBookingObject::setPostFile (   $a_value)

Set post file.

Parameters
string$a_value

Definition at line 231 of file class.ilBookingObject.php.

232 {
233 $this->post_file = $a_value;
234 }

Referenced by deleteFiles(), deletePostFile(), read(), and uploadPostFile().

+ Here is the caller graph for this function:

◆ setPostText()

ilBookingObject::setPostText (   $a_value)

Set post text.

Parameters
string$a_value

Definition at line 213 of file class.ilBookingObject.php.

214 {
215 $this->post_text = $a_value;
216 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setScheduleId()

ilBookingObject::setScheduleId (   $a_schedule_id)

Set booking schedule id.

Parameters
int$a_schedule_id

Definition at line 104 of file class.ilBookingObject.php.

105 {
106 $this->schedule_id = (int)$a_schedule_id;
107 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilBookingObject::setTitle (   $a_title)

Set object title.

Parameters
string$a_title

Definition at line 50 of file class.ilBookingObject.php.

51 {
52 $this->title = $a_title;
53 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingObject::update ( )

Update entry in db.

Returns
bool

Definition at line 414 of file class.ilBookingObject.php.

415 {
416 global $ilDB;
417
418 if(!$this->id)
419 {
420 return false;
421 }
422
423 $fields = $this->getDBFields();
424
425 return $ilDB->update('booking_object', $fields,
426 array('booking_object_id'=>array('integer', $this->id)));
427 }

References $ilDB, and getDBFields().

+ Here is the call graph for this function:

◆ uploadFile()

ilBookingObject::uploadFile ( array  $a_upload)

Upload new info file.

Parameters
array$a_upload
Returns
bool

Definition at line 172 of file class.ilBookingObject.php.

173 {
174 if(!$this->id)
175 {
176 return false;
177 }
178
179 $this->deleteFile();
180
181 $path = $this->initStorage($this->id, "file");
182 $original = $a_upload["name"];
183 if (ilUtil::moveUploadedFile($a_upload["tmp_name"], $original, $path.$original))
184 {
185 chmod($path.$original, 0770);
186
187 $this->setFile($original);
188 return true;
189 }
190 return false;
191 }
deleteFile()
remove existing info file
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References $path, deleteFile(), initStorage(), ilUtil\moveUploadedFile(), and setFile().

+ Here is the call graph for this function:

◆ uploadPostFile()

ilBookingObject::uploadPostFile ( array  $a_upload)

Upload new post file.

Parameters
array$a_upload
Returns
bool

Definition at line 263 of file class.ilBookingObject.php.

264 {
265 if(!$this->id)
266 {
267 return false;
268 }
269
270 $this->deletePostFile();
271
272 $path = $this->initStorage($this->id, "post");
273 $original = $a_upload["name"];
274
275 if (ilUtil::moveUploadedFile($a_upload["tmp_name"], $original, $path.$original))
276 {
277 chmod($path.$original, 0770);
278
279 $this->setPostFile($original);
280 return true;
281 }
282 return false;
283 }
deletePostFile()
remove existing post file

References $path, deletePostFile(), initStorage(), ilUtil\moveUploadedFile(), and setPostFile().

+ Here is the call graph for this function:

Field Documentation

◆ $description

ilBookingObject::$description
protected

Definition at line 17 of file class.ilBookingObject.php.

Referenced by getDescription().

◆ $id

ilBookingObject::$id
protected

Definition at line 14 of file class.ilBookingObject.php.

Referenced by getId().

◆ $info_file

ilBookingObject::$info_file
protected

Definition at line 20 of file class.ilBookingObject.php.

Referenced by getFile().

◆ $nr_of_items

ilBookingObject::$nr_of_items
protected

Definition at line 18 of file class.ilBookingObject.php.

Referenced by getNrOfItems().

◆ $pool_id

ilBookingObject::$pool_id
protected

Definition at line 15 of file class.ilBookingObject.php.

Referenced by getPoolId().

◆ $post_file

ilBookingObject::$post_file
protected

Definition at line 22 of file class.ilBookingObject.php.

Referenced by getPostFile().

◆ $post_text

ilBookingObject::$post_text
protected

Definition at line 21 of file class.ilBookingObject.php.

Referenced by getPostText().

◆ $schedule_id

ilBookingObject::$schedule_id
protected

Definition at line 19 of file class.ilBookingObject.php.

Referenced by doClone(), and getScheduleId().

◆ $title

ilBookingObject::$title
protected

Definition at line 16 of file class.ilBookingObject.php.

Referenced by getTitle().


The documentation for this class was generated from the following file: