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)
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)) {
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"];
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'));
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());
573 "SELECT pool_id FROM booking_object " .
574 " WHERE booking_object_id = %s ",
578 $rec =
$db->fetchAssoc($set);
579 return (
int) $rec[
"pool_id"];
594 "SELECT title FROM booking_object " .
595 " WHERE booking_object_id = %s ",
599 $rec =
$db->fetchAssoc($set);
600 return $rec[
"title"];
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
static lookupTitle($object_id)
Lookup pool id.
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 moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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