25 protected \ILIAS\BookingManager\InternalRepoService
$repo;
27 protected int $id = 0;
42 $this->db = $DIC->database();
43 $this->
id = (
int) $a_id;
45 $this->repo = $DIC->bookingManager()->internal()->repo();
53 public function setTitle(
string $a_title): void
55 $this->title = $a_title;
65 $this->description = $a_value;
75 $this->pool_id = $a_pool_id;
85 $this->schedule_id = $a_schedule_id;
95 $this->nr_of_items = $a_value;
103 public function setFile(
string $a_value): void
105 $this->info_file = $a_value;
115 if ($this->
id && $this->info_file) {
116 $path = self::initStorage($this->
id,
"file");
133 $path = self::initStorage($this->
id,
"file");
134 $original = $a_upload[
"name"];
136 chmod(
$path . $original, 0770);
150 if (is_file(
$path)) {
160 $this->post_text = $a_value;
170 $this->post_file = $a_value;
180 if ($this->
id && $this->post_file) {
181 $path = self::initStorage($this->
id,
"post");
198 $path = self::initStorage($this->
id,
"post");
199 $original = $a_upload[
"name"];
202 chmod(
$path . $original, 0770);
216 if (is_file(
$path)) {
240 string $a_subdir =
"" 245 $path = $storage->getAbsolutePath() .
"/";
248 $path .= $a_subdir .
"/";
251 throw new \RuntimeException(sprintf(
'Directory "%s" was not created',
$path));
258 protected function read(): void
263 $set =
$ilDB->query(
'SELECT *' .
264 ' FROM booking_object' .
265 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
266 $row =
$ilDB->fetchAssoc($set);
267 $this->
setTitle((
string) $row[
'title']);
272 $this->
setFile((
string) $row[
'info_file']);
284 'title' => array(
'text', $this->
getTitle()),
288 'info_file' => array(
'text', $this->
getFile()),
289 'post_text' => array(
'text', $this->
getPostText()),
302 $this->
id =
$ilDB->nextId(
'booking_object');
305 $fields[
'booking_object_id'] = array(
'integer', $this->
id);
306 $fields[
'pool_id'] = array(
'integer', $this->
getPoolId());
308 return $ilDB->insert(
'booking_object', $fields);
321 return $ilDB->update(
324 array(
'booking_object_id' => array(
'integer', $this->
id))
333 string $a_title = null
337 $ilDB = $DIC->database();
340 ' FROM booking_object' .
341 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
344 $sql .=
' AND (' .
$ilDB->like(
'title',
'text',
'%' . $a_title .
'%') .
345 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $a_title .
'%') .
')';
348 $sql .=
' ORDER BY title';
350 $set =
$ilDB->query($sql);
352 while ($row =
$ilDB->fetchAssoc($set)) {
366 $ilDB = $DIC->database();
368 $sql =
'SELECT count(*) as count' .
369 ' FROM booking_object' .
370 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
371 $set =
$ilDB->query($sql);
372 $rec =
$ilDB->fetchAssoc($set);
374 return (
int) $rec[
"count"];
384 $ilDB = $DIC->database();
386 $set =
$ilDB->query(
"SELECT booking_object_id" .
387 " FROM booking_object" .
388 " WHERE pool_id = " .
$ilDB->quote($a_pool_id,
'integer'));
391 while ($row =
$ilDB->fetchAssoc($set)) {
392 $objects[] = (
int) $row[
'booking_object_id'];
402 public function delete():
int 409 return $ilDB->manipulate(
'DELETE FROM booking_object' .
410 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
417 $reservation_db = $this->repo->reservation();
418 $reservation_ids = $reservation_db->getReservationIdsByBookingObjectId($object_id);
420 foreach ($reservation_ids as $reservation_id) {
423 $reservation_db->
delete($reservation_id);
438 $ilDB = $DIC->database();
442 $set =
$ilDB->query(
"SELECT booking_object_id,nr_items" .
443 " FROM booking_object" .
444 " WHERE " .
$ilDB->in(
"booking_object_id", $a_obj_ids,
"",
"integer"));
445 while ($row =
$ilDB->fetchAssoc($set)) {
446 $map[(
int) $row[
"booking_object_id"]] = (
int) $row[
"nr_items"];
454 array $a_schedule_map = null
456 $new_obj =
new self();
457 $new_obj->setPoolId($a_pool_id);
458 $new_obj->setTitle($this->
getTitle());
461 $new_obj->setFile($this->
getFile());
465 if ($a_schedule_map) {
468 $new_obj->setScheduleId($a_schedule_map[$schedule_id] ?? null);
475 $source = self::initStorage($this->
getId());
476 $target = $new_obj::initStorage($new_obj->getId());
484 $db = $DIC->database();
486 "SELECT pool_id FROM booking_object " .
487 " WHERE booking_object_id = %s ",
492 return (
int) $rec[
"pool_id"];
499 $db = $DIC->database();
501 "SELECT title FROM booking_object " .
502 " WHERE booking_object_id = %s ",
507 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)
ILIAS BookingManager InternalRepoService $repo
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.
__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...