ILIAS  release_8 Revision v8.24
ilBookingObject Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilBookingObject:

Public Member Functions

 __construct (int $a_id=null)
 
 getId ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setDescription (string $a_value)
 
 getDescription ()
 
 setPoolId (int $a_pool_id)
 
 getPoolId ()
 
 setScheduleId (?int $a_schedule_id)
 
 getScheduleId ()
 
 setNrOfItems (int $a_value)
 
 getNrOfItems ()
 
 setFile (string $a_value)
 
 getFile ()
 
 getFileFullPath ()
 
 uploadFile (array $a_upload)
 Upload new info file. More...
 
 deleteFile ()
 
 setPostText (string $a_value)
 
 getPostText ()
 
 setPostFile (string $a_value)
 
 getPostFile ()
 
 getPostFileFullPath ()
 
 uploadPostFile (array $a_upload)
 Upload new post file. More...
 
 deletePostFile ()
 
 deleteFiles ()
 
 save ()
 
 update ()
 
 delete ()
 Delete single entry. More...
 
 deleteReservationsAndCalEntries (int $object_id)
 
 doClone (int $a_pool_id, array $a_schedule_map=null)
 

Static Public Member Functions

static initStorage (int $a_id, string $a_subdir="")
 Init file system storage. More...
 
static getList (int $a_pool_id, string $a_title=null)
 Get list of booking objects. More...
 
static getNumberOfObjectsForPool (int $a_pool_id)
 Get number of booking objects for given booking pool id. More...
 
static getObjectsForPool (int $a_pool_id)
 Get all booking pool object ids from an specific booking pool. More...
 
static getNrOfItemsForObjects (array $a_obj_ids)
 Get nr of available items for a set of object ids. More...
 
static lookupPoolId (int $object_id)
 
static lookupTitle (int $object_id)
 

Protected Member Functions

 read ()
 
 getDBFields ()
 

Protected Attributes

ilDBInterface $db
 
int $id = 0
 
int $pool_id = 0
 
string $title = ""
 
string $description = ""
 
int $nr_of_items = 0
 
int $schedule_id = null
 
string $info_file = ""
 
string $post_text = ""
 
string $post_file = ""
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Constructor & Destructor Documentation

◆ __construct()

ilBookingObject::__construct ( int  $a_id = null)

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

38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42 $this->id = (int) $a_id;
43 $this->read();
44 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\int(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilBookingObject::delete ( )

Delete single entry.

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

400 : int
401 {
403
404 if ($this->id) {
405 $this->deleteFiles();
406
407 return $ilDB->manipulate('DELETE FROM booking_object' .
408 ' WHERE booking_object_id = ' . $ilDB->quote($this->id, 'integer'));
409 }
410 return 0;
411 }

References $ilDB.

◆ deleteFile()

ilBookingObject::deleteFile ( )

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

143 : void
144 {
145 if ($this->id) {
146 $path = $this->getFileFullPath();
147 if ($path) {
148 if (is_file($path)) {
149 unlink($path);
150 }
151 $this->setFile("");
152 }
153 }
154 }
setFile(string $a_value)
$path
Definition: ltiservices.php:32

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 ( )

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

222 : void
223 {
224 if ($this->id) {
225 $storage = new ilFSStorageBooking($this->id);
226 $storage->delete();
227
228 $this->setFile("");
229 $this->setPostFile("");
230 }
231 }
setPostFile(string $a_value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References setFile(), and setPostFile().

+ Here is the call graph for this function:

◆ deletePostFile()

ilBookingObject::deletePostFile ( )

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

209 : void
210 {
211 if ($this->id) {
212 $path = $this->getPostFileFullPath();
213 if ($path) {
214 if (is_file($path)) {
215 unlink($path);
216 }
217 $this->setPostFile("");
218 }
219 }
220 }

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

Referenced by uploadPostFile().

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

◆ deleteReservationsAndCalEntries()

ilBookingObject::deleteReservationsAndCalEntries ( int  $object_id)

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

413 : void
414 {
416 $reservation_db = $repo_fac->getRepo();
417 $reservation_ids = $reservation_db->getReservationIdsByBookingObjectId($object_id);
418
419 foreach ($reservation_ids as $reservation_id) {
420 $reservation = new ilBookingReservation($reservation_id);
421 $entry = new ilCalendarEntry($reservation->getCalendarEntry());
422 $reservation_db->delete($reservation_id);
423 $entry->delete();
424 }
425 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ doClone()

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

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

454 : void {
455 $new_obj = new self();
456 $new_obj->setPoolId($a_pool_id);
457 $new_obj->setTitle($this->getTitle());
458 $new_obj->setDescription($this->getDescription());
459 $new_obj->setNrOfItems($this->getNrOfItems());
460 $new_obj->setFile($this->getFile());
461 $new_obj->setPostText($this->getPostText());
462 $new_obj->setPostFile($this->getPostFile());
463
464 if ($a_schedule_map) {
465 $schedule_id = $this->getScheduleId();
466 if ($schedule_id) {
467 $new_obj->setScheduleId($a_schedule_map[$schedule_id] ?? null);
468 }
469 }
470
471 $new_obj->save();
472
473 // files
474 $source = self::initStorage($this->getId());
475 $target = $new_obj::initStorage($new_obj->getId());
476 ilFileUtils::rCopy($source, $target);
477 }
static initStorage(int $a_id, string $a_subdir="")
Init file system storage.
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
$source
Definition: metadata.php:93

◆ getDBFields()

ilBookingObject::getDBFields ( )
protected
Returns
string[][]

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

279 : array
280 {
281 return array(
282 'title' => array('text', $this->getTitle()),
283 'description' => array('text', $this->getDescription()),
284 'schedule_id' => array('text', $this->getScheduleId()),
285 'nr_items' => array('text', $this->getNrOfItems()),
286 'info_file' => array('text', $this->getFile()),
287 'post_text' => array('text', $this->getPostText()),
288 'post_file' => array('text', $this->getPostFile())
289 );
290 }

◆ getDescription()

ilBookingObject::getDescription ( )

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

66 : string
67 {
68 return $this->description;
69 }

References $description.

◆ getFile()

ilBookingObject::getFile ( )

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

106 : string
107 {
108 return $this->info_file;
109 }

References $info_file.

◆ getFileFullPath()

ilBookingObject::getFileFullPath ( )

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

111 : string
112 {
113 if ($this->id && $this->info_file) {
114 $path = self::initStorage($this->id, "file");
115 return $path . $this->info_file;
116 }
117 return "";
118 }

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 ( )

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

46 : int
47 {
48 return $this->id;
49 }

References $id.

◆ getList()

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

Get list of booking objects.

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

332 : array {
333 global $DIC;
334
335 $ilDB = $DIC->database();
336
337 $sql = 'SELECT *' .
338 ' FROM booking_object' .
339 ' WHERE pool_id = ' . $ilDB->quote($a_pool_id, 'integer');
340
341 if ($a_title) {
342 $sql .= ' AND (' . $ilDB->like('title', 'text', '%' . $a_title . '%') .
343 ' OR ' . $ilDB->like('description', 'text', '%' . $a_title . '%') . ')';
344 }
345
346 $sql .= ' ORDER BY title';
347
348 $set = $ilDB->query($sql);
349 $res = array();
350 while ($row = $ilDB->fetchAssoc($set)) {
351 $res[] = $row;
352 }
353 return $res;
354 }
$res
Definition: ltiservices.php:69

References $ilDB.

Referenced by ilObjBookingPool\cloneObject(), ilBookingObjectsTableGUI\getItems(), ilBookingAssignObjectsTableGUI\getItems(), ilObjBookingPoolGUI\initEditCustomForm(), ilBookingParticipantsTableGUI\initFilter(), ilBookingPreferencesGUI\initPreferenceForm(), ilBookingPreferencesManager\readBookings(), ilBookingScheduleGUI\render(), and ilBookingReservationsGUI\rsvConfirmCancel().

+ Here is the caller graph for this function:

◆ getNrOfItems()

ilBookingObject::getNrOfItems ( )

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

96 : int
97 {
98 return $this->nr_of_items;
99 }

References $nr_of_items.

◆ getNrOfItemsForObjects()

static ilBookingObject::getNrOfItemsForObjects ( array  $a_obj_ids)
static

Get nr of available items for a set of object ids.

Parameters
int[]$a_obj_ids
Returns
int[]

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

434 : array {
435 global $DIC;
436
437 $ilDB = $DIC->database();
438
439 $map = array();
440
441 $set = $ilDB->query("SELECT booking_object_id,nr_items" .
442 " FROM booking_object" .
443 " WHERE " . $ilDB->in("booking_object_id", $a_obj_ids, "", "integer"));
444 while ($row = $ilDB->fetchAssoc($set)) {
445 $map[(int) $row["booking_object_id"]] = (int) $row["nr_items"];
446 }
447
448 return $map;
449 }

Referenced by ilBookingProcessGUI\confirmedBooking(), and ilBookingReservation\getNumAvailablesNoSchedule().

+ Here is the caller graph for this function:

◆ getNumberOfObjectsForPool()

static ilBookingObject::getNumberOfObjectsForPool ( int  $a_pool_id)
static

Get number of booking objects for given booking pool id.

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

361 : int {
362 global $DIC;
363
364 $ilDB = $DIC->database();
365
366 $sql = 'SELECT count(*) as count' .
367 ' FROM booking_object' .
368 ' WHERE pool_id = ' . $ilDB->quote($a_pool_id, 'integer');
369 $set = $ilDB->query($sql);
370 $rec = $ilDB->fetchAssoc($set);
371
372 return (int) $rec["count"];
373 }

Referenced by ilBookingParticipantsTableGUI\fillRow().

+ Here is the caller graph for this function:

◆ getObjectsForPool()

static ilBookingObject::getObjectsForPool ( int  $a_pool_id)
static

Get all booking pool object ids from an specific booking pool.

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

380 : array {
381 global $DIC;
382 $ilDB = $DIC->database();
383
384 $set = $ilDB->query("SELECT booking_object_id" .
385 " FROM booking_object" .
386 " WHERE pool_id = " . $ilDB->quote($a_pool_id, 'integer'));
387
388 $objects = array();
389 while ($row = $ilDB->fetchAssoc($set)) {
390 $objects[] = $row['booking_object_id'];
391 }
392
393 return $objects;
394 }

◆ getPoolId()

ilBookingObject::getPoolId ( )

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

76 : int
77 {
78 return $this->pool_id;
79 }

References $pool_id.

◆ getPostFile()

ilBookingObject::getPostFile ( )

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

171 : string
172 {
173 return $this->post_file;
174 }

References $post_file.

◆ getPostFileFullPath()

ilBookingObject::getPostFileFullPath ( )

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

176 : string
177 {
178 if ($this->id && $this->post_file) {
179 $path = self::initStorage($this->id, "post");
180 return $path . $this->post_file;
181 }
182 return "";
183 }

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 ( )

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

161 : string
162 {
163 return $this->post_text;
164 }

References $post_text.

◆ getScheduleId()

ilBookingObject::getScheduleId ( )

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

86 : ?int
87 {
88 return $this->schedule_id;
89 }

References $schedule_id.

◆ getTitle()

ilBookingObject::getTitle ( )

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

56 : string
57 {
58 return $this->title;
59 }

References $title.

◆ initStorage()

static ilBookingObject::initStorage ( int  $a_id,
string  $a_subdir = "" 
)
static

Init file system storage.

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

239 : string {
240 $storage = new ilFSStorageBooking($a_id);
241 $storage->create();
242
243 $path = $storage->getAbsolutePath() . "/";
244
245 if ($a_subdir) {
246 $path .= $a_subdir . "/";
247
248 if (!is_dir($path) && !mkdir($path)) {
249 throw new \RuntimeException(sprintf('Directory "%s" was not created', $path));
250 }
251 }
252
253 return $path;
254 }

References $path.

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

+ Here is the caller graph for this function:

◆ lookupPoolId()

static ilBookingObject::lookupPoolId ( int  $object_id)
static

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

479 : int
480 {
481 global $DIC;
482
483 $db = $DIC->database();
484 $set = $db->queryF(
485 "SELECT pool_id FROM booking_object " .
486 " WHERE booking_object_id = %s ",
487 array("integer"),
488 array($object_id)
489 );
490 $rec = $db->fetchAssoc($set);
491 return (int) $rec["pool_id"];
492 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

References $DIC, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

Referenced by ilBookingReservationsGUI\__construct(), and ilBookingObjectGUI\__construct().

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

◆ lookupTitle()

static ilBookingObject::lookupTitle ( int  $object_id)
static

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

494 : string
495 {
496 global $DIC;
497
498 $db = $DIC->database();
499 $set = $db->queryF(
500 "SELECT title FROM booking_object " .
501 " WHERE booking_object_id = %s ",
502 array("integer"),
503 array($object_id)
504 );
505 $rec = $db->fetchAssoc($set);
506 return $rec["title"];
507 }

References $DIC, ilDBInterface\fetchAssoc(), and ilDBInterface\queryF().

Referenced by ilBookingPreferencesGUI\savePreferences().

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

◆ read()

ilBookingObject::read ( )
protected

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

256 : void
257 {
259
260 if ($this->id) {
261 $set = $ilDB->query('SELECT *' .
262 ' FROM booking_object' .
263 ' WHERE booking_object_id = ' . $ilDB->quote($this->id, 'integer'));
264 $row = $ilDB->fetchAssoc($set);
265 $this->setTitle((string) $row['title']);
266 $this->setDescription((string) $row['description']);
267 $this->setPoolId((int) $row['pool_id']);
268 $this->setScheduleId($row['schedule_id']);
269 $this->setNrOfItems((int) $row['nr_items']);
270 $this->setFile((string) $row['info_file']);
271 $this->setPostText((string) $row['post_text']);
272 $this->setPostFile((string) $row['post_file']);
273 }
274 }
setPostText(string $a_value)
setPoolId(int $a_pool_id)
setDescription(string $a_value)
setNrOfItems(int $a_value)
setScheduleId(?int $a_schedule_id)
setTitle(string $a_title)

References $ilDB.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ save()

ilBookingObject::save ( )

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

292 : ?int
293 {
295
296 if ($this->id) {
297 return null;
298 }
299
300 $this->id = $ilDB->nextId('booking_object');
301
302 $fields = $this->getDBFields();
303 $fields['booking_object_id'] = array('integer', $this->id);
304 $fields['pool_id'] = array('integer', $this->getPoolId());
305
306 return $ilDB->insert('booking_object', $fields);
307 }

References $ilDB.

◆ setDescription()

ilBookingObject::setDescription ( string  $a_value)

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

61 : void
62 {
63 $this->description = $a_value;
64 }

◆ setFile()

ilBookingObject::setFile ( string  $a_value)

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

101 : void
102 {
103 $this->info_file = $a_value;
104 }

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

+ Here is the caller graph for this function:

◆ setNrOfItems()

ilBookingObject::setNrOfItems ( int  $a_value)

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

91 : void
92 {
93 $this->nr_of_items = $a_value;
94 }

◆ setPoolId()

ilBookingObject::setPoolId ( int  $a_pool_id)

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

71 : void
72 {
73 $this->pool_id = $a_pool_id;
74 }

◆ setPostFile()

ilBookingObject::setPostFile ( string  $a_value)

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

166 : void
167 {
168 $this->post_file = $a_value;
169 }

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

+ Here is the caller graph for this function:

◆ setPostText()

ilBookingObject::setPostText ( string  $a_value)

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

156 : void
157 {
158 $this->post_text = $a_value;
159 }

◆ setScheduleId()

ilBookingObject::setScheduleId ( ?int  $a_schedule_id)

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

81 : void
82 {
83 $this->schedule_id = $a_schedule_id;
84 }

◆ setTitle()

ilBookingObject::setTitle ( string  $a_title)

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

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

◆ update()

ilBookingObject::update ( )

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

309 : ?int
310 {
312
313 if (!$this->id) {
314 return null;
315 }
316
317 $fields = $this->getDBFields();
318
319 return $ilDB->update(
320 'booking_object',
321 $fields,
322 array('booking_object_id' => array('integer', $this->id))
323 );
324 }

References $ilDB.

◆ uploadFile()

ilBookingObject::uploadFile ( array  $a_upload)

Upload new info file.

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

123 : bool
124 {
125 if (!$this->id) {
126 return false;
127 }
128
129 $this->deleteFile();
130
131 $path = self::initStorage($this->id, "file");
132 $original = $a_upload["name"];
133 if (ilFileUtils::moveUploadedFile($a_upload["tmp_name"], $original, $path . $original)) {
134 chmod($path . $original, 0770);
135
136 $this->setFile($original);
137 return true;
138 }
139 return false;
140 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

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

+ Here is the call graph for this function:

◆ uploadPostFile()

ilBookingObject::uploadPostFile ( array  $a_upload)

Upload new post file.

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

188 : bool
189 {
190 if (!$this->id) {
191 return false;
192 }
193
194 $this->deletePostFile();
195
196 $path = self::initStorage($this->id, "post");
197 $original = $a_upload["name"];
198
199 if (ilFileUtils::moveUploadedFile($a_upload["tmp_name"], $original, $path . $original)) {
200 chmod($path . $original, 0770);
201
202 $this->setPostFile($original);
203 return true;
204 }
205 return false;
206 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilBookingObject::$db
protected

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

◆ $description

string ilBookingObject::$description = ""
protected

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

Referenced by getDescription().

◆ $id

int ilBookingObject::$id = 0
protected

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

Referenced by getId().

◆ $info_file

string ilBookingObject::$info_file = ""
protected

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

Referenced by getFile(), and getFileFullPath().

◆ $nr_of_items

int ilBookingObject::$nr_of_items = 0
protected

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

Referenced by getNrOfItems().

◆ $pool_id

int ilBookingObject::$pool_id = 0
protected

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

Referenced by getPoolId().

◆ $post_file

string ilBookingObject::$post_file = ""
protected

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

Referenced by getPostFile(), and getPostFileFullPath().

◆ $post_text

string ilBookingObject::$post_text = ""
protected

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

Referenced by getPostText().

◆ $schedule_id

int ilBookingObject::$schedule_id = null
protected

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

Referenced by getScheduleId().

◆ $title

string ilBookingObject::$title = ""
protected

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

Referenced by getTitle().


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