ILIAS  release_8 Revision v8.24
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 21 of file class.ilCalendarUserNotification.php.

22 {
23 global $DIC;
24
25 $this->lng = $DIC->language();
26 $this->db = $DIC->database();
27 $this->error = $DIC['ilErr'];
28
29 $this->cal_id = $a_cal_id;
30 $this->read();
31 }
error(string $a_errmsg)
global $DIC
Definition: feed.php:28

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 102 of file class.ilCalendarUserNotification.php.

102 : void
103 {
104 $this->rcps[] = array(
105 'type' => $a_type,
106 'usr_id' => $a_usr_id,
107 'email' => $a_email
108 );
109 }

Referenced by read().

+ Here is the caller graph for this function:

◆ createTable()

static ilCalendarUserNotification::createTable ( )
static

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

143 : void
144 {
145 global $DIC;
146
147 $ilDB = $DIC['ilDB'];
148 if ($ilDB->tableExists('cal_notification')) {
149 return;
150 }
151
152 // Create notification table
153 $ilDB->createTable(
154 'cal_notification',
155 array(
156 'notification_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true),
157 'cal_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
158 'user_type' => array('type' => 'integer', 'length' => 1, 'notnull' => true, 'default' => 0),
159 'user_id' => array('type' => 'integer', 'length' => 4, 'notnull' => true, 'default' => 0),
160 'email' => array('type' => 'text', 'length' => 64, 'notnull' => false)
161 )
162 );
163 $ilDB->addPrimaryKey(
164 'cal_notification',
165 array(
166 'notification_id'
167 )
168 );
169 $ilDB->createSequence('cal_notification');
170 $ilDB->addIndex('cal_notification', array('cal_id'), 'i1');
171 }

References $DIC, and $ilDB.

◆ deleteCalendarEntry()

static ilCalendarUserNotification::deleteCalendarEntry ( int  $a_cal_id)
static

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

43 : void
44 {
45 global $DIC;
46
47 $ilDB = $DIC['ilDB'];
48 $query = 'DELETE FROM cal_notification ' .
49 'WHERE cal_id = ' . $ilDB->quote($a_cal_id, 'integer');
50 $res = $ilDB->manipulate($query);
51 }
$res
Definition: ltiservices.php:69
$query

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

Referenced by ilCalendarAppointmentGUI\delete().

+ Here is the caller graph for this function:

◆ deleteRecipients()

ilCalendarUserNotification::deleteRecipients ( )

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

116 : void
117 {
118 $query = 'DELETE FROM cal_notification ' .
119 'WHERE cal_id = ' . $this->db->quote($this->getEntryId(), 'integer');
120 $res = $this->db->manipulate($query);
121 }

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

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

33 : void
34 {
35 global $DIC;
36
37 $ilDB = $DIC['ilDB'];
38 $query = 'DELETE FROM cal_notification ' .
39 'WHERE user_id = ' . $ilDB->quote($a_usr_id, 'integer');
40 $res = $ilDB->manipulate($query);
41 }

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

◆ getEntryId()

ilCalendarUserNotification::getEntryId ( )

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

63 : array
64 {
65 return $this->rcps;
66 }

References $rcps.

Referenced by save(), and validate().

+ Here is the caller graph for this function:

◆ read()

ilCalendarUserNotification::read ( )
protected

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

123 : void
124 {
125 if (!$this->getEntryId()) {
126 return;
127 }
128
129 $query = 'SELECT * FROM cal_notification ' .
130 'WHERE cal_id = ' . $this->db->quote($this->getEntryId(), 'integer');
131 $res = $this->db->query($query);
132
133 $this->rcps = array();
134 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
135 $this->addRecipient(
136 (int) $row->user_type,
137 (int) $row->user_id,
138 $row->email
139 );
140 }
141 }
addRecipient(int $a_type, int $a_usr_id=0, string $a_email='')

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

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

84 : bool
85 {
86 $this->deleteRecipients();
87 foreach ($this->getRecipients() as $rcp) {
88 $query = 'INSERT INTO cal_notification ' .
89 '(notification_id,cal_id, user_type, user_id, email) ' .
90 'VALUES ( ' .
91 $this->db->quote($this->db->nextId('cal_notification'), 'integer') . ', ' .
92 $this->db->quote($this->getEntryId(), 'integer') . ', ' .
93 $this->db->quote((int) $rcp['type'], 'integer') . ', ' .
94 $this->db->quote((int) $rcp['usr_id'], 'integer') . ', ' .
95 $this->db->quote($rcp['email'], 'text') .
96 ')';
97 $this->db->manipulate($query);
98 }
99 return true;
100 }

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

+ Here is the call graph for this function:

◆ setEntryId()

ilCalendarUserNotification::setEntryId ( int  $a_id)

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

53 : void
54 {
55 $this->cal_id = $a_id;
56 }

◆ setRecipients()

ilCalendarUserNotification::setRecipients ( array  $a_rcps)

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

111 : void
112 {
113 $this->rcps = array();
114 }

Referenced by ilCalendarAppointmentGUI\distributeUserNotifications().

+ Here is the caller graph for this function:

◆ validate()

ilCalendarUserNotification::validate ( )

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

68 : bool
69 {
70 if (!count($this->getRecipients())) {
71 return true;
72 }
73 foreach ($this->getRecipients() as $rcp_data) {
74 if ($rcp_data['type'] == self::TYPE_USER) {
75 continue;
76 } elseif (!ilUtil::is_email($rcp_data['email'])) {
77 $this->error->appendMessage($this->lng->txt('cal_err_invalid_notification_rcps'));
78 return false;
79 }
80 }
81 return true;
82 }
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 14 of file class.ilCalendarUserNotification.php.

Referenced by getEntryId().

◆ $db

ilDBInterface ilCalendarUserNotification::$db
protected

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

◆ $error

ilErrorHandling ilCalendarUserNotification::$error
protected

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

◆ $lng

ilLanguage ilCalendarUserNotification::$lng
protected

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

◆ $rcps

array ilCalendarUserNotification::$rcps = array()
private

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

Referenced by getRecipients().

◆ TYPE_EMAIL

◆ TYPE_USER


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