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)
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);
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"];
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'));
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"));
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());
575 "SELECT pool_id FROM booking_object " .
576 " WHERE booking_object_id = %s ",
580 $rec =
$db->fetchAssoc($set);
581 return (
int) $rec[
"pool_id"];
An exception for terminatinating execution or to throw for unit testing.
setScheduleId($a_schedule_id)
Set booking schedule id.
setFile($a_value)
Set info file.
uploadFile(array $a_upload)
Upload new info file.
setTitle($a_title)
Set object title.
getScheduleId()
Get booking schedule id.
getPostText()
Get post text.
static lookupPoolId($object_id)
Lookup pool id.
static getNrOfItemsForObjects(array $a_obj_ids)
Get nr of available items.
getPostFile()
Get post file.
setPoolId($a_pool_id)
Set booking pool id.
getTitle()
Get object title.
getNrOfItems()
Get number of items.
static getNumberOfObjectsForPool($a_pool_id)
Get number of booking objects for given booking pool id.
setPostFile($a_value)
Set post file.
__construct($a_id=null)
Constructor.
deleteFile()
remove existing info file
uploadPostFile(array $a_upload)
Upload new post file.
setDescription($a_value)
Set object description.
getPoolId()
Get booking pool id.
doClone($a_pool_id, $a_schedule_map=null)
setNrOfItems($a_value)
Set number of items.
getFileFullPath()
Get path to info file.
setPostText($a_value)
Set post text.
getDescription()
Get object description.
deleteFiles()
remove existing files
static getObjectsForPool(int $a_pool_id)
Get all booking pool object ids from an specific booking pool.
static getList($a_pool_id, $a_title=null)
Get list of booking objects for given type.
save()
Create new entry in db.
getPostFileFullPath()
Get path to post file.
getDBFields()
Parse properties for sql statements.
deletePostFile()
remove existing post file
static initStorage($a_id, $a_subdir=null)
Init file system storage.
update()
Update entry in db.
read()
Get dataset from db.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
foreach($_POST as $key=> $value) $res