ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailOptions Class Reference

Class ilMailOptions this class handles user mails. More...

+ Collaboration diagram for ilMailOptions:

Public Member Functions

 __construct (int $usrId, ilMailTransportSettings $mailTransportSettings=null, ilSetting $settings=null, ilDBInterface $db=null)
 
 createMailOptionsEntry ()
 create entry in table_mail_options for a new user this method should only be called from createUser() More...
 
 mayModifyIndividualTransportSettings ()
 
 maySeeIndividualTransportSettings ()
 
 mayManageInvididualSettings ()
 
 updateOptions ()
 
 getLinebreak ()
 
 getSignature ()
 
 getIncomingType ()
 
 setLinebreak (int $linebreak)
 
 setSignature (string $signature)
 
 setIncomingType (int $incomingType)
 
 setIsCronJobNotificationStatus (bool $isCronJobNotificationEnabled)
 
 isCronJobNotificationEnabled ()
 
 getEmailAddressMode ()
 
 setEmailAddressMode (int $emailAddressMode)
 
 getExternalEmailAddresses ()
 

Data Fields

const INCOMING_LOCAL = 0
 
const INCOMING_EMAIL = 1
 
const INCOMING_BOTH = 2
 
const FIRST_EMAIL = 3
 
const SECOND_EMAIL = 4
 
const BOTH_EMAIL = 5
 
const DEFAULT_LINE_BREAK = 60
 

Protected Member Functions

 read ()
 
 lookupNotificationSetting (int $usrId)
 

Protected Attributes

 $ilias
 
 $db
 
 $usrId = 0
 
 $settings
 
 $table_mail_options = 'mail_options'
 
 $linebreak = 0
 
 $signature = ''
 
 $isCronJobNotificationEnabled = false
 
 $incomingType = self::INCOMING_LOCAL
 
 $default_incoming_type = self::INCOMING_LOCAL
 
 $emailAddressMode = self::FIRST_EMAIL
 
 $default_email_address_mode = self::FIRST_EMAIL
 
 $mailTransportSettings
 
 $firstEmailAddress = ''
 
 $secondEmailAddress = ''
 

Detailed Description

Class ilMailOptions this class handles user mails.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 10 of file class.ilMailOptions.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailOptions::__construct ( int  $usrId,
ilMailTransportSettings  $mailTransportSettings = null,
ilSetting  $settings = null,
ilDBInterface  $db = null 
)
Parameters
int$usrId
ilMailTransportSettings | null$mailTransportSettings

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

62 {
63 global $DIC;
64
65 $this->usrId = $usrId;
66
67 $this->db = $db ?? $DIC->database();
68 $this->settings = $settings ?? $DIC->settings();
69
70 $this->incomingType = self::INCOMING_LOCAL;
71 $default_incoming_type = $this->settings->get('mail_incoming_mail', '');
72 if ($default_incoming_type !== '') {
73 $this->default_incoming_type = (int) $default_incoming_type;
74 $this->incomingType = $this->default_incoming_type;
75 }
76
77 $this->emailAddressMode = self::FIRST_EMAIL;
78 $default_email_address_mode = $this->settings->get('mail_address_option', '');
79 if ($default_email_address_mode !== '') {
80 $this->default_email_address_mode = (int) $default_email_address_mode;
81 $this->emailAddressMode = $this->default_email_address_mode;
82 }
83
84 $this->linebreak = self::DEFAULT_LINE_BREAK;
85 $this->isCronJobNotificationEnabled = false;
86 $this->signature = '';
87
88 if ($mailTransportSettings === null) {
90 }
91 $this->mailTransportSettings = $mailTransportSettings;
92
93 $this->read();
94 }
global $DIC
Definition: goto.php:24
settings()
Definition: settings.php:2

References $db, $default_email_address_mode, $default_incoming_type, $DIC, $mailTransportSettings, $settings, $usrId, DEFAULT_LINE_BREAK, FIRST_EMAIL, INCOMING_LOCAL, isCronJobNotificationEnabled(), read(), and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ createMailOptionsEntry()

ilMailOptions::createMailOptionsEntry ( )

create entry in table_mail_options for a new user this method should only be called from createUser()

Definition at line 100 of file class.ilMailOptions.php.

100 : void
101 {
102 $this->db->replace(
103 $this->table_mail_options,
104 [
105 'user_id' => ['integer', $this->usrId],
106 ],
107 [
108 'linebreak' => ['integer', $this->linebreak],
109 'signature' => ['text', $this->signature],
110 'incoming_type' => ['integer', $this->default_incoming_type],
111 'mail_address_option' => ['integer', $this->default_email_address_mode],
112 'cronjob_notification' => ['integer', (int) $this->isCronJobNotificationEnabled]
113 ]
114 );
115 }

References isCronJobNotificationEnabled().

+ Here is the call graph for this function:

◆ getEmailAddressMode()

ilMailOptions::getEmailAddressMode ( )
Returns
int

Definition at line 281 of file class.ilMailOptions.php.

281 : int
282 {
284 }

References $emailAddressMode.

Referenced by getExternalEmailAddresses(), and updateOptions().

+ Here is the caller graph for this function:

◆ getExternalEmailAddresses()

ilMailOptions::getExternalEmailAddresses ( )
Returns
string[]

Definition at line 314 of file class.ilMailOptions.php.

314 : array
315 {
316 $emailAddresses = [];
317
318 switch ($this->getEmailAddressMode()) {
320 if (strlen($this->secondEmailAddress)) {
321 $emailAddresses[] = $this->secondEmailAddress;
322 } elseif (strlen($this->firstEmailAddress)) {
323 // fallback, use first email address
324 $emailAddresses[] = $this->firstEmailAddress;
325 }
326 break;
327
328 case self::BOTH_EMAIL:
329 if (strlen($this->firstEmailAddress)) {
330 $emailAddresses[] = $this->firstEmailAddress;
331 }
332 if (strlen($this->secondEmailAddress)) {
333 $emailAddresses[] = $this->secondEmailAddress;
334 }
335 break;
336
338 default:
339 if (strlen($this->firstEmailAddress)) {
340 $emailAddresses[] = $this->firstEmailAddress;
341 } elseif (strlen($this->secondEmailAddress)) {
342 // fallback, use first email address
343 $emailAddresses[] = $this->secondEmailAddress;
344 }
345 break;
346 }
347
348 return $emailAddresses;
349 }

References $firstEmailAddress, $secondEmailAddress, BOTH_EMAIL, FIRST_EMAIL, getEmailAddressMode(), and SECOND_EMAIL.

+ Here is the call graph for this function:

◆ getIncomingType()

ilMailOptions::getIncomingType ( )
Returns
int

Definition at line 233 of file class.ilMailOptions.php.

233 : int
234 {
235 return $this->incomingType;
236 }

References $incomingType.

Referenced by updateOptions().

+ Here is the caller graph for this function:

◆ getLinebreak()

ilMailOptions::getLinebreak ( )
Returns
int

Definition at line 217 of file class.ilMailOptions.php.

217 : int
218 {
219 return $this->linebreak;
220 }

References $linebreak.

Referenced by updateOptions().

+ Here is the caller graph for this function:

◆ getSignature()

ilMailOptions::getSignature ( )
Returns
string

Definition at line 225 of file class.ilMailOptions.php.

225 : string
226 {
227 return $this->signature;
228 }

References $signature.

Referenced by updateOptions().

+ Here is the caller graph for this function:

◆ isCronJobNotificationEnabled()

ilMailOptions::isCronJobNotificationEnabled ( )
Returns
bool

Definition at line 273 of file class.ilMailOptions.php.

273 : bool
274 {
276 }

References $isCronJobNotificationEnabled.

Referenced by __construct(), createMailOptionsEntry(), read(), setIsCronJobNotificationStatus(), and updateOptions().

+ Here is the caller graph for this function:

◆ lookupNotificationSetting()

ilMailOptions::lookupNotificationSetting ( int  $usrId)
protected
Parameters
int$usrId
Returns
int

Definition at line 298 of file class.ilMailOptions.php.

298 : int
299 {
300 global $DIC;
301
302 $row = $DIC->database()->fetchAssoc($DIC->database()->queryF(
303 'SELECT cronjob_notification FROM mail_options WHERE user_id = %s',
304 ['integer'],
305 [$usrId]
306 ));
307
308 return (int) $row['cronjob_notification'];
309 }

References $DIC, and $usrId.

Referenced by updateOptions().

+ Here is the caller graph for this function:

◆ mayManageInvididualSettings()

ilMailOptions::mayManageInvididualSettings ( )

Definition at line 131 of file class.ilMailOptions.php.

131 : bool
132 {
133 return $this->settings->get('show_mail_settings') === '1';
134 }

References settings().

Referenced by mayModifyIndividualTransportSettings(), and read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mayModifyIndividualTransportSettings()

ilMailOptions::mayModifyIndividualTransportSettings ( )

Definition at line 117 of file class.ilMailOptions.php.

117 : bool
118 {
119 return (
122 $this->settings->get('usr_settings_disable_mail_incoming_mail') !== '1'
123 );
124 }

References mayManageInvididualSettings(), maySeeIndividualTransportSettings(), and settings().

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maySeeIndividualTransportSettings()

ilMailOptions::maySeeIndividualTransportSettings ( )

Definition at line 126 of file class.ilMailOptions.php.

126 : bool
127 {
128 return $this->settings->get('usr_settings_hide_mail_incoming_mail') !== '1';
129 }

References settings().

Referenced by mayModifyIndividualTransportSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilMailOptions::read ( )
protected

Definition at line 136 of file class.ilMailOptions.php.

136 : void
137 {
138 $query = implode(' ', [
139 'SELECT mail_options.cronjob_notification,',
140 'mail_options.signature, mail_options.linebreak, mail_options.incoming_type,',
141 'mail_options.mail_address_option, usr_data.email, usr_data.second_email',
142 'FROM mail_options',
143 'INNER JOIN usr_data ON mail_options.user_id = usr_data.usr_id',
144 'WHERE mail_options.user_id = %s',
145 ]);
146 $res = $this->db->queryF(
147 $query,
148 ['integer'],
149 [$this->usrId]
150 );
151 $row = $this->db->fetchObject($res);
152 if ($row === null) {
153 $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress, false);
154 return;
155 }
156
157 $this->firstEmailAddress = (string) $row->email;
158 $this->secondEmailAddress = (string) $row->second_email;
159
160 if ($this->mayManageInvididualSettings()) {
161 $this->signature = (string) $row->signature;
162 $this->linebreak = (int) $row->linebreak;
163 $this->isCronJobNotificationEnabled = (bool) $row->cronjob_notification;
164 }
165
167 $this->incomingType = (int) $row->incoming_type;
168 $this->emailAddressMode = (int) $row->mail_address_option;
169
170 if (false === filter_var(
171 $this->incomingType,
172 FILTER_VALIDATE_INT,
173 ['options' => ['min_range' => self::INCOMING_LOCAL, 'max_range' => self::INCOMING_BOTH]]
174 )) {
175 $this->incomingType = self::INCOMING_LOCAL;
176 }
177
178 if (false === filter_var(
179 $this->emailAddressMode,
180 FILTER_VALIDATE_INT,
181 ['options' => ['min_range' => self::FIRST_EMAIL, 'max_range' => self::BOTH_EMAIL]]
182 )) {
183 $this->emailAddressMode = self::FIRST_EMAIL;
184 }
185 }
186
187 $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress);
188 }
$query
foreach($_POST as $key=> $value) $res

References $query, $res, FIRST_EMAIL, INCOMING_LOCAL, isCronJobNotificationEnabled(), mayManageInvididualSettings(), and mayModifyIndividualTransportSettings().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setEmailAddressMode()

ilMailOptions::setEmailAddressMode ( int  $emailAddressMode)
Parameters
int$emailAddressMode

Definition at line 289 of file class.ilMailOptions.php.

289 : void
290 {
291 $this->emailAddressMode = $emailAddressMode;
292 }

References $emailAddressMode.

◆ setIncomingType()

ilMailOptions::setIncomingType ( int  $incomingType)
Parameters
int$incomingType

Definition at line 257 of file class.ilMailOptions.php.

257 : void
258 {
259 $this->incomingType = $incomingType;
260 }

References $incomingType.

◆ setIsCronJobNotificationStatus()

ilMailOptions::setIsCronJobNotificationStatus ( bool  $isCronJobNotificationEnabled)
Parameters
bool$isCronJobNotificationEnabled

Definition at line 265 of file class.ilMailOptions.php.

265 : void
266 {
268 }

References $isCronJobNotificationEnabled, and isCronJobNotificationEnabled().

+ Here is the call graph for this function:

◆ setLinebreak()

ilMailOptions::setLinebreak ( int  $linebreak)
Parameters
int$linebreak

Definition at line 241 of file class.ilMailOptions.php.

241 : void
242 {
243 $this->linebreak = $linebreak;
244 }

References $linebreak.

◆ setSignature()

ilMailOptions::setSignature ( string  $signature)
Parameters
string$signature

Definition at line 249 of file class.ilMailOptions.php.

249 : void
250 {
251 $this->signature = $signature;
252 }

References $signature.

◆ updateOptions()

ilMailOptions::updateOptions ( )

Definition at line 190 of file class.ilMailOptions.php.

191 {
192 $data = [
193 'signature' => ['text', $this->getSignature()],
194 'linebreak' => ['integer', (int) $this->getLinebreak()],
195 'incoming_type' => ['integer', $this->getIncomingType()],
196 'mail_address_option' => ['integer', $this->getEmailAddressMode()]
197 ];
198
199 if ($this->settings->get('mail_notification')) {
200 $data['cronjob_notification'] = ['integer', (int) $this->isCronJobNotificationEnabled()];
201 } else {
202 $data['cronjob_notification'] = ['integer', $this->lookupNotificationSetting($this->usrId)];
203 }
204
205 return $this->db->replace(
206 $this->table_mail_options,
207 [
208 'user_id' => ['integer', $this->usrId]
209 ],
210 $data
211 );
212 }
lookupNotificationSetting(int $usrId)
$data
Definition: storeScorm.php:23

References $data, getEmailAddressMode(), getIncomingType(), getLinebreak(), getSignature(), isCronJobNotificationEnabled(), lookupNotificationSetting(), and settings().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilMailOptions::$db
protected

Definition at line 25 of file class.ilMailOptions.php.

Referenced by __construct().

◆ $default_email_address_mode

ilMailOptions::$default_email_address_mode = self::FIRST_EMAIL
protected

Definition at line 45 of file class.ilMailOptions.php.

Referenced by __construct().

◆ $default_incoming_type

ilMailOptions::$default_incoming_type = self::INCOMING_LOCAL
protected

Definition at line 41 of file class.ilMailOptions.php.

Referenced by __construct().

◆ $emailAddressMode

ilMailOptions::$emailAddressMode = self::FIRST_EMAIL
protected

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

Referenced by getEmailAddressMode(), and setEmailAddressMode().

◆ $firstEmailAddress

ilMailOptions::$firstEmailAddress = ''
protected

Definition at line 49 of file class.ilMailOptions.php.

Referenced by getExternalEmailAddresses().

◆ $ilias

ilMailOptions::$ilias
protected

Definition at line 23 of file class.ilMailOptions.php.

◆ $incomingType

ilMailOptions::$incomingType = self::INCOMING_LOCAL
protected

Definition at line 39 of file class.ilMailOptions.php.

Referenced by getIncomingType(), and setIncomingType().

◆ $isCronJobNotificationEnabled

ilMailOptions::$isCronJobNotificationEnabled = false
protected

◆ $linebreak

ilMailOptions::$linebreak = 0
protected

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

Referenced by getLinebreak(), and setLinebreak().

◆ $mailTransportSettings

ilMailOptions::$mailTransportSettings
protected

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

Referenced by __construct().

◆ $secondEmailAddress

ilMailOptions::$secondEmailAddress = ''
protected

Definition at line 51 of file class.ilMailOptions.php.

Referenced by getExternalEmailAddresses().

◆ $settings

ilMailOptions::$settings
protected

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

Referenced by __construct().

◆ $signature

ilMailOptions::$signature = ''
protected

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

Referenced by getSignature(), and setSignature().

◆ $table_mail_options

ilMailOptions::$table_mail_options = 'mail_options'
protected

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

◆ $usrId

ilMailOptions::$usrId = 0
protected

Definition at line 27 of file class.ilMailOptions.php.

Referenced by __construct(), and lookupNotificationSetting().

◆ BOTH_EMAIL

const ilMailOptions::BOTH_EMAIL = 5

◆ DEFAULT_LINE_BREAK

const ilMailOptions::DEFAULT_LINE_BREAK = 60

Definition at line 20 of file class.ilMailOptions.php.

Referenced by __construct(), and ilMailOptionsTest\testConstructor().

◆ FIRST_EMAIL

◆ INCOMING_BOTH

const ilMailOptions::INCOMING_BOTH = 2

◆ INCOMING_EMAIL

◆ INCOMING_LOCAL

◆ SECOND_EMAIL

const ilMailOptions::SECOND_EMAIL = 4

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