ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
static lookupPoolId ($object_id)
 Lookup pool id. More...
 

Protected Member Functions

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

Protected Attributes

 $db
 
 $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 36 of file class.ilBookingObject.php.

37 {
38 global $DIC;
39
40 $this->db = $DIC->database();
41 $this->id = (int) $a_id;
42 $this->read();
43 }
read()
Get dataset from db.
global $DIC
Definition: saml.php:7

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingObject::delete ( )

Delete single entry.

Returns
bool

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

460 {
462
463 if ($this->id) {
464 $this->deleteFiles();
465
466 return $ilDB->manipulate('DELETE FROM booking_object' .
467 ' WHERE booking_object_id = ' . $ilDB->quote($this->id, 'integer'));
468 }
469 }
deleteFiles()
remove existing files
global $ilDB

References $db, $ilDB, and deleteFiles().

+ Here is the call graph for this function:

◆ deleteFile()

ilBookingObject::deleteFile ( )

remove existing info file

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

202 {
203 if ($this->id) {
204 $path = $this->getFileFullPath();
205 if ($path) {
206 @unlink($path);
207 $this->setFile(null);
208 }
209 }
210 }
setFile($a_value)
Set info file.
getFileFullPath()
Get path to info file.

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 302 of file class.ilBookingObject.php.

303 {
304 if ($this->id) {
305 include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
306 $storage = new ilFSStorageBooking($this->id);
307 $storage->delete();
308
309 $this->setFile(null);
310 $this->setPostFile(null);
311 }
312 }
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 $path = $this->getPostFileFullPath();
292 if ($path) {
293 @unlink($path);
294 $this->setPostFile(null);
295 }
296 }
297 }
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 494 of file class.ilBookingObject.php.

495 {
496 $new_obj = new self();
497 $new_obj->setPoolId($a_pool_id);
498 $new_obj->setTitle($this->getTitle());
499 $new_obj->setDescription($this->getDescription());
500 $new_obj->setNrOfItems($this->getNrOfItems());
501 $new_obj->setFile($this->getFile());
502 $new_obj->setPostText($this->getPostText());
503 $new_obj->setPostFile($this->getPostFile());
504
505 if ($a_schedule_map) {
506 $schedule_id = $this->getScheduleId();
507 if ($schedule_id) {
508 $new_obj->setScheduleId($a_schedule_map[$schedule_id]);
509 }
510 }
511
512 $new_obj->save();
513
514 // files
515 $source = $this->initStorage($this->getId());
516 $target = $new_obj->initStorage($new_obj->getId());
518 }
$source
Definition: linkback.php:22
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, $source, $target, 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 367 of file class.ilBookingObject.php.

368 {
369 $fields = array(
370 'title' => array('text', $this->getTitle()),
371 'description' => array('text', $this->getDescription()),
372 'schedule_id' => array('text', $this->getScheduleId()),
373 'nr_items' => array('text', $this->getNrOfItems()),
374 'info_file' => array('text', $this->getFile()),
375 'post_text' => array('text', $this->getPostText()),
376 'post_file' => array('text', $this->getPostFile())
377 );
378
379 return $fields;
380 }

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 85 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 157 of file class.ilBookingObject.php.

158 {
159 return $this->info_file;
160 }

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 165 of file class.ilBookingObject.php.

166 {
167 if ($this->id && $this->info_file) {
168 $path = $this->initStorage($this->id, "file");
169 return $path . $this->info_file;
170 }
171 }

References $info_file, $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 49 of file class.ilBookingObject.php.

50 {
51 return $this->id;
52 }

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 430 of file class.ilBookingObject.php.

431 {
432 global $DIC;
433
434 $ilDB = $DIC->database();
435
436 $sql = 'SELECT *' .
437 ' FROM booking_object' .
438 ' WHERE pool_id = ' . $ilDB->quote($a_pool_id, 'integer');
439
440 if ($a_title) {
441 $sql .= ' AND (' . $ilDB->like('title', 'text', '%' . $a_title . '%') .
442 ' OR ' . $ilDB->like('description', 'text', '%' . $a_title . '%') . ')';
443 }
444
445 $sql .= ' ORDER BY title';
446
447 $set = $ilDB->query($sql);
448 $res = array();
449 while ($row = $ilDB->fetchAssoc($set)) {
450 $res[] = $row;
451 }
452 return $res;
453 }
foreach($_POST as $key=> $value) $res

References $DIC, $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 139 of file class.ilBookingObject.php.

140 {
141 return $this->nr_of_items;
142 }

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 476 of file class.ilBookingObject.php.

477 {
478 global $DIC;
479
480 $ilDB = $DIC->database();
481
482 $map = array();
483
484 $set = $ilDB->query("SELECT booking_object_id,nr_items" .
485 " FROM booking_object" .
486 " WHERE " . $ilDB->in("booking_object_id", $a_obj_ids, "", "integer"));
487 while ($row = $ilDB->fetchAssoc($set)) {
488 $map[$row["booking_object_id"]] = $row["nr_items"];
489 }
490
491 return $map;
492 }

References $DIC, $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 103 of file class.ilBookingObject.php.

104 {
105 return $this->pool_id;
106 }

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 243 of file class.ilBookingObject.php.

244 {
245 return $this->post_file;
246 }

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 251 of file class.ilBookingObject.php.

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

References $path, $post_file, 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 225 of file class.ilBookingObject.php.

226 {
227 return $this->post_text;
228 }

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 121 of file class.ilBookingObject.php.

122 {
123 return $this->schedule_id;
124 }

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 67 of file class.ilBookingObject.php.

68 {
69 return $this->title;
70 }

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 321 of file class.ilBookingObject.php.

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

References $path.

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

+ Here is the caller graph for this function:

◆ lookupPoolId()

static ilBookingObject::lookupPoolId (   $object_id)
static

Lookup pool id.

Parameters
int$object_id
Returns
int

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

527 {
528 global $DIC;
529
530 $db = $DIC->database();
531 $set = $db->queryF(
532 "SELECT pool_id FROM booking_object " .
533 " WHERE booking_object_id = %s ",
534 array("integer"),
535 array($object_id)
536 );
537 $rec = $db->fetchAssoc($set);
538 return (int) $rec["pool_id"];
539 }

References $db, and $DIC.

Referenced by ilObjBookingPoolGUI\__construct().

+ Here is the caller graph for this function:

◆ read()

ilBookingObject::read ( )
protected

Get dataset from db.

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

344 {
346
347 if ($this->id) {
348 $set = $ilDB->query('SELECT *' .
349 ' FROM booking_object' .
350 ' WHERE booking_object_id = ' . $ilDB->quote($this->id, 'integer'));
351 $row = $ilDB->fetchAssoc($set);
352 $this->setTitle($row['title']);
353 $this->setDescription($row['description']);
354 $this->setPoolId($row['pool_id']);
355 $this->setScheduleId($row['schedule_id']);
356 $this->setNrOfItems($row['nr_items']);
357 $this->setFile($row['info_file']);
358 $this->setPostText($row['post_text']);
359 $this->setPostFile($row['post_file']);
360 }
361 }
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 $db, $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 386 of file class.ilBookingObject.php.

387 {
389
390 if ($this->id) {
391 return false;
392 }
393
394 $this->id = $ilDB->nextId('booking_object');
395
396 $fields = $this->getDBFields();
397 $fields['booking_object_id'] = array('integer', $this->id);
398 $fields['pool_id'] = array('integer', $this->getPoolId());
399
400 return $ilDB->insert('booking_object', $fields);
401 }
getPoolId()
Get booking pool id.
getDBFields()
Parse properties for sql statements.

References $db, $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 76 of file class.ilBookingObject.php.

77 {
78 $this->description = $a_value;
79 }

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 148 of file class.ilBookingObject.php.

149 {
150 $this->info_file = $a_value;
151 }

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 130 of file class.ilBookingObject.php.

131 {
132 $this->nr_of_items = (int) $a_value;
133 }

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 94 of file class.ilBookingObject.php.

95 {
96 $this->pool_id = (int) $a_pool_id;
97 }

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 234 of file class.ilBookingObject.php.

235 {
236 $this->post_file = $a_value;
237 }

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 216 of file class.ilBookingObject.php.

217 {
218 $this->post_text = $a_value;
219 }

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 112 of file class.ilBookingObject.php.

113 {
114 $this->schedule_id = (int) $a_schedule_id;
115 }

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 58 of file class.ilBookingObject.php.

59 {
60 $this->title = $a_title;
61 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingObject::update ( )

Update entry in db.

Returns
bool

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

408 {
410
411 if (!$this->id) {
412 return false;
413 }
414
415 $fields = $this->getDBFields();
416
417 return $ilDB->update(
418 'booking_object',
419 $fields,
420 array('booking_object_id'=>array('integer', $this->id))
421 );
422 }

References $db, $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 179 of file class.ilBookingObject.php.

180 {
181 if (!$this->id) {
182 return false;
183 }
184
185 $this->deleteFile();
186
187 $path = $this->initStorage($this->id, "file");
188 $original = $a_upload["name"];
189 if (ilUtil::moveUploadedFile($a_upload["tmp_name"], $original, $path . $original)) {
190 chmod($path . $original, 0770);
191
192 $this->setFile($original);
193 return true;
194 }
195 return false;
196 }
deleteFile()
remove existing info file

References $path, deleteFile(), initStorage(), 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 265 of file class.ilBookingObject.php.

266 {
267 if (!$this->id) {
268 return false;
269 }
270
271 $this->deletePostFile();
272
273 $path = $this->initStorage($this->id, "post");
274 $original = $a_upload["name"];
275
276 if (ilUtil::moveUploadedFile($a_upload["tmp_name"], $original, $path . $original)) {
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(), and setPostFile().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilBookingObject::$db
protected

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

Referenced by delete(), lookupPoolId(), read(), save(), and update().

◆ $description

ilBookingObject::$description
protected

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

Referenced by getDescription().

◆ $id

ilBookingObject::$id
protected

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

Referenced by getId().

◆ $info_file

ilBookingObject::$info_file
protected

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

Referenced by getFile(), and getFileFullPath().

◆ $nr_of_items

ilBookingObject::$nr_of_items
protected

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

Referenced by getNrOfItems().

◆ $pool_id

ilBookingObject::$pool_id
protected

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

Referenced by getPoolId().

◆ $post_file

ilBookingObject::$post_file
protected

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

Referenced by getPostFile(), and getPostFileFullPath().

◆ $post_text

ilBookingObject::$post_text
protected

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

Referenced by getPostText().

◆ $schedule_id

ilBookingObject::$schedule_id
protected

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

Referenced by doClone(), and getScheduleId().

◆ $title

ilBookingObject::$title
protected

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

Referenced by getTitle().


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