ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBookingEntry Class Reference

Booking definition. More...

+ Collaboration diagram for ilBookingEntry:

Public Member Functions

 __construct ($a_booking_id=0)
 Constructor.
 getId ()
 Get id.
 setBookingGroup ($a_id)
 getBookingGroup ()
 setObjId ($a_id)
 Set obj id.
 getObjId ()
 get obj id
 setDeadlineHours ($a_hours)
 set deadline hours
 getDeadlineHours ()
 get deadline hours
 setNumberOfBookings ($a_num)
 set number of bookings
 getNumberOfBookings ()
 get number of bookings
 setTargetObjIds ($a_obj_id)
 set target object id
 getTargetObjIds ()
 get target object id
 isTargetObjectVisible ($a_ref_id)
 Check if target ref id is visible.
 save ()
 Save a new booking entry.
 update ()
 Update an existing booking entry.
 delete ()
 Delete.
 isOwner ($a_user_id=NULL)
 check if current (or given) user is entry owner
 getCurrentNumberOfBookings ($a_entry_id)
 get current number of bookings
 getCurrentBookings ($a_entry_id)
 get current bookings
 hasBooked ($a_entry_id, $a_user_id=NULL)
 get current number of bookings
 isBookedOut ($a_entry_id, $a_check_current_user=false)
 get current number of bookings
 isAppointmentBookableForUser ($a_app_id, $a_user_id)
 Check if a calendar appointment is bookable for a specific user.
 book ($a_entry_id, $a_user_id=false)
 book calendar entry for user
 cancelBooking ($a_entry_id, $a_user_id=false)
 cancel calendar booking for user
 deleteBooking ($a_entry_id, $a_user_id)
 Delete booking type $ilDB.

Static Public Member Functions

static resetGroup ($a_group_id)
 Reset booking group (in case of deletion) type $ilDB.
static lookupBookingsOfUser ($a_app_ids, $a_usr_id, ilDateTime $start=null)
 Lookup bookings if user.
static removeObsoleteEntries ()
 Remove unused booking entries.
static getInstanceByCalendarEntryId ($a_id)
 Get instance by calendar entry.
static isBookable (array $a_obj_ids, $a_target_obj_id=NULL)
 Which objects are bookable?
static lookupBookableUsersForObject ($a_obj_id, $a_user_ids)
 Consultation hours are offered if 1) consultation hour owner is admin or tutor and no object assignment 2) object is assigned to consultation hour.
static hasObjectBookingEntries ($a_obj_id, $a_usr_id)
 Check if object has assigned consultation hour appointments.
static lookupBookingMessage ($a_entry_id, $a_usr_id)
static writeBookingMessage ($a_entry_id, $a_usr_id, $a_message)
 Write booking message.
static lookupBookingsForAppointment ($a_app_id)
 Lookup booked users for appointment type $ilDB.
static lookupBookingsForObject ($a_obj_id, $a_usr_id)
 Lookup booking for an object and user.
static lookupManagedBookingsForObject ($a_obj_id, $a_usr_id)
 Lookup bookings for own and managed consultation hours of an object.

Protected Member Functions

 setId ($a_id)
 Set id.
 read ()
 Read settings from db.

Private Attributes

 $id = 0
 $obj_id = 0
 $deadline = 0
 $num_bookings = 1
 $target_obj_ids = array()
 $booking_group = 0

Detailed Description

Booking definition.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 13 of file class.ilBookingEntry.php.

Constructor & Destructor Documentation

ilBookingEntry::__construct (   $a_booking_id = 0)

Constructor.

Definition at line 27 of file class.ilBookingEntry.php.

References getId(), read(), and setId().

{
$this->setId($a_booking_id);
if($this->getId())
{
$this->read();
}
}

+ Here is the call graph for this function:

Member Function Documentation

ilBookingEntry::book (   $a_entry_id,
  $a_user_id = false 
)

book calendar entry for user

Parameters
int$a_entry_id
int$a_user_id

Definition at line 778 of file class.ilBookingEntry.php.

References $ilUser, hasBooked(), and ilCalendarMailNotification\TYPE_BOOKING_CONFIRMATION.

Referenced by ilConsultationHourUtils\bookAppointment().

{
global $ilUser, $ilDB;
if(!$a_user_id)
{
$a_user_id = $ilUser->getId();
}
if(!$this->hasBooked($a_entry_id, $a_user_id))
{
$ilDB->manipulate('INSERT INTO booking_user (entry_id, user_id, tstamp)'.
' VALUES ('.$ilDB->quote($a_entry_id, 'integer').','.
$ilDB->quote($a_user_id, 'integer').','.$ilDB->quote(time(), 'integer').')');
include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
$mail->setAppointmentId($a_entry_id);
$mail->setRecipients(array($a_user_id));
$mail->send();
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingEntry::cancelBooking (   $a_entry_id,
  $a_user_id = false 
)

cancel calendar booking for user

Parameters
int$a_entry_id
int$a_user_id

Definition at line 808 of file class.ilBookingEntry.php.

References $ilUser, ilDateTime\_before(), deleteBooking(), hasBooked(), IL_CAL_UNIX, and ilCalendarMailNotification\TYPE_BOOKING_CANCELLATION.

Referenced by ilConsultationHourUtils\cancelBooking(), and ilCalendarAppointmentGUI\cancelConfirmed().

{
global $ilUser, $ilDB;
if(!$a_user_id)
{
$a_user_id = $ilUser->getId();
}
// @todo do not send mails about past consultation hours
$entry = new ilCalendarEntry($a_entry_id);
$past = ilDateTime::_before($entry->getStart(), new ilDateTime(time(),IL_CAL_UNIX));
if($this->hasBooked($a_entry_id, $a_user_id) && !$past)
{
include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
$mail->setAppointmentId($a_entry_id);
$mail->setRecipients(array($a_user_id));
$mail->send();
}
$this->deleteBooking($a_entry_id,$a_user_id);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingEntry::delete ( )

Delete.

Returns

Definition at line 268 of file class.ilBookingEntry.php.

References $query, and getId().

{
global $ilDB;
$query = "DELETE FROM booking_entry ".
"WHERE booking_id = ".$ilDB->quote($this->getId(),'integer');
$ilDB->manipulate($query);
$query = 'DELETE FROM booking_obj_assignment '.
'WHERE booking_id = '.$ilDB->quote($this->getId(),'integer');
$ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

ilBookingEntry::deleteBooking (   $a_entry_id,
  $a_user_id 
)

Delete booking type $ilDB.

Parameters
type$a_entry_id
type$a_user_id
Returns
boolean

Definition at line 841 of file class.ilBookingEntry.php.

References $query.

Referenced by cancelBooking().

{
global $ilDB;
$query = 'DELETE FROM booking_user ' .
'WHERE entry_id = '.$ilDB->quote($a_entry_id, 'integer').' '.
'AND user_id = '.$ilDB->quote($a_user_id, 'integer');
$ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

ilBookingEntry::getBookingGroup ( )

Definition at line 99 of file class.ilBookingEntry.php.

References $booking_group.

Referenced by isAppointmentBookableForUser(), save(), and update().

{
}

+ Here is the caller graph for this function:

ilBookingEntry::getCurrentBookings (   $a_entry_id)

get current bookings

Parameters
int$a_entry_id
Returns
array

Definition at line 553 of file class.ilBookingEntry.php.

References $res, and $row.

Referenced by ilConsultationHoursTableGUI\parse().

{
global $ilDB;
$set = $ilDB->query('SELECT user_id FROM booking_user'.
' WHERE entry_id = '.$ilDB->quote($a_entry_id, 'integer'));
$res = array();
while($row = $ilDB->fetchAssoc($set))
{
$res[] = $row['user_id'];
}
return $res;
}

+ Here is the caller graph for this function:

ilBookingEntry::getCurrentNumberOfBookings (   $a_entry_id)

get current number of bookings

Parameters
int$a_entry_id
Returns
int

Definition at line 538 of file class.ilBookingEntry.php.

References $row.

Referenced by isAppointmentBookableForUser(), and isBookedOut().

{
global $ilDB;
$set = $ilDB->query('SELECT COUNT(*) AS counter FROM booking_user'.
' WHERE entry_id = '.$ilDB->quote($a_entry_id, 'integer'));
$row = $ilDB->fetchAssoc($set);
return (int)$row['counter'];
}

+ Here is the caller graph for this function:

ilBookingEntry::getDeadlineHours ( )

get deadline hours

Returns

Definition at line 137 of file class.ilBookingEntry.php.

References $deadline.

Referenced by isAppointmentBookableForUser(), isBookedOut(), save(), and update().

{
}

+ Here is the caller graph for this function:

ilBookingEntry::getId ( )

Get id.

Returns

Definition at line 89 of file class.ilBookingEntry.php.

References $id.

Referenced by __construct(), ilConsultationHoursGUI\createAppointments(), delete(), read(), save(), and update().

{
return $this->id;
}

+ Here is the caller graph for this function:

static ilBookingEntry::getInstanceByCalendarEntryId (   $a_id)
static

Get instance by calendar entry.

Parameters
int$id
Returns
ilBookingEntry

Definition at line 367 of file class.ilBookingEntry.php.

Referenced by ilConsultationHoursGUI\assignUsersToAppointment(), ilConsultationHoursGUI\assignUsersToGroup(), ilConsultationHoursGUI\delete(), and ilConsultationHoursGUI\updateMulti().

{
include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
$cal_entry = new ilCalendarEntry($a_id);
$booking_id = $cal_entry->getContextId();
if($booking_id)
{
return new self($booking_id);
}
}

+ Here is the caller graph for this function:

ilBookingEntry::getNumberOfBookings ( )

get number of bookings

Returns

Definition at line 156 of file class.ilBookingEntry.php.

References $num_bookings.

Referenced by isAppointmentBookableForUser(), isBookedOut(), save(), and update().

{
}

+ Here is the caller graph for this function:

ilBookingEntry::getObjId ( )

get obj id

Returns

Definition at line 118 of file class.ilBookingEntry.php.

References $obj_id.

Referenced by isAppointmentBookableForUser(), isBookedOut(), isOwner(), save(), and update().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

ilBookingEntry::getTargetObjIds ( )

get target object id

Returns
int

Definition at line 175 of file class.ilBookingEntry.php.

References $target_obj_ids.

Referenced by isTargetObjectVisible().

{
}

+ Here is the caller graph for this function:

ilBookingEntry::hasBooked (   $a_entry_id,
  $a_user_id = NULL 
)

get current number of bookings

Parameters
int$a_entry_id
int$a_user_id
Returns
bool

Definition at line 655 of file class.ilBookingEntry.php.

References $ilUser, $query, and $row.

Referenced by book(), cancelBooking(), and isBookedOut().

{
global $ilUser, $ilDB;
if(!$a_user_id)
{
$a_user_id = $ilUser->getId();
}
$query = 'SELECT COUNT(*) AS counter FROM booking_user'.
' WHERE entry_id = '.$ilDB->quote($a_entry_id, 'integer').
' AND user_id = '.$ilDB->quote($a_user_id, 'integer');
$set = $ilDB->query($query);
$row = $ilDB->fetchAssoc($set);
return (bool) $row['counter'];
}

+ Here is the caller graph for this function:

static ilBookingEntry::hasObjectBookingEntries (   $a_obj_id,
  $a_usr_id 
)
static

Check if object has assigned consultation hour appointments.

Parameters
type$a_obj_id
type$a_usr_id

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

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilExportFieldsInfo\getSelectableFieldsInfo(), and ilMemberExportGUI\show().

{
global $ilDB;
$user_restriction = '';
if($a_usr_id)
{
$user_restriction = 'AND obj_id = '.$ilDB->quote($a_usr_id). ' ';
}
$query = 'SELECT be.booking_id FROM booking_entry be '.
'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
'WHERE bo.target_obj_id = '.$ilDB->quote($a_obj_id,'integer').' '.
$user_restriction;
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return true;
}
return false;
}

+ Here is the caller graph for this function:

ilBookingEntry::isAppointmentBookableForUser (   $a_app_id,
  $a_user_id 
)

Check if a calendar appointment is bookable for a specific user.

Parameters
type$a_cal_entry_id
type$a_user_id
Returns
bool

Definition at line 719 of file class.ilBookingEntry.php.

References ilDateTime\_after(), ilConsultationHourAppointments\getAppointmentIdsByGroup(), getBookingGroup(), getCurrentNumberOfBookings(), getDeadlineHours(), getNumberOfBookings(), getObjId(), IL_CAL_HOUR, IL_CAL_UNIX, lookupBookingsOfUser(), and ilConsultationHourGroups\lookupMaxBookings().

{
// #12025
if($a_user_id == ANONYMOUS_USER_ID)
{
return false;
}
// Check max bookings
if($this->getNumberOfBookings() <= $this->getCurrentNumberOfBookings($a_app_id))
{
#$GLOBALS['ilLog']->write(__METHOD__.': Number of bookings exceeded');
return false;
}
// Check deadline
$dead_limit = new ilDateTime(time(),IL_CAL_UNIX);
$dead_limit->increment(IL_CAL_HOUR,$this->getDeadlineHours());
include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
$entry = new ilCalendarEntry($a_app_id);
if(ilDateTime::_after($dead_limit, $entry->getStart()))
{
#$GLOBALS['ilLog']->write(__METHOD__.': Deadline reached');
return false;
}
// Check group restrictions
if(!$this->getBookingGroup())
{
#$GLOBALS['ilLog']->write(__METHOD__.': No booking group');
return true;
}
include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourAppointments.php';
$this->getObjId(),
$this->getBookingGroup()
);
// Number of bookings in group
$bookings = self::lookupBookingsOfUser($group_apps, $a_user_id);
include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourGroups.php';
#$GLOBALS['ilLog']->write(__METHOD__.': '.ilConsultationHourGroups::lookupMaxBookings($this->getBookingGroup()));
{
#$GLOBALS['ilLog']->write(__METHOD__.': Personal booking limit reached');
return false;
}
#$GLOBALS['ilLog']->write(__METHOD__.': Is bookable!');
return true;
}

+ Here is the call graph for this function:

static ilBookingEntry::isBookable ( array  $a_obj_ids,
  $a_target_obj_id = NULL 
)
static

Which objects are bookable?

Parameters
array$a_obj_ids
int$a_target_obj_id
Returns
array

Definition at line 385 of file class.ilBookingEntry.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

{
global $ilDB;
if($a_target_obj_id)
{
$query = 'SELECT DISTINCT(obj_id) FROM booking_entry be '.
'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
'WHERE '.$ilDB->in('obj_id', $a_obj_ids, false, 'integer').' '.
'AND bo.target_obj_id = '.$ilDB->quote($a_target_obj_id,'integer');
}
else
{
$query = 'SELECT DISTINCT(obj_id) FROM booking_entry be '.
'WHERE '.$ilDB->in('obj_id', $a_obj_ids, false, 'integer').' ';
}
$res = $ilDB->query($query);
$all = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$all[] = $row->obj_id;
}
return $all;
}
ilBookingEntry::isBookedOut (   $a_entry_id,
  $a_check_current_user = false 
)

get current number of bookings

Parameters
int$a_entry_id(calendar entry)
bool$a_check_current_user
Returns
bool

Definition at line 679 of file class.ilBookingEntry.php.

References $deadline, $ilUser, getCurrentNumberOfBookings(), getDeadlineHours(), getNumberOfBookings(), getObjId(), hasBooked(), and IL_CAL_UNIX.

{
global $ilUser;
if($this->getNumberOfBookings() == $this->getCurrentNumberOfBookings($a_entry_id))
{
// check against current user
if($a_check_current_user)
{
if($this->hasBooked($a_entry_id))
{
return false;
}
if($ilUser->getId() == $this->getObjId())
{
return false;
}
}
return true;
}
{
include_once 'Services/Calendar/classes/class.ilCalendarEntry.php';
$entry = new ilCalendarEntry($a_entry_id);
if(time()+($deadline*60*60) > $entry->getStart()->get(IL_CAL_UNIX))
{
return true;
}
}
return false;
}

+ Here is the call graph for this function:

ilBookingEntry::isOwner (   $a_user_id = NULL)

check if current (or given) user is entry owner

Parameters
int$a_user_id
Returns
bool

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

References $ilUser, and getObjId().

{
global $ilUser;
if(!$a_user_id)
{
$a_user_id = $ilUser->getId();
}
if($this->getObjId() == $a_user_id)
{
return true;
}
return false;
}

+ Here is the call graph for this function:

ilBookingEntry::isTargetObjectVisible (   $a_ref_id)

Check if target ref id is visible.

Parameters
type$a_ref_id

Definition at line 184 of file class.ilBookingEntry.php.

References $obj_id, ilObject\_lookupObjId(), and getTargetObjIds().

{
// no course/group filter
if(!$this->getTargetObjIds())
{
return true;
}
return in_array($obj_id, $this->getTargetObjIds());
}

+ Here is the call graph for this function:

static ilBookingEntry::lookupBookableUsersForObject (   $a_obj_id,
  $a_user_ids 
)
static

Consultation hours are offered if 1) consultation hour owner is admin or tutor and no object assignment 2) object is assigned to consultation hour.

Parameters
type$a_obj_ids
type$a_user_ids
Returns
array user ids

Definition at line 419 of file class.ilBookingEntry.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and ilCalendarCategory\TYPE_CH.

Referenced by ilCalendarBlockGUI\getHTML().

{
global $ilDB;
$query = 'SELECT be.obj_id bobj FROM booking_entry be '.
'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
'JOIN cal_entries ce on be.booking_id = ce.context_id '.
'JOIN cal_cat_assignments cca on ce.cal_id = cca.cal_id '.
'JOIN cal_categories cc on cca.cat_id = cc.cat_id '.
'WHERE '.$ilDB->in('be.obj_id', (array) $a_user_ids,false,'integer'). ' '.
'AND '.$ilDB->in('bo.target_obj_id', (array) $a_obj_id,false,'integer'). ' '.
'AND cc.obj_id = be.obj_id '.
'AND cc.type = '. $ilDB->quote(ilCalendarCategory::TYPE_CH,'integer').' ';
$res = $ilDB->query($query);
$objs = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(!in_array($row->bobj,$objs))
{
$objs[] = $row->bobj;
}
}
// non filtered booking entries
$query = 'SELECT be.obj_id bobj FROM booking_entry be '.
'LEFT JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
'JOIN cal_entries ce on be.booking_id = ce.context_id '.
'JOIN cal_cat_assignments cca on ce.cal_id = cca.cal_id '.
'JOIN cal_categories cc on cca.cat_id = cc.cat_id '.
'WHERE bo.booking_id IS NULL '.
'AND '.$ilDB->in('be.obj_id', (array) $a_user_ids,false,'integer'). ' '.
'AND cc.obj_id = be.obj_id '.
'AND cc.type = '. $ilDB->quote(ilCalendarCategory::TYPE_CH,'integer').' ';
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
if(!in_array($row->bobj,$objs))
{
$objs[] = $row->bobj;
}
}
return $objs;
}

+ Here is the caller graph for this function:

static ilBookingEntry::lookupBookingMessage (   $a_entry_id,
  $a_usr_id 
)
static

Definition at line 497 of file class.ilBookingEntry.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilConsultationHourBookingTableGUI\parse().

{
global $ilDB;
$query = 'SELECT * from booking_user '.
'WHERE entry_id = '.$ilDB->quote($a_entry_id,'integer').' '.
'AND user_id = '.$ilDB->quote($a_usr_id,'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
return $row->booking_message;
}
return '';
}

+ Here is the caller graph for this function:

static ilBookingEntry::lookupBookingsForAppointment (   $a_app_id)
static

Lookup booked users for appointment type $ilDB.

Parameters
type$a_app_id
Returns
type

Definition at line 573 of file class.ilBookingEntry.php.

References $query, $res, and $row.

Referenced by ilConsultationHoursGUI\confirmDelete(), and ilConsultationHourBookingTableGUI\parse().

{
global $ilDB;
$query = 'SELECT user_id FROM booking_user '.
'WHERE entry_id = '.$ilDB->quote($a_app_id, 'integer');
$res = $ilDB->query($query);
$users = array();
while($row = $ilDB->fetchObject($res))
{
$users[] = $row->user_id;
}
return $users;
}

+ Here is the caller graph for this function:

static ilBookingEntry::lookupBookingsForObject (   $a_obj_id,
  $a_usr_id 
)
static

Lookup booking for an object and user.

Parameters
type$a_obj_id
type$a_usr_id
Returns
array

Definition at line 595 of file class.ilBookingEntry.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, IL_CAL_DATETIME, IL_CAL_UNIX, and ilTimeZone\UTC.

Referenced by lookupManagedBookingsForObject().

{
global $ilDB;
$query = 'SELECT bu.user_id, starta, enda FROM booking_user bu '.
'JOIN cal_entries ca ON entry_id = ca.cal_id '.
'JOIN booking_entry be ON context_id = booking_id '.
'JOIN booking_obj_assignment bo ON be.booking_id = bo.booking_id '.
'WHERE bo.target_obj_id = '.$ilDB->quote($a_obj_id,'integer').' '.
'AND be.obj_id = '.$ilDB->quote($a_usr_id).' '.
'ORDER BY starta';
$res = $ilDB->query($query);
$bookings = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$bookings[$row->user_id][] = array(
'dt' => $dt->get(IL_CAL_UNIX),
'dtend' => $dt_end->get(IL_CAL_UNIX),
'owner' => $a_usr_id);
}
return $bookings;
}

+ Here is the caller graph for this function:

static ilBookingEntry::lookupBookingsOfUser (   $a_app_ids,
  $a_usr_id,
ilDateTime  $start = null 
)
static

Lookup bookings if user.

Parameters
type$a_app_ids
type$a_usr_id

Definition at line 57 of file class.ilBookingEntry.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilConsultationHoursGUI\assignUsersToAppointment(), ilConsultationHoursGUI\assignUsersToGroup(), and isAppointmentBookableForUser().

{
global $ilDB;
$query = 'SELECT entry_id FROM booking_user '.
'WHERE '.$ilDB->in('entry_id',$a_app_ids,false,'integer').' '.
'AND user_id = '.$ilDB->quote($a_usr_id,'integer');
$res = $ilDB->query($query);
$booked_entries = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$booked_entries[] = $row->entry_id;
}
return $booked_entries;
}

+ Here is the caller graph for this function:

static ilBookingEntry::lookupManagedBookingsForObject (   $a_obj_id,
  $a_usr_id 
)
static

Lookup bookings for own and managed consultation hours of an object.

Parameters
type$a_obj_id
type$a_usr_id
Returns
array

Definition at line 629 of file class.ilBookingEntry.php.

References ilObjUser\_lookupFullname(), lookupBookingsForObject(), and ilConsultationHourUtils\lookupManagedUsers().

Referenced by ilGroupParticipantsTableGUI\parse(), ilCourseParticipantsTableGUI\parse(), and ilMemberExport\write().

{
$bookings = self::lookupBookingsForObject($a_obj_id, $a_usr_id);
include_once './Services/Calendar/classes/ConsultationHours/class.ilConsultationHourUtils.php';
foreach(ilConsultationHourUtils::lookupManagedUsers($a_usr_id) as $managed_user_id)
{
foreach(self::lookupBookingsForObject($a_obj_id, $managed_user_id) as $booked_user => $booking)
{
$fullname = ilObjUser::_lookupFullname($managed_user_id);
foreach($booking as $booking_entry)
{
$booking_entry['explanation'] = '('.$fullname.')';
$bookings[$booked_user][] = $booking_entry;
}
}
}
return $bookings;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBookingEntry::read ( )
protected

Read settings from db.

Returns

Definition at line 287 of file class.ilBookingEntry.php.

References $query, $res, $row, DB_FETCHMODE_ASSOC, DB_FETCHMODE_OBJECT, getId(), setBookingGroup(), setDeadlineHours(), setNumberOfBookings(), and setObjId().

Referenced by __construct().

{
global $ilDB;
if(!$this->getId())
{
return false;
}
$query = "SELECT * FROM booking_entry ".
"WHERE booking_id = ".$ilDB->quote($this->getId(),'integer');
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$this->setObjId($row['obj_id']);
$this->setDeadlineHours($row['deadline']);
$this->setNumberOfBookings($row['num_bookings']);
$this->setBookingGroup($row['booking_group']);
}
$query = 'SELECT * FROM booking_obj_assignment '.
'WHERE booking_id = '.$ilDB->quote($this->getId(),'integer');
$res = $ilDB->query($query);
$this->target_obj_ids = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->target_obj_ids[] = $row->target_obj_id;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilBookingEntry::removeObsoleteEntries ( )
static

Remove unused booking entries.

Definition at line 344 of file class.ilBookingEntry.php.

References $row, and ilCalendarCategory\TYPE_CH.

Referenced by ilConsultationHoursGUI\delete(), and ilConsultationHoursGUI\updateMulti().

{
global $ilDB;
$set = $ilDB->query('SELECT DISTINCT(context_id) FROM cal_entries e'.
' JOIN cal_cat_assignments a ON (e.cal_id = a.cal_id)'.
' JOIN cal_categories c ON (a.cat_id = c.cat_id) WHERE c.type = '.$ilDB->quote(ilCalendarCategory::TYPE_CH, 'integer'));
$used = array();
while($row = $ilDB->fetchAssoc($set))
{
$used[] = $row['context_id'];
}
$ilDB->query($q = 'DELETE FROM booking_entry WHERE '.$ilDB->in('booking_id', $used, true, 'integer'));
$ilDB->query($q = 'DELETE FROM booking_obj_assignment WHERE '.$ilDB->in('booking_id',$used,true,'integer'));
}

+ Here is the caller graph for this function:

static ilBookingEntry::resetGroup (   $a_group_id)
static

Reset booking group (in case of deletion) type $ilDB.

Parameters
type$a_group_id
Returns
boolean

Definition at line 42 of file class.ilBookingEntry.php.

References $query.

Referenced by ilConsultationHourGroup\delete().

{
global $ilDB;
$query = 'UPDATE booking_entry SET booking_group = '.$ilDB->quote(0,'integer').' '.
'WHERE booking_group = '.$ilDB->quote($a_group_id,'integer');
$ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

ilBookingEntry::save ( )

Save a new booking entry.

Returns

Definition at line 200 of file class.ilBookingEntry.php.

References $obj_id, $query, getBookingGroup(), getDeadlineHours(), getId(), getNumberOfBookings(), getObjId(), and setId().

{
global $ilDB;
$this->setId($ilDB->nextId('booking_entry'));
$query = 'INSERT INTO booking_entry (booking_id,obj_id,deadline,num_bookings,booking_group) '.
"VALUES ( ".
$ilDB->quote($this->getId(),'integer').', '.
$ilDB->quote($this->getObjId(),'integer').', '.
$ilDB->quote($this->getDeadlineHours(),'integer').', '.
$ilDB->quote($this->getNumberOfBookings(),'integer').','.
$ilDB->quote($this->getBookingGroup(),'integer').' '.
") ";
$ilDB->manipulate($query);
foreach((array) $this->target_obj_ids as $obj_id)
{
$query = 'INSERT INTO booking_obj_assignment (booking_id, target_obj_id) '.
'VALUES( '.
$ilDB->quote($this->getId(),'integer').', '.
$ilDB->quote($obj_id,'integer').' '.
')';
$ilDB->manipulate($query);
}
return true;
}

+ Here is the call graph for this function:

ilBookingEntry::setBookingGroup (   $a_id)

Definition at line 94 of file class.ilBookingEntry.php.

Referenced by read().

{
$this->booking_group = $a_id;
}

+ Here is the caller graph for this function:

ilBookingEntry::setDeadlineHours (   $a_hours)

set deadline hours

Parameters
int$a_hours
Returns

Definition at line 128 of file class.ilBookingEntry.php.

Referenced by read().

{
$this->deadline = (int)$a_hours;
}

+ Here is the caller graph for this function:

ilBookingEntry::setId (   $a_id)
protected

Set id.

Parameters
int$a_id
Returns

Definition at line 80 of file class.ilBookingEntry.php.

Referenced by __construct(), and save().

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

+ Here is the caller graph for this function:

ilBookingEntry::setNumberOfBookings (   $a_num)

set number of bookings

Parameters
int$a_num
Returns

Definition at line 147 of file class.ilBookingEntry.php.

Referenced by read().

{
$this->num_bookings = (int)$a_num;
}

+ Here is the caller graph for this function:

ilBookingEntry::setObjId (   $a_id)

Set obj id.

Parameters
int$a_id
Returns

Definition at line 109 of file class.ilBookingEntry.php.

Referenced by read().

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

+ Here is the caller graph for this function:

ilBookingEntry::setTargetObjIds (   $a_obj_id)

set target object id

Parameters
int$a_obj_id
Returns

Definition at line 166 of file class.ilBookingEntry.php.

Referenced by ilCalendarScheduleFilterBookings\isValidEvent().

{
$this->target_obj_ids = $a_obj_id;
}

+ Here is the caller graph for this function:

ilBookingEntry::update ( )

Update an existing booking entry.

Returns

Definition at line 231 of file class.ilBookingEntry.php.

References $obj_id, $query, getBookingGroup(), getDeadlineHours(), getId(), getNumberOfBookings(), and getObjId().

{
global $ilDB;
if(!$this->getId())
{
return false;
}
$query = "UPDATE booking_entry SET ".
"SET obj_id = ".$ilDB->quote($this->getObjId(),'integer').", ".
" deadline = ".$ilDB->quote($this->getDeadlineHours(),'integer').", ".
" num_bookings = ".$ilDB->quote($this->getNumberOfBookings(),'integer').', '.
'booking_group = '.$ilDB->quote($this->getBookingGroup(),'integer');
$ilDB->manipulate($query);
// obj assignments
$query = 'DELETE FROM booking_obj_assignment '.
'WHERE booking_id = '.$ilDB->quote($this->getId(),'integer');
$ilDB->manipulate($query);
foreach((array) $this->target_obj_ids as $obj_id)
{
$query = 'INSERT INTO booking_obj_assignment (booking_id, target_obj_id) '.
'VALUES( '.
$ilDB->quote($this->getId(),'integer').', '.
$ilDB->quote($obj_id,'integer').' '.
')';
$ilDB->manipulate($query);
}
return true;
}

+ Here is the call graph for this function:

static ilBookingEntry::writeBookingMessage (   $a_entry_id,
  $a_usr_id,
  $a_message 
)
static

Write booking message.

Parameters
type$a_entry_id
type$a_usr_id
type$a_message

Definition at line 518 of file class.ilBookingEntry.php.

References $GLOBALS, and $query.

Referenced by ilCalendarAppointmentGUI\bookconfirmed().

{
global $ilDB;
$query = 'UPDATE booking_user SET '.
'booking_message = '.$ilDB->quote($a_message,'text').' '.
'WHERE entry_id = '.$ilDB->quote($a_entry_id,'integer').' '.
'AND user_id = '.$ilDB->quote($a_usr_id,'integer');
$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
$ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

Field Documentation

ilBookingEntry::$booking_group = 0
private

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

Referenced by getBookingGroup().

ilBookingEntry::$deadline = 0
private

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

Referenced by getDeadlineHours(), and isBookedOut().

ilBookingEntry::$id = 0
private

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

Referenced by getId().

ilBookingEntry::$num_bookings = 1
private

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

Referenced by getNumberOfBookings().

ilBookingEntry::$obj_id = 0
private

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

Referenced by getObjId(), isTargetObjectVisible(), save(), and update().

ilBookingEntry::$target_obj_ids = array()
private

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

Referenced by getTargetObjIds().


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