ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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 }
error(string $a_errmsg)
global $DIC
Definition: shib_login.php:26

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

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ createTable()

static ilCalendarUserNotification::createTable ( )
static

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

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 }

References $DIC, and $ilDB.

◆ deleteCalendarEntry()

static ilCalendarUserNotification::deleteCalendarEntry ( int  $a_cal_id)
static

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

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:69

References $DIC, $ilDB, and $res.

Referenced by ilCalendarAppointmentGUI\delete().

+ Here is the caller graph for this function:

◆ deleteRecipients()

ilCalendarUserNotification::deleteRecipients ( )

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

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 }

References $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 ( int  $a_usr_id)
static

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

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 }

References $DIC, $ilDB, and $res.

◆ getEntryId()

ilCalendarUserNotification::getEntryId ( )

Definition at line 72 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 77 of file class.ilCalendarUserNotification.php.

77 : array
78 {
79 return $this->rcps;
80 }

References $rcps.

Referenced by save(), and validate().

+ Here is the caller graph for this function:

◆ read()

ilCalendarUserNotification::read ( )
protected

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

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 }
addRecipient(int $a_type, int $a_usr_id=0, string $a_email='')

References $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 ( )

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

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 }

References deleteRecipients(), getEntryId(), and getRecipients().

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

125 : void
126 {
127 $this->rcps = array();
128 }

Referenced by ilCalendarAppointmentGUI\distributeUserNotifications().

+ Here is the caller graph for this function:

◆ validate()

ilCalendarUserNotification::validate ( )

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

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.

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

+ 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: