19 declare(strict_types=1);
59 $this->db = $db ?? $DIC->database();
60 $this->
settings = $settings ?? $DIC->settings();
63 $this->incomingType = self::INCOMING_LOCAL;
64 $default_incoming_type = $this->
settings->get(
'mail_incoming_mail',
'');
65 if ($default_incoming_type !==
'') {
66 $this->default_incoming_type = (
int) $default_incoming_type;
70 $this->emailAddressMode = self::FIRST_EMAIL;
71 $default_email_address_mode = $this->
settings->get(
'mail_address_option',
'');
72 if ($default_email_address_mode !==
'') {
73 $this->default_email_address_mode = (
int) $default_email_address_mode;
77 $this->linebreak = self::DEFAULT_LINE_BREAK;
79 $this->signature =
'';
91 $this->table_mail_options,
93 'user_id' => [
'integer', $this->usrId],
96 'linebreak' => [
'integer', $this->linebreak],
97 'signature' => [
'text', $this->signature],
98 'incoming_type' => [
'integer', $this->default_incoming_type],
99 'mail_address_option' => [
'integer', $this->default_email_address_mode],
110 $this->
settings->get(
'usr_settings_disable_mail_incoming_mail') !==
'1' 116 return $this->
settings->get(
'usr_settings_hide_mail_incoming_mail') !==
'1';
121 return $this->
settings->get(
'show_mail_settings') ===
'1';
124 protected function read(): void
127 'SELECT mail_options.cronjob_notification,',
128 'mail_options.signature, mail_options.linebreak, mail_options.incoming_type,',
129 'mail_options.mail_address_option, usr_data.email, usr_data.second_email',
131 'INNER JOIN usr_data ON mail_options.user_id = usr_data.usr_id',
132 'WHERE mail_options.user_id = %s',
134 $res = $this->db->queryF(
139 $row = $this->db->fetchObject(
$res);
141 $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress,
false);
145 $this->firstEmailAddress = (string) $row->email;
146 $this->secondEmailAddress = (
string) $row->second_email;
148 $this->signature = (string) $row->signature;
149 $this->linebreak = (
int) $row->linebreak;
154 $this->incomingType = (
int) $row->incoming_type;
155 $this->emailAddressMode = (
int) $row->mail_address_option;
157 if (
false === filter_var(
160 [
'options' => [
'min_range' => self::INCOMING_LOCAL,
'max_range' => self::INCOMING_BOTH]]
162 $this->incomingType = self::INCOMING_LOCAL;
165 if (
false === filter_var(
166 $this->emailAddressMode,
168 [
'options' => [
'min_range' => self::FIRST_EMAIL,
'max_range' => self::BOTH_EMAIL]]
170 $this->emailAddressMode = self::FIRST_EMAIL;
174 $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress);
186 if ($this->
settings->get(
'mail_notification',
'0')) {
192 return $this->db->replace(
193 $this->table_mail_options,
195 'user_id' => [
'integer', $this->usrId],
255 $row = $DIC->database()->fetchAssoc($DIC->database()->queryF(
256 'SELECT cronjob_notification FROM mail_options WHERE user_id = %s',
261 return (
int) $row[
'cronjob_notification'];
269 $emailAddresses = [];
272 case self::SECOND_EMAIL:
273 if ($this->secondEmailAddress !==
'') {
275 } elseif ($this->firstEmailAddress !==
'') {
281 case self::BOTH_EMAIL:
282 if ($this->firstEmailAddress !==
'') {
285 if ($this->secondEmailAddress !==
'') {
290 case self::FIRST_EMAIL:
292 if ($this->firstEmailAddress !==
'') {
294 } elseif ($this->secondEmailAddress !==
'') {
301 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()...
Class ChatMainBarProvider .
mayModifyIndividualTransportSettings()
string $firstEmailAddress
mayManageInvididualSettings()
setSignature(string $signature)
bool $isCronJobNotificationEnabled
__construct(int $usrId, ilMailTransportSettings $mailTransportSettings=null, ilSetting $settings=null, ilDBInterface $db=null)
setLinebreak(int $linebreak)
int $default_email_address_mode
setIsCronJobNotificationStatus(bool $isCronJobNotificationEnabled)
string $table_mail_options
ilMailTransportSettings $mailTransportSettings
setEmailAddressMode(int $emailAddressMode)
setIncomingType(int $incomingType)
isCronJobNotificationEnabled()
string $secondEmailAddress
static lookupNotificationSetting(int $usrId)
int $default_incoming_type