ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailOptions Class Reference

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

+ Collaboration diagram for ilMailOptions:

Public Member Functions

 __construct (int $usrId, ilMailTransportSettings $mailTransportSettings=null)
 
 createMailOptionsEntry ()
 create entry in table_mail_options for a new user this method should only be called from createUser() More...
 
 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 ()
 

Protected Attributes

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

Static Private Member Functions

static lookupNotificationSetting (int $usrId)
 

Private Attributes

 $mailTransportSettings
 

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 
)
Parameters
int$usrId
ilMailTransportSettings | null$mailTransportSettings

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

References $DIC, $mailTransportSettings, $usrId, read(), and settings().

54  {
55  global $DIC;
56 
57  $this->usrId = $usrId;
58 
59  $this->db = $DIC->database();
60  $this->settings = $DIC->settings();
61 
62  if ($mailTransportSettings === null) {
63  $mailTransportSettings = new ilMailTransportSettings($this);
64  }
65  $this->mailTransportSettings = $mailTransportSettings;
66 
67  $this->read();
68  }
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46
+ 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 74 of file class.ilMailOptions.php.

References isCronJobNotificationEnabled(), and settings().

74  : void
75  {
76  $this->incomingType = self::INCOMING_LOCAL;
77  if (strlen($this->settings->get('mail_incoming_mail', '')) > 0) {
78  $this->incomingType = (int) $this->settings->get('mail_incoming_mail');
79  }
80 
81  $this->emailAddressMode = self::FIRST_EMAIL;
82  if (strlen($this->settings->get('mail_address_option', '')) > 0) {
83  $this->emailAddressMode = (int) $this->settings->get('mail_address_option');
84  }
85 
86  $this->linebreak = self::DEFAULT_LINE_BREAK;
87  $this->isCronJobNotificationEnabled = false;
88  $this->signature = '';
89 
90  $this->db->replace(
91  $this->table_mail_options,
92  [
93  'user_id' => ['integer', $this->usrId],
94  ],
95  [
96  'linebreak' => ['integer', $this->linebreak],
97  'signature' => ['text', $this->signature],
98  'incoming_type' => ['integer', $this->incomingType],
99  'mail_address_option' => ['integer', $this->emailAddressMode],
100  'cronjob_notification' => ['integer', (int) $this->isCronJobNotificationEnabled]
101  ]
102  );
103  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ getEmailAddressMode()

ilMailOptions::getEmailAddressMode ( )
Returns
int

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

References $emailAddressMode.

Referenced by getExternalEmailAddresses(), and updateOptions().

242  : int
243  {
245  }
+ Here is the caller graph for this function:

◆ getExternalEmailAddresses()

ilMailOptions::getExternalEmailAddresses ( )
Returns
string[]

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

References $firstEmailAddress, $secondEmailAddress, and getEmailAddressMode().

275  : array
276  {
277  $emailAddresses = [];
278 
279  switch ($this->getEmailAddressMode()) {
280  case self::SECOND_EMAIL:
281  if (strlen($this->secondEmailAddress)) {
282  $emailAddresses[] = $this->secondEmailAddress;
283  } elseif (strlen($this->firstEmailAddress)) {
284  // fallback, use first email address
285  $emailAddresses[] = $this->firstEmailAddress;
286  }
287  break;
288 
289  case self::BOTH_EMAIL:
290  if (strlen($this->firstEmailAddress)) {
291  $emailAddresses[] = $this->firstEmailAddress;
292  }
293  if (strlen($this->secondEmailAddress)) {
294  $emailAddresses[] = $this->secondEmailAddress;
295  }
296  break;
297 
298  case self::FIRST_EMAIL:
299  default:
300  if (strlen($this->firstEmailAddress)) {
301  $emailAddresses[] = $this->firstEmailAddress;
302  } elseif (strlen($this->secondEmailAddress)) {
303  // fallback, use first email address
304  $emailAddresses[] = $this->secondEmailAddress;
305  }
306  break;
307  }
308 
309  return $emailAddresses;
310  }
+ Here is the call graph for this function:

◆ getIncomingType()

ilMailOptions::getIncomingType ( )
Returns
int

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

References $incomingType.

Referenced by updateOptions().

194  : int
195  {
196  return $this->incomingType;
197  }
+ Here is the caller graph for this function:

◆ getLinebreak()

ilMailOptions::getLinebreak ( )
Returns
int

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

References $linebreak.

Referenced by updateOptions().

178  : int
179  {
180  return $this->linebreak;
181  }
+ Here is the caller graph for this function:

◆ getSignature()

ilMailOptions::getSignature ( )
Returns
string

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

References $signature.

Referenced by updateOptions().

186  : string
187  {
188  return $this->signature;
189  }
+ Here is the caller graph for this function:

◆ isCronJobNotificationEnabled()

ilMailOptions::isCronJobNotificationEnabled ( )
Returns
bool

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

References $isCronJobNotificationEnabled.

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

234  : bool
235  {
237  }
+ Here is the caller graph for this function:

◆ lookupNotificationSetting()

static ilMailOptions::lookupNotificationSetting ( int  $usrId)
staticprivate
Parameters
int$usrId
Returns
int

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

References $DIC.

259  : int
260  {
261  global $DIC;
262 
263  $row = $DIC->database()->fetchAssoc($DIC->database()->queryF(
264  'SELECT cronjob_notification FROM mail_options WHERE user_id = %s',
265  ['integer'],
266  [$usrId]
267  ));
268 
269  return (int) $row['cronjob_notification'];
270  }
$DIC
Definition: xapitoken.php:46

◆ read()

ilMailOptions::read ( )
protected

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

References $query, $res, if, and isCronJobNotificationEnabled().

Referenced by __construct().

105  : void
106  {
107  $query = implode(' ', [
108  'SELECT mail_options.cronjob_notification,',
109  'mail_options.signature, mail_options.linebreak, mail_options.incoming_type,',
110  'mail_options.mail_address_option, usr_data.email, usr_data.second_email',
111  'FROM mail_options',
112  'LEFT JOIN usr_data ON mail_options.user_id = usr_data.usr_id',
113  'WHERE mail_options.user_id = %s',
114  ]);
115  $res = $this->db->queryF(
116  $query,
117  ['integer'],
118  [$this->usrId]
119  );
120  $row = $this->db->fetchObject($res);
121  if ($row !== null) {
122  $this->isCronJobNotificationEnabled = (bool) $row->cronjob_notification;
123  $this->signature = (string) $row->signature;
124  $this->linebreak = (int) $row->linebreak;
125  $this->incomingType = (int) $row->incoming_type;
126  $this->emailAddressMode = (int) $row->mail_address_option;
127 
128  if (false === filter_var(
129  $this->incomingType,
130  FILTER_VALIDATE_INT,
131  ['options' => ['min_range' => self::INCOMING_LOCAL, 'max_range' => self::INCOMING_BOTH]]
132  )) {
133  $this->incomingType = self::INCOMING_LOCAL;
134  }
135 
136  if (false === filter_var(
137  $this->emailAddressMode,
138  FILTER_VALIDATE_INT,
139  ['options' => ['min_range' => self::FIRST_EMAIL, 'max_range' => self::BOTH_EMAIL]]
140  )) {
141  $this->emailAddressMode = self::FIRST_EMAIL;
142  }
143 
144  $this->firstEmailAddress = (string) $row->email;
145  $this->secondEmailAddress = (string) $row->second_email;
146 
147  $this->mailTransportSettings->adjust($this->firstEmailAddress, $this->secondEmailAddress);
148  }
149  }
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
foreach($_POST as $key=> $value) $res
$query
+ 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 250 of file class.ilMailOptions.php.

References $emailAddressMode.

250  : void
251  {
252  $this->emailAddressMode = $emailAddressMode;
253  }

◆ setIncomingType()

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

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

References $incomingType.

218  : void
219  {
220  $this->incomingType = $incomingType;
221  }

◆ setIsCronJobNotificationStatus()

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

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

References $isCronJobNotificationEnabled, and isCronJobNotificationEnabled().

226  : void
227  {
229  }
+ Here is the call graph for this function:

◆ setLinebreak()

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

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

References $linebreak.

202  : void
203  {
204  $this->linebreak = $linebreak;
205  }

◆ setSignature()

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

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

References $signature.

210  : void
211  {
212  $this->signature = $signature;
213  }

◆ updateOptions()

ilMailOptions::updateOptions ( )

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

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

152  {
153  $data = [
154  'signature' => ['text', $this->getSignature()],
155  'linebreak' => ['integer', (int) $this->getLinebreak()],
156  'incoming_type' => ['integer', $this->getIncomingType()],
157  'mail_address_option' => ['integer', $this->getEmailAddressMode()]
158  ];
159 
160  if ($this->settings->get('mail_notification')) {
161  $data['cronjob_notification'] = ['integer', (int) $this->isCronJobNotificationEnabled()];
162  } else {
163  $data['cronjob_notification'] = ['integer', (int) self::lookupNotificationSetting($this->usrId)];
164  }
165 
166  return $this->db->replace(
167  $this->table_mail_options,
168  [
169  'user_id' => ['integer', $this->usrId]
170  ],
171  $data
172  );
173  }
settings()
Definition: settings.php:2
$data
Definition: storeScorm.php:23
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilMailOptions::$db
protected

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

◆ $emailAddressMode

ilMailOptions::$emailAddressMode = self::FIRST_EMAIL
protected

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

Referenced by getEmailAddressMode(), and setEmailAddressMode().

◆ $firstEmailAddress

ilMailOptions::$firstEmailAddress = ''
protected

Definition at line 45 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
private

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

Referenced by __construct().

◆ $secondEmailAddress

ilMailOptions::$secondEmailAddress = ''
protected

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

Referenced by getExternalEmailAddresses().

◆ $settings

ilMailOptions::$settings
protected

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

◆ $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().

◆ BOTH_EMAIL

const ilMailOptions::BOTH_EMAIL = 5

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

Referenced by ilIncomingMailInputGUI\addSubOptions().

◆ DEFAULT_LINE_BREAK

const ilMailOptions::DEFAULT_LINE_BREAK = 60

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

◆ 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: