ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 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.

References read().

32  {
33  $this->id = (int)$a_id;
34  $this->read();
35  }
read()
Get dataset from db.
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingObject::delete ( )

Delete single entry.

Returns
bool

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

References $ilDB, and deleteFiles().

456  {
457  global $ilDB;
458 
459  if($this->id)
460  {
461  $this->deleteFiles();
462 
463  return $ilDB->manipulate('DELETE FROM booking_object'.
464  ' WHERE booking_object_id = '.$ilDB->quote($this->id, 'integer'));
465  }
466  }
global $ilDB
deleteFiles()
remove existing files
+ Here is the call graph for this function:

◆ deleteFile()

ilBookingObject::deleteFile ( )

remove existing info file

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

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

Referenced by uploadFile().

198  {
199  if($this->id)
200  {
201  $path = $this->getFileFullPath();
202  if($path)
203  {
204  @unlink($path);
205  $this->setFile(null);
206  }
207  }
208  }
getFileFullPath()
Get path to info file.
setFile($a_value)
Set info file.
$path
Definition: index.php:22
+ 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 305 of file class.ilBookingObject.php.

References setFile(), and setPostFile().

Referenced by delete().

306  {
307  if($this->id)
308  {
309  include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
310  $storage = new ilFSStorageBooking($this->id);
311  $storage->delete();
312 
313  $this->setFile(null);
314  $this->setPostFile(null);
315  }
316  }
setFile($a_value)
Set info file.
setPostFile($a_value)
Set post file.
+ 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 289 of file class.ilBookingObject.php.

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

Referenced by uploadPostFile().

290  {
291  if($this->id)
292  {
293  $path = $this->getPostFileFullPath();
294  if($path)
295  {
296  @unlink($path);
297  $this->setPostFile(null);
298  }
299  }
300  }
getPostFileFullPath()
Get path to post file.
$path
Definition: index.php:22
setPostFile($a_value)
Set post file.
+ 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 490 of file class.ilBookingObject.php.

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

491  {
492  $new_obj = new self();
493  $new_obj->setPoolId($a_pool_id);
494  $new_obj->setTitle($this->getTitle());
495  $new_obj->setDescription($this->getDescription());
496  $new_obj->setNrOfItems($this->getNrOfItems());
497  $new_obj->setFile($this->getFile());
498  $new_obj->setPostText($this->getPostText());
499  $new_obj->setPostFile($this->getPostFile());
500 
501  if($a_schedule_map)
502  {
503  $schedule_id = $this->getScheduleId();
504  if($schedule_id)
505  {
506  $new_obj->setScheduleId($a_schedule_map[$schedule_id]);
507  }
508  }
509 
510  $new_obj->save();
511 
512  // files
513  $source = $this->initStorage($this->getId());
514  $target = $new_obj->initStorage($new_obj->getId());
515  ilUtil::rCopy($source, $target);
516  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
getPostFile()
Get post file.
getFile()
Get info file.
getTitle()
Get object title.
getScheduleId()
Get booking schedule id.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
getNrOfItems()
Get number of items.
getPostText()
Get post text.
getDescription()
Get object description.
+ Here is the call graph for this function:

◆ getDBFields()

ilBookingObject::getDBFields ( )
protected

Parse properties for sql statements.

Returns
array

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

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

Referenced by save(), and update().

375  {
376  $fields = array(
377  'title' => array('text', $this->getTitle()),
378  'description' => array('text', $this->getDescription()),
379  'schedule_id' => array('text', $this->getScheduleId()),
380  'nr_items' => array('text', $this->getNrOfItems()),
381  'info_file' => array('text', $this->getFile()),
382  'post_text' => array('text', $this->getPostText()),
383  'post_file' => array('text', $this->getPostFile())
384  );
385 
386  return $fields;
387  }
getPostFile()
Get post file.
getFile()
Get info file.
getTitle()
Get object title.
getScheduleId()
Get booking schedule id.
getNrOfItems()
Get number of items.
getPostText()
Get post text.
getDescription()
Get object description.
+ 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().

78  {
79  return $this->description;
80  }
+ 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.

References $info_file.

Referenced by doClone(), and getDBFields().

150  {
151  return $this->info_file;
152  }
+ 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.

References $path, and initStorage().

Referenced by deleteFile().

158  {
159  if($this->id && $this->info_file)
160  {
161  $path = $this->initStorage($this->id, "file");
162  return $path.$this->info_file;
163  }
164  }
static initStorage($a_id, $a_subdir=null)
Init file system storage.
$path
Definition: index.php:22
+ 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.

References $id.

Referenced by doClone().

42  {
43  return $this->id;
44  }
+ Here is the caller graph for this function:

◆ getList()

static ilBookingObject::getList (   $a_pool_id)
static

Get list of booking objects for given type.

Parameters
int$a_pool_id
Returns
array

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

References $ilDB, $res, and $row.

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

436  {
437  global $ilDB;
438 
439  $set = $ilDB->query('SELECT *'.
440  ' FROM booking_object'.
441  ' WHERE pool_id = '.$ilDB->quote($a_pool_id, 'integer').
442  ' ORDER BY title');
443  $res = array();
444  while($row = $ilDB->fetchAssoc($set))
445  {
446  $res[] = $row;
447  }
448  return $res;
449  }
global $ilDB
+ 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.

References $nr_of_items.

Referenced by doClone(), and getDBFields().

132  {
133  return $this->nr_of_items;
134  }
+ 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 473 of file class.ilBookingObject.php.

References $ilDB, and $row.

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

474  {
475  global $ilDB;
476 
477  $map = array();
478 
479  $set = $ilDB->query("SELECT booking_object_id,nr_items".
480  " FROM booking_object".
481  " WHERE ".$ilDB->in("booking_object_id", $a_obj_ids, "", "integer"));
482  while($row = $ilDB->fetchAssoc($set))
483  {
484  $map[$row["booking_object_id"]] = $row["nr_items"];
485  }
486 
487  return $map;
488  }
global $ilDB
+ 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.

References $pool_id.

Referenced by save().

96  {
97  return $this->pool_id;
98  }
+ Here is the caller graph for this function:

◆ getPostFile()

ilBookingObject::getPostFile ( )

Get post file.

Returns
string

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

References $post_file.

Referenced by doClone(), and getDBFields().

242  {
243  return $this->post_file;
244  }
+ Here is the caller graph for this function:

◆ getPostFileFullPath()

ilBookingObject::getPostFileFullPath ( )

Get path to post file.

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

References $path, and initStorage().

Referenced by deletePostFile().

250  {
251  if($this->id && $this->post_file)
252  {
253  $path = $this->initStorage($this->id, "post");
254  return $path.$this->post_file;
255  }
256  }
static initStorage($a_id, $a_subdir=null)
Init file system storage.
$path
Definition: index.php:22
+ 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 223 of file class.ilBookingObject.php.

References $post_text.

Referenced by doClone(), and getDBFields().

224  {
225  return $this->post_text;
226  }
+ 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.

References $schedule_id.

Referenced by doClone(), and getDBFields().

114  {
115  return $this->schedule_id;
116  }
+ 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.

References $title.

Referenced by doClone(), getDBFields(), ilObjBookingPoolGUI\rsvConfirmCancelAggregationForm(), and ilObjBookingPoolGUI\rsvConfirmCancelObject().

60  {
61  return $this->title;
62  }
+ 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 325 of file class.ilBookingObject.php.

References $path.

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

326  {
327  include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
328  $storage = new ilFSStorageBooking($a_id);
329  $storage->create();
330 
331  $path = $storage->getAbsolutePath()."/";
332 
333  if($a_subdir)
334  {
335  $path .= $a_subdir."/";
336 
337  if(!is_dir($path))
338  {
339  mkdir($path);
340  }
341  }
342 
343  return $path;
344  }
$path
Definition: index.php:22
+ Here is the caller graph for this function:

◆ read()

ilBookingObject::read ( )
protected

Get dataset from db.

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

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

Referenced by __construct().

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

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

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

Referenced by read().

69  {
70  $this->description = $a_value;
71  }
+ 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.

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

141  {
142  $this->info_file = $a_value;
143  }
+ 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.

Referenced by read().

123  {
124  $this->nr_of_items = (int)$a_value;
125  }
+ 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.

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

87  {
88  $this->pool_id = (int)$a_pool_id;
89  }
+ Here is the caller graph for this function:

◆ setPostFile()

ilBookingObject::setPostFile (   $a_value)

Set post file.

Parameters
string$a_value

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

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

233  {
234  $this->post_file = $a_value;
235  }
+ Here is the caller graph for this function:

◆ setPostText()

ilBookingObject::setPostText (   $a_value)

Set post text.

Parameters
string$a_value

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

Referenced by read().

215  {
216  $this->post_text = $a_value;
217  }
+ 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.

Referenced by read().

105  {
106  $this->schedule_id = (int)$a_schedule_id;
107  }
+ 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.

Referenced by read().

51  {
52  $this->title = $a_title;
53  }
+ Here is the caller graph for this function:

◆ update()

ilBookingObject::update ( )

Update entry in db.

Returns
bool

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

References $ilDB, and getDBFields().

416  {
417  global $ilDB;
418 
419  if(!$this->id)
420  {
421  return false;
422  }
423 
424  $fields = $this->getDBFields();
425 
426  return $ilDB->update('booking_object', $fields,
427  array('booking_object_id'=>array('integer', $this->id)));
428  }
getDBFields()
Parse properties for sql statements.
global $ilDB
+ 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.

References $path, deleteFile(), initStorage(), and setFile().

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 
184  if(@move_uploaded_file($a_upload["tmp_name"], $path.$original))
185  {
186  chmod($path.$original, 0770);
187 
188  $this->setFile($original);
189  return true;
190  }
191  return false;
192  }
deleteFile()
remove existing info file
setFile($a_value)
Set info file.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
$path
Definition: index.php:22
+ 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 264 of file class.ilBookingObject.php.

References $path, deletePostFile(), initStorage(), and setPostFile().

265  {
266  if(!$this->id)
267  {
268  return false;
269  }
270 
271  $this->deletePostFile();
272 
273  $path = $this->initStorage($this->id, "post");
274  $original = $a_upload["name"];
275 
276  if(@move_uploaded_file($a_upload["tmp_name"], $path.$original))
277  {
278  chmod($path.$original, 0770);
279 
280  $this->setPostFile($original);
281  return true;
282  }
283  return false;
284  }
deletePostFile()
remove existing post file
static initStorage($a_id, $a_subdir=null)
Init file system storage.
$path
Definition: index.php:22
setPostFile($a_value)
Set post file.
+ 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: