53 $this->user_id = $a_user_id;
55 $this->db =
$DIC->database();
73 if (strlen($this->
settings->get(
'mail_incoming_mail',
'')) > 0) {
74 $this->incoming_type = (int) $this->
settings->get(
'mail_incoming_mail');
78 if (strlen($this->
settings->get(
'mail_address_option',
'')) > 0) {
79 $this->mail_address_option = (int) $this->
settings->get(
'mail_address_option');
83 $this->cronjob_notification = 0;
84 $this->signature =
null;
87 $this->table_mail_options,
89 'user_id' => [
'integer', $this->user_id],
92 'linebreak' => [
'integer', $this->linebreak],
93 'signature' => [
'text', $this->signature],
94 'incoming_type' => [
'integer', $this->incoming_type],
95 'mail_address_option' => [
'integer', $this->mail_address_option],
96 'cronjob_notification' => [
'integer', $this->cronjob_notification]
103 $res = $this->db->queryF(
104 'SELECT mail_options.cronjob_notification,
105 mail_options.signature,
106 mail_options.linebreak,
107 mail_options.incoming_type,
108 mail_options.mail_address_option,
110 usr_data.second_email
112 LEFT JOIN usr_data ON mail_options.user_id = usr_data.usr_id
113 WHERE mail_options.user_id = %s',
115 array($this->user_id)
117 $row = $this->db->fetchObject(
$res);
120 $this->cronjob_notification = (int)
$row->cronjob_notification;
121 $this->signature =
$row->signature;
122 $this->linebreak = (
int)
$row->linebreak;
123 $this->incoming_type = (int)
$row->incoming_type;
124 $this->mail_address_option = (
int)
$row->mail_address_option;
128 $this->incoming_type,
130 [
'options' => [
'min_range' => self::INCOMING_LOCAL,
'max_range' => self::INCOMING_BOTH]]
138 $this->mail_address_option,
140 [
'options' => [
'min_range' => self::FIRST_EMAIL,
'max_range' => self::BOTH_EMAIL]]
146 $firstMailAddress = (string)
$row->email;
147 $secondMailAddress = (
string)
$row->second_email;
149 $this->mailTransportSettings->adjust($firstMailAddress, $secondMailAddress);
157 'linebreak' => [
'integer', (int) $this->
getLinebreak()],
162 if ($this->
settings->get(
'mail_notification')) {
165 $data[
'cronjob_notification'] = [
'integer', (int) self::lookupNotificationSetting($this->user_id)];
168 return $this->db->replace(
169 $this->table_mail_options,
171 'user_id' => [
'integer', $this->user_id]
265 $query =
"SELECT cronjob_notification FROM mail_options WHERE user_id = " .
$DIC->database()->quote($usr_id,
'integer');
267 return (
int)
$row[
'cronjob_notification'];
277 $emailAddresses = array();
281 if (strlen(
$user->getSecondEmail())) {
282 $emailAddresses[] =
$user->getSecondEmail();
283 } elseif (strlen(
$user->getEmail())) {
285 $emailAddresses[] =
$user->getEmail();
290 if (strlen(
$user->getEmail())) {
291 $emailAddresses[] =
$user->getEmail();
293 if (strlen(
$user->getSecondEmail())) {
294 $emailAddresses[] =
$user->getSecondEmail();
300 if (strlen(
$user->getEmail())) {
301 $emailAddresses[] =
$user->getEmail();
302 } elseif (strlen(
$user->getSecondEmail())) {
304 $emailAddresses[] =
$user->getSecondEmail();
309 return $emailAddresses;
320 $mail_options =
new self(
$user->getId());
An exception for terminatinating execution or to throw for unit testing.
Class ilMailOptions this class handles user mails.
static lookupExternalEmails(ilObjUser $user, ilMailOptions $mail_options)
__construct($a_user_id, ilMailTransportSettings $mailTransportSettings=null)
static getExternalEmailsByUser(ilObjUser $user, ilMailOptions $mail_options=null)
createMailOptionsEntry()
create entry in table_mail_options for a new user this method should only be called from createUser()
setIncomingType($incoming_type)
static getExternalEmailsByUserId($user_id, ilMailOptions $mail_options=null)
setCronjobNotification($cronjob_notification)
setMailAddressOption($mail_address_option)
static lookupNotificationSetting($usr_id)
foreach($_POST as $key=> $value) $res