ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBookingObject Class Reference

a bookable ressource More...

+ Collaboration diagram for ilBookingObject:

Public Member Functions

 __construct ($a_id=NULL)
 Constructor.
 getId ()
 Get id.
 setTitle ($a_title)
 Set object title.
 getTitle ()
 Get object title.
 setDescription ($a_value)
 Set object description.
 getDescription ()
 Get object description.
 setPoolId ($a_pool_id)
 Set booking pool id.
 getPoolId ()
 Get booking pool id.
 setScheduleId ($a_schedule_id)
 Set booking schedule id.
 getScheduleId ()
 Get booking schedule id.
 setNrOfItems ($a_value)
 Set number of items.
 getNrOfItems ()
 Get number of items.
 setFile ($a_value)
 Set info file.
 getFile ()
 Get info file.
 getFileFullPath ()
 Get path to info file.
 uploadFile (array $a_upload)
 Upload new info file.
 deleteFile ()
 remove existing info file
 setPostText ($a_value)
 Set post text.
 getPostText ()
 Get post text.
 setPostFile ($a_value)
 Set post file.
 getPostFile ()
 Get post file.
 getPostFileFullPath ()
 Get path to post file.
 uploadPostFile (array $a_upload)
 Upload new post file.
 deletePostFile ()
 remove existing post file
 deleteFiles ()
 remove existing files
 save ()
 Create new entry in db.
 update ()
 Update entry in db.
 delete ()
 Delete single entry.
 doClone ($a_pool_id, $a_schedule_map=null)

Static Public Member Functions

static initStorage ($a_id, $a_subdir=null)
 Init file system storage.
static getList ($a_pool_id)
 Get list of booking objects for given type.
static getNrOfItemsForObjects (array $a_obj_ids)
 Get nr of available items.

Protected Member Functions

 read ()
 Get dataset from db.
 getDBFields ()
 Parse properties for sql statements.

Protected Attributes

 $id
 $pool_id
 $title
 $description
 $nr_of_items
 $schedule_id
 $info_file
 $post_text
 $post_file

Detailed Description

a bookable ressource

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 12 of file class.ilBookingObject.php.

Constructor & Destructor Documentation

ilBookingObject::__construct (   $a_id = NULL)

Constructor.

if id is given will read dataset from db

Parameters
int$a_id

Definition at line 31 of file class.ilBookingObject.php.

References read().

{
$this->id = (int)$a_id;
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilBookingObject::delete ( )

Delete single entry.

Returns
bool

Definition at line 455 of file class.ilBookingObject.php.

References deleteFiles().

{
global $ilDB;
if($this->id)
{
$this->deleteFiles();
return $ilDB->manipulate('DELETE FROM booking_object'.
' WHERE booking_object_id = '.$ilDB->quote($this->id, 'integer'));
}
}

+ Here is the call graph for this function:

ilBookingObject::deleteFile ( )

remove existing info file

Definition at line 197 of file class.ilBookingObject.php.

References $path, getFileFullPath(), and setFile().

Referenced by uploadFile().

{
if($this->id)
{
$path = $this->getFileFullPath();
if($path)
{
@unlink($path);
$this->setFile(null);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::deleteFiles ( )

remove existing files

Definition at line 305 of file class.ilBookingObject.php.

References setFile(), and setPostFile().

Referenced by delete().

{
if($this->id)
{
include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
$storage = new ilFSStorageBooking($this->id);
$storage->delete();
$this->setFile(null);
$this->setPostFile(null);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::deletePostFile ( )

remove existing post file

Definition at line 289 of file class.ilBookingObject.php.

References $path, getPostFileFullPath(), and setPostFile().

Referenced by uploadPostFile().

{
if($this->id)
{
if($path)
{
@unlink($path);
$this->setPostFile(null);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::doClone (   $a_pool_id,
  $a_schedule_map = null 
)

Definition at line 490 of file class.ilBookingObject.php.

References $schedule_id, getDescription(), getFile(), getId(), getNrOfItems(), getPostFile(), getPostText(), getScheduleId(), getTitle(), initStorage(), and ilUtil\rCopy().

{
$new_obj = new self();
$new_obj->setPoolId($a_pool_id);
$new_obj->setTitle($this->getTitle());
$new_obj->setDescription($this->getDescription());
$new_obj->setNrOfItems($this->getNrOfItems());
$new_obj->setFile($this->getFile());
$new_obj->setPostText($this->getPostText());
$new_obj->setPostFile($this->getPostFile());
if($a_schedule_map)
{
{
$new_obj->setScheduleId($a_schedule_map[$schedule_id]);
}
}
$new_obj->save();
// files
$source = $this->initStorage($this->getId());
$target = $new_obj->initStorage($new_obj->getId());
ilUtil::rCopy($source, $target);
}

+ Here is the call graph for this function:

ilBookingObject::getDBFields ( )
protected

Parse properties for sql statements.

Returns
array

Definition at line 374 of file class.ilBookingObject.php.

References getDescription(), getFile(), getNrOfItems(), getPostFile(), getPostText(), getScheduleId(), and getTitle().

Referenced by save(), and update().

{
$fields = array(
'title' => array('text', $this->getTitle()),
'description' => array('text', $this->getDescription()),
'schedule_id' => array('text', $this->getScheduleId()),
'nr_items' => array('text', $this->getNrOfItems()),
'info_file' => array('text', $this->getFile()),
'post_text' => array('text', $this->getPostText()),
'post_file' => array('text', $this->getPostFile())
);
return $fields;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::getDescription ( )

Get object description.

Returns
string

Definition at line 77 of file class.ilBookingObject.php.

References $description.

Referenced by doClone(), and getDBFields().

{
}

+ Here is the caller graph for this function:

ilBookingObject::getFile ( )

Get info file.

Returns
string

Definition at line 149 of file class.ilBookingObject.php.

References $info_file.

Referenced by doClone(), and getDBFields().

{
}

+ Here is the caller graph for this function:

ilBookingObject::getFileFullPath ( )

Get path to info file.

Definition at line 157 of file class.ilBookingObject.php.

References $path, and initStorage().

Referenced by deleteFile().

{
if($this->id && $this->info_file)
{
$path = $this->initStorage($this->id, "file");
return $path.$this->info_file;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::getId ( )

Get id.

Returns
int

Definition at line 41 of file class.ilBookingObject.php.

References $id.

Referenced by doClone().

{
return $this->id;
}

+ Here is the caller graph for this function:

static ilBookingObject::getList (   $a_pool_id)
static

Get list of booking objects for given type.

Parameters
int$a_pool_id
Returns
array

Definition at line 435 of file class.ilBookingObject.php.

References $res, and $row.

Referenced by ilObjBookingPool\cloneObject(), ilBookingObjectsTableGUI\getItems(), ilBookingReservationsTableGUI\getItems(), ilObjBookingPoolGUI\initEditCustomForm(), and ilBookingScheduleGUI\render().

{
global $ilDB;
$set = $ilDB->query('SELECT *'.
' FROM booking_object'.
' WHERE pool_id = '.$ilDB->quote($a_pool_id, 'integer').
' ORDER BY title');
$res = array();
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row;
}
return $res;
}

+ Here is the caller graph for this function:

ilBookingObject::getNrOfItems ( )

Get number of items.

Returns
int

Definition at line 131 of file class.ilBookingObject.php.

References $nr_of_items.

Referenced by doClone(), and getDBFields().

{
}

+ Here is the caller graph for this function:

static ilBookingObject::getNrOfItemsForObjects ( array  $a_obj_ids)
static

Get nr of available items.

Parameters
array$a_obj_ids
Returns
array

Definition at line 473 of file class.ilBookingObject.php.

References $row.

Referenced by ilBookingReservation\getAvailableObject(), and ilBookingReservation\isObjectAvailableNoSchedule().

{
global $ilDB;
$map = array();
$set = $ilDB->query("SELECT booking_object_id,nr_items".
" FROM booking_object".
" WHERE ".$ilDB->in("booking_object_id", $a_obj_ids, "", "integer"));
while($row = $ilDB->fetchAssoc($set))
{
$map[$row["booking_object_id"]] = $row["nr_items"];
}
return $map;
}

+ Here is the caller graph for this function:

ilBookingObject::getPoolId ( )

Get booking pool id.

Returns
int

Definition at line 95 of file class.ilBookingObject.php.

References $pool_id.

Referenced by save().

{
}

+ Here is the caller graph for this function:

ilBookingObject::getPostFile ( )

Get post file.

Returns
string

Definition at line 241 of file class.ilBookingObject.php.

References $post_file.

Referenced by doClone(), and getDBFields().

{
}

+ Here is the caller graph for this function:

ilBookingObject::getPostFileFullPath ( )

Get path to post file.

Definition at line 249 of file class.ilBookingObject.php.

References $path, and initStorage().

Referenced by deletePostFile().

{
if($this->id && $this->post_file)
{
$path = $this->initStorage($this->id, "post");
return $path.$this->post_file;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::getPostText ( )

Get post text.

Returns
string

Definition at line 223 of file class.ilBookingObject.php.

References $post_text.

Referenced by doClone(), and getDBFields().

{
}

+ Here is the caller graph for this function:

ilBookingObject::getScheduleId ( )

Get booking schedule id.

Returns
int

Definition at line 113 of file class.ilBookingObject.php.

References $schedule_id.

Referenced by doClone(), and getDBFields().

{
}

+ Here is the caller graph for this function:

ilBookingObject::getTitle ( )

Get object title.

Returns
string

Definition at line 59 of file class.ilBookingObject.php.

References $title.

Referenced by doClone(), and getDBFields().

{
return $this->title;
}

+ Here is the caller graph for this function:

static ilBookingObject::initStorage (   $a_id,
  $a_subdir = null 
)
static

Init file system storage.

Parameters
type$a_id
type$a_subdir
Returns
string

Definition at line 325 of file class.ilBookingObject.php.

References $path.

Referenced by doClone(), getFileFullPath(), getPostFileFullPath(), uploadFile(), and uploadPostFile().

{
include_once "Modules/BookingManager/classes/class.ilFSStorageBooking.php";
$storage = new ilFSStorageBooking($a_id);
$storage->create();
$path = $storage->getAbsolutePath()."/";
if($a_subdir)
{
$path .= $a_subdir."/";
if(!is_dir($path))
{
mkdir($path);
}
}
return $path;
}

+ Here is the caller graph for this function:

ilBookingObject::read ( )
protected

Get dataset from db.

Definition at line 349 of file class.ilBookingObject.php.

References $row, setDescription(), setFile(), setNrOfItems(), setPoolId(), setPostFile(), setPostText(), setScheduleId(), and setTitle().

Referenced by __construct().

{
global $ilDB;
if($this->id)
{
$set = $ilDB->query('SELECT *'.
' FROM booking_object'.
' WHERE booking_object_id = '.$ilDB->quote($this->id, 'integer'));
$row = $ilDB->fetchAssoc($set);
$this->setTitle($row['title']);
$this->setDescription($row['description']);
$this->setPoolId($row['pool_id']);
$this->setScheduleId($row['schedule_id']);
$this->setNrOfItems($row['nr_items']);
$this->setFile($row['info_file']);
$this->setPostText($row['post_text']);
$this->setPostFile($row['post_file']);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingObject::save ( )

Create new entry in db.

Returns
bool

Definition at line 393 of file class.ilBookingObject.php.

References getDBFields(), and getPoolId().

{
global $ilDB;
if($this->id)
{
return false;
}
$this->id = $ilDB->nextId('booking_object');
$fields = $this->getDBFields();
$fields['booking_object_id'] = array('integer', $this->id);
$fields['pool_id'] = array('integer', $this->getPoolId());
return $ilDB->insert('booking_object', $fields);
}

+ Here is the call graph for this function:

ilBookingObject::setDescription (   $a_value)

Set object description.

Parameters
string$a_value

Definition at line 68 of file class.ilBookingObject.php.

Referenced by read().

{
$this->description = $a_value;
}

+ Here is the caller graph for this function:

ilBookingObject::setFile (   $a_value)

Set info file.

Parameters
string$a_value

Definition at line 140 of file class.ilBookingObject.php.

Referenced by deleteFile(), deleteFiles(), read(), and uploadFile().

{
$this->info_file = $a_value;
}

+ Here is the caller graph for this function:

ilBookingObject::setNrOfItems (   $a_value)

Set number of items.

Parameters
int$a_value

Definition at line 122 of file class.ilBookingObject.php.

Referenced by read().

{
$this->nr_of_items = (int)$a_value;
}

+ Here is the caller graph for this function:

ilBookingObject::setPoolId (   $a_pool_id)

Set booking pool id.

Parameters
int$a_pool_id

Definition at line 86 of file class.ilBookingObject.php.

Referenced by read(), and ilBookingObjectGUI\save().

{
$this->pool_id = (int)$a_pool_id;
}

+ Here is the caller graph for this function:

ilBookingObject::setPostFile (   $a_value)

Set post file.

Parameters
string$a_value

Definition at line 232 of file class.ilBookingObject.php.

Referenced by deleteFiles(), deletePostFile(), read(), and uploadPostFile().

{
$this->post_file = $a_value;
}

+ Here is the caller graph for this function:

ilBookingObject::setPostText (   $a_value)

Set post text.

Parameters
string$a_value

Definition at line 214 of file class.ilBookingObject.php.

Referenced by read().

{
$this->post_text = $a_value;
}

+ Here is the caller graph for this function:

ilBookingObject::setScheduleId (   $a_schedule_id)

Set booking schedule id.

Parameters
int$a_schedule_id

Definition at line 104 of file class.ilBookingObject.php.

Referenced by read().

{
$this->schedule_id = (int)$a_schedule_id;
}

+ Here is the caller graph for this function:

ilBookingObject::setTitle (   $a_title)

Set object title.

Parameters
string$a_title

Definition at line 50 of file class.ilBookingObject.php.

Referenced by read().

{
$this->title = $a_title;
}

+ Here is the caller graph for this function:

ilBookingObject::update ( )

Update entry in db.

Returns
bool

Definition at line 415 of file class.ilBookingObject.php.

References getDBFields().

{
global $ilDB;
if(!$this->id)
{
return false;
}
$fields = $this->getDBFields();
return $ilDB->update('booking_object', $fields,
array('booking_object_id'=>array('integer', $this->id)));
}

+ Here is the call graph for this function:

ilBookingObject::uploadFile ( array  $a_upload)

Upload new info file.

Parameters
array$a_upload
Returns
bool

Definition at line 172 of file class.ilBookingObject.php.

References $path, deleteFile(), initStorage(), and setFile().

{
if(!$this->id)
{
return false;
}
$this->deleteFile();
$path = $this->initStorage($this->id, "file");
$original = $a_upload["name"];
if(@move_uploaded_file($a_upload["tmp_name"], $path.$original))
{
chmod($path.$original, 0770);
$this->setFile($original);
return true;
}
return false;
}

+ Here is the call graph for this function:

ilBookingObject::uploadPostFile ( array  $a_upload)

Upload new post file.

Parameters
array$a_upload
Returns
bool

Definition at line 264 of file class.ilBookingObject.php.

References $path, deletePostFile(), initStorage(), and setPostFile().

{
if(!$this->id)
{
return false;
}
$this->deletePostFile();
$path = $this->initStorage($this->id, "post");
$original = $a_upload["name"];
if(@move_uploaded_file($a_upload["tmp_name"], $path.$original))
{
chmod($path.$original, 0770);
$this->setPostFile($original);
return true;
}
return false;
}

+ Here is the call graph for this function:

Field Documentation

ilBookingObject::$description
protected

Definition at line 17 of file class.ilBookingObject.php.

Referenced by getDescription().

ilBookingObject::$id
protected

Definition at line 14 of file class.ilBookingObject.php.

Referenced by getId().

ilBookingObject::$info_file
protected

Definition at line 20 of file class.ilBookingObject.php.

Referenced by getFile().

ilBookingObject::$nr_of_items
protected

Definition at line 18 of file class.ilBookingObject.php.

Referenced by getNrOfItems().

ilBookingObject::$pool_id
protected

Definition at line 15 of file class.ilBookingObject.php.

Referenced by getPoolId().

ilBookingObject::$post_file
protected

Definition at line 22 of file class.ilBookingObject.php.

Referenced by getPostFile().

ilBookingObject::$post_text
protected

Definition at line 21 of file class.ilBookingObject.php.

Referenced by getPostText().

ilBookingObject::$schedule_id
protected

Definition at line 19 of file class.ilBookingObject.php.

Referenced by doClone(), and getScheduleId().

ilBookingObject::$title
protected

Definition at line 16 of file class.ilBookingObject.php.

Referenced by getTitle().


The documentation for this class was generated from the following file: