26 protected int $id = 0;
41 $this->db = $DIC->database();
42 $this->
id = (
int) $a_id;
51 public function setTitle(
string $a_title): void
53 $this->title = $a_title;
63 $this->description = $a_value;
73 $this->pool_id = $a_pool_id;
83 $this->schedule_id = $a_schedule_id;
93 $this->nr_of_items = $a_value;
101 public function setFile(
string $a_value): void
103 $this->info_file = $a_value;
113 if ($this->
id && $this->info_file) {
114 $path = self::initStorage($this->
id,
"file");
131 $path = self::initStorage($this->
id,
"file");
132 $original = $a_upload[
"name"];
134 chmod(
$path . $original, 0770);
148 if (is_file(
$path)) {
158 $this->post_text = $a_value;
168 $this->post_file = $a_value;
178 if ($this->
id && $this->post_file) {
179 $path = self::initStorage($this->
id,
"post");
196 $path = self::initStorage($this->
id,
"post");
197 $original = $a_upload[
"name"];
200 chmod(
$path . $original, 0770);
214 if (is_file(
$path)) {
238 string $a_subdir =
"" 243 $path = $storage->getAbsolutePath() .
"/";
246 $path .= $a_subdir .
"/";
249 throw new \RuntimeException(sprintf(
'Directory "%s" was not created',
$path));
256 protected function read(): void
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']);
270 $this->
setFile((
string) $row[
'info_file']);
282 'title' => array(
'text', $this->
getTitle()),
286 'info_file' => array(
'text', $this->
getFile()),
287 'post_text' => array(
'text', $this->
getPostText()),
300 $this->
id =
$ilDB->nextId(
'booking_object');
303 $fields[
'booking_object_id'] = array(
'integer', $this->
id);
304 $fields[
'pool_id'] = array(
'integer', $this->
getPoolId());
306 return $ilDB->insert(
'booking_object', $fields);
319 return $ilDB->update(
322 array(
'booking_object_id' => array(
'integer', $this->
id))
331 string $a_title = null
335 $ilDB = $DIC->database();
338 ' FROM booking_object' .
339 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
342 $sql .=
' AND (' .
$ilDB->like(
'title',
'text',
'%' . $a_title .
'%') .
343 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $a_title .
'%') .
')';
346 $sql .=
' ORDER BY title';
348 $set =
$ilDB->query($sql);
350 while ($row =
$ilDB->fetchAssoc($set)) {
364 $ilDB = $DIC->database();
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);
372 return (
int) $rec[
"count"];
382 $ilDB = $DIC->database();
384 $set =
$ilDB->query(
"SELECT booking_object_id" .
385 " FROM booking_object" .
386 " WHERE pool_id = " .
$ilDB->quote($a_pool_id,
'integer'));
389 while ($row =
$ilDB->fetchAssoc($set)) {
390 $objects[] = $row[
'booking_object_id'];
400 public function delete():
int 407 return $ilDB->manipulate(
'DELETE FROM booking_object' .
408 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
416 $reservation_db = $repo_fac->getRepo();
417 $reservation_ids = $reservation_db->getReservationIdsByBookingObjectId($object_id);
419 foreach ($reservation_ids as $reservation_id) {
422 $reservation_db->
delete($reservation_id);
437 $ilDB = $DIC->database();
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"];
453 array $a_schedule_map = null
455 $new_obj =
new self();
456 $new_obj->setPoolId($a_pool_id);
457 $new_obj->setTitle($this->
getTitle());
460 $new_obj->setFile($this->
getFile());
464 if ($a_schedule_map) {
467 $new_obj->setScheduleId($a_schedule_map[$schedule_id] ?? null);
475 $target = $new_obj::initStorage($new_obj->getId());
483 $db = $DIC->database();
485 "SELECT pool_id FROM booking_object " .
486 " WHERE booking_object_id = %s ",
491 return (
int) $rec[
"pool_id"];
498 $db = $DIC->database();
500 "SELECT title FROM booking_object " .
501 " WHERE booking_object_id = %s ",
506 return $rec[
"title"];
doClone(int $a_pool_id, array $a_schedule_map=null)
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...
setPostText(string $a_value)
fetchAssoc(ilDBStatement $statement)
uploadPostFile(array $a_upload)
Upload new post file.
static getNumberOfObjectsForPool(int $a_pool_id)
Get number of booking objects for given booking pool id.
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
setNrOfItems(int $a_value)
setDescription(string $a_value)
static getObjectsForPool(int $a_pool_id)
Get all booking pool object ids from an specific booking pool.
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items for a set of object ids.
uploadFile(array $a_upload)
Upload new info file.
setScheduleId(?int $a_schedule_id)
deleteReservationsAndCalEntries(int $object_id)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
setPostFile(string $a_value)
queryF(string $query, array $types, array $values)
static initStorage(int $a_id, string $a_subdir="")
Init file system storage.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_id=null)
static lookupTitle(int $object_id)
setTitle(string $a_title)
static lookupPoolId(int $object_id)
setPoolId(int $a_pool_id)
static getList(int $a_pool_id, string $a_title=null)
Get list of booking objects.
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...