ILIAS  release_8 Revision v8.24
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 11 of file class.ilCalendarRegistration.php.

Constructor & Destructor Documentation

◆ __construct()

ilCalendarRegistration::__construct ( int  $a_appointment_id)

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

19 {
20 global $DIC;
21
22 $this->appointment_id = $a_appointment_id;
23
24 $this->db = $DIC->database();
25 $this->read();
26 }
global $DIC
Definition: feed.php:28

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 38 of file class.ilCalendarRegistration.php.

38 : void
39 {
40 global $DIC;
41
42 $ilDB = $DIC['ilDB'];
43 $query = "DELETE FROM cal_registrations " .
44 "WHERE cal_id = " . $ilDB->quote($a_cal_id, 'integer');
45 $ilDB->manipulate($query);
46 }
$query

References $DIC, $ilDB, and $query.

◆ deleteByUser()

static ilCalendarRegistration::deleteByUser ( int  $a_usr_id)
static

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

28 : void
29 {
30 global $DIC;
31
32 $ilDB = $DIC['ilDB'];
33 $query = "DELETE FROM cal_registrations " .
34 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
35 $ilDB->manipulate($query);
36 }

References $DIC, $ilDB, and $query.

◆ getAppointmentId()

ilCalendarRegistration::getAppointmentId ( )

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

48 : int
49 {
51 }

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 53 of file class.ilCalendarRegistration.php.

53 : array
54 {
55 $users = [];
56 foreach ($this->registered as $reg_data) {
57 if (
58 $reg_data['dstart'] == $start->get(IL_CAL_UNIX) &&
59 $reg_data['dend'] == $end->get(IL_CAL_UNIX)
60 ) {
61 $users[] = (int) $reg_data['usr_id'];
62 }
63 }
64 return $users;
65 }
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 67 of file class.ilCalendarRegistration.php.

67 : bool
68 {
69 foreach ($this->registered as $reg_data) {
70 if ($reg_data['usr_id'] == $a_usr_id) {
71 if ($reg_data['dstart'] == $start->get(IL_CAL_UNIX) and $reg_data['dend'] == $end->get(IL_CAL_UNIX)) {
72 return true;
73 }
74 }
75 }
76 return false;
77 }
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 114 of file class.ilCalendarRegistration.php.

114 : void
115 {
116 if (!$this->getAppointmentId()) {
117 return;
118 }
119
120 $query = "SELECT * FROM cal_registrations WHERE cal_id = " . $this->db->quote(
121 $this->getAppointmentId(),
122 'integer'
123 );
124 $res = $this->db->query($query);
125 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
126 $this->registered[] = array(
127 'usr_id' => (int) $row->usr_id,
128 'dstart' => (int) $row->dstart,
129 'dend' => (int) $row->dend
130 );
131 }
132 }
$res
Definition: ltiservices.php:69

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

79 : void
80 {
81 $this->unregister($a_usr_id, $start, $end);
82
83 $query = "INSERT INTO cal_registrations (cal_id,usr_id,dstart,dend) " .
84 "VALUES ( " .
85 $this->db->quote($this->getAppointmentId(), 'integer') . ", " .
86 $this->db->quote($a_usr_id, 'integer') . ", " .
87 $this->db->quote($start->get(IL_CAL_UNIX), 'integer') . ", " .
88 $this->db->quote($end->get(IL_CAL_UNIX), 'integer') .
89 ")";
90 $this->db->manipulate($query);
91 $this->registered[] = [
92 'usr_id' => $a_usr_id,
93 'dstart' => $start->get(IL_CAL_UNIX),
94 'dend' => $end->get(IL_CAL_UNIX)
95 ];
96 }
unregister(int $a_usr_id, ilDateTime $start, ilDateTime $end)
unregister one user

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

101 : void
102 {
103 $query = "DELETE FROM cal_registrations " .
104 "WHERE cal_id = " . $this->db->quote($this->getAppointmentId(), 'integer') . ' ' .
105 "AND usr_id = " . $this->db->quote($a_usr_id, 'integer') . ' ' .
106 "AND dstart = " . $this->db->quote($start->get(IL_CAL_UNIX), 'integer') . ' ' .
107 "AND dend = " . $this->db->quote($end->get(IL_CAL_UNIX), 'integer');
108 $res = $this->db->manipulate($query);
109 }

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

int ilCalendarRegistration::$appointment_id = 0
private

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

Referenced by getAppointmentId().

◆ $db

ilDBInterface ilCalendarRegistration::$db
protected

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

◆ $registered

array ilCalendarRegistration::$registered = array()
private

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


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