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"];
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"];
277 chmod($path . $original, 0770);
325 $path = $storage->getAbsolutePath() .
"/";
328 $path .= $a_subdir .
"/";
330 if (!is_dir($path)) {
346 $set =
$ilDB->query(
'SELECT *' .
347 ' FROM booking_object' .
348 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
349 $row =
$ilDB->fetchAssoc($set);
355 $this->
setFile($row[
'info_file']);
368 'title' => array(
'text', $this->
getTitle()),
372 'info_file' => array(
'text', $this->
getFile()),
373 'post_text' => array(
'text', $this->
getPostText()),
392 $this->
id =
$ilDB->nextId(
'booking_object');
395 $fields[
'booking_object_id'] = array(
'integer', $this->
id);
396 $fields[
'pool_id'] = array(
'integer', $this->
getPoolId());
398 return $ilDB->insert(
'booking_object', $fields);
415 return $ilDB->update(
418 array(
'booking_object_id' => array(
'integer', $this->
id))
428 public static function getList($a_pool_id, $a_title = null)
432 $ilDB = $DIC->database();
435 ' FROM booking_object' .
436 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
439 $sql .=
' AND (' .
$ilDB->like(
'title',
'text',
'%' . $a_title .
'%') .
440 ' OR ' .
$ilDB->like(
'description',
'text',
'%' . $a_title .
'%') .
')';
443 $sql .=
' ORDER BY title';
445 $set =
$ilDB->query($sql);
447 while ($row =
$ilDB->fetchAssoc($set)) {
462 $ilDB = $DIC->database();
464 $sql =
'SELECT count(*) as count' .
465 ' FROM booking_object' .
466 ' WHERE pool_id = ' .
$ilDB->quote($a_pool_id,
'integer');
467 $set =
$ilDB->query($sql);
468 $rec =
$ilDB->fetchAssoc($set);
470 return $rec[
"count"];
481 $ilDB = $DIC->database();
483 $set =
$ilDB->query(
"SELECT booking_object_id" .
484 " FROM booking_object" .
485 " WHERE pool_id = " .
$ilDB->quote($a_pool_id,
'integer'));
488 while ($row =
$ilDB->fetchAssoc($set)) {
489 $objects[] = $row[
'booking_object_id'];
500 public function delete()
507 return $ilDB->manipulate(
'DELETE FROM booking_object' .
508 ' WHERE booking_object_id = ' .
$ilDB->quote($this->id,
'integer'));
521 $ilDB = $DIC->database();
525 $set =
$ilDB->query(
"SELECT booking_object_id,nr_items" .
526 " FROM booking_object" .
527 " WHERE " .
$ilDB->in(
"booking_object_id", $a_obj_ids,
"",
"integer"));
528 while ($row =
$ilDB->fetchAssoc($set)) {
529 $map[$row[
"booking_object_id"]] = $row[
"nr_items"];
535 public function doClone($a_pool_id, $a_schedule_map = null)
537 $new_obj =
new self();
538 $new_obj->setPoolId($a_pool_id);
539 $new_obj->setTitle($this->
getTitle());
542 $new_obj->setFile($this->
getFile());
546 if ($a_schedule_map) {
557 $target = $new_obj->initStorage($new_obj->getId());
571 $db = $DIC->database();
573 "SELECT pool_id FROM booking_object " .
574 " WHERE booking_object_id = %s ",
578 $rec =
$db->fetchAssoc($set);
579 return (
int) $rec[
"pool_id"];
592 $db = $DIC->database();
594 "SELECT title FROM booking_object " .
595 " WHERE booking_object_id = %s ",
599 $rec =
$db->fetchAssoc($set);
600 return $rec[
"title"];
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.
static lookupTitle($object_id)
Lookup pool id.
foreach($_POST as $key=> $value) $res
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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.