ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ilDB $ilDB. More...
 

Static Public Member Functions

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

Data Fields

const TYPE_USER = 1
 
const TYPE_EMAIL = 2
 

Protected Member Functions

 read ()
 Read recipients 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.

References read().

23  {
24  $this->cal_id = $a_cal_id;
25  $this->read();
26  }
+ 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 132 of file class.ilCalendarUserNotification.php.

References $a_type, and array.

Referenced by read().

133  {
134  $this->rcps[] = array(
135  'type' => $a_type,
136  'usr_id' => $a_usr_id,
137  'email' => $a_email
138  );
139  }
$a_type
Definition: workflow.php:92
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ createTable()

static ilCalendarUserNotification::createTable ( )
static

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

References $ilDB, and array.

195  {
196  global $ilDB;
197 
198  if ($ilDB->tableExists('cal_notification')) {
199  return true;
200  }
201 
202  // Create notification table
203  $ilDB->createTable(
204  'cal_notification',
205  array(
206  'notification_id' => array('type' => 'integer','length' => 4,'notnull' => true),
207  'cal_id' => array('type' => 'integer','length' => 4, 'notnull' => true, 'default' => 0),
208  'user_type' => array('type' => 'integer','length' => 1, 'notnull' => true, 'default' => 0),
209  'user_id' => array('type' => 'integer','length' => 4, 'notnull' => true, 'default' => 0),
210  'email' => array('type' => 'text','length' => 64, 'notnull' => false)
211  )
212  );
213  $ilDB->addPrimaryKey(
214  'cal_notification',
215  array(
216  'notification_id'
217  )
218  );
219  $ilDB->createSequence('cal_notification');
220  $ilDB->addIndex('cal_notification', array('cal_id'), 'i1');
221  }
Create styles array
The data for the language used.
global $ilDB

◆ deleteCalendarEntry()

static ilCalendarUserNotification::deleteCalendarEntry (   $a_cal_id)
static

Delete notification for a calendar entry ilDB $ilDB.

Parameters
int$a_cal_id
Returns
bool

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

References $ilDB, $query, and $res.

Referenced by ilCalendarAppointmentGUI\delete().

51  {
52  global $ilDB;
53 
54  $query = 'DELETE FROM cal_notification ' .
55  'WHERE cal_id = ' . $ilDB->quote($a_cal_id, 'integer');
56  $res = $ilDB->manipulate($query);
57  return true;
58  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ deleteRecipients()

ilCalendarUserNotification::deleteRecipients ( )

Delete all recipients ilDB $ilDB.

Returns
bool

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

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

Referenced by save().

156  {
157  global $ilDB;
158 
159  $query = 'DELETE FROM cal_notification ' .
160  'WHERE cal_id = ' . $ilDB->quote($this->getEntryId(), 'integer');
161  $res = $ilDB->manipulate($query);
162  return true;
163  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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 ilDB $ilDB.

Parameters
int$a_usr_id
Returns
bool

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

References $ilDB, $query, and $res.

35  {
36  global $ilDB;
37 
38  $query = 'DELETE FROM cal_notification ' .
39  'WHERE user_id = ' . $ilDB->quote($a_usr_id, 'integer');
40  $res = $ilDB->manipulate($query);
41  return true;
42  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ getEntryId()

ilCalendarUserNotification::getEntryId ( )

Get calendar entry id.

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

References $cal_id.

Referenced by deleteRecipients(), and read().

+ Here is the caller graph for this function:

◆ getRecipients()

ilCalendarUserNotification::getRecipients ( )

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

References $rcps, and array.

Referenced by save(), and validate().

78  {
79  return (array) $this->rcps;
80  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ read()

ilCalendarUserNotification::read ( )
protected

Read recipients ilDB $ilDB.

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

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

Referenced by __construct().

172  {
173  global $ilDB;
174 
175  if (!$this->getEntryId()) {
176  return true;
177  }
178 
179  $query = 'SELECT * FROM cal_notification ' .
180  'WHERE cal_id = ' . $ilDB->quote($this->getEntryId(), 'integer');
181  $res = $ilDB->query($query);
182 
183  $this->rcps = array();
184  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
185  $this->addRecipient(
186  $row->user_type,
187  $row->user_id,
188  $row->email
189  );
190  }
191  }
addRecipient($a_type, $a_usr_id=0, $a_email='')
Add recipient.
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ 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 105 of file class.ilCalendarUserNotification.php.

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

106  {
107  global $ilDB;
108 
109  $this->deleteRecipients();
110 
111  foreach ($this->getRecipients() as $rcp) {
112  $query = 'INSERT INTO cal_notification ' .
113  '(notification_id,cal_id, user_type, user_id, email) ' .
114  'VALUES ( ' .
115  $ilDB->quote($ilDB->nextId('cal_notification'), 'integer') . ', ' .
116  $ilDB->quote((int) $this->getEntryId(), 'integer') . ', ' .
117  $ilDB->quote((int) $rcp['type'], 'integer') . ', ' .
118  $ilDB->quote((int) $rcp['usr_id'], 'integer') . ', ' .
119  $ilDB->quote($rcp['email'], 'text') .
120  ')';
121  $ilDB->manipulate($query);
122  }
123  return true;
124  }
$query
global $ilDB
deleteRecipients()
Delete all recipients ilDB $ilDB.
+ Here is the call graph for this function:

◆ setEntryId()

ilCalendarUserNotification::setEntryId (   $a_id)

Set calendar entry id.

Parameters
int$a_id

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

65  {
66  $this->cal_id = $a_id;
67  }

◆ setRecipients()

ilCalendarUserNotification::setRecipients (   $a_rcps)

Set recipients.

Parameters
array$a_rcps

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

References array.

146  {
147  $this->rcps = array();
148  }
Create styles array
The data for the language used.

◆ validate()

ilCalendarUserNotification::validate ( )

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

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

83  {
84  global $ilErr, $lng;
85 
86  if (!count($this->getRecipients())) {
87  return true;
88  }
89  foreach ((array) $this->getRecipients() as $rcp_data) {
90  if ($rcp_data['type'] == self::TYPE_USER) {
91  continue;
92  } else {
93  if (!ilUtil::is_email($rcp_data['email'])) {
94  $ilErr->appendMessage($lng->txt('cal_err_invalid_notification_rcps'));
95  return false;
96  }
97  }
98  }
99  return true;
100  }
global $ilErr
Definition: raiseError.php:16
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ 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: