1 <?php declare(strict_types=1);
67 $this->db =
$db ?? $DIC->database();
70 $this->incomingType = self::INCOMING_LOCAL;
77 $this->emailAddressMode = self::FIRST_EMAIL;
84 $this->linebreak = self::DEFAULT_LINE_BREAK;
86 $this->signature =
'';
103 $this->table_mail_options,
105 'user_id' => [
'integer', $this->usrId],
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],
122 $this->
settings->get(
'usr_settings_disable_mail_incoming_mail') !==
'1' 128 return $this->
settings->get(
'usr_settings_hide_mail_incoming_mail') !==
'1';
133 return $this->
settings->get(
'show_mail_settings') ===
'1';
136 protected function read() : void
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',
143 'INNER JOIN usr_data ON mail_options.user_id = usr_data.usr_id',
144 'WHERE mail_options.user_id = %s',
146 $res = $this->db->queryF(
151 $row = $this->db->fetchObject(
$res);
153 $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress,
false);
157 $this->firstEmailAddress = (string) $row->email;
158 $this->secondEmailAddress = (
string) $row->second_email;
161 $this->signature = (string) $row->signature;
162 $this->linebreak = (
int) $row->linebreak;
167 $this->incomingType = (int) $row->incoming_type;
168 $this->emailAddressMode = (
int) $row->mail_address_option;
170 if (
false === filter_var(
173 [
'options' => [
'min_range' => self::INCOMING_LOCAL,
'max_range' => self::INCOMING_BOTH]]
175 $this->incomingType = self::INCOMING_LOCAL;
178 if (
false === filter_var(
179 $this->emailAddressMode,
181 [
'options' => [
'min_range' => self::FIRST_EMAIL,
'max_range' => self::BOTH_EMAIL]]
183 $this->emailAddressMode = self::FIRST_EMAIL;
187 $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress);
194 'linebreak' => [
'integer', (int) $this->
getLinebreak()],
199 if ($this->
settings->get(
'mail_notification')) {
205 return $this->db->replace(
206 $this->table_mail_options,
208 'user_id' => [
'integer', $this->usrId]
302 $row = $DIC->database()->fetchAssoc($DIC->database()->queryF(
303 'SELECT cronjob_notification FROM mail_options WHERE user_id = %s',
308 return (
int) $row[
'cronjob_notification'];
316 $emailAddresses = [];
319 case self::SECOND_EMAIL:
320 if (strlen($this->secondEmailAddress)) {
322 } elseif (strlen($this->firstEmailAddress)) {
328 case self::BOTH_EMAIL:
329 if (strlen($this->firstEmailAddress)) {
332 if (strlen($this->secondEmailAddress)) {
337 case self::FIRST_EMAIL:
339 if (strlen($this->firstEmailAddress)) {
341 } elseif (strlen($this->secondEmailAddress)) {
348 return $emailAddresses;
Class ilMailOptions this class handles user mails.
getExternalEmailAddresses()
maySeeIndividualTransportSettings()
createMailOptionsEntry()
create entry in table_mail_options for a new user this method should only be called from createUser()...
$default_email_address_mode
mayModifyIndividualTransportSettings()
$isCronJobNotificationEnabled
lookupNotificationSetting(int $usrId)
mayManageInvididualSettings()
setSignature(string $signature)
__construct(int $usrId, ilMailTransportSettings $mailTransportSettings=null, ilSetting $settings=null, ilDBInterface $db=null)
setLinebreak(int $linebreak)
foreach($_POST as $key=> $value) $res
setIsCronJobNotificationStatus(bool $isCronJobNotificationEnabled)
setEmailAddressMode(int $emailAddressMode)
setIncomingType(int $incomingType)
isCronJobNotificationEnabled()