ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCalendarUserNotification Class Reference
+ Collaboration diagram for ilCalendarUserNotification:

Public Member Functions

 __construct (int $a_cal_id=0)
 
 setEntryId (int $a_id)
 
 getEntryId ()
 
 getRecipients ()
 
 validate ()
 
 save ()
 
 addRecipient (int $a_type, int $a_usr_id=0, string $a_email='')
 
 setRecipients (array $a_rcps)
 
 deleteRecipients ()
 

Static Public Member Functions

static deleteUser (int $a_usr_id)
 
static deleteCalendarEntry (int $a_cal_id)
 
static createTable ()
 

Data Fields

const TYPE_USER = 1
 
const TYPE_EMAIL = 2
 

Protected Member Functions

 read ()
 

Protected Attributes

ilLanguage $lng
 
ilDBInterface $db
 
ilErrorHandling $error
 

Private Attributes

int $cal_id = 0
 
array $rcps = array()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCalendarUserNotification::__construct ( int  $a_cal_id = 0)

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

References $DIC, ILIAS\Repository\lng(), and read().

36  {
37  global $DIC;
38 
39  $this->lng = $DIC->language();
40  $this->db = $DIC->database();
41  $this->error = $DIC['ilErr'];
42 
43  $this->cal_id = $a_cal_id;
44  $this->read();
45  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ addRecipient()

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

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

Referenced by read().

116  : void
117  {
118  $this->rcps[] = array(
119  'type' => $a_type,
120  'usr_id' => $a_usr_id,
121  'email' => $a_email
122  );
123  }
+ Here is the caller graph for this function:

◆ createTable()

static ilCalendarUserNotification::createTable ( )
static

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

References $DIC, and $ilDB.

157  : void
158  {
159  global $DIC;
160 
161  $ilDB = $DIC['ilDB'];
162  if ($ilDB->tableExists('cal_notification')) {
163  return;
164  }
165 
166  // Create notification table
167  $ilDB->createTable(
168  'cal_notification',
169  array(
170  'notification_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true),
171  'cal_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
172  'user_type' => array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0),
173  'user_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
174  'email' => array('type' => 'text', 'length' => 64, 'notnull' => false)
175  )
176  );
177  $ilDB->addPrimaryKey(
178  'cal_notification',
179  array(
180  'notification_id'
181  )
182  );
183  $ilDB->createSequence('cal_notification');
184  $ilDB->addIndex('cal_notification', array('cal_id'), 'i1');
185  }
global $DIC
Definition: shib_login.php:22

◆ deleteCalendarEntry()

static ilCalendarUserNotification::deleteCalendarEntry ( int  $a_cal_id)
static

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

References $DIC, $ilDB, and $res.

Referenced by ilCalendarAppointmentGUI\delete().

57  : void
58  {
59  global $DIC;
60 
61  $ilDB = $DIC['ilDB'];
62  $query = 'DELETE FROM cal_notification ' .
63  'WHERE cal_id = ' . $ilDB->quote($a_cal_id, 'integer');
64  $res = $ilDB->manipulate($query);
65  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ deleteRecipients()

ilCalendarUserNotification::deleteRecipients ( )

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

References $res, and getEntryId().

Referenced by save().

130  : void
131  {
132  $query = 'DELETE FROM cal_notification ' .
133  'WHERE cal_id = ' . $this->db->quote($this->getEntryId(), 'integer');
134  $res = $this->db->manipulate($query);
135  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUser()

static ilCalendarUserNotification::deleteUser ( int  $a_usr_id)
static

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

References $DIC, $ilDB, and $res.

47  : void
48  {
49  global $DIC;
50 
51  $ilDB = $DIC['ilDB'];
52  $query = 'DELETE FROM cal_notification ' .
53  'WHERE user_id = ' . $ilDB->quote($a_usr_id, 'integer');
54  $res = $ilDB->manipulate($query);
55  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22

◆ getEntryId()

ilCalendarUserNotification::getEntryId ( )

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

References $cal_id.

Referenced by deleteRecipients(), and read().

72  : int
73  {
74  return $this->cal_id;
75  }
+ 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().

77  : array
78  {
79  return $this->rcps;
80  }
+ Here is the caller graph for this function:

◆ read()

ilCalendarUserNotification::read ( )
protected

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

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

Referenced by __construct().

137  : void
138  {
139  if (!$this->getEntryId()) {
140  return;
141  }
142 
143  $query = 'SELECT * FROM cal_notification ' .
144  'WHERE cal_id = ' . $this->db->quote($this->getEntryId(), 'integer');
145  $res = $this->db->query($query);
146 
147  $this->rcps = array();
148  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
149  $this->addRecipient(
150  (int) $row->user_type,
151  (int) $row->user_id,
152  $row->email
153  );
154  }
155  }
$res
Definition: ltiservices.php:66
addRecipient(int $a_type, int $a_usr_id=0, string $a_email='')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilCalendarUserNotification::save ( )

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

References deleteRecipients(), and getRecipients().

98  : bool
99  {
100  $this->deleteRecipients();
101  foreach ($this->getRecipients() as $rcp) {
102  $query = 'INSERT INTO cal_notification ' .
103  '(notification_id,cal_id, user_type, user_id, email) ' .
104  'VALUES ( ' .
105  $this->db->quote($this->db->nextId('cal_notification'), 'integer') . ', ' .
106  $this->db->quote($this->getEntryId(), 'integer') . ', ' .
107  $this->db->quote((int) $rcp['type'], 'integer') . ', ' .
108  $this->db->quote((int) $rcp['usr_id'], 'integer') . ', ' .
109  $this->db->quote($rcp['email'], 'text') .
110  ')';
111  $this->db->manipulate($query);
112  }
113  return true;
114  }
+ Here is the call graph for this function:

◆ setEntryId()

ilCalendarUserNotification::setEntryId ( int  $a_id)

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

67  : void
68  {
69  $this->cal_id = $a_id;
70  }

◆ setRecipients()

ilCalendarUserNotification::setRecipients ( array  $a_rcps)

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

Referenced by ilCalendarAppointmentGUI\distributeUserNotifications().

125  : void
126  {
127  $this->rcps = array();
128  }
+ Here is the caller graph for this function:

◆ validate()

ilCalendarUserNotification::validate ( )

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

References getRecipients(), ilUtil\is_email(), and ILIAS\Repository\lng().

82  : bool
83  {
84  if (!count($this->getRecipients())) {
85  return true;
86  }
87  foreach ($this->getRecipients() as $rcp_data) {
88  if ($rcp_data['type'] == self::TYPE_USER) {
89  continue;
90  } elseif (!ilUtil::is_email($rcp_data['email'])) {
91  $this->error->appendMessage($this->lng->txt('cal_err_invalid_notification_rcps'));
92  return false;
93  }
94  }
95  return true;
96  }
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
+ Here is the call graph for this function:

Field Documentation

◆ $cal_id

int ilCalendarUserNotification::$cal_id = 0
private

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

Referenced by getEntryId().

◆ $db

ilDBInterface ilCalendarUserNotification::$db
protected

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

◆ $error

ilErrorHandling ilCalendarUserNotification::$error
protected

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

◆ $lng

ilLanguage ilCalendarUserNotification::$lng
protected

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

◆ $rcps

array ilCalendarUserNotification::$rcps = array()
private

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

Referenced by getRecipients().

◆ TYPE_EMAIL

◆ TYPE_USER


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