ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMailOptions Class Reference

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

+ Collaboration diagram for ilMailOptions:

Public Member Functions

 __construct ($a_user_id, 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 ($linebreak)
 
 setSignature ($signature)
 
 setIncomingType ($incoming_type)
 
 setCronjobNotification ($cronjob_notification)
 
 getCronjobNotification ()
 
 getMailAddressOption ()
 
 setMailAddressOption ($mail_address_option)
 

Static Public Member Functions

static getExternalEmailsByUser (ilObjUser $user, ilMailOptions $mail_options=null)
 
static getExternalEmailsByUserId ($user_id, ilMailOptions $mail_options=null)
 

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 ()
 

Static Protected Member Functions

static lookupNotificationSetting ($usr_id)
 
static lookupExternalEmails (ilObjUser $user, ilMailOptions $mail_options)
 

Protected Attributes

 $ilias
 
 $db
 
 $user_id
 
 $settings
 
 $table_mail_options = 'mail_options'
 
 $linebreak
 
 $signature
 
 $cronjob_notification
 
 $incoming_type = self::INCOMING_LOCAL
 
 $mail_address_option = self::FIRST_EMAIL
 

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 (   $a_user_id,
ilMailTransportSettings  $mailTransportSettings = null 
)
Parameters
int$a_user_id
ilMailTransportSettings | null$mailTransportSettings

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

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

83  {
84  global $DIC;
85 
86  $this->user_id = $a_user_id;
87 
88  $this->db = $DIC->database();
89  $this->settings = $DIC->settings();
90 
91  if ($mailTransportSettings === null) {
92  $mailTransportSettings = new ilMailTransportSettings($this);
93  }
94  $this->mailTransportSettings = $mailTransportSettings;
95 
96  $this->read();
97  }
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
+ 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 103 of file class.ilMailOptions.php.

References $mail_address_option, array, and settings().

104  {
105  $incomingMail = strlen($this->settings->get('mail_incoming_mail')) ? (int) $this->settings->get('mail_incoming_mail') : self::INCOMING_LOCAL;
106  $mail_address_option = strlen($this->settings->get('mail_address_option')) ? (int) $this->settings->get('mail_address_option') : self::FIRST_EMAIL;
107 
108  $this->db->replace(
109  $this->table_mail_options,
110  array(
111  'user_id' => array('integer', $this->user_id),
112  ),
113  array(
114  'linebreak' => array('integer', (int) self::DEFAULT_LINE_BREAK),
115  'signature' => array('text', null),
116  'incoming_type' => array('integer', $incomingMail),
117  'mail_address_option' => array('integer', $mail_address_option),
118  'cronjob_notification' => array('integer', 0)
119  )
120  );
121  }
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ getCronjobNotification()

ilMailOptions::getCronjobNotification ( )
Returns
int

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

References $cronjob_notification.

Referenced by updateOptions().

240  {
242  }
+ Here is the caller graph for this function:

◆ getExternalEmailsByUser()

static ilMailOptions::getExternalEmailsByUser ( ilObjUser  $user,
ilMailOptions  $mail_options = null 
)
static
Parameters
ilObjUser$user
ilMailOptions$mail_options
Returns
string[]

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

References ilObject\getId().

Referenced by ilMail\distributeMail(), and ilObjUserGUI\showUpperIcon().

321  {
322  if (!($mail_options instanceof ilMailOptions)) {
323  $mail_options = new self($user->getId());
324  }
325 
326  return self::lookupExternalEmails($user, $mail_options);
327  }
Class ilMailOptions this class handles user mails.
getId()
get object id public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExternalEmailsByUserId()

static ilMailOptions::getExternalEmailsByUserId (   $user_id,
ilMailOptions  $mail_options = null 
)
static
Parameters
int$user_id
ilMailOptions | NULL$mail_options
Returns
string[]

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

References $user_id.

Referenced by ilMailSummaryNotification\__construct().

335  {
336  return self::getExternalEmailsByUser(new ilObjUser($user_id), $mail_options);
337  }
+ Here is the caller graph for this function:

◆ getIncomingType()

ilMailOptions::getIncomingType ( )
Returns
int

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

References $incoming_type.

Referenced by updateOptions().

200  {
201  return $this->incoming_type;
202  }
+ Here is the caller graph for this function:

◆ getLinebreak()

ilMailOptions::getLinebreak ( )
Returns
string

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

References $linebreak.

Referenced by updateOptions().

184  {
185  return $this->linebreak;
186  }
+ Here is the caller graph for this function:

◆ getMailAddressOption()

ilMailOptions::getMailAddressOption ( )
Returns
int

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

References $mail_address_option.

Referenced by lookupExternalEmails(), and updateOptions().

248  {
250  }
+ Here is the caller graph for this function:

◆ getSignature()

ilMailOptions::getSignature ( )
Returns
string

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

References $signature.

Referenced by updateOptions().

192  {
193  return $this->signature;
194  }
+ Here is the caller graph for this function:

◆ lookupExternalEmails()

static ilMailOptions::lookupExternalEmails ( ilObjUser  $user,
ilMailOptions  $mail_options 
)
staticprotected
Parameters
ilObjUser$user
ilMailOptions$mail_options
Returns
string[]

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

References array, ilObjUser\getEmail(), getMailAddressOption(), and ilObjUser\getSecondEmail().

279  {
280  $emailAddresses = array();
281 
282  switch ($mail_options->getMailAddressOption()) {
283  case self::SECOND_EMAIL:
284  if (strlen($user->getSecondEmail())) {
285  $emailAddresses[] = $user->getSecondEmail();
286  } elseif (strlen($user->getEmail())) {
287  // fallback, use first email address
288  $emailAddresses[] = $user->getEmail();
289  }
290  break;
291 
292  case self::BOTH_EMAIL:
293  if (strlen($user->getEmail())) {
294  $emailAddresses[] = $user->getEmail();
295  }
296  if (strlen($user->getSecondEmail())) {
297  $emailAddresses[] = $user->getSecondEmail();
298  }
299  break;
300 
301  case self::FIRST_EMAIL:
302  default:
303  if (strlen($user->getEmail())) {
304  $emailAddresses[] = $user->getEmail();
305  } elseif (strlen($user->getSecondEmail())) {
306  // fallback, use first email address
307  $emailAddresses[] = $user->getSecondEmail();
308  }
309  break;
310  }
311 
312  return $emailAddresses;
313  }
getEmail()
get email address public
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ lookupNotificationSetting()

static ilMailOptions::lookupNotificationSetting (   $usr_id)
staticprotected
Parameters
int$usr_id
Returns
int

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

References $DIC, $query, and $row.

265  {
266  global $DIC;
267 
268  $query = "SELECT cronjob_notification FROM mail_options WHERE user_id = " . $DIC->database()->quote($usr_id, 'integer');
269  $row = $DIC->database()->fetchAssoc($DIC->database()->query($query));
270  return (int) $row['cronjob_notification'];
271  }
global $DIC
Definition: saml.php:7
$query

◆ read()

ilMailOptions::read ( )
protected

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

References $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct().

124  {
125  $res = $this->db->queryF(
126  'SELECT mail_options.cronjob_notification,
127  mail_options.signature,
128  mail_options.linebreak,
129  mail_options.incoming_type,
130  mail_options.mail_address_option,
131  usr_data.email,
132  usr_data.second_email
133  FROM mail_options
134  LEFT JOIN usr_data ON mail_options.user_id = usr_data.usr_id
135  WHERE mail_options.user_id = %s',
136  array('integer'),
137  array($this->user_id)
138  );
140 
141  $this->cronjob_notification = $row->cronjob_notification;
142  $this->signature = $row->signature;
143  $this->linebreak = $row->linebreak;
144  $this->incoming_type = $row->incoming_type;
145  $this->mail_address_option = (int) $row->mail_address_option >= 3 ? $row->mail_address_option : self::FIRST_EMAIL;
146 
147  $firstMailAddress = $row->email;
148 
149  $secondMailAddress = $row->second_email;
150 
151  $this->mailTransportSettings->adjust($firstMailAddress, $secondMailAddress);
152  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setCronjobNotification()

ilMailOptions::setCronjobNotification (   $cronjob_notification)
Returns
int

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

References $cronjob_notification.

232  {
233  $this->cronjob_notification = $cronjob_notification;
234  }

◆ setIncomingType()

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

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

References $incoming_type.

224  {
225  $this->incoming_type = $incoming_type;
226  }

◆ setLinebreak()

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

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

References $linebreak.

208  {
209  $this->linebreak = $linebreak;
210  }

◆ setMailAddressOption()

ilMailOptions::setMailAddressOption (   $mail_address_option)
Parameters
int$mail_address_option

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

References $mail_address_option.

256  {
257  $this->mail_address_option = $mail_address_option;
258  }

◆ setSignature()

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

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

References $signature.

216  {
217  $this->signature = $signature;
218  }

◆ updateOptions()

ilMailOptions::updateOptions ( )

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

References $data, array, getCronjobNotification(), getIncomingType(), getLinebreak(), getMailAddressOption(), getSignature(), and settings().

157  {
158  $data = array(
159  'signature' => array('text', $this->getSignature()),
160  'linebreak' => array('integer', (int) $this->getLinebreak()),
161  'incoming_type' => array('integer', $this->getIncomingType()),
162  'mail_address_option' => array('integer', $this->getMailAddressOption())
163  );
164 
165  if ($this->settings->get('mail_notification')) {
166  $data['cronjob_notification'] = array('integer', (int) $this->getCronjobNotification());
167  } else {
168  $data['cronjob_notification'] = array('integer', (int) self::lookupNotificationSetting($this->user_id));
169  }
170 
171  return $this->db->replace(
172  $this->table_mail_options,
173  array(
174  'user_id' => array('integer', $this->user_id)
175  ),
176  $data
177  );
178  }
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Field Documentation

◆ $cronjob_notification

ilMailOptions::$cronjob_notification
protected

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

Referenced by getCronjobNotification(), and setCronjobNotification().

◆ $db

ilMailOptions::$db
protected

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

◆ $ilias

ilMailOptions::$ilias
protected

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

◆ $incoming_type

ilMailOptions::$incoming_type = self::INCOMING_LOCAL
protected

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

Referenced by getIncomingType(), and setIncomingType().

◆ $linebreak

ilMailOptions::$linebreak
protected

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

Referenced by getLinebreak(), and setLinebreak().

◆ $mail_address_option

ilMailOptions::$mail_address_option = self::FIRST_EMAIL
protected

◆ $mailTransportSettings

ilMailOptions::$mailTransportSettings
private

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

Referenced by __construct().

◆ $settings

ilMailOptions::$settings
protected

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

◆ $signature

ilMailOptions::$signature
protected

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

Referenced by getSignature(), and setSignature().

◆ $table_mail_options

ilMailOptions::$table_mail_options = 'mail_options'
protected

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

◆ $user_id

ilMailOptions::$user_id
protected

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

Referenced by getExternalEmailsByUserId().

◆ 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

const ilMailOptions::INCOMING_EMAIL = 1

◆ INCOMING_LOCAL

◆ SECOND_EMAIL

const ilMailOptions::SECOND_EMAIL = 4

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