40 $this->db = $DIC->database();
41 $this->
id = (int) $a_id;
60 $this->title = $a_title;
78 $this->description = $a_value;
96 $this->pool_id = (int) $a_pool_id;
114 $this->schedule_id = (int) $a_schedule_id;
132 $this->nr_of_items = (int) $a_value;
150 $this->info_file = $a_value;
167 if ($this->
id && $this->info_file) {
188 $original = $a_upload[
"name"];
189 if (ilUtil::moveUploadedFile($a_upload[
"tmp_name"], $original,
$path . $original)) {
190 chmod(
$path . $original, 0770);
218 $this->post_text = $a_value;
236 $this->post_file = $a_value;
253 if ($this->
id && $this->post_file) {
274 $original = $a_upload[
"name"];
276 if (ilUtil::moveUploadedFile($a_upload[
"tmp_name"], $original,
$path . $original)) {
277 chmod(
$path . $original, 0770);
305 include_once
"Modules/BookingManager/classes/class.ilFSStorageBooking.php";
323 include_once
"Modules/BookingManager/classes/class.ilFSStorageBooking.php";
327 $path = $storage->getAbsolutePath() .
"/";
330 $path .= $a_subdir .
"/";
332 if (!is_dir(
$path)) {
348 $set =
$ilDB->query(
'SELECT *' .
349 ' FROM booking_object' .
350 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
370 'title' => array(
'text', $this->
getTitle()),
374 'info_file' => array(
'text', $this->
getFile()),
375 'post_text' => array(
'text', $this->
getPostText()),
394 $this->
id =
$ilDB->nextId(
'booking_object');
397 $fields[
'booking_object_id'] = array(
'integer', $this->
id);
398 $fields[
'pool_id'] = array(
'integer', $this->
getPoolId());
400 return $ilDB->insert(
'booking_object', $fields);
417 return $ilDB->update(
420 array(
'booking_object_id' => array(
'integer', $this->
id))
430 public static function getList($a_pool_id, $a_title = null)
434 $ilDB = $DIC->database();
437 ' FROM booking_object' .
438 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
441 $sql .=
' AND (' .
$ilDB->like(
'title',
'text',
'%' . $a_title .
'%') .
442 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $a_title .
'%') .
')';
445 $sql .=
' ORDER BY title';
447 $set =
$ilDB->query($sql);
464 $ilDB = $DIC->database();
466 $sql =
'SELECT count(*) as count' .
467 ' FROM booking_object' .
468 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
469 $set =
$ilDB->query($sql);
470 $rec =
$ilDB->fetchAssoc($set);
472 return $rec[
"count"];
483 $ilDB = $DIC->database();
485 $set =
$ilDB->query(
"SELECT booking_object_id" .
486 " FROM booking_object" .
487 " WHERE pool_id = " .
$ilDB->quote($a_pool_id,
'integer'));
491 $objects[] =
$row[
'booking_object_id'];
502 public function delete()
509 return $ilDB->manipulate(
'DELETE FROM booking_object' .
510 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
523 $ilDB = $DIC->database();
527 $set =
$ilDB->query(
"SELECT booking_object_id,nr_items" .
528 " FROM booking_object" .
529 " WHERE " .
$ilDB->in(
"booking_object_id", $a_obj_ids,
"",
"integer"));
531 $map[
$row[
"booking_object_id"]] = $row[
"nr_items"];
537 public function doClone($a_pool_id, $a_schedule_map = null)
539 $new_obj =
new self();
540 $new_obj->setPoolId($a_pool_id);
541 $new_obj->setTitle($this->
getTitle());
544 $new_obj->setFile($this->
getFile());
548 if ($a_schedule_map) {
559 $target = $new_obj->initStorage($new_obj->getId());
573 $db = $DIC->database();
575 "SELECT pool_id FROM booking_object " .
576 " WHERE booking_object_id = %s ",
580 $rec =
$db->fetchAssoc($set);
581 return (
int) $rec[
"pool_id"];
getPostFileFullPath()
Get path to post file.
deleteFile()
remove existing info file
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
setPostText($a_value)
Set post text.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static getNumberOfObjectsForPool($a_pool_id)
Get number of booking objects for given booking pool id.
getFileFullPath()
Get path to info file.
setScheduleId($a_schedule_id)
Set booking schedule id.
deletePostFile()
remove existing post file
doClone($a_pool_id, $a_schedule_map=null)
getPostFile()
Get post file.
uploadPostFile(array $a_upload)
Upload new post file.
setFile($a_value)
Set info file.
static getObjectsForPool(int $a_pool_id)
Get all booking pool object ids from an specific booking pool.
setDescription($a_value)
Set object description.
setTitle($a_title)
Set object title.
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items.
getTitle()
Get object title.
update()
Update entry in db.
getScheduleId()
Get booking schedule id.
uploadFile(array $a_upload)
Upload new info file.
static initStorage($a_id, $a_subdir=null)
Init file system storage.
foreach($_POST as $key=> $value) $res
getDBFields()
Parse properties for sql statements.
getNrOfItems()
Get number of items.
setNrOfItems($a_value)
Set number of items.
getPoolId()
Get booking pool id.
static lookupPoolId($object_id)
Lookup pool id.
getPostText()
Get post text.
read()
Get dataset from db.
setPostFile($a_value)
Set post file.
save()
Create new entry in db.
setPoolId($a_pool_id)
Set booking pool id.
deleteFiles()
remove existing files
getDescription()
Get object description.
__construct($a_id=null)
Constructor.