ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilCalendarUserNotification Class Reference
+ Collaboration diagram for ilCalendarUserNotification:

Public Member Functions

 __construct ($a_cal_id=0)
 Init with calendar entry id. More...
 
 setEntryId ($a_id)
 Set calendar entry id. More...
 
 getEntryId ()
 Get calendar entry id. More...
 
 getRecipients ()
 
 validate ()
 
 save ()
 Save recipients to db. More...
 
 addRecipient ($a_type, $a_usr_id=0, $a_email='')
 Add recipient. More...
 
 setRecipients ($a_rcps)
 Set recipients. More...
 
 deleteRecipients ()
 Delete all recipients @global ilDB $ilDB. More...
 

Static Public Member Functions

static deleteUser ($a_usr_id)
 Delete a singel user @global ilDB $ilDB. More...
 
static deleteCalendarEntry ($a_cal_id)
 Delete notification for a calendar entry @global ilDB $ilDB. More...
 
static createTable ()
 

Data Fields

const TYPE_USER = 1
 
const TYPE_EMAIL = 2
 

Protected Member Functions

 read ()
 Read recipients @global ilDB $ilDB. More...
 

Private Attributes

 $cal_id = 0
 
 $rcps = array()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCalendarUserNotification::__construct (   $a_cal_id = 0)

Init with calendar entry id.

Definition at line 22 of file class.ilCalendarUserNotification.php.

23 {
24 $this->cal_id = $a_cal_id;
25 $this->read();
26 }
read()
Read recipients @global ilDB $ilDB.

References read().

+ Here is the call graph for this function:

Member Function Documentation

◆ addRecipient()

ilCalendarUserNotification::addRecipient (   $a_type,
  $a_usr_id = 0,
  $a_email = '' 
)

Add recipient.

Parameters
int$a_type
int$a_usr_id
string$a_email

Definition at line 141 of file class.ilCalendarUserNotification.php.

142 {
143 $this->rcps[] = array(
144 'type' => $a_type,
145 'usr_id' => $a_usr_id,
146 'email' => $a_email
147 );
148 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by read().

+ Here is the caller graph for this function:

◆ createTable()

static ilCalendarUserNotification::createTable ( )
static

Definition at line 207 of file class.ilCalendarUserNotification.php.

208 {
209 global $DIC;
210
211 $ilDB = $DIC['ilDB'];
212
213 if ($ilDB->tableExists('cal_notification')) {
214 return true;
215 }
216
217 // Create notification table
218 $ilDB->createTable(
219 'cal_notification',
220 array(
221 'notification_id' => array('type' => 'integer','length' => 4,'notnull' => true),
222 'cal_id' => array('type' => 'integer','length' => 4, 'notnull' => true, 'default' => 0),
223 'user_type' => array('type' => 'integer','length' => 1, 'notnull' => true, 'default' => 0),
224 'user_id' => array('type' => 'integer','length' => 4, 'notnull' => true, 'default' => 0),
225 'email' => array('type' => 'text','length' => 64, 'notnull' => false)
226 )
227 );
228 $ilDB->addPrimaryKey(
229 'cal_notification',
230 array(
231 'notification_id'
232 )
233 );
234 $ilDB->createSequence('cal_notification');
235 $ilDB->addIndex('cal_notification', array('cal_id'), 'i1');
236 }
global $ilDB
$DIC
Definition: xapitoken.php:46

References $DIC, and $ilDB.

◆ deleteCalendarEntry()

static ilCalendarUserNotification::deleteCalendarEntry (   $a_cal_id)
static

Delete notification for a calendar entry @global ilDB $ilDB.

Parameters
int$a_cal_id
Returns
bool

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

53 {
54 global $DIC;
55
56 $ilDB = $DIC['ilDB'];
57
58 $query = 'DELETE FROM cal_notification ' .
59 'WHERE cal_id = ' . $ilDB->quote($a_cal_id, 'integer');
60 $res = $ilDB->manipulate($query);
61 return true;
62 }
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, and $res.

Referenced by ilCalendarAppointmentGUI\delete().

+ Here is the caller graph for this function:

◆ deleteRecipients()

ilCalendarUserNotification::deleteRecipients ( )

Delete all recipients @global ilDB $ilDB.

Returns
bool

Definition at line 164 of file class.ilCalendarUserNotification.php.

165 {
166 global $DIC;
167
168 $ilDB = $DIC['ilDB'];
169
170 $query = 'DELETE FROM cal_notification ' .
171 'WHERE cal_id = ' . $ilDB->quote($this->getEntryId(), 'integer');
172 $res = $ilDB->manipulate($query);
173 return true;
174 }

References $DIC, $ilDB, $query, $res, and getEntryId().

Referenced by save().

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

◆ deleteUser()

static ilCalendarUserNotification::deleteUser (   $a_usr_id)
static

Delete a singel user @global ilDB $ilDB.

Parameters
int$a_usr_id
Returns
bool

Definition at line 34 of file class.ilCalendarUserNotification.php.

35 {
36 global $DIC;
37
38 $ilDB = $DIC['ilDB'];
39
40 $query = 'DELETE FROM cal_notification ' .
41 'WHERE user_id = ' . $ilDB->quote($a_usr_id, 'integer');
42 $res = $ilDB->manipulate($query);
43 return true;
44 }

References $DIC, $ilDB, $query, and $res.

◆ getEntryId()

ilCalendarUserNotification::getEntryId ( )

Get calendar entry id.

Definition at line 76 of file class.ilCalendarUserNotification.php.

References $cal_id.

Referenced by deleteRecipients(), read(), and save().

+ Here is the caller graph for this function:

◆ getRecipients()

ilCalendarUserNotification::getRecipients ( )

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

References $rcps.

Referenced by save(), and validate().

+ Here is the caller graph for this function:

◆ read()

ilCalendarUserNotification::read ( )
protected

Read recipients @global ilDB $ilDB.

Definition at line 182 of file class.ilCalendarUserNotification.php.

183 {
184 global $DIC;
185
186 $ilDB = $DIC['ilDB'];
187
188 if (!$this->getEntryId()) {
189 return true;
190 }
191
192 $query = 'SELECT * FROM cal_notification ' .
193 'WHERE cal_id = ' . $ilDB->quote($this->getEntryId(), 'integer');
194 $res = $ilDB->query($query);
195
196 $this->rcps = array();
197 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
198 $this->addRecipient(
199 $row->user_type,
200 $row->user_id,
201 $row->email
202 );
203 }
204 }
addRecipient($a_type, $a_usr_id=0, $a_email='')
Add recipient.

References $DIC, $ilDB, $query, $res, addRecipient(), ilDBConstants\FETCHMODE_OBJECT, and getEntryId().

Referenced by __construct().

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

◆ save()

ilCalendarUserNotification::save ( )

Save recipients to db.

Definition at line 112 of file class.ilCalendarUserNotification.php.

113 {
114 global $DIC;
115
116 $ilDB = $DIC['ilDB'];
117
118 $this->deleteRecipients();
119
120 foreach ($this->getRecipients() as $rcp) {
121 $query = 'INSERT INTO cal_notification ' .
122 '(notification_id,cal_id, user_type, user_id, email) ' .
123 'VALUES ( ' .
124 $ilDB->quote($ilDB->nextId('cal_notification'), 'integer') . ', ' .
125 $ilDB->quote((int) $this->getEntryId(), 'integer') . ', ' .
126 $ilDB->quote((int) $rcp['type'], 'integer') . ', ' .
127 $ilDB->quote((int) $rcp['usr_id'], 'integer') . ', ' .
128 $ilDB->quote($rcp['email'], 'text') .
129 ')';
130 $ilDB->manipulate($query);
131 }
132 return true;
133 }
deleteRecipients()
Delete all recipients @global ilDB $ilDB.

References $DIC, $ilDB, $query, deleteRecipients(), getEntryId(), and getRecipients().

+ Here is the call graph for this function:

◆ setEntryId()

ilCalendarUserNotification::setEntryId (   $a_id)

Set calendar entry id.

Parameters
int$a_id

Definition at line 68 of file class.ilCalendarUserNotification.php.

69 {
70 $this->cal_id = $a_id;
71 }

◆ setRecipients()

ilCalendarUserNotification::setRecipients (   $a_rcps)

Set recipients.

Parameters
array$a_rcps

Definition at line 154 of file class.ilCalendarUserNotification.php.

155 {
156 $this->rcps = array();
157 }

◆ validate()

ilCalendarUserNotification::validate ( )

Definition at line 86 of file class.ilCalendarUserNotification.php.

87 {
88 global $DIC;
89
90 $ilErr = $DIC['ilErr'];
91 $lng = $DIC['lng'];
92
93 if (!count($this->getRecipients())) {
94 return true;
95 }
96 foreach ((array) $this->getRecipients() as $rcp_data) {
97 if ($rcp_data['type'] == self::TYPE_USER) {
98 continue;
99 } else {
100 if (!ilUtil::is_email($rcp_data['email'])) {
101 $ilErr->appendMessage($lng->txt('cal_err_invalid_notification_rcps'));
102 return false;
103 }
104 }
105 }
106 return true;
107 }
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
$ilErr
Definition: raiseError.php:18
$lng

References $DIC, $ilErr, $lng, getRecipients(), and ilUtil\is_email().

+ Here is the call graph for this function:

Field Documentation

◆ $cal_id

ilCalendarUserNotification::$cal_id = 0
private

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

Referenced by getEntryId().

◆ $rcps

ilCalendarUserNotification::$rcps = array()
private

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

Referenced by getRecipients().

◆ TYPE_EMAIL

◆ TYPE_USER


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