ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 
 setPostText (string $a_value)
 
 getPostText ()
 
 setPostFile (string $a_value)
 
 getPostFile ()
 
 getPostFileFullPath ()
 
 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 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 ()
 Init file system storage. More...
 
 getDBFields ()
 

Protected Attributes

ILIAS BookingManager Objects ObjectsManager $objects_manager
 
ILIAS BookingManager InternalRepoService $repo
 
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 38 of file class.ilBookingObject.php.

40 {
41 global $DIC;
42
43 $this->db = $DIC->database();
44 $this->id = (int) $a_id;
45 $this->read();
46 $this->repo = $DIC->bookingManager()->internal()->repo();
47 $this->objects_manager = $DIC->bookingManager()->internal()->domain()->objects($this->getPoolId());
48 }
read()
Init file system storage.
global $DIC
Definition: shib_login.php:26

References $DIC, getPoolId(), 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 310 of file class.ilBookingObject.php.

310 : int
311 {
313
314 if ($this->id) {
315 $this->deleteFiles();
316
317 return $ilDB->manipulate('DELETE FROM booking_object' .
318 ' WHERE booking_object_id = ' . $ilDB->quote($this->id, 'integer'));
319 }
320 return 0;
321 }

References $ilDB.

◆ deleteFiles()

ilBookingObject::deleteFiles ( )

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

152 : void
153 {
154 if ($this->id) {
155 $this->objects_manager->deleteObjectInfo($this->id);
156 $this->objects_manager->deleteBookingInfo($this->id);
157 $this->setFile("");
158 $this->setPostFile("");
159 }
160 }
setFile(string $a_value)
setPostFile(string $a_value)

References setFile(), and setPostFile().

+ Here is the call graph for this function:

◆ deleteReservationsAndCalEntries()

ilBookingObject::deleteReservationsAndCalEntries ( int  $object_id)

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

323 : void
324 {
325 $reservation_db = $this->repo->reservation();
326 $reservation_ids = $reservation_db->getReservationIdsByBookingObjectId($object_id);
327
328 foreach ($reservation_ids as $reservation_id) {
329 $reservation = new ilBookingReservation($reservation_id);
330 $entry = new ilCalendarEntry($reservation->getCalendarEntry());
331 $reservation_db->delete($reservation_id);
332 $entry->delete();
333 }
334 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Model for a calendar entry.

◆ doClone()

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

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

363 : void {
364 $new_obj = new self();
365 $new_obj->setPoolId($a_pool_id);
366 $new_obj->setTitle($this->getTitle());
367 $new_obj->setDescription($this->getDescription());
368 $new_obj->setNrOfItems($this->getNrOfItems());
369 $new_obj->setFile($this->getFile());
370 $new_obj->setPostText($this->getPostText());
371 $new_obj->setPostFile($this->getPostFile());
372
373 if ($a_schedule_map) {
374 $schedule_id = $this->getScheduleId();
375 if ($schedule_id) {
376 $new_obj->setScheduleId($a_schedule_map[$schedule_id] ?? null);
377 }
378 }
379
380 $new_obj->save();
381
382 $this->objects_manager->cloneTo($this->getId(), $new_obj->getId());
383 }

◆ getDBFields()

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

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

189 : array
190 {
191 return array(
192 'title' => array('text', $this->getTitle()),
193 'description' => array('text', $this->getDescription()),
194 'schedule_id' => array('text', $this->getScheduleId()),
195 'nr_items' => array('text', $this->getNrOfItems()),
196 'info_file' => array('text', $this->getFile()),
197 'post_text' => array('text', $this->getPostText()),
198 'post_file' => array('text', $this->getPostFile())
199 );
200 }

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

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

70 : string
71 {
72 return $this->description;
73 }

References $description.

Referenced by getDBFields().

+ Here is the caller graph for this function:

◆ getFile()

ilBookingObject::getFile ( )

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

110 : string
111 {
112 return $this->info_file;
113 }

References $info_file.

Referenced by getDBFields().

+ Here is the caller graph for this function:

◆ getFileFullPath()

ilBookingObject::getFileFullPath ( )

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

115 : string
116 {
117 if ($this->id && $this->info_file) {
118 return $this->objects_manager->getObjectInfoPath($this->id);
119 }
120 return "";
121 }

◆ getId()

ilBookingObject::getId ( )

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

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

References $id.

◆ getList()

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

Get list of booking objects.

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

242 : array {
243 global $DIC;
244
245 $ilDB = $DIC->database();
246
247 $sql = 'SELECT *' .
248 ' FROM booking_object' .
249 ' WHERE pool_id = ' . $ilDB->quote($a_pool_id, 'integer');
250
251 if ($a_title) {
252 $sql .= ' AND (' . $ilDB->like('title', 'text', '%' . $a_title . '%') .
253 ' OR ' . $ilDB->like('description', 'text', '%' . $a_title . '%') . ')';
254 }
255
256 $sql .= ' ORDER BY title';
257
258 $set = $ilDB->query($sql);
259 $res = array();
260 while ($row = $ilDB->fetchAssoc($set)) {
261 $res[] = $row;
262 }
263 return $res;
264 }
$res
Definition: ltiservices.php:69

References $ilDB.

Referenced by ilObjBookingPool\cloneObject(), ILIAS\BookingManager\Settings\SettingsGUI\getEditForm(), 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 100 of file class.ilBookingObject.php.

100 : int
101 {
102 return $this->nr_of_items;
103 }

References $nr_of_items.

Referenced by getDBFields().

+ Here is the caller graph for this function:

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

343 : array {
344 global $DIC;
345
346 $ilDB = $DIC->database();
347
348 $map = array();
349
350 $set = $ilDB->query("SELECT booking_object_id,nr_items" .
351 " FROM booking_object" .
352 " WHERE " . $ilDB->in("booking_object_id", $a_obj_ids, "", "integer"));
353 while ($row = $ilDB->fetchAssoc($set)) {
354 $map[(int) $row["booking_object_id"]] = (int) $row["nr_items"];
355 }
356
357 return $map;
358 }

Referenced by 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 269 of file class.ilBookingObject.php.

271 : int {
272 global $DIC;
273
274 $ilDB = $DIC->database();
275
276 $sql = 'SELECT count(*) as count' .
277 ' FROM booking_object' .
278 ' WHERE pool_id = ' . $ilDB->quote($a_pool_id, 'integer');
279 $set = $ilDB->query($sql);
280 $rec = $ilDB->fetchAssoc($set);
281
282 return (int) $rec["count"];
283 }

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

290 : array {
291 global $DIC;
292 $ilDB = $DIC->database();
293
294 $set = $ilDB->query("SELECT booking_object_id" .
295 " FROM booking_object" .
296 " WHERE pool_id = " . $ilDB->quote($a_pool_id, 'integer'));
297
298 $objects = array();
299 while ($row = $ilDB->fetchAssoc($set)) {
300 $objects[] = (int) $row['booking_object_id'];
301 }
302
303 return $objects;
304 }

◆ getPoolId()

ilBookingObject::getPoolId ( )

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

80 : int
81 {
82 return $this->pool_id;
83 }

References $pool_id.

Referenced by __construct(), and save().

+ Here is the caller graph for this function:

◆ getPostFile()

ilBookingObject::getPostFile ( )

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

138 : string
139 {
140 return $this->post_file;
141 }

References $post_file.

Referenced by getDBFields().

+ Here is the caller graph for this function:

◆ getPostFileFullPath()

ilBookingObject::getPostFileFullPath ( )

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

143 : string
144 {
145 if ($this->id && $this->post_file) {
146 return $this->objects_manager->getBookingInfoPath($this->id);
147 }
148 return "";
149 }

◆ getPostText()

ilBookingObject::getPostText ( )

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

128 : string
129 {
130 return $this->post_text;
131 }

References $post_text.

Referenced by getDBFields().

+ Here is the caller graph for this function:

◆ getScheduleId()

ilBookingObject::getScheduleId ( )

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

90 : ?int
91 {
92 return $this->schedule_id;
93 }

References $schedule_id.

Referenced by getDBFields().

+ Here is the caller graph for this function:

◆ getTitle()

ilBookingObject::getTitle ( )

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

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

References $title.

Referenced by getDBFields().

+ Here is the caller graph for this function:

◆ lookupPoolId()

static ilBookingObject::lookupPoolId ( int  $object_id)
static

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

385 : int
386 {
387 global $DIC;
388
389 $db = $DIC->database();
390 $set = $db->queryF(
391 "SELECT pool_id FROM booking_object " .
392 " WHERE booking_object_id = %s ",
393 array("integer"),
394 array($object_id)
395 );
396 $rec = $db->fetchAssoc($set);
397 return (int) $rec["pool_id"];
398 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

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

Referenced by ilBookingReservationsGUI\__construct(), and ILIAS\BookingManager\Access\AccessManager\validateBookingObjId().

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

400 : string
401 {
402 global $DIC;
403
404 $db = $DIC->database();
405 $set = $db->queryF(
406 "SELECT title FROM booking_object " .
407 " WHERE booking_object_id = %s ",
408 array("integer"),
409 array($object_id)
410 );
411 $rec = $db->fetchAssoc($set);
412 return $rec["title"];
413 }

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

Init file system storage.

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

166 : void
167 {
169
170 if ($this->id) {
171 $set = $ilDB->query('SELECT *' .
172 ' FROM booking_object' .
173 ' WHERE booking_object_id = ' . $ilDB->quote($this->id, 'integer'));
174 $row = $ilDB->fetchAssoc($set);
175 $this->setTitle((string) $row['title']);
176 $this->setDescription((string) $row['description']);
177 $this->setPoolId((int) $row['pool_id']);
178 $this->setScheduleId($row['schedule_id']);
179 $this->setNrOfItems((int) $row['nr_items']);
180 $this->setFile((string) $row['info_file']);
181 $this->setPostText((string) $row['post_text']);
182 $this->setPostFile((string) $row['post_file']);
183 }
184 }
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 $db, $ilDB, 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 ( )

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

202 : ?int
203 {
205
206 if ($this->id) {
207 return null;
208 }
209
210 $this->id = $ilDB->nextId('booking_object');
211
212 $fields = $this->getDBFields();
213 $fields['booking_object_id'] = array('integer', $this->id);
214 $fields['pool_id'] = array('integer', $this->getPoolId());
215
216 return $ilDB->insert('booking_object', $fields);
217 }

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

+ Here is the call graph for this function:

◆ setDescription()

ilBookingObject::setDescription ( string  $a_value)

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

65 : void
66 {
67 $this->description = $a_value;
68 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setFile()

ilBookingObject::setFile ( string  $a_value)

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

105 : void
106 {
107 $this->info_file = $a_value;
108 }

Referenced by deleteFiles(), and read().

+ Here is the caller graph for this function:

◆ setNrOfItems()

ilBookingObject::setNrOfItems ( int  $a_value)

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

95 : void
96 {
97 $this->nr_of_items = $a_value;
98 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPoolId()

ilBookingObject::setPoolId ( int  $a_pool_id)

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

75 : void
76 {
77 $this->pool_id = $a_pool_id;
78 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setPostFile()

ilBookingObject::setPostFile ( string  $a_value)

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

133 : void
134 {
135 $this->post_file = $a_value;
136 }

Referenced by deleteFiles(), and read().

+ Here is the caller graph for this function:

◆ setPostText()

ilBookingObject::setPostText ( string  $a_value)

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

123 : void
124 {
125 $this->post_text = $a_value;
126 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setScheduleId()

ilBookingObject::setScheduleId ( ?int  $a_schedule_id)

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

85 : void
86 {
87 $this->schedule_id = $a_schedule_id;
88 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilBookingObject::setTitle ( string  $a_title)

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

55 : void
56 {
57 $this->title = $a_title;
58 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilBookingObject::update ( )

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

219 : ?int
220 {
222
223 if (!$this->id) {
224 return null;
225 }
226
227 $fields = $this->getDBFields();
228
229 return $ilDB->update(
230 'booking_object',
231 $fields,
232 array('booking_object_id' => array('integer', $this->id))
233 );
234 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilBookingObject::$db
protected

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

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

◆ $description

string ilBookingObject::$description = ""
protected

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

Referenced by getDescription().

◆ $id

int ilBookingObject::$id = 0
protected

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

Referenced by getId().

◆ $info_file

string ilBookingObject::$info_file = ""
protected

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

Referenced by getFile().

◆ $nr_of_items

int ilBookingObject::$nr_of_items = 0
protected

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

Referenced by getNrOfItems().

◆ $objects_manager

ILIAS BookingManager Objects ObjectsManager ilBookingObject::$objects_manager
protected

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

◆ $pool_id

int ilBookingObject::$pool_id = 0
protected

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

Referenced by getPoolId().

◆ $post_file

string ilBookingObject::$post_file = ""
protected

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

Referenced by getPostFile().

◆ $post_text

string ilBookingObject::$post_text = ""
protected

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

Referenced by getPostText().

◆ $repo

ILIAS BookingManager InternalRepoService ilBookingObject::$repo
protected

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

◆ $schedule_id

int ilBookingObject::$schedule_id = null
protected

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

Referenced by getScheduleId().

◆ $title

string ilBookingObject::$title = ""
protected

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

Referenced by getTitle().


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