ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCalendarRegistration Class Reference

registration for calendar appointments More...

+ Collaboration diagram for ilCalendarRegistration:

Public Member Functions

 __construct (int $a_appointment_id)
 
 getAppointmentId ()
 
 getRegisteredUsers (\ilDateTime $start, \ilDateTime $end)
 
 isRegistered ($a_usr_id, ilDateTime $start, ilDateTime $end)
 
 register (int $a_usr_id, ilDateTime $start, ilDateTime $end)
 
 unregister (int $a_usr_id, ilDateTime $start, ilDateTime $end)
 unregister one user More...
 

Static Public Member Functions

static deleteByUser (int $a_usr_id)
 
static deleteByAppointment (int $a_cal_id)
 

Protected Member Functions

 read ()
 Read registration. More...
 

Protected Attributes

ilDBInterface $db
 

Private Attributes

int $appointment_id = 0
 
array $registered = array()
 

Detailed Description

registration for calendar appointments

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

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

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRegistration::__construct ( int  $a_appointment_id)

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

33 {
34 global $DIC;
35
36 $this->appointment_id = $a_appointment_id;
37
38 $this->db = $DIC->database();
39 $this->read();
40 }
global $DIC
Definition: shib_login.php:26

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ deleteByAppointment()

static ilCalendarRegistration::deleteByAppointment ( int  $a_cal_id)
static

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

52 : void
53 {
54 global $DIC;
55
56 $ilDB = $DIC['ilDB'];
57 $query = "DELETE FROM cal_registrations " .
58 "WHERE cal_id = " . $ilDB->quote($a_cal_id, 'integer');
59 $ilDB->manipulate($query);
60 }

References $DIC, and $ilDB.

◆ deleteByUser()

static ilCalendarRegistration::deleteByUser ( int  $a_usr_id)
static

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

42 : void
43 {
44 global $DIC;
45
46 $ilDB = $DIC['ilDB'];
47 $query = "DELETE FROM cal_registrations " .
48 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
49 $ilDB->manipulate($query);
50 }

References $DIC, and $ilDB.

◆ getAppointmentId()

ilCalendarRegistration::getAppointmentId ( )

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

62 : int
63 {
65 }

References $appointment_id.

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

+ Here is the caller graph for this function:

◆ getRegisteredUsers()

ilCalendarRegistration::getRegisteredUsers ( \ilDateTime  $start,
\ilDateTime  $end 
)

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

67 : array
68 {
69 $users = [];
70 foreach ($this->registered as $reg_data) {
71 if (
72 $reg_data['dstart'] == $start->get(IL_CAL_UNIX) &&
73 $reg_data['dend'] == $end->get(IL_CAL_UNIX)
74 ) {
75 $users[] = (int) $reg_data['usr_id'];
76 }
77 }
78 return $users;
79 }
const IL_CAL_UNIX

References ilDateTime\get(), IL_CAL_UNIX, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ isRegistered()

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

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

81 : bool
82 {
83 foreach ($this->registered as $reg_data) {
84 if ($reg_data['usr_id'] == $a_usr_id) {
85 if ($reg_data['dstart'] == $start->get(IL_CAL_UNIX) and $reg_data['dend'] == $end->get(IL_CAL_UNIX)) {
86 return true;
87 }
88 }
89 }
90 return false;
91 }
get(int $a_format, string $a_format_str='', string $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.

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

128 : void
129 {
130 if (!$this->getAppointmentId()) {
131 return;
132 }
133
134 $query = "SELECT * FROM cal_registrations WHERE cal_id = " . $this->db->quote(
135 $this->getAppointmentId(),
136 'integer'
137 );
138 $res = $this->db->query($query);
139 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
140 $this->registered[] = array(
141 'usr_id' => (int) $row->usr_id,
142 'dstart' => (int) $row->dstart,
143 'dend' => (int) $row->dend
144 );
145 }
146 }
$res
Definition: ltiservices.php:69

References $res, 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 ( int  $a_usr_id,
ilDateTime  $start,
ilDateTime  $end 
)

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

93 : void
94 {
95 $this->unregister($a_usr_id, $start, $end);
96
97 $query = "INSERT INTO cal_registrations (cal_id,usr_id,dstart,dend) " .
98 "VALUES ( " .
99 $this->db->quote($this->getAppointmentId(), 'integer') . ", " .
100 $this->db->quote($a_usr_id, 'integer') . ", " .
101 $this->db->quote($start->get(IL_CAL_UNIX), 'integer') . ", " .
102 $this->db->quote($end->get(IL_CAL_UNIX), 'integer') .
103 ")";
104 $this->db->manipulate($query);
105 $this->registered[] = [
106 'usr_id' => $a_usr_id,
107 'dstart' => $start->get(IL_CAL_UNIX),
108 'dend' => $end->get(IL_CAL_UNIX)
109 ];
110 }
unregister(int $a_usr_id, ilDateTime $start, ilDateTime $end)
unregister one user

References getAppointmentId(), IL_CAL_UNIX, and unregister().

+ Here is the call graph for this function:

◆ unregister()

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

unregister one user

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

115 : void
116 {
117 $query = "DELETE FROM cal_registrations " .
118 "WHERE cal_id = " . $this->db->quote($this->getAppointmentId(), 'integer') . ' ' .
119 "AND usr_id = " . $this->db->quote($a_usr_id, 'integer') . ' ' .
120 "AND dstart = " . $this->db->quote($start->get(IL_CAL_UNIX), 'integer') . ' ' .
121 "AND dend = " . $this->db->quote($end->get(IL_CAL_UNIX), 'integer');
122 $res = $this->db->manipulate($query);
123 }

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

int ilCalendarRegistration::$appointment_id = 0
private

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

Referenced by getAppointmentId().

◆ $db

ilDBInterface ilCalendarRegistration::$db
protected

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

◆ $registered

array ilCalendarRegistration::$registered = array()
private

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


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