ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 (\ilDateTime $start, \ilDateTime $end)
 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.

References read().

24  {
25  $this->appointment_id = $a_appointment_id;
26 
27  $this->read();
28  }
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteByAppointment()

static ilCalendarRegistration::deleteByAppointment (   $a_cal_id)
static

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

References $DIC, $ilDB, and $query.

47  {
48  global $DIC;
49 
50  $ilDB = $DIC['ilDB'];
51 
52  $query = "DELETE FROM cal_registrations " .
53  "WHERE cal_id = " . $ilDB->quote($a_cal_id, 'integer');
54  $ilDB->manipulate($query);
55  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ 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.

References $DIC, $ilDB, and $query.

36  {
37  global $DIC;
38 
39  $ilDB = $DIC['ilDB'];
40 
41  $query = "DELETE FROM cal_registrations " .
42  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer');
43  $ilDB->manipulate($query);
44  }
global $DIC
Definition: saml.php:7
$query
global $ilDB

◆ getAppointmentId()

ilCalendarRegistration::getAppointmentId ( )

Get appoinmtent id.

Returns
int app_id

Definition at line 61 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 ( \ilDateTime  $start,
\ilDateTime  $end 
)

Get all registered users.

Returns

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

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

71  {
72  $users = [];
73  foreach ($this->registered as $reg_data) {
74  if (
75  $reg_data['dstart'] == $start->get(IL_CAL_UNIX) &&
76  $reg_data['dend'] == $end->get(IL_CAL_UNIX)
77  ) {
78  $users[] = $reg_data['usr_id'];
79  }
80  }
81  return $users;
82  }
const IL_CAL_UNIX
$start
Definition: bench.php:8
$users
Definition: authpage.php:44
+ Here is the call graph for this function:

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

References ilDateTime\get(), and IL_CAL_UNIX.

90  {
91  foreach ($this->registered as $reg_data) {
92  if ($reg_data['usr_id'] == $a_usr_id) {
93  if ($reg_data['dstart'] == $start->get(IL_CAL_UNIX) and $reg_data['dend'] == $end->get(IL_CAL_UNIX)) {
94  return true;
95  }
96  }
97  }
98  }
const IL_CAL_UNIX
get($a_format, $a_format_str='', $a_tz='')
get formatted date
+ Here is the call graph for this function:

◆ read()

ilCalendarRegistration::read ( )
protected

Read registration.

Returns

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

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

Referenced by __construct().

151  {
152  global $DIC;
153 
154  $ilDB = $DIC['ilDB'];
155 
156  if (!$this->getAppointmentId()) {
157  return false;
158  }
159 
160  $query = "SELECT * FROM cal_registrations WHERE cal_id = " . $ilDB->quote($this->getAppointmentId(), 'integer');
161  $res = $ilDB->query($query);
162  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
163  $this->registered[] = array(
164  'usr_id' => $row->usr_id,
165  'dstart' => $row->dstart,
166  'dend' => $row->dend
167  );
168  }
169  }
global $DIC
Definition: saml.php:7
getAppointmentId()
Get appoinmtent id.
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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.

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

106  {
107  global $DIC;
108 
109  $ilDB = $DIC['ilDB'];
110 
111  $this->unregister($a_usr_id, $start, $end);
112 
113  $query = "INSERT INTO cal_registrations (cal_id,usr_id,dstart,dend) " .
114  "VALUES ( " .
115  $ilDB->quote($this->getAppointmentId(), 'integer') . ", " .
116  $ilDB->quote($a_usr_id, 'integer') . ", " .
117  $ilDB->quote($start->get(IL_CAL_UNIX), 'integer') . ", " .
118  $ilDB->quote($end->get(IL_CAL_UNIX), 'integer') .
119  ")";
120  $ilDB->manipulate($query);
121 
122  $this->registered[] = $a_usr_id;
123  return true;
124  }
global $DIC
Definition: saml.php:7
const IL_CAL_UNIX
getAppointmentId()
Get appoinmtent id.
$query
get($a_format, $a_format_str='', $a_tz='')
get formatted date
unregister($a_usr_id, ilDateTime $start, ilDateTime $end)
unregister one user
global $ilDB
+ 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 131 of file class.ilCalendarRegistration.php.

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

Referenced by register().

132  {
133  global $DIC;
134 
135  $ilDB = $DIC['ilDB'];
136 
137  $query = "DELETE FROM cal_registrations " .
138  "WHERE cal_id = " . $ilDB->quote($this->getAppointmentId(), 'integer') . ' ' .
139  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . ' ' .
140  "AND dstart = " . $ilDB->quote($start->get(IL_CAL_UNIX), 'integer') . ' ' .
141  "AND dend = " . $ilDB->quote($end->get(IL_CAL_UNIX), 'integer');
142  $res = $ilDB->manipulate($query);
143  }
global $DIC
Definition: saml.php:7
const IL_CAL_UNIX
getAppointmentId()
Get appoinmtent id.
foreach($_POST as $key=> $value) $res
$query
get($a_format, $a_format_str='', $a_tz='')
get formatted date
global $ilDB
+ 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.


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