ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 }
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 {
70 if($reg_data['usr_id'] == $a_usr_id)
71 {
72 if($reg_data['dstart'] == $start->get(IL_CAL_UNIX) and $reg_data['dend'] == $end->get(IL_CAL_UNIX))
73 {
74 return true;
75 }
76 }
77 }
78 return (array) $this->registered;
79 }
const IL_CAL_UNIX

References $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 86 of file class.ilCalendarRegistration.php.

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

References ilDateTime\get(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ read()

ilCalendarRegistration::read ( )
protected

Read registration.

Returns

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

147 {
148 global $ilDB;
149
150 if(!$this->getAppointmentId())
151 {
152 return false;
153 }
154
155 $query = "SELECT * FROM cal_registrations WHERE cal_id = ".$ilDB->quote($this->getAppointmentId(),'integer');
156 $res = $ilDB->query($query);
157 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
158 {
159 $this->registered[] = array(
160 'usr_id'=> $row->usr_id,
161 'dstart' =>$row->dstart,
162 'dend' => $row->dend
163 );
164 }
165 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $query, $res, $row, DB_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 105 of file class.ilCalendarRegistration.php.

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

References $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 129 of file class.ilCalendarRegistration.php.

130 {
131 global $ilDB;
132
133 $query = "DELETE FROM cal_registrations ".
134 "WHERE cal_id = ".$ilDB->quote($this->getAppointmentId(),'integer').' '.
135 "AND usr_id = ".$ilDB->quote($a_usr_id,'integer').' '.
136 "AND dstart = ".$ilDB->quote($start->get(IL_CAL_UNIX),'integer').' '.
137 "AND dend = ".$ilDB->quote($end->get(IL_CAL_UNIX),'integer');
138 $res = $ilDB->manipulate($query);
139 }

References $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: