ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilMailOptions Class Reference
+ Collaboration diagram for ilMailOptions:

Public Member Functions

 __construct (protected int $usr_id, ?ilMailTransportSettings $mail_transport_settings=null, ?ClockInterface $clock_service=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 ()
 
 getSignature ()
 
 getIncomingType ()
 
 setSignature (string $signature)
 
 setIncomingType (int $incoming_type)
 
 setIsCronJobNotificationStatus (bool $is_cron_notification_enabled)
 
 isCronJobNotificationEnabled ()
 
 getEmailAddressMode ()
 
 setEmailAddressmode (int $email_address_mode)
 
 getUsrId ()
 
 getExternalEmailAddresses ()
 
 setAbsenceAutoresponderBody (string $absence_auto_responder_body)
 
 getAbsenceAutoresponderBody ()
 
 setAbsenceStatus (bool $absence_status)
 
 getAbsenceStatus ()
 
 setAbsentFrom (int $absent_from)
 
 getAbsentFrom ()
 
 setAbsentUntil (int $absent_until)
 
 getAbsentUntil ()
 
 setAbsenceAutoresponderSubject (string $absence_auto_responder_subject)
 
 getAbsenceAutoresponderSubject ()
 
 isAbsent ()
 

Data Fields

final const int INCOMING_LOCAL = 0
 
final const int INCOMING_EMAIL = 1
 
final const int INCOMING_BOTH = 2
 
final const int FIRST_EMAIL = 3
 
final const int SECOND_EMAIL = 4
 
final const int BOTH_EMAIL = 5
 
final const bool ABSENCE_STATUS_PRESENT = false
 
final const bool ABSENCE_STATUS_ABSENT = true
 

Protected Member Functions

 read ()
 

Protected Attributes

ILIAS $ilias
 
ilDBInterface $db
 
ilSetting $settings
 
string $table_mail_options = 'mail_options'
 
string $signature = ''
 
bool $is_cron_notification_enabled = false
 
int $incoming_type = self::INCOMING_LOCAL
 
int $default_incoming_type = self::INCOMING_LOCAL
 
int $email_address_mode = self::FIRST_EMAIL
 
int $default_email_address_mode = self::FIRST_EMAIL
 
ilMailTransportSettings $mail_transport_settings
 
string $first_mail_address = ''
 
string $second_mail_address = ''
 
bool $absence_status = self::ABSENCE_STATUS_PRESENT
 
int $absent_from = 0
 
int $absent_until = 0
 
string $absence_auto_responder_body = ''
 
string $absence_auto_responder_subject = ''
 
ClockInterface $clock_service
 

Static Private Member Functions

static lookupNotificationSetting (int $usr_id)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilMailOptions::__construct ( protected int  $usr_id,
?ilMailTransportSettings  $mail_transport_settings = null,
?ClockInterface  $clock_service = null,
?ilSetting  $settings = null,
?ilDBInterface  $db = null 
)

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

References $default_email_address_mode, $default_incoming_type, $DIC, ILIAS\Repository\int(), read(), and ILIAS\Repository\settings().

61  {
62  global $DIC;
63  $this->db = $db ?? $DIC->database();
64  $this->settings = $settings ?? $DIC->settings();
65  $this->mail_transport_settings = $mail_transport_settings ?? new ilMailTransportSettings($this);
66  $this->clock_service = $clock_service ?? (new DataFactory())->clock()->utc();
67 
68  $this->incoming_type = self::INCOMING_LOCAL;
69  $default_incoming_type = $this->settings->get('mail_incoming_mail', '');
70  if ($default_incoming_type !== '') {
71  $this->default_incoming_type = (int) $default_incoming_type;
72  $this->incoming_type = $this->default_incoming_type;
73  }
74 
75  $this->email_address_mode = self::FIRST_EMAIL;
76  $default_email_address_mode = $this->settings->get('mail_address_option', '');
77  if ($default_email_address_mode !== '') {
78  $this->default_email_address_mode = (int) $default_email_address_mode;
79  $this->email_address_mode = $this->default_email_address_mode;
80  }
81 
82  $this->is_cron_notification_enabled = false;
83  $this->signature = '';
84 
85  $this->read();
86  }
ilDBInterface $db
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
ClockInterface $clock_service
ilMailTransportSettings $mail_transport_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 92 of file class.ilMailOptions.php.

92  : void
93  {
94  $this->db->replace(
95  $this->table_mail_options,
96  [
97  'user_id' => ['integer', $this->usr_id],
98  ],
99  [
100  'signature' => ['text', $this->signature],
101  'incoming_type' => ['integer', $this->default_incoming_type],
102  'mail_address_option' => ['integer', $this->default_email_address_mode],
103  'cronjob_notification' => ['integer', (int) $this->is_cron_notification_enabled]
104  ]
105  );
106  }

◆ getAbsenceAutoresponderBody()

ilMailOptions::getAbsenceAutoresponderBody ( )

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

References $absence_auto_responder_body.

Referenced by updateOptions().

322  : string
323  {
325  }
string $absence_auto_responder_body
+ Here is the caller graph for this function:

◆ getAbsenceAutoresponderSubject()

ilMailOptions::getAbsenceAutoresponderSubject ( )

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

References $absence_auto_responder_subject.

Referenced by updateOptions().

362  : string
363  {
365  }
string $absence_auto_responder_subject
+ Here is the caller graph for this function:

◆ getAbsenceStatus()

ilMailOptions::getAbsenceStatus ( )

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

References $absence_status.

Referenced by isAbsent(), and updateOptions().

332  : bool
333  {
334  return $this->absence_status;
335  }
+ Here is the caller graph for this function:

◆ getAbsentFrom()

ilMailOptions::getAbsentFrom ( )

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

References $absent_from.

Referenced by isAbsent(), and updateOptions().

342  : int
343  {
344  return $this->absent_from;
345  }
+ Here is the caller graph for this function:

◆ getAbsentUntil()

ilMailOptions::getAbsentUntil ( )

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

References $absent_until.

Referenced by isAbsent(), and updateOptions().

352  : int
353  {
354  return $this->absent_until;
355  }
+ Here is the caller graph for this function:

◆ getEmailAddressMode()

ilMailOptions::getEmailAddressMode ( )

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

References $email_address_mode.

Referenced by getExternalEmailAddresses(), and updateOptions().

250  : int
251  {
253  }
+ Here is the caller graph for this function:

◆ getExternalEmailAddresses()

ilMailOptions::getExternalEmailAddresses ( )
Returns
string[]

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

References $first_mail_address, $second_mail_address, and getEmailAddressMode().

281  : array
282  {
283  $email_addresses = [];
284  switch ($this->getEmailAddressMode()) {
285  case self::SECOND_EMAIL:
286  if ($this->second_mail_address !== '') {
287  $email_addresses[] = $this->second_mail_address;
288  } elseif ($this->first_mail_address !== '') {
289  // fallback, use first email address
290  $email_addresses[] = $this->first_mail_address;
291  }
292  break;
293 
294  case self::BOTH_EMAIL:
295  if ($this->first_mail_address !== '') {
296  $email_addresses[] = $this->first_mail_address;
297  }
298  if ($this->second_mail_address !== '') {
299  $email_addresses[] = $this->second_mail_address;
300  }
301  break;
302 
303  case self::FIRST_EMAIL:
304  default:
305  if ($this->first_mail_address !== '') {
306  $email_addresses[] = $this->first_mail_address;
307  } elseif ($this->second_mail_address !== '') {
308  // fallback, use first email address
309  $email_addresses[] = $this->second_mail_address;
310  }
311  break;
312  }
313 
314  return $email_addresses;
315  }
+ Here is the call graph for this function:

◆ getIncomingType()

ilMailOptions::getIncomingType ( )

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

References $incoming_type.

Referenced by updateOptions().

225  : int
226  {
227  return $this->incoming_type;
228  }
+ Here is the caller graph for this function:

◆ getSignature()

ilMailOptions::getSignature ( )

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

References $signature.

Referenced by updateOptions().

220  : string
221  {
222  return $this->signature;
223  }
+ Here is the caller graph for this function:

◆ getUsrId()

ilMailOptions::getUsrId ( )

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

260  : int
261  {
262  return $this->usr_id;
263  }

◆ isAbsent()

ilMailOptions::isAbsent ( )

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

References getAbsenceStatus(), getAbsentFrom(), and getAbsentUntil().

Referenced by ILIAS\Mail\Autoresponder\AutoresponderServiceImpl\enqueueAutoresponderIfEnabled().

367  : bool
368  {
369  return
370  $this->getAbsenceStatus() &&
371  $this->getAbsentFrom() &&
372  $this->getAbsentUntil() &&
373  $this->getAbsentFrom() <= $this->clock_service->now()->getTimestamp() &&
374  $this->getAbsentUntil() >= $this->clock_service->now()->getTimestamp();
375  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCronJobNotificationEnabled()

ilMailOptions::isCronJobNotificationEnabled ( )

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

References $is_cron_notification_enabled.

Referenced by updateOptions().

245  : bool
246  {
248  }
bool $is_cron_notification_enabled
+ Here is the caller graph for this function:

◆ lookupNotificationSetting()

static ilMailOptions::lookupNotificationSetting ( int  $usr_id)
staticprivate

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

References $DIC.

265  : int
266  {
267  global $DIC;
268 
269  $row = $DIC->database()->fetchAssoc($DIC->database()->queryF(
270  'SELECT cronjob_notification FROM mail_options WHERE user_id = %s',
271  ['integer'],
272  [$usr_id]
273  ));
274 
275  return (int) $row['cronjob_notification'];
276  }
global $DIC
Definition: shib_login.php:26

◆ mayManageInvididualSettings()

ilMailOptions::mayManageInvididualSettings ( )

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

References ILIAS\Repository\settings().

Referenced by mayModifyIndividualTransportSettings(), and read().

122  : bool
123  {
124  return $this->settings->get('show_mail_settings') === '1';
125  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mayModifyIndividualTransportSettings()

ilMailOptions::mayModifyIndividualTransportSettings ( )

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

References mayManageInvididualSettings(), maySeeIndividualTransportSettings(), and ILIAS\Repository\settings().

Referenced by read().

108  : bool
109  {
110  return (
111  $this->mayManageInvididualSettings() &&
113  $this->settings->get('usr_settings_disable_mail_incoming_mail') !== '1'
114  );
115  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maySeeIndividualTransportSettings()

ilMailOptions::maySeeIndividualTransportSettings ( )

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

References ILIAS\Repository\settings().

Referenced by mayModifyIndividualTransportSettings().

117  : bool
118  {
119  return $this->settings->get('usr_settings_hide_mail_incoming_mail') !== '1';
120  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilMailOptions::read ( )
protected

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

References $res, ILIAS\Repository\int(), mayManageInvididualSettings(), mayModifyIndividualTransportSettings(), null, setAbsenceAutoresponderBody(), setAbsenceAutoresponderSubject(), setAbsenceStatus(), setAbsentFrom(), and setAbsentUntil().

Referenced by __construct().

127  : void
128  {
129  $query = 'SELECT mail_options.cronjob_notification,
130  mail_options.signature,
131 
132  mail_options.incoming_type,
133  mail_options.mail_address_option,
134  mail_options.absence_status,
135  mail_options.absent_from,
136  mail_options.absent_until,
137  mail_options.absence_ar_subject,
138  mail_options.absence_ar_body,
139  usr_data.email,
140  usr_data.second_email
141  FROM mail_options
142  INNER JOIN usr_data ON mail_options.user_id = usr_data.usr_id
143  WHERE mail_options.user_id = %s';
144  $res = $this->db->queryF(
145  $query,
146  ['integer'],
147  [$this->usr_id]
148  );
149  $row = $this->db->fetchObject($res);
150  if ($row === null) {
151  $this->mail_transport_settings->adjust($this->first_mail_address, $this->second_mail_address, false);
152  return;
153  }
154 
155  $this->first_mail_address = (string) $row->email;
156  $this->second_mail_address = (string) $row->second_email;
157  if ($this->mayManageInvididualSettings()) {
158  $this->is_cron_notification_enabled = (bool) $row->cronjob_notification;
159  $this->signature = (string) $row->signature;
160  $this->setAbsenceStatus((bool) $row->absence_status);
161  $this->setAbsentFrom((int) $row->absent_from);
162  $this->setAbsentUntil((int) $row->absent_until);
163  $this->setAbsenceAutoresponderSubject($row->absence_ar_subject ?? '');
164  $this->setAbsenceAutoresponderBody($row->absence_ar_body ?? '');
165  }
166 
168  $this->incoming_type = (int) $row->incoming_type;
169  $this->email_address_mode = (int) $row->mail_address_option;
170 
171  if (filter_var(
172  $this->incoming_type,
173  FILTER_VALIDATE_INT,
174  ['options' => ['min_range' => self::INCOMING_LOCAL, 'max_range' => self::INCOMING_BOTH]]
175  ) === false) {
176  $this->incoming_type = self::INCOMING_LOCAL;
177  }
178 
179  if (filter_var(
180  $this->email_address_mode,
181  FILTER_VALIDATE_INT,
182  ['options' => ['min_range' => self::FIRST_EMAIL, 'max_range' => self::BOTH_EMAIL]]
183  ) === false) {
184  $this->email_address_mode = self::FIRST_EMAIL;
185  }
186  }
187 
188  $this->mail_transport_settings->adjust($this->first_mail_address, $this->second_mail_address);
189  }
$res
Definition: ltiservices.php:66
setAbsentFrom(int $absent_from)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setAbsenceStatus(bool $absence_status)
setAbsenceAutoresponderBody(string $absence_auto_responder_body)
setAbsenceAutoresponderSubject(string $absence_auto_responder_subject)
setAbsentUntil(int $absent_until)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAbsenceAutoresponderBody()

ilMailOptions::setAbsenceAutoresponderBody ( string  $absence_auto_responder_body)

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

References $absence_auto_responder_body.

Referenced by read().

317  : void
318  {
319  $this->absence_auto_responder_body = $absence_auto_responder_body;
320  }
string $absence_auto_responder_body
+ Here is the caller graph for this function:

◆ setAbsenceAutoresponderSubject()

ilMailOptions::setAbsenceAutoresponderSubject ( string  $absence_auto_responder_subject)

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

References $absence_auto_responder_subject.

Referenced by read().

357  : void
358  {
359  $this->absence_auto_responder_subject = $absence_auto_responder_subject;
360  }
string $absence_auto_responder_subject
+ Here is the caller graph for this function:

◆ setAbsenceStatus()

ilMailOptions::setAbsenceStatus ( bool  $absence_status)

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

References $absence_status.

Referenced by read().

327  : void
328  {
329  $this->absence_status = $absence_status;
330  }
+ Here is the caller graph for this function:

◆ setAbsentFrom()

ilMailOptions::setAbsentFrom ( int  $absent_from)

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

References $absent_from.

Referenced by read().

337  : void
338  {
339  $this->absent_from = $absent_from;
340  }
+ Here is the caller graph for this function:

◆ setAbsentUntil()

ilMailOptions::setAbsentUntil ( int  $absent_until)

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

References $absent_until.

Referenced by read().

347  : void
348  {
349  $this->absent_until = $absent_until;
350  }
+ Here is the caller graph for this function:

◆ setEmailAddressmode()

ilMailOptions::setEmailAddressmode ( int  $email_address_mode)

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

References $email_address_mode.

255  : void
256  {
257  $this->email_address_mode = $email_address_mode;
258  }

◆ setIncomingType()

ilMailOptions::setIncomingType ( int  $incoming_type)

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

References $incoming_type.

235  : void
236  {
237  $this->incoming_type = $incoming_type;
238  }

◆ setIsCronJobNotificationStatus()

ilMailOptions::setIsCronJobNotificationStatus ( bool  $is_cron_notification_enabled)

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

References $is_cron_notification_enabled.

240  : void
241  {
242  $this->is_cron_notification_enabled = $is_cron_notification_enabled;
243  }
bool $is_cron_notification_enabled

◆ setSignature()

ilMailOptions::setSignature ( string  $signature)

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

References $signature.

230  : void
231  {
232  $this->signature = $signature;
233  }

◆ updateOptions()

ilMailOptions::updateOptions ( )

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

References $data, getAbsenceAutoresponderBody(), getAbsenceAutoresponderSubject(), getAbsenceStatus(), getAbsentFrom(), getAbsentUntil(), getEmailAddressMode(), getIncomingType(), getSignature(), ILIAS\Repository\int(), isCronJobNotificationEnabled(), and ILIAS\Repository\settings().

191  : int
192  {
193  $data = [
194  'signature' => ['text', $this->getSignature()],
195  'incoming_type' => ['integer', $this->getIncomingType()],
196  'mail_address_option' => ['integer', $this->getEmailAddressMode()],
197  ];
198 
199  if ($this->settings->get('mail_notification', '0')) {
200  $data['cronjob_notification'] = ['integer', (int) $this->isCronJobNotificationEnabled()];
201  } else {
202  $data['cronjob_notification'] = ['integer', self::lookupNotificationSetting($this->usr_id)];
203  }
204 
205  $data['absence_status'] = ['integer', (int) $this->getAbsenceStatus()];
206  $data['absent_from'] = ['integer', $this->getAbsentFrom()];
207  $data['absent_until'] = ['integer', $this->getAbsentUntil()];
208  $data['absence_ar_subject'] = ['text', $this->getAbsenceAutoresponderSubject()];
209  $data['absence_ar_body'] = ['clob', $this->getAbsenceAutoresponderBody()];
210 
211  return $this->db->replace(
212  $this->table_mail_options,
213  [
214  'user_id' => ['integer', $this->usr_id],
215  ],
216  $data
217  );
218  }
+ Here is the call graph for this function:

Field Documentation

◆ $absence_auto_responder_body

string ilMailOptions::$absence_auto_responder_body = ''
protected

◆ $absence_auto_responder_subject

string ilMailOptions::$absence_auto_responder_subject = ''
protected

◆ $absence_status

bool ilMailOptions::$absence_status = self::ABSENCE_STATUS_PRESENT
protected

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

Referenced by getAbsenceStatus(), and setAbsenceStatus().

◆ $absent_from

int ilMailOptions::$absent_from = 0
protected

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

Referenced by getAbsentFrom(), and setAbsentFrom().

◆ $absent_until

int ilMailOptions::$absent_until = 0
protected

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

Referenced by getAbsentUntil(), and setAbsentUntil().

◆ $clock_service

ClockInterface ilMailOptions::$clock_service
protected

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

◆ $db

ilDBInterface ilMailOptions::$db
protected

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

◆ $default_email_address_mode

int ilMailOptions::$default_email_address_mode = self::FIRST_EMAIL
protected

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

Referenced by __construct().

◆ $default_incoming_type

int ilMailOptions::$default_incoming_type = self::INCOMING_LOCAL
protected

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

Referenced by __construct().

◆ $email_address_mode

int ilMailOptions::$email_address_mode = self::FIRST_EMAIL
protected

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

Referenced by getEmailAddressMode(), and setEmailAddressmode().

◆ $first_mail_address

string ilMailOptions::$first_mail_address = ''
protected

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

Referenced by getExternalEmailAddresses().

◆ $ilias

ILIAS ilMailOptions::$ilias
protected

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

◆ $incoming_type

int ilMailOptions::$incoming_type = self::INCOMING_LOCAL
protected

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

Referenced by getIncomingType(), and setIncomingType().

◆ $is_cron_notification_enabled

bool ilMailOptions::$is_cron_notification_enabled = false
protected

◆ $mail_transport_settings

ilMailTransportSettings ilMailOptions::$mail_transport_settings
protected

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

◆ $second_mail_address

string ilMailOptions::$second_mail_address = ''
protected

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

Referenced by getExternalEmailAddresses().

◆ $settings

ilSetting ilMailOptions::$settings
protected

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

◆ $signature

string ilMailOptions::$signature = ''
protected

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

Referenced by getSignature(), and setSignature().

◆ $table_mail_options

string ilMailOptions::$table_mail_options = 'mail_options'
protected

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

◆ ABSENCE_STATUS_ABSENT

final const bool ilMailOptions::ABSENCE_STATUS_ABSENT = true

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

◆ ABSENCE_STATUS_PRESENT

final const bool ilMailOptions::ABSENCE_STATUS_PRESENT = false

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

◆ BOTH_EMAIL

final const int ilMailOptions::BOTH_EMAIL = 5

◆ FIRST_EMAIL

◆ INCOMING_BOTH

◆ INCOMING_EMAIL

◆ INCOMING_LOCAL

◆ SECOND_EMAIL

final const int ilMailOptions::SECOND_EMAIL = 4

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