ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 139 of file class.ilCalendarUserNotification.php.

Referenced by read().

140  {
141  $this->rcps[] = array(
142  'type' => $a_type,
143  'usr_id' => $a_usr_id,
144  'email' => $a_email
145  );
146  }
+ Here is the caller graph for this function:

◆ createTable()

static ilCalendarUserNotification::createTable ( )
static

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

References $ilDB.

204  {
205  global $ilDB;
206 
207  if($ilDB->tableExists('cal_notification'))
208  {
209  return true;
210  }
211 
212  // Create notification table
213  $ilDB->createTable(
214  'cal_notification',
215  array(
216  'notification_id' => array('type' => 'integer','length' => 4,'notnull' => true),
217  'cal_id' => array('type' => 'integer','length' => 4, 'notnull' => true, 'default' => 0),
218  'user_type' => array('type' => 'integer','length' => 1, 'notnull' => true, 'default' => 0),
219  'user_id' => array('type' => 'integer','length' => 4, 'notnull' => true, 'default' => 0),
220  'email' => array('type' => 'text','length' => 64, 'notnull' => false)
221  )
222  );
223  $ilDB->addPrimaryKey(
224  'cal_notification',
225  array(
226  'notification_id'
227  )
228  );
229  $ilDB->createSequence('cal_notification');
230  $ilDB->addIndex('cal_notification', array('cal_id'),'i1');
231  }
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  }
global $ilDB
+ Here is the caller graph for this function:

◆ deleteRecipients()

ilCalendarUserNotification::deleteRecipients ( )

Delete all recipients ilDB $ilDB.

Returns
bool

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

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

Referenced by save().

163  {
164  global $ilDB;
165 
166  $query = 'DELETE FROM cal_notification '.
167  'WHERE cal_id = '.$ilDB->quote($this->getEntryId(),'integer');
168  $res = $ilDB->manipulate($query);
169  return true;
170  }
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  }
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.

Referenced by save(), and validate().

+ Here is the caller graph for this function:

◆ read()

ilCalendarUserNotification::read ( )
protected

Read recipients ilDB $ilDB.

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

References $ilDB, $query, $res, $row, addRecipient(), DB_FETCHMODE_OBJECT, and getEntryId().

Referenced by __construct().

179  {
180  global $ilDB;
181 
182  if(!$this->getEntryId())
183  {
184  return true;
185  }
186 
187  $query = 'SELECT * FROM cal_notification '.
188  'WHERE cal_id = '.$ilDB->quote($this->getEntryId(),'integer');
189  $res = $ilDB->query($query);
190 
191  $this->rcps = array();
192  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
193  {
194  $this->addRecipient(
195  $row->user_type,
196  $row->user_id,
197  $row->email
198  );
199  }
200  }
addRecipient($a_type, $a_usr_id=0, $a_email='')
Add recipient.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
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 111 of file class.ilCalendarUserNotification.php.

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

112  {
113  global $ilDB;
114 
115  $this->deleteRecipients();
116 
117  foreach($this->getRecipients() as $rcp)
118  {
119  $query = 'INSERT INTO cal_notification '.
120  '(notification_id,cal_id, user_type, user_id, email) '.
121  'VALUES ( '.
122  $ilDB->quote($ilDB->nextId('cal_notification'),'integer').', '.
123  $ilDB->quote((int) $this->getEntryId(),'integer').', '.
124  $ilDB->quote((int) $rcp['type'],'integer').', '.
125  $ilDB->quote((int) $rcp['usr_id'],'integer').', '.
126  $ilDB->quote($rcp['email'],'text').
127  ')';
128  $ilDB->manipulate($query);
129  }
130  return true;
131  }
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 152 of file class.ilCalendarUserNotification.php.

153  {
154  $this->rcps = array();
155  }

◆ validate()

ilCalendarUserNotification::validate ( )

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

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

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