ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCalendarRegistration Class Reference

registration for calendar appointments More...

+ Collaboration diagram for ilCalendarRegistration:

Public Member Functions

 __construct ($a_appointment_id)
 Constructor. More...
 
 getAppointmentId ()
 Get appoinmtent id. More...
 
 getRegisteredUsers ()
 Get all registered users. More...
 
 isRegistered ($a_usr_id, ilDateTime $start, ilDateTime $end)
 Check if one user is registered. More...
 
 register ($a_usr_id, ilDateTime $start, ilDateTime $end)
 Register one user. More...
 
 unregister ($a_usr_id, ilDateTime $start, ilDateTime $end)
 unregister one user More...
 

Static Public Member Functions

static deleteByUser ($a_usr_id)
 Delete all user registrations. More...
 
static deleteByAppointment ($a_cal_id)
 

Protected Member Functions

 read ()
 Read registration. More...
 

Private Attributes

 $appointment_id = 0
 
 $registered = array()
 

Detailed Description

registration for calendar appointments

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

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRegistration::__construct (   $a_appointment_id)

Constructor.

Returns

Definition at line 23 of file class.ilCalendarRegistration.php.

24 {
25 $this->appointment_id = $a_appointment_id;
26
27 $this->read();
28 }

References read().

+ Here is the call graph for this function:

Member Function Documentation

◆ deleteByAppointment()

static ilCalendarRegistration::deleteByAppointment (   $a_cal_id)
static

Definition at line 44 of file class.ilCalendarRegistration.php.

45 {
46 global $ilDB;
47
48 $query = "DELETE FROM cal_registrations " .
49 "WHERE cal_id = " . $ilDB->quote($a_cal_id, 'integer');
50 $ilDB->manipulate($query);
51 }
$query
global $ilDB

References $ilDB, and $query.

◆ deleteByUser()

static ilCalendarRegistration::deleteByUser (   $a_usr_id)
static

Delete all user registrations.

Parameters
object$a_usr_id
Returns

Definition at line 35 of file class.ilCalendarRegistration.php.

36 {
37 global $ilDB;
38
39 $query = "DELETE FROM cal_registrations " .
40 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
41 $ilDB->manipulate($query);
42 }

References $ilDB, and $query.

◆ getAppointmentId()

ilCalendarRegistration::getAppointmentId ( )

Get appoinmtent id.

Returns
int app_id

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

References $appointment_id.

Referenced by read(), register(), and unregister().

+ Here is the caller graph for this function:

◆ getRegisteredUsers()

ilCalendarRegistration::getRegisteredUsers ( )

Get all registered users.

Returns

Definition at line 66 of file class.ilCalendarRegistration.php.

67 {
68 foreach ($this->registered as $reg_data) {
69 if ($reg_data['usr_id'] == $a_usr_id) {
70 if ($reg_data['dstart'] == $start->get(IL_CAL_UNIX) and $reg_data['dend'] == $end->get(IL_CAL_UNIX)) {
71 return true;
72 }
73 }
74 }
75 return (array) $this->registered;
76 }
const IL_CAL_UNIX
$end
Definition: saml1-acs.php:18

References $end, $registered, and IL_CAL_UNIX.

◆ isRegistered()

ilCalendarRegistration::isRegistered (   $a_usr_id,
ilDateTime  $start,
ilDateTime  $end 
)

Check if one user is registered.

Parameters
object$a_usr_id
Returns
bool

Definition at line 83 of file class.ilCalendarRegistration.php.

84 {
85 foreach ($this->registered as $reg_data) {
86 if ($reg_data['usr_id'] == $a_usr_id) {
87 if ($reg_data['dstart'] == $start->get(IL_CAL_UNIX) and $reg_data['dend'] == $end->get(IL_CAL_UNIX)) {
88 return true;
89 }
90 }
91 }
92 }
get($a_format, $a_format_str='', $a_tz='')
get formatted date

References $end, ilDateTime\get(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ read()

ilCalendarRegistration::read ( )
protected

Read registration.

Returns

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

141 {
142 global $ilDB;
143
144 if (!$this->getAppointmentId()) {
145 return false;
146 }
147
148 $query = "SELECT * FROM cal_registrations WHERE cal_id = " . $ilDB->quote($this->getAppointmentId(), 'integer');
149 $res = $ilDB->query($query);
150 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
151 $this->registered[] = array(
152 'usr_id'=> $row->usr_id,
153 'dstart' =>$row->dstart,
154 'dend' => $row->dend
155 );
156 }
157 }
foreach($_POST as $key=> $value) $res

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and getAppointmentId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ register()

ilCalendarRegistration::register (   $a_usr_id,
ilDateTime  $start,
ilDateTime  $end 
)

Register one user.

Parameters
int$a_usr_id
Returns

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

100 {
101 global $ilDB;
102
103 $this->unregister($a_usr_id, $start, $end);
104
105 $query = "INSERT INTO cal_registrations (cal_id,usr_id,dstart,dend) " .
106 "VALUES ( " .
107 $ilDB->quote($this->getAppointmentId(), 'integer') . ", " .
108 $ilDB->quote($a_usr_id, 'integer') . ", " .
109 $ilDB->quote($start->get(IL_CAL_UNIX), 'integer') . ", " .
110 $ilDB->quote($end->get(IL_CAL_UNIX), 'integer') .
111 ")";
112 $ilDB->manipulate($query);
113
114 $this->registered[] = $a_usr_id;
115 return true;
116 }
unregister($a_usr_id, ilDateTime $start, ilDateTime $end)
unregister one user

References $end, $ilDB, $query, getAppointmentId(), IL_CAL_UNIX, and unregister().

+ Here is the call graph for this function:

◆ unregister()

ilCalendarRegistration::unregister (   $a_usr_id,
ilDateTime  $start,
ilDateTime  $end 
)

unregister one user

Parameters
int$a_usr_id
Returns

Definition at line 123 of file class.ilCalendarRegistration.php.

124 {
125 global $ilDB;
126
127 $query = "DELETE FROM cal_registrations " .
128 "WHERE cal_id = " . $ilDB->quote($this->getAppointmentId(), 'integer') . ' ' .
129 "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . ' ' .
130 "AND dstart = " . $ilDB->quote($start->get(IL_CAL_UNIX), 'integer') . ' ' .
131 "AND dend = " . $ilDB->quote($end->get(IL_CAL_UNIX), 'integer');
132 $res = $ilDB->manipulate($query);
133 }

References $end, $ilDB, $query, $res, ilDateTime\get(), getAppointmentId(), and IL_CAL_UNIX.

Referenced by register().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $appointment_id

ilCalendarRegistration::$appointment_id = 0
private

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

Referenced by getAppointmentId().

◆ $registered

ilCalendarRegistration::$registered = array()
private

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

Referenced by getRegisteredUsers().


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