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

This class handles base functions for mail handling. More...

+ Inheritance diagram for ilMail:
+ Collaboration diagram for ilMail:

Public Member Functions

 __construct ( $a_user_id, ilMailAddressTypeFactory $mailAddressTypeFactory=null, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
 
 __get ($name)
 Magic interceptor method __get Used to include files / instantiate objects at runtime. More...
 
 existsRecipient ($a_recipient, $a_existing_recipients)
 
 enableSOAP ($a_status)
 Define if external mails should be sent using SOAP client or not. More...
 
 isSOAPEnabled ()
 
 setSaveInSentbox ($a_save_in_sentbox)
 
 getSaveInSentbox ()
 
 getMailObjectReferenceId ()
 
 formatNamesForOutput ($a_recipients)
 Prepends the fullname of each ILIAS login name (if user has a public profile) found in the passed string and brackets the ILIAS login name afterwards. More...
 
 getPreviousMail ($a_mail_id)
 
 getNextMail ($a_mail_id)
 
 getMailsOfFolder ($a_folder_id, $filter=array())
 
 countMailsOfFolder ($a_folder_id)
 
 deleteMailsOfFolder ($a_folder_id)
 
 getMail ($a_mail_id)
 
 markRead (array $a_mail_ids)
 
 markUnread (array $a_mail_ids)
 
 moveMailsToFolder (array $a_mail_ids, $a_folder_id)
 
 deleteMails (array $a_mail_ids)
 
 getNewDraftId ($usrId, $folderId)
 
 updateDraft ( $a_folder_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_draft_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
 
 sendInternalMail ( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
 save mail in folder private More...
 
 savePostData ( $a_user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_use_placeholders, $a_tpl_context_id=null, $a_tpl_ctx_params=array())
 save post data in table public More...
 
 getSavedData ()
 
 sendMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $a_type, $a_use_placeholders=0)
 Should be used to send notifcations over the internal or external mail channel. More...
 
 validateRecipients ($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
 
 saveAttachments ($a_attachments)
 
 appendInstallationSignature ($a_flag=null)
 Setter/Getter for appending the installation signarue. More...
 
 formatLinebreakMessage ($a_message)
 

Static Public Member Functions

static _getAutoGeneratedMessageString (ilLanguage $lang=null)
 Get auto generated info string. More...
 
static _getInstallationSignature ()
 
static getSubjectPrefix ()
 Get text that will be prepended to auto generated mails. More...
 
static getSalutation ($a_usr_id, ilLanguage $a_language=null)
 

Data Fields

const ILIAS_HOST = 'ilias'
 
const MAIL_SUBJECT_PREFIX = '[ILIAS]'
 
 $user_id
 

Protected Member Functions

 isSystemMail ()
 
 readMailObjectReferenceId ()
 Read and set the mail object ref id (administration node) More...
 
 fetchMailData ($a_row)
 
 replacePlaceholders ($a_message, $a_user_id=0, $replace_empty=true)
 
 distributeMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_subject, $a_message, $a_attachments, $sent_mail_id, $a_type, $a_action, $a_use_placeholders=0)
 
 getUserIds (array $a_recipients)
 
 checkMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject)
 
 checkRecipients ($a_recipients)
 Check if recipients are valid. More...
 
 saveInSentbox ($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
 Stores a message in the sent bod of the current user. More...
 
 parseAddresses ($addresses)
 Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAddress instances. More...
 
 getCountRecipient ($a_recipients, $a_only_email=true)
 
 getCountRecipients ($a_to, $a_cc, $a_bcc, $a_only_email=true)
 
 getEmailRecipients ($a_recipients)
 

Static Protected Member Functions

static getCachedUserInstance ($a_usr_id)
 

Protected Attributes

 $lng
 
 $db
 
 $mfile
 
 $mail_options
 
 $table_mail
 
 $table_mail_saved
 
 $mail_data = array()
 
 $mail_obj_ref_id
 
 $save_in_sentbox
 
 $soap_enabled = true
 
 $mail_to_global_roles = 0
 
 $appendInstallationSignature = false
 
 $properties = array()
 

Static Protected Attributes

static $userInstances = array()
 

Private Attributes

 $mailAddressTypeFactory
 
 $mailAddressParserFactory
 

Detailed Description

This class handles base functions for mail handling.

RFC 822 compliant email addresses

ILIAS is enabled to use standards compliant email addresses. The class supports RFC 822 compliant address lists as specified in http://www.ietf.org/rfc/rfc0822.txt

Examples: The following mailbox addresses work for sending an email to the user with the login john.doe and email address jd@ma.nosp@m.il.c.nosp@m.om. The user is member of the course "French Course". The member role of the course object has the name "il_crs_member_998" and the object ID "1000".

john.doe John Doe <john.doe> john.doe #member@[French Course] #il_crs_member_998 #il_role_1000 jd@ma.nosp@m.il.c.nosp@m.om John Doe jd@ma.nosp@m.il.c.nosp@m.om

Syntax Rules: The following excerpt from chapter 6.1 "Syntax" of RFC 822 is relevant for the semantics described below:

addr-spec = local-part [ "@", domain ]

Semantics: User account mailbox address:

  • The local-part denotes the login of an ILIAS user account.
  • The domain denotes the current ILIAS client.
  • The local-part must not start with a "#" character
  • The domain must be omitted or must have the value "ilias"

Role object mailbox address:

  • The local part denotes the title of an ILIAS role.
  • The domain denotes the title of an ILIAS object.
  • The local-part must start with a "#" character.
  • If the domain is omitted, the title "ilias" is assumed.
  • If the local-part starts with "#il_role_" its remaining characters directly specify the object id of the role. For example "#il_role_1234 identifies the role with object id "1234".
  • If the object title identifies an object that is an ILIAS role, then the local-part is ignored.
  • If the object title identifies an object that is not an ILIAS role, then the local-part is used to identify a local role for that object.
  • The local-part can be a substring of the role name. For example, "#member" can be used instead of "#il_crs_member_1234".

External Email address:

  • The local-part must not start with a "#" character
  • The domain must be specified and it must not have the value "ilias"
Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 66 of file class.ilMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilMail::__construct (   $a_user_id,
ilMailAddressTypeFactory  $mailAddressTypeFactory = null,
ilMailRfc822AddressParserFactory  $mailAddressParserFactory = null 
)
Parameters
integer$a_user_id
ilMailAddressTypeFactory | null$mailAddressTypeFactory
ilMailRfc822AddressParserFactory | null$mailAddressParserFactory

Definition at line 127 of file class.ilMail.php.

References $DIC, $mailAddressParserFactory, $mailAddressTypeFactory, readMailObjectReferenceId(), and setSaveInSentbox().

131  {
132  global $DIC;
133 
134  require_once 'Services/Mail/classes/class.ilFileDataMail.php';
135  require_once 'Services/Mail/classes/class.ilMailOptions.php';
136 
137  if ($mailAddressTypeFactory === null) {
138  $mailAddressTypeFactory = new ilMailAddressTypeFactory();
139  }
140 
141  if ($mailAddressParserFactory === null) {
142  $mailAddressParserFactory = new ilMailRfc822AddressParserFactory();
143  }
144 
145  $this->mailAddressParserFactory = $mailAddressParserFactory;
146  $this->mailAddressTypeFactory = $mailAddressTypeFactory;
147 
148  $this->lng = $DIC->language();
149  $this->db = $DIC->database();
150 
151  $this->lng->loadLanguageModule('mail');
152 
153  $this->table_mail = 'mail';
154  $this->table_mail_saved = 'mail_saved';
155 
156  $this->user_id = $a_user_id;
157 
158  $this->mfile = new ilFileDataMail($this->user_id);
159  $this->mail_options = new ilMailOptions($a_user_id);
160 
161  $this->setSaveInSentbox(false);
162  $this->readMailObjectReferenceId();
163  }
Class ilMailOptions this class handles user mails.
global $DIC
Definition: saml.php:7
This class handles all operations on files (attachments) in directory ilias_data/mail.
setSaveInSentbox($a_save_in_sentbox)
$mailAddressParserFactory
Class ilMailRfc822AddressParserFactory.
$mailAddressTypeFactory
Class ilMailAddressTypeFactory.
readMailObjectReferenceId()
Read and set the mail object ref id (administration node)
+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

ilMail::__get (   $name)

Magic interceptor method __get Used to include files / instantiate objects at runtime.

Parameters
string$nameThe name of the class property
Returns
ilMailingLists

Definition at line 179 of file class.ilMail.php.

References $DIC, $name, and properties.

180  {
181  global $DIC;
182 
183  if (isset($this->properties[$name])) {
184  return $this->properties[$name];
185  }
186 
187  if ($name == 'mlists') {
188  if (is_object($DIC->user())) {
189  require_once 'Services/Contact/classes/class.ilMailingLists.php';
190  $this->properties[$name] = new ilMailingLists($DIC->user());
191  return $this->properties[$name];
192  }
193  }
194  }
global $DIC
Definition: saml.php:7
if($format !==null) $name
Definition: metadata.php:146
Set document properties

◆ _getAutoGeneratedMessageString()

static ilMail::_getAutoGeneratedMessageString ( ilLanguage  $lang = null)
static

Get auto generated info string.

Parameters
ilLanguage$lang
Returns
string;

Definition at line 1613 of file class.ilMail.php.

References $DIC, $GLOBALS, $lang, ilUtil\_getHttpPath(), and ilLanguageFactory\_getLanguage().

Referenced by ilMailSummaryNotification\__construct(), ilECSAppEventListener\_sendNotification(), ilSystemNotification\compose(), ilECSObjectSettings\sendNewContentNotification(), ilRemoteObjectBase\sendNewContentNotification(), and ilAuthContainerECS\sendNotification().

1614  {
1615  global $DIC;
1616 
1617  if (!($lang instanceof ilLanguage)) {
1618  require_once 'Services/Language/classes/class.ilLanguageFactory.php';
1620  }
1621 
1622  $lang->loadLanguageModule('mail');
1623 
1624  return sprintf(
1625  $lang->txt('mail_auto_generated_info'),
1626  $DIC->settings()->get('inst_name', 'ILIAS 5'),
1628  ) . "\n\n";
1629  }
global $DIC
Definition: saml.php:7
static _getLanguage($a_lang_key='')
Get langauge object.
static _getHttpPath()
loadLanguageModule($a_module)
language handling
txt($a_topic, $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getInstallationSignature()

static ilMail::_getInstallationSignature ( )
static
Returns
string The installation mail signature

Definition at line 1661 of file class.ilMail.php.

References $DIC, and ilUtil\_getHttpPath().

Referenced by ilRegistrationMimeMailNotification\__construct(), ilMailSummaryNotification\__construct(), ilSystemNotification\compose(), ilCronDeleteInactiveUserReminderMailNotification\send(), ilMailCronOrphanedMailsNotification\send(), ilForumMailNotification\send(), ilAccountRegistrationMail\sendLanguageVariableBasedAccountMail(), and ilObjSurveyGUI\sendUserResultsMail().

1662  {
1663  global $DIC;
1664 
1665  $signature = $DIC->settings()->get('mail_system_sys_signature');
1666 
1667  $clientUrl = ilUtil::_getHttpPath();
1668  $clientdirs = glob(ILIAS_WEB_DIR . '/*', GLOB_ONLYDIR);
1669  if (is_array($clientdirs) && count($clientdirs) > 1) {
1670  $clientUrl .= '/login.php?client_id=' . CLIENT_ID; // #18051
1671  }
1672 
1673  $signature = str_ireplace('[CLIENT_NAME]', $DIC['ilClientIniFile']->readVariable('client', 'name'), $signature);
1674  $signature = str_ireplace('[CLIENT_DESC]', $DIC['ilClientIniFile']->readVariable('client', 'description'), $signature);
1675  $signature = str_ireplace('[CLIENT_URL]', $clientUrl, $signature);
1676 
1677  if (!preg_match('/^[\n\r]+/', $signature)) {
1678  $signature = "\n" . $signature;
1679  }
1680 
1681  return $signature;
1682  }
global $DIC
Definition: saml.php:7
static _getHttpPath()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendInstallationSignature()

ilMail::appendInstallationSignature (   $a_flag = null)

Setter/Getter for appending the installation signarue.

Parameters
mixedboolean or nothing
Returns
mixed boolean if called without passing any params, otherwise $this

Definition at line 1648 of file class.ilMail.php.

References $appendInstallationSignature.

Referenced by sendMail().

1649  {
1650  if (null === $a_flag) {
1652  }
1653 
1654  $this->appendInstallationSignature = $a_flag;
1655  return $this;
1656  }
$appendInstallationSignature
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
+ Here is the caller graph for this function:

◆ checkMail()

ilMail::checkMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_m_subject 
)
protected
Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
string$a_m_subject
Returns
array message

Definition at line 1104 of file class.ilMail.php.

References $errors, and array.

Referenced by sendMail().

1105  {
1106  $errors = array();
1107  foreach (array(
1108  $a_m_subject => array('mail_add_subject'),
1109  $a_rcp_to => array('mail_add_recipient')
1110  ) as $string => $e) {
1111  if (strlen($string) === 0) {
1112  $errors[] = $e;
1113  }
1114  }
1115 
1116  return $errors;
1117  }
Create styles array
The data for the language used.
$errors
Definition: index.php:6
+ Here is the caller graph for this function:

◆ checkRecipients()

ilMail::checkRecipients (   $a_recipients)
protected

Check if recipients are valid.

Parameters
string$a_recipientsstring with login names or group names (start with #)
string$a_type
Returns
array Returns an empty array, if all recipients are okay. Returns an array with invalid recipients, if some are not okay.
Exceptions
ilMailException

Definition at line 1126 of file class.ilMail.php.

References $errors, array, and parseAddresses().

Referenced by validateRecipients().

1127  {
1128  $errors = array();
1129 
1130  try {
1131  $recipients = $this->parseAddresses($a_recipients);
1132  foreach ($recipients as $recipient) {
1133  $address_type = $this->mailAddressTypeFactory->getByPrefix($recipient);
1134  if (!$address_type->validate($this->user_id)) {
1135  $errors = array_merge($errors, $address_type->getErrors());
1136  }
1137  }
1138  } catch (ilException $e) {
1139  $colon_pos = strpos($e->getMessage(), ':');
1140  throw new ilMailException(($colon_pos === false) ? $e->getMessage() : substr($e->getMessage(), $colon_pos + 2));
1141  }
1142 
1143  return $errors;
1144  }
Class ilMailException.
Create styles array
The data for the language used.
$errors
Definition: index.php:6
parseAddresses($addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39; Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ countMailsOfFolder()

ilMail::countMailsOfFolder (   $a_folder_id)
Parameters
int$a_folder_id
Returns
int

Definition at line 407 of file class.ilMail.php.

References $res, and array.

408  {
409  $res = $this->db->queryF(
410  "
411  SELECT COUNT(*) FROM {$this->table_mail}
412  WHERE user_id = %s AND folder_id = %s",
413  array('integer', 'integer'),
414  array($this->user_id, $a_folder_id)
415  );
416 
417  return $this->db->numRows($res);
418  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.

◆ deleteMails()

ilMail::deleteMails ( array  $a_mail_ids)
Parameters
array$a_mail_ids
Returns
bool

Definition at line 570 of file class.ilMail.php.

References $id, and array.

Referenced by deleteMailsOfFolder(), and sendMail().

571  {
572  foreach ($a_mail_ids as $id) {
573  $this->db->manipulateF(
574  "
575  DELETE FROM {$this->table_mail}
576  WHERE user_id = %s AND mail_id = %s ",
577  array('integer', 'integer'),
578  array($this->user_id, $id)
579  );
580  $this->mfile->deassignAttachmentFromDirectory($id);
581  }
582 
583  return true;
584  }
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ deleteMailsOfFolder()

ilMail::deleteMailsOfFolder (   $a_folder_id)
Parameters
int$a_folder_idid of folder
Returns
bool

Definition at line 424 of file class.ilMail.php.

References $mail_data, array, deleteMails(), and getMailsOfFolder().

425  {
426  if ($a_folder_id) {
427  $mails = $this->getMailsOfFolder($a_folder_id);
428  foreach ((array) $mails as $mail_data) {
429  $this->deleteMails(array($mail_data['mail_id']));
430  }
431 
432  return true;
433  }
434 
435  return false;
436  }
deleteMails(array $a_mail_ids)
Create styles array
The data for the language used.
getMailsOfFolder($a_folder_id, $filter=array())
+ Here is the call graph for this function:

◆ distributeMail()

ilMail::distributeMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_subject,
  $a_message,
  $a_attachments,
  $sent_mail_id,
  $a_type,
  $a_action,
  $a_use_placeholders = 0 
)
protected
Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
string$a_subject
string$a_message
array$a_attachments
integer$sent_mail_id
array$a_type
array$a_action
array | int$a_use_placeholders
Returns
bool

Definition at line 811 of file class.ilMail.php.

References $a_type, $email, $id, array, formatLinebreakMessage(), ilMailOptions\getExternalEmailsByUser(), ilLoggerFactory\getLogger(), getUserIds(), ilMailOptions\INCOMING_BOTH, ilMailOptions\INCOMING_EMAIL, replacePlaceholders(), and sendInternalMail().

Referenced by sendMail().

812  {
813  require_once 'Services/Mail/classes/class.ilMailbox.php';
814  require_once 'Services/User/classes/class.ilObjUser.php';
815 
816  $mbox = new ilMailbox();
817  if (!$a_use_placeholders) {
818  $rcp_ids = $this->getUserIds(array($a_rcp_to, $a_rcp_cc, $a_rcp_bcc));
819 
820  ilLoggerFactory::getLogger('mail')->debug(sprintf(
821  "Parsed TO/CC/BCC user ids from given recipients: %s",
822  implode(', ', $rcp_ids)
823  ));
824 
825  $as_email = array();
826 
827  foreach ($rcp_ids as $id) {
828  $tmp_mail_options = new ilMailOptions($id);
829 
830  $tmp_user = self::getCachedUserInstance($id);
831  $user_is_active = $tmp_user->getActive();
832  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
833 
834  if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
835  ilLoggerFactory::getLogger('mail')->debug(sprintf(
836  "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
837  $id,
838  var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
839  var_export(!$tmp_user->checkTimeLimit(), 1)
840  ));
841  continue;
842  }
843 
844  if ($user_is_active) {
845  if (!$user_can_read_internal_mails
846  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL
847  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_BOTH) {
848  $newEmailAddresses = ilMailOptions::getExternalEmailsByUser($tmp_user, $tmp_mail_options);
849  $as_email = array_unique(array_merge($newEmailAddresses, $as_email));
850 
851  if ($tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL) {
852  ilLoggerFactory::getLogger('mail')->debug(sprintf(
853  "Recipient with id %s will only receive external emails sent to: %s",
854  $id,
855  implode(', ', $newEmailAddresses)
856  ));
857  continue;
858  } else {
859  ilLoggerFactory::getLogger('mail')->debug(sprintf(
860  "Recipient with id %s will additionally receive external emails sent to: %s",
861  $id,
862  implode(', ', $newEmailAddresses)
863  ));
864  }
865  }
866  }
867 
868  $mbox->setUserId($id);
869  $inbox_id = $mbox->getInboxFolder();
870 
871  $mail_id = $this->sendInternalMail(
872  $inbox_id,
873  $this->user_id,
874  $a_attachments,
875  $a_rcp_to,
876  $a_rcp_cc,
877  '',
878  'unread',
879  $a_type,
880  0,
881  $a_subject,
882  $a_message,
883  $id,
884  0
885  );
886 
887  if ($a_attachments) {
888  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
889  }
890  }
891 
892  $to = array();
893  $bcc = array();
894 
895  $as_email = array_values(array_unique($as_email));
896  if (count($as_email) == 1) {
897  $to[] = $as_email[0];
898  } else {
899  foreach ($as_email as $email) {
900  $bcc[] = $email;
901  }
902  }
903 
904  if (count($to) > 0 || count($bcc) > 0) {
905  $this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $this->formatLinebreakMessage($a_message), $a_attachments);
906  }
907  } else {
908  $rcp_ids_replace = $this->getUserIds(array($a_rcp_to));
909  $rcp_ids_no_replace = $this->getUserIds(array($a_rcp_cc, $a_rcp_bcc));
910 
911  ilLoggerFactory::getLogger('mail')->debug(sprintf(
912  "Parsed TO user ids from given recipients for serial letter notification: %s",
913  implode(', ', $rcp_ids_replace)
914  ));
915  ilLoggerFactory::getLogger('mail')->debug(sprintf(
916  "Parsed CC/BCC user ids from given recipients for serial letter notification: %s",
917  implode(', ', $rcp_ids_no_replace)
918  ));
919 
920  $as_email = array();
921  $id_to_message_map = array();
922 
923  foreach ($rcp_ids_replace as $id) {
924  $tmp_mail_options = new ilMailOptions($id);
925 
926  $tmp_user = self::getCachedUserInstance($id);
927  $user_is_active = $tmp_user->getActive();
928  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
929 
930  if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
931  ilLoggerFactory::getLogger('mail')->debug(sprintf(
932  "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
933  $id,
934  var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
935  var_export(!$tmp_user->checkTimeLimit(), 1)
936  ));
937  continue;
938  }
939 
940  $id_to_message_map[$id] = $this->replacePlaceholders($a_message, $id);
941 
942  if ($user_is_active) {
943  if (!$user_can_read_internal_mails
944  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL
945  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_BOTH) {
946  $as_email[$tmp_user->getId()] = ilMailOptions::getExternalEmailsByUser($tmp_user, $tmp_mail_options);
947 
948  if ($tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL) {
949  ilLoggerFactory::getLogger('mail')->debug(sprintf(
950  "Recipient with id %s will only receive external emails sent to: %s",
951  $id,
952  implode(', ', $as_email[$tmp_user->getId()])
953  ));
954  continue;
955  } else {
956  ilLoggerFactory::getLogger('mail')->debug(sprintf(
957  "Recipient with id %s will additionally receive external emails sent to: %s",
958  $id,
959  implode(', ', $as_email[$tmp_user->getId()])
960  ));
961  }
962  }
963  }
964 
965  $mbox->setUserId($id);
966  $inbox_id = $mbox->getInboxFolder();
967 
968  $mail_id = $this->sendInternalMail(
969  $inbox_id,
970  $this->user_id,
971  $a_attachments,
972  $a_rcp_to,
973  $a_rcp_cc,
974  '',
975  'unread',
976  $a_type,
977  0,
978  $a_subject,
979  $id_to_message_map[$id],
980  $id,
981  0
982  );
983 
984  if ($a_attachments) {
985  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
986  }
987  }
988 
989  if (count($as_email)) {
990  foreach ($as_email as $id => $emails) {
991  if (0 == count($emails)) {
992  continue;
993  }
994 
995  $toEmailAddresses = implode(',', $emails);
996  $this->sendMimeMail($toEmailAddresses, '', '', $a_subject, $this->formatLinebreakMessage($id_to_message_map[$id]), $a_attachments);
997  }
998  }
999 
1000  $as_email = array();
1001 
1002  $cc_and_bcc_message = $this->replacePlaceholders($a_message, 0, false);
1003 
1004  foreach ($rcp_ids_no_replace as $id) {
1005  $tmp_mail_options = new ilMailOptions($id);
1006 
1007  $tmp_user = self::getCachedUserInstance($id);
1008  $user_is_active = $tmp_user->getActive();
1009  $user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
1010 
1011  if ($user_is_active) {
1012  if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
1013  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1014  "Message is marked as 'system', skipped recipient with id %s (Accepted User Agreement:%s|Expired Account:%s)",
1015  $id,
1016  var_export(!$tmp_user->hasToAcceptTermsOfService(), 1),
1017  var_export(!$tmp_user->checkTimeLimit(), 1)
1018  ));
1019  continue;
1020  }
1021 
1022 
1023  if (!$user_can_read_internal_mails
1024  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL
1025  || $tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_BOTH) {
1026  $newEmailAddresses = ilMailOptions::getExternalEmailsByUser($tmp_user, $tmp_mail_options);
1027  $as_email = array_unique(array_merge($newEmailAddresses, $as_email));
1028 
1029  if ($tmp_mail_options->getIncomingType() == ilMailOptions::INCOMING_EMAIL) {
1030  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1031  "Recipient with id %s will only receive external emails sent to: %s",
1032  $id,
1033  implode(', ', $newEmailAddresses)
1034  ));
1035  continue;
1036  } else {
1037  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1038  "Recipient with id %s will additionally receive external emails sent to: %s",
1039  $id,
1040  implode(', ', $newEmailAddresses)
1041  ));
1042  }
1043  }
1044  }
1045 
1046  $mbox->setUserId($id);
1047  $inbox_id = $mbox->getInboxFolder();
1048 
1049  $mail_id = $this->sendInternalMail(
1050  $inbox_id,
1051  $this->user_id,
1052  $a_attachments,
1053  $a_rcp_to,
1054  $a_rcp_cc,
1055  '',
1056  'unread',
1057  $a_type,
1058  0,
1059  $a_subject,
1060  $cc_and_bcc_message,
1061  $id,
1062  0
1063  );
1064 
1065  if ($a_attachments) {
1066  $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id);
1067  }
1068  }
1069 
1070  if (count($as_email)) {
1071  $this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $this->formatLinebreakMessage($cc_and_bcc_message), $a_attachments);
1072  }
1073  }
1074 
1075  return true;
1076  }
if($orgName !==null) if($spconfig->hasValue('contacts')) $email
Definition: metadata.php:193
Class ilMailOptions this class handles user mails.
if(!array_key_exists('StateId', $_REQUEST)) $id
static getExternalEmailsByUser(ilObjUser $user, ilMailOptions $mail_options=null)
$a_type
Definition: workflow.php:92
Mail Box class Base class for creating and handling mail boxes.
Create styles array
The data for the language used.
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
sendInternalMail( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
save mail in folder private
static getLogger($a_component_id)
Get component logger.
getUserIds(array $a_recipients)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableSOAP()

ilMail::enableSOAP (   $a_status)

Define if external mails should be sent using SOAP client or not.

The autogenerated mails in new user registration sets this value to false, since there is no valid session.

Parameters
bool$a_status

Definition at line 228 of file class.ilMail.php.

229  {
230  $this->soap_enabled = (bool) $a_status;
231  }

◆ existsRecipient()

ilMail::existsRecipient (   $a_recipient,
  $a_existing_recipients 
)
Parameters
string$a_recipient
string$a_existing_recipients
Returns
bool

Definition at line 201 of file class.ilMail.php.

References parseAddresses().

202  {
203  $recipients = $this->parseAddresses($a_existing_recipients);
204  foreach ($recipients as $rcp) {
205  if (substr($rcp->getMailbox(), 0, 1) != '#') {
206  if (trim($rcp->getMailbox()) == trim($a_recipient) || trim($rcp->getMailbox() . '@' . $rcp->getHost()) == trim($a_recipient)) {
207  return true;
208  }
209  } elseif (substr($rcp->getMailbox(), 0, 7) == '#il_ml_') {
210  if (trim($rcp->getMailbox() . '@' . $rcp->getHost()) == trim($a_recipient)) {
211  return true;
212  }
213  } else {
214  if (trim($rcp->getMailbox() . '@' . $rcp->getHost()) == trim($a_recipient)) {
215  return true;
216  }
217  }
218  }
219 
220  return false;
221  }
parseAddresses($addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39; Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:

◆ fetchMailData()

ilMail::fetchMailData (   $a_row)
protected
Parameters
array|null
Returns
array|null

Definition at line 590 of file class.ilMail.php.

References array.

Referenced by getMail(), getMailsOfFolder(), getNextMail(), getPreviousMail(), and getSavedData().

591  {
592  if (!is_array($a_row) || empty($a_row)) {
593  return null;
594  }
595 
596  $a_row['attachments'] = unserialize(stripslashes($a_row['attachments']));
597  $a_row['m_type'] = unserialize(stripslashes($a_row['m_type']));
598  $a_row['tpl_ctx_params'] = (array) (@json_decode($a_row['tpl_ctx_params'], true));
599 
600  return $a_row;
601  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ formatLinebreakMessage()

ilMail::formatLinebreakMessage (   $a_message)

Definition at line 1744 of file class.ilMail.php.

Referenced by distributeMail(), sendInternalMail(), and sendMail().

1745  {
1746  return $a_message;
1747  }
+ Here is the caller graph for this function:

◆ formatNamesForOutput()

ilMail::formatNamesForOutput (   $a_recipients)

Prepends the fullname of each ILIAS login name (if user has a public profile) found in the passed string and brackets the ILIAS login name afterwards.

Parameters
string$a_recipientsA string containing to, cc or bcc recipients
Returns
string

Definition at line 290 of file class.ilMail.php.

References $DIC, $names, ilObjUser\_lookupId(), ilObjUser\_lookupPref(), and array.

291  {
292  global $DIC;
293 
294  $a_recipients = trim($a_recipients);
295  if (!strlen($a_recipients)) {
296  return $this->lng->txt('not_available');
297  }
298 
299  $names = array();
300 
301  $recipients = array_filter(array_map('trim', explode(',', $a_recipients)));
302  foreach ($recipients as $recipient) {
303  $usr_id = ilObjUser::_lookupId($recipient);
304  if ($usr_id > 0) {
305  $pp = ilObjUser::_lookupPref($usr_id, 'public_profile');
306  if ($pp == 'y' || ($pp == 'g' && !$DIC->user()->isAnonymous())) {
307  $user = self::getCachedUserInstance($usr_id);
308  $names[] = $user->getFullname() . ' [' . $recipient . ']';
309  continue;
310  }
311  }
312 
313  $names[] = $recipient;
314  }
315 
316  return implode(', ', $names);
317  }
global $DIC
Definition: saml.php:7
static _lookupId($a_user_str)
Lookup id by login.
Create styles array
The data for the language used.
static _lookupPref($a_usr_id, $a_keyword)
+ Here is the call graph for this function:

◆ getCachedUserInstance()

static ilMail::getCachedUserInstance (   $a_usr_id)
staticprotected
Parameters
int$a_usr_id
Returns
ilObjUser

Definition at line 1731 of file class.ilMail.php.

1732  {
1733  if (isset(self::$userInstances[$a_usr_id])) {
1734  return self::$userInstances[$a_usr_id];
1735  }
1736 
1737  self::$userInstances[$a_usr_id] = new ilObjUser($a_usr_id);
1738  return self::$userInstances[$a_usr_id];
1739  }

◆ getCountRecipient()

ilMail::getCountRecipient (   $a_recipients,
  $a_only_email = true 
)
protected
Parameters
string$a_recipients
bool$a_only_email
Returns
int

Definition at line 1544 of file class.ilMail.php.

References $counter, ilObjUser\_lookupId(), and parseAddresses().

Referenced by getCountRecipients().

1545  {
1546  $counter = 0;
1547 
1548  $recipients = $this->parseAddresses($a_recipients);
1549  foreach ($recipients as $recipient) {
1550  if ($a_only_email) {
1551  // Fixed mantis bug #5875
1552  if (ilObjUser::_lookupId($recipient->getMailbox() . '@' . $recipient->getHost())) {
1553  continue;
1554  }
1555 
1556  // Addresses which aren't on the self::ILIAS_HOST host, and
1557  // which have a mailbox which does not start with '#',
1558  // are external e-mail addresses
1559  if ($recipient->getHost() != self::ILIAS_HOST && substr($recipient->getMailbox(), 0, 1) != '#') {
1560  ++$counter;
1561  }
1562  } else {
1563  ++$counter;
1564  }
1565  }
1566 
1567  return $counter;
1568  }
static _lookupId($a_user_str)
Lookup id by login.
$counter
parseAddresses($addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39; Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountRecipients()

ilMail::getCountRecipients (   $a_to,
  $a_cc,
  $a_bcc,
  $a_only_email = true 
)
protected
Parameters
string$a_to
string$a_cc
string$a_bcc
bool$a_only_email
Returns
int

Definition at line 1577 of file class.ilMail.php.

References getCountRecipient().

Referenced by sendMail().

1578  {
1579  return
1580  $this->getCountRecipient($a_to, $a_only_email) +
1581  $this->getCountRecipient($a_cc, $a_only_email) +
1582  $this->getCountRecipient($a_bcc, $a_only_email);
1583  }
getCountRecipient($a_recipients, $a_only_email=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEmailRecipients()

ilMail::getEmailRecipients (   $a_recipients)
protected
Parameters
string$a_recipients
Returns
string

Definition at line 1589 of file class.ilMail.php.

References ilObjUser\_lookupId(), array, and parseAddresses().

Referenced by sendMail().

1590  {
1591  $rcp = array();
1592 
1593  $recipients = $this->parseAddresses($a_recipients);
1594  foreach ($recipients as $recipient) {
1595  if (substr($recipient->getMailbox(), 0, 1) != '#' && $recipient->getHost() != self::ILIAS_HOST) {
1596  // Fixed mantis bug #5875
1597  if (ilObjUser::_lookupId($recipient->getMailbox() . '@' . $recipient->getHost())) {
1598  continue;
1599  }
1600 
1601  $rcp[] = $recipient->getMailbox() . '@' . $recipient->getHost();
1602  }
1603  }
1604 
1605  return implode(',', $rcp);
1606  }
static _lookupId($a_user_str)
Lookup id by login.
Create styles array
The data for the language used.
parseAddresses($addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39; Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMail()

ilMail::getMail (   $a_mail_id)
Parameters
int$a_mail_id
Returns
array

Definition at line 442 of file class.ilMail.php.

References $mail_data, $res, array, and fetchMailData().

443  {
444  $res = $this->db->queryF(
445  "
446  SELECT * FROM {$this->table_mail}
447  WHERE user_id = %s AND mail_id = %s",
448  array('integer', 'integer'),
449  array($this->user_id, $a_mail_id)
450  );
451 
452  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
453 
454  return $this->mail_data;
455  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
fetchMailData($a_row)
+ Here is the call graph for this function:

◆ getMailObjectReferenceId()

ilMail::getMailObjectReferenceId ( )
Returns
int

Definition at line 279 of file class.ilMail.php.

References $mail_obj_ref_id.

280  {
281  return $this->mail_obj_ref_id;
282  }
$mail_obj_ref_id

◆ getMailsOfFolder()

ilMail::getMailsOfFolder (   $a_folder_id,
  $filter = array() 
)
Parameters
int$a_folder_idThe id of the folder
array$filterAn optional filter array
Returns
array

Definition at line 370 of file class.ilMail.php.

References $output, $query, $res, $row, array, and fetchMailData().

Referenced by deleteMailsOfFolder(), ilPDSysMessageBlockGUI\getMails(), and ilPDMailBlockGUI\getMails().

371  {
372  $output = array();
373 
374  $query = "
375  SELECT sender_id, m_subject, mail_id, m_status, send_time FROM {$this->table_mail}
376  LEFT JOIN object_data ON obj_id = sender_id
377  WHERE user_id = %s AND folder_id = %s
378  AND ((sender_id > 0 AND sender_id IS NOT NULL AND obj_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) ";
379 
380  if (isset($filter['status']) && strlen($filter['status']) > 0) {
381  $query .= ' AND m_status = ' . $this->db->quote($filter['status'], 'text');
382  }
383 
384  if (isset($filter['type']) && strlen($filter['type']) > 0) {
385  $query .= ' AND ' . $this->db->like('m_type', 'text', '%%:"' . $filter['type'] . '"%%', false);
386  }
387 
388  $query .= " ORDER BY send_time DESC";
389 
390  $res = $this->db->queryF(
391  $query,
392  array('integer', 'integer'),
393  array($this->user_id, $a_folder_id)
394  );
395 
396  while ($row = $this->db->fetchAssoc($res)) {
397  $output[] = $this->fetchMailData($row);
398  }
399 
400  return $output;
401  }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
fetchMailData($a_row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNewDraftId()

ilMail::getNewDraftId (   $usrId,
  $folderId 
)
Parameters
int$usrId
int$folderId
Returns
int

Definition at line 608 of file class.ilMail.php.

References array.

609  {
610  $next_id = $this->db->nextId($this->table_mail);
611  $this->db->insert($this->table_mail, array(
612  'mail_id' => array('integer', $next_id),
613  'user_id' => array('integer', $usrId),
614  'folder_id' => array('integer', $folderId),
615  'sender_id' => array('integer', $usrId)
616  ));
617 
618  return $next_id;
619  }
Create styles array
The data for the language used.

◆ getNextMail()

ilMail::getNextMail (   $a_mail_id)
Parameters
int$a_mail_id
Returns
array

Definition at line 346 of file class.ilMail.php.

References $mail_data, $res, array, and fetchMailData().

347  {
348  $this->db->setLimit(1);
349 
350  $res = $this->db->queryF(
351  "
352  SELECT b.* FROM {$this->table_mail} a
353  INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id
354  AND b.user_id = a.user_id AND b.send_time < a.send_time
355  WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time DESC",
356  array('integer', 'integer'),
357  array($this->user_id, $a_mail_id)
358  );
359 
360  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
361 
362  return $this->mail_data;
363  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
fetchMailData($a_row)
+ Here is the call graph for this function:

◆ getPreviousMail()

ilMail::getPreviousMail (   $a_mail_id)
Parameters
int$a_mail_id
Returns
array

Definition at line 323 of file class.ilMail.php.

References $mail_data, $res, array, and fetchMailData().

324  {
325  $this->db->setLimit(1);
326 
327  $res = $this->db->queryF(
328  "
329  SELECT b.* FROM {$this->table_mail} a
330  INNER JOIN {$this->table_mail} b ON b.folder_id = a.folder_id
331  AND b.user_id = a.user_id AND b.send_time > a.send_time
332  WHERE a.user_id = %s AND a.mail_id = %s ORDER BY b.send_time ASC",
333  array('integer', 'integer'),
334  array($this->user_id, $a_mail_id)
335  );
336 
337  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
338 
339  return $this->mail_data;
340  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
fetchMailData($a_row)
+ Here is the call graph for this function:

◆ getSalutation()

static ilMail::getSalutation (   $a_usr_id,
ilLanguage  $a_language = null 
)
static
Parameters
int$a_usr_id
$a_languageilLanguage|null
Returns
string

Definition at line 1705 of file class.ilMail.php.

References $DIC, $lang, $name, ilObjUser\_lookupGender(), and ilObjUser\_lookupName().

Referenced by ilMailSummaryNotification\__construct(), ilTestManScoringParticipantNotification\buildBody(), ilSystemNotification\compose(), ilChatroom\isOwnerOfPrivateRoom(), ilRegistrationMailNotification\send(), ilMailCronOrphanedMailsNotification\send(), ilDiskQuotaSummaryNotification\send(), ilSessionMembershipMailNotification\send(), ilBuddySystemNotification\send(), ilIndividualAssessmentPrimitiveInternalNotificator\send(), ilLMMailNotification\send(), ilExerciseMailNotification\send(), ilCourseMembershipMailNotification\send(), ilGroupMembershipMailNotification\send(), ilCalendarMailNotification\send(), ilForumMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilTestMailNotification\sendSimpleNotification(), and ilObjSurveyGUI\sendUserResultsMail().

1706  {
1707  global $DIC;
1708 
1709  $lang = ($a_language instanceof ilLanguage) ? $a_language : $DIC->language();
1710  $lang->loadLanguageModule('mail');
1711 
1712  $gender = ilObjUser::_lookupGender($a_usr_id);
1713  $gender = $gender ? $gender : 'n';
1714  $name = ilObjUser::_lookupName($a_usr_id);
1715 
1716  if (!strlen($name['firstname'])) {
1717  return $lang->txt('mail_salutation_anonymous') . ',';
1718  }
1719 
1720  return
1721  $lang->txt('mail_salutation_' . $gender) . ' ' .
1722  ($name['title'] ? $name['title'] . ' ' : '') .
1723  ($name['firstname'] ? $name['firstname'] . ' ' : '') .
1724  $name['lastname'] . ',';
1725  }
static _lookupName($a_user_id)
lookup user name
global $DIC
Definition: saml.php:7
static _lookupGender($a_user_id)
Lookup gender.
if($format !==null) $name
Definition: metadata.php:146
language handling
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSavedData()

ilMail::getSavedData ( )
Returns
array

Definition at line 1230 of file class.ilMail.php.

References $mail_data, $res, array, and fetchMailData().

Referenced by ilObjUserFolderGUI\mailObject(), and savePostData().

1231  {
1232  $res = $this->db->queryF(
1233  "SELECT * FROM {$this->table_mail_saved} WHERE user_id = %s",
1234  array('integer'),
1235  array($this->user_id)
1236  );
1237 
1238  $this->mail_data = $this->fetchMailData($this->db->fetchAssoc($res));
1239 
1240  return $this->mail_data;
1241  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
fetchMailData($a_row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSaveInSentbox()

ilMail::getSaveInSentbox ( )
Returns
bool

Definition at line 262 of file class.ilMail.php.

References $save_in_sentbox.

Referenced by sendMail().

263  {
264  return (bool) $this->save_in_sentbox;
265  }
+ Here is the caller graph for this function:

◆ getSubjectPrefix()

static ilMail::getSubjectPrefix ( )
static

Get text that will be prepended to auto generated mails.

Returns
string subject prefix

Definition at line 1688 of file class.ilMail.php.

References $DIC.

Referenced by ilMimeMail\Subject().

1689  {
1690  global $DIC;
1691 
1692  $subjectPrefix = $DIC->settings()->get('mail_subject_prefix');
1693  if (false === $subjectPrefix) {
1694  $subjectPrefix = self::MAIL_SUBJECT_PREFIX;
1695  }
1696 
1697  return $subjectPrefix;
1698  }
global $DIC
Definition: saml.php:7
+ Here is the caller graph for this function:

◆ getUserIds()

ilMail::getUserIds ( array  $a_recipients)
protected
Parameters
string[]$a_recipients
Returns
int[]

Definition at line 1082 of file class.ilMail.php.

References array, and parseAddresses().

Referenced by distributeMail().

1083  {
1084  $usr_ids = array();
1085 
1086  $a_recipients = implode(',', array_filter(array_map('trim', $a_recipients)));
1087 
1088  $recipients = $this->parseAddresses($a_recipients);
1089  foreach ($recipients as $recipient) {
1090  $address_type = $this->mailAddressTypeFactory->getByPrefix($recipient);
1091  $usr_ids = array_merge($usr_ids, $address_type->resolve());
1092  }
1093 
1094  return array_unique($usr_ids);
1095  }
Create styles array
The data for the language used.
parseAddresses($addresses)
Explode recipient string, allowed separators are &#39;,&#39; &#39;;&#39; &#39; &#39; Returns an array with recipient ilMailAd...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSOAPEnabled()

ilMail::isSOAPEnabled ( )
Returns
bool

Definition at line 236 of file class.ilMail.php.

References $DIC, $soap_enabled, ilContext\CONTEXT_CRON, and ilContext\getType().

Referenced by saveInSentbox().

237  {
238  global $DIC;
239 
240  if (!extension_loaded('curl') || !$DIC->settings()->get('soap_user_administration')) {
241  return false;
242  }
243 
245  return false;
246  }
247 
248  return (bool) $this->soap_enabled;
249  }
global $DIC
Definition: saml.php:7
const CONTEXT_CRON
static getType()
Get context type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSystemMail()

ilMail::isSystemMail ( )
protected
Returns
bool

Definition at line 168 of file class.ilMail.php.

Referenced by sendMail().

169  {
170  return $this->user_id == ANONYMOUS_USER_ID;
171  }
+ Here is the caller graph for this function:

◆ markRead()

ilMail::markRead ( array  $a_mail_ids)
Parameters
array$a_mail_ids
Returns
bool

Definition at line 461 of file class.ilMail.php.

References $counter, $data, $in, $query, and array.

462  {
463  $data = array();
464  $data_types = array();
465 
466  $query = "UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
467  array_push($data_types, 'text', 'integer');
468  array_push($data, 'read', $this->user_id);
469 
470  if (count($a_mail_ids) > 0) {
471  $in = 'mail_id IN (';
472  $counter = 0;
473  foreach ($a_mail_ids as $a_mail_id) {
474  array_push($data, $a_mail_id);
475  array_push($data_types, 'integer');
476 
477  if ($counter > 0) {
478  $in .= ',';
479  }
480  $in .= '%s';
481  ++$counter;
482  }
483  $in .= ')';
484 
485  $query .= ' AND ' . $in;
486  }
487 
488  $this->db->manipulateF($query, $data_types, $data);
489 
490  return true;
491  }
$counter
$query
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ markUnread()

ilMail::markUnread ( array  $a_mail_ids)
Parameters
array$a_mail_ids
Returns
bool

Definition at line 497 of file class.ilMail.php.

References $counter, $data, $in, $query, and array.

498  {
499  $data = array();
500  $data_types = array();
501 
502  $query = "UPDATE {$this->table_mail} SET m_status = %s WHERE user_id = %s ";
503  array_push($data_types, 'text', 'integer');
504  array_push($data, 'unread', $this->user_id);
505 
506  if (count($a_mail_ids) > 0) {
507  $in = 'mail_id IN (';
508  $counter = 0;
509  foreach ($a_mail_ids as $a_mail_id) {
510  array_push($data, $a_mail_id);
511  array_push($data_types, 'integer');
512 
513  if ($counter > 0) {
514  $in .= ',';
515  }
516  $in .= '%s';
517  ++$counter;
518  }
519  $in .= ')';
520 
521  $query .= ' AND ' . $in;
522  }
523 
524  $this->db->manipulateF($query, $data_types, $data);
525 
526  return true;
527  }
$counter
$query
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ moveMailsToFolder()

ilMail::moveMailsToFolder ( array  $a_mail_ids,
  $a_folder_id 
)
Parameters
array$a_mail_ids
int$a_folder_id
Returns
bool

Definition at line 534 of file class.ilMail.php.

References $counter, $data, $in, $query, and array.

535  {
536  $data = array();
537  $data_types = array();
538 
539  $query = "UPDATE {$this->table_mail} SET folder_id = %s WHERE user_id = %s ";
540  array_push($data_types, 'text', 'integer');
541  array_push($data, $a_folder_id, $this->user_id);
542 
543  if (count($a_mail_ids) > 0) {
544  $in = 'mail_id IN (';
545  $counter = 0;
546  foreach ($a_mail_ids as $a_mail_id) {
547  array_push($data, $a_mail_id);
548  array_push($data_types, 'integer');
549 
550  if ($counter > 0) {
551  $in .= ',';
552  }
553  $in .= '%s';
554  ++$counter;
555  }
556  $in .= ')';
557 
558  $query .= ' AND ' . $in;
559  }
560 
561  $this->db->manipulateF($query, $data_types, $data);
562 
563  return true;
564  }
$counter
$query
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ parseAddresses()

ilMail::parseAddresses (   $addresses)
protected

Explode recipient string, allowed separators are ',' ';' ' ' Returns an array with recipient ilMailAddress instances.

Parameters
string$addresses
Returns
ilMailAddress[] An array with objects of type ilMailAddress

Definition at line 1515 of file class.ilMail.php.

References $parser, ilMailAddress\getHost(), ilLoggerFactory\getLogger(), and ilMailAddress\getMailbox().

Referenced by checkRecipients(), existsRecipient(), getCountRecipient(), getEmailRecipients(), and getUserIds().

1516  {
1517  if (strlen($addresses) > 0) {
1518  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1519  "Started parsing of recipient string: %s",
1520  $addresses
1521  ));
1522  }
1523 
1524  $parser = $this->mailAddressParserFactory->getParser($addresses);
1525  $parsedAddresses = $parser->parse();
1526 
1527  if (strlen($addresses) > 0) {
1528  ilLoggerFactory::getLogger('mail')->debug(sprintf(
1529  "Parsed addresses: %s",
1530  implode(',', array_map(function (ilMailAddress $address) {
1531  return $address->getMailbox() . '@' . $address->getHost();
1532  }, $parsedAddresses))
1533  ));
1534  }
1535 
1536  return $parsedAddresses;
1537  }
$parser
Definition: BPMN2Parser.php:23
static getLogger($a_component_id)
Get component logger.
Class ilMailAddress.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readMailObjectReferenceId()

ilMail::readMailObjectReferenceId ( )
protected

Read and set the mail object ref id (administration node)

Definition at line 270 of file class.ilMail.php.

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

271  {
272  require_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
273  $this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
274  }
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholders()

ilMail::replacePlaceholders (   $a_message,
  $a_user_id = 0,
  $replace_empty = true 
)
protected
Parameters
string$a_message
int$a_user_id
boolean$replace_empty
Returns
string

Definition at line 772 of file class.ilMail.php.

References ilMailFormCall\getContextId(), ilMailFormCall\getContextParameters(), ilLoggerFactory\getLogger(), and ilMailTemplateService\getTemplateContextById().

Referenced by distributeMail(), sendInternalMail(), and sendMail().

773  {
774  try {
775  include_once 'Services/Mail/classes/class.ilMailFormCall.php';
776 
778  require_once 'Services/Mail/classes/class.ilMailTemplateService.php';
780  } else {
781  require_once 'Services/Mail/classes/class.ilMailTemplateGenericContext.php';
782  $context = new ilMailTemplateGenericContext();
783  }
784 
785  $user = $a_user_id > 0 ? self::getCachedUserInstance($a_user_id) : null;
786 
787  require_once 'Services/Mail/classes/class.ilMailTemplatePlaceholderResolver.php';
788  $processor = new ilMailTemplatePlaceholderResolver($context, $a_message);
789  $a_message = $processor->resolve($user, ilMailFormCall::getContextParameters(), $replace_empty);
790  } catch (Exception $e) {
791  require_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
792  ilLoggerFactory::getLogger('mail')->error(__METHOD__ . ' has been called with invalid context.');
793  }
794 
795  return $a_message;
796  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAttachments()

ilMail::saveAttachments (   $a_attachments)
Parameters
array$a_attachmentsAn array of attachments
Returns
bool

Definition at line 1494 of file class.ilMail.php.

References array.

1495  {
1496  $this->db->update(
1497  $this->table_mail_saved,
1498  array(
1499  'attachments' => array('clob', serialize($a_attachments))
1500  ),
1501  array(
1502  'user_id' => array('integer', $this->user_id)
1503  )
1504  );
1505 
1506  return true;
1507  }
Create styles array
The data for the language used.

◆ saveInSentbox()

ilMail::saveInSentbox (   $a_attachment,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_type,
  $a_m_subject,
  $a_m_message 
)
protected

Stores a message in the sent bod of the current user.

Parameters
array$a_attachment
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
array$a_type
string$a_m_subject
string$a_m_message
Returns
int mail id

Definition at line 1390 of file class.ilMail.php.

References $_COOKIE, $a_type, $GLOBALS, array, isSOAPEnabled(), and sendInternalMail().

Referenced by sendMail().

1391  {
1392  require_once 'Services/Mail/classes/class.ilMailbox.php';
1393 
1394  $mbox = new ilMailbox($this->user_id);
1395  $sent_folder_id = $mbox->getSentFolder();
1396 
1397  return $this->sendInternalMail(
1398  $sent_folder_id,
1399  $this->user_id,
1400  $a_attachment,
1401  $a_rcp_to,
1402  $a_rcp_cc,
1403  $a_rcp_bcc,
1404  'read',
1405  $a_type,
1406  0,
1407  $a_m_subject,
1408  $a_m_message,
1409  $this->user_id,
1410  0
1411  );
1412  }
$a_type
Definition: workflow.php:92
Mail Box class Base class for creating and handling mail boxes.
sendInternalMail( $a_folder_id, $a_sender_id, $a_attachments, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_status, $a_m_type, $a_m_email, $a_m_subject, $a_m_message, $a_user_id=0, $a_use_placeholders=0, $a_tpl_context_id=null, $a_tpl_context_params=array())
save mail in folder private
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePostData()

ilMail::savePostData (   $a_user_id,
  $a_attachments,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_m_type,
  $a_m_email,
  $a_m_subject,
  $a_m_message,
  $a_use_placeholders,
  $a_tpl_context_id = null,
  $a_tpl_ctx_params = array() 
)

save post data in table public

Parameters
int$a_user_id
array$a_attachments
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
array$a_m_type
int$a_m_email
string$a_m_subject
string$a_m_message
int$a_use_placeholders
string | null$a_tpl_context_id
array | null$a_tpl_ctx_params
Returns
bool

Definition at line 1163 of file class.ilMail.php.

References array, and getSavedData().

1176  {
1177  if (!$a_attachments) {
1178  $a_attachments = null;
1179  }
1180  if (!$a_rcp_to) {
1181  $a_rcp_to = null;
1182  }
1183  if (!$a_rcp_cc) {
1184  $a_rcp_cc = null;
1185  }
1186  if (!$a_rcp_bcc) {
1187  $a_rcp_bcc = null;
1188  }
1189  if (!$a_m_type) {
1190  $a_m_type = null;
1191  }
1192  if (!$a_m_email) {
1193  $a_m_email = null;
1194  }
1195  if (!$a_m_message) {
1196  $a_m_message = null;
1197  }
1198  if (!$a_use_placeholders) {
1199  $a_use_placeholders = '0';
1200  }
1201 
1202  $this->db->replace(
1203  $this->table_mail_saved,
1204  array(
1205  'user_id' => array('integer', $this->user_id)
1206  ),
1207  array(
1208  'attachments' => array('clob', serialize($a_attachments)),
1209  'rcp_to' => array('clob', $a_rcp_to),
1210  'rcp_cc' => array('clob', $a_rcp_cc),
1211  'rcp_bcc' => array('clob', $a_rcp_bcc),
1212  'm_type' => array('text', serialize($a_m_type)),
1213  'm_email' => array('integer', $a_m_email),
1214  'm_subject' => array('text', $a_m_subject),
1215  'm_message' => array('clob', $a_m_message),
1216  'use_placeholders' => array('integer', $a_use_placeholders),
1217  'tpl_ctx_id' => array('text', $a_tpl_context_id),
1218  'tpl_ctx_params' => array('blob', json_encode((array) $a_tpl_ctx_params))
1219  )
1220  );
1221 
1222  $this->getSavedData();
1223 
1224  return true;
1225  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ sendInternalMail()

ilMail::sendInternalMail (   $a_folder_id,
  $a_sender_id,
  $a_attachments,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_status,
  $a_m_type,
  $a_m_email,
  $a_m_subject,
  $a_m_message,
  $a_user_id = 0,
  $a_use_placeholders = 0,
  $a_tpl_context_id = null,
  $a_tpl_context_params = array() 
)

save mail in folder private

Parameters
integer$a_folder_id
integer$a_sender_id
array$a_attachments
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bcc
string$a_status
array$a_m_type
integer$a_m_email
string$a_m_subject
string$a_m_message
integer$a_user_id
integer$a_use_placeholders
string | null$a_tpl_context_id
array | null$a_tpl_context_params
Returns
integer mail_id

Definition at line 682 of file class.ilMail.php.

References $user_id, array, date, formatLinebreakMessage(), replacePlaceholders(), and time.

Referenced by distributeMail(), and saveInSentbox().

698  {
699  $a_user_id = $a_user_id ? $a_user_id : $this->user_id;
700 
701  if ($a_use_placeholders) {
702  $a_m_message = $this->replacePlaceholders($a_m_message, $a_user_id);
703  }
704  $a_m_message = $this->formatLinebreakMessage($a_m_message);
705 
706  if (!$a_user_id) {
707  $a_user_id = '0';
708  }
709  if (!$a_folder_id) {
710  $a_folder_id = '0';
711  }
712  if (!$a_sender_id) {
713  $a_sender_id = null;
714  }
715  if (!$a_attachments) {
716  $a_attachments = null;
717  }
718  if (!$a_rcp_to) {
719  $a_rcp_to = null;
720  }
721  if (!$a_rcp_cc) {
722  $a_rcp_cc = null;
723  }
724  if (!$a_rcp_bcc) {
725  $a_rcp_bcc = null;
726  }
727  if (!$a_status) {
728  $a_status = null;
729  }
730  if (!$a_m_type) {
731  $a_m_type = null;
732  }
733  if (!$a_m_email) {
734  $a_m_email = null;
735  }
736  if (!$a_m_subject) {
737  $a_m_subject = null;
738  }
739  if (!$a_m_message) {
740  $a_m_message = null;
741  }
742 
743  $next_id = $this->db->nextId($this->table_mail);
744  $this->db->insert($this->table_mail, array(
745  'mail_id' => array('integer', $next_id),
746  'user_id' => array('integer', $a_user_id),
747  'folder_id' => array('integer', $a_folder_id),
748  'sender_id' => array('integer', $a_sender_id),
749  'attachments' => array('clob', serialize($a_attachments)),
750  'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
751  'rcp_to' => array('clob', $a_rcp_to),
752  'rcp_cc' => array('clob', $a_rcp_cc),
753  'rcp_bcc' => array('clob', $a_rcp_bcc),
754  'm_status' => array('text', $a_status),
755  'm_type' => array('text', serialize($a_m_type)),
756  'm_email' => array('integer', $a_m_email),
757  'm_subject' => array('text', $a_m_subject),
758  'm_message' => array('clob', $a_m_message),
759  'tpl_ctx_id' => array('text', $a_tpl_context_id),
760  'tpl_ctx_params' => array('blob', @json_encode((array) $a_tpl_context_params))
761  ));
762 
763  return $next_id;
764  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendMail()

ilMail::sendMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bc,
  $a_m_subject,
  $a_m_message,
  $a_attachment,
  $a_type,
  $a_use_placeholders = 0 
)

Should be used to send notifcations over the internal or external mail channel.

Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bc
string$a_m_subject
string$a_m_message
array$a_attachment
array$a_type(normal and/or system and/or email)
bool | int$a_use_placeholders
Returns
array

Definition at line 1255 of file class.ilMail.php.

References $a_type, $DIC, $errors, appendInstallationSignature(), array, checkMail(), deleteMails(), distributeMail(), formatLinebreakMessage(), getCountRecipients(), getEmailRecipients(), ilLoggerFactory\getLogger(), getSaveInSentbox(), isSystemMail(), replacePlaceholders(), saveInSentbox(), and validateRecipients().

1256  {
1257  global $DIC;
1258 
1259  ilLoggerFactory::getLogger('mail')->debug(
1260  "New mail system task:" .
1261  " To: " . $a_rcp_to .
1262  " | CC: " . $a_rcp_cc .
1263  " | BCC: " . $a_rcp_bc .
1264  " | Subject: " . $a_m_subject
1265  );
1266 
1267  $this->mail_to_global_roles = true;
1268  if (!$this->isSystemMail()) {
1269  $this->mail_to_global_roles = $DIC->rbac()->system()->checkAccessOfUser($this->user_id, 'mail_to_global_roles', $this->mail_obj_ref_id);
1270  }
1271 
1272  if (in_array('system', $a_type)) {
1273  $a_type = array('system');
1274  }
1275 
1276  if ($a_attachment && !$this->mfile->checkFilesExist($a_attachment)) {
1277  return array(array('mail_attachment_file_not_exist', $a_attachment));
1278  }
1279 
1280  $errors = $this->checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject);
1281  if (count($errors) > 0) {
1282  return $errors;
1283  }
1284 
1285  $errors = $this->validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc);
1286  if (count($errors) > 0) {
1287  return $errors;
1288  }
1289 
1290  $rcp_to = $a_rcp_to;
1291  $rcp_cc = $a_rcp_cc;
1292  $rcp_bc = $a_rcp_bc;
1293 
1294  $c_emails = $this->getCountRecipients($rcp_to, $rcp_cc, $rcp_bc, true);
1295 
1296  if (
1297  $c_emails && !$this->isSystemMail() &&
1298  !$DIC->rbac()->system()->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id)
1299  ) {
1300  return array(array('mail_no_permissions_write_smtp'));
1301  }
1302 
1303  if ($this->appendInstallationSignature()) {
1304  $a_m_message .= self::_getInstallationSignature();
1305  }
1306 
1307  $sent_id = $this->saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_type, $a_m_subject, $a_m_message);
1308 
1309  if ($a_attachment) {
1310  $this->mfile->assignAttachmentsToDirectory($sent_id, $sent_id);
1311  $this->mfile->saveFiles($sent_id, $a_attachment);
1312  }
1313 
1314  if ($c_emails) {
1315  $externalMailRecipientsTo = $this->getEmailRecipients($rcp_to);
1316  $externalMailRecipientsCc = $this->getEmailRecipients($rcp_cc);
1317  $externalMailRecipientsBcc = $this->getEmailRecipients($rcp_bc);
1318 
1319  ilLoggerFactory::getLogger('mail')->debug(
1320  "Parsed external email addresses from given recipients:" .
1321  " To: " . $externalMailRecipientsTo .
1322  " | CC: " . $externalMailRecipientsCc .
1323  " | BCC: " . $externalMailRecipientsBcc .
1324  " | Subject: " . $a_m_subject
1325  );
1326 
1327  $this->sendMimeMail(
1328  $externalMailRecipientsTo,
1329  $externalMailRecipientsCc,
1330  $externalMailRecipientsBcc,
1331  $a_m_subject,
1332  $this->formatLinebreakMessage($a_use_placeholders ? $this->replacePlaceholders($a_m_message, 0, false) : $a_m_message),
1333  $a_attachment,
1334  0
1335  );
1336  } else {
1337  ilLoggerFactory::getLogger('mail')->debug("No external email addresses given in recipient string");
1338  }
1339 
1340  if (in_array('system', $a_type) && !$this->distributeMail($rcp_to, $rcp_cc, $rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $sent_id, $a_type, 'system', $a_use_placeholders)) {
1341  return array(array('mail_send_error'));
1342  }
1343 
1344  if (in_array('normal', $a_type) && !$this->distributeMail($rcp_to, $rcp_cc, $rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $sent_id, $a_type, 'normal', $a_use_placeholders)) {
1345  return array(array('mail_send_error'));
1346  }
1347 
1348  if (!$this->getSaveInSentbox()) {
1349  $this->deleteMails(array($sent_id));
1350  }
1351 
1352  return array();
1353  }
checkMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject)
deleteMails(array $a_mail_ids)
distributeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_subject, $a_message, $a_attachments, $sent_mail_id, $a_type, $a_action, $a_use_placeholders=0)
global $DIC
Definition: saml.php:7
getEmailRecipients($a_recipients)
$a_type
Definition: workflow.php:92
validateRecipients($a_rcp_to, $a_rcp_cc, $a_rcp_bc)
isSystemMail()
getCountRecipients($a_to, $a_cc, $a_bcc, $a_only_email=true)
getSaveInSentbox()
appendInstallationSignature($a_flag=null)
Setter/Getter for appending the installation signarue.
Create styles array
The data for the language used.
formatLinebreakMessage($a_message)
replacePlaceholders($a_message, $a_user_id=0, $replace_empty=true)
$errors
Definition: index.php:6
static getLogger($a_component_id)
Get component logger.
saveInSentbox($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
Stores a message in the sent bod of the current user.
+ Here is the call graph for this function:

◆ setSaveInSentbox()

ilMail::setSaveInSentbox (   $a_save_in_sentbox)
Parameters
bool$a_save_in_sentbox

Definition at line 254 of file class.ilMail.php.

Referenced by __construct(), and ilSoapUtils\distributeMails().

255  {
256  $this->save_in_sentbox = (bool) $a_save_in_sentbox;
257  }
+ Here is the caller graph for this function:

◆ updateDraft()

ilMail::updateDraft (   $a_folder_id,
  $a_attachments,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_m_type,
  $a_m_email,
  $a_m_subject,
  $a_m_message,
  $a_draft_id = 0,
  $a_use_placeholders = 0,
  $a_tpl_context_id = null,
  $a_tpl_context_params = array() 
)

Definition at line 621 of file class.ilMail.php.

References array, date, and time.

635  {
636  $this->db->update(
637  $this->table_mail,
638  array(
639  'folder_id' => array('integer', $a_folder_id),
640  'attachments' => array('clob', serialize($a_attachments)),
641  'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
642  'rcp_to' => array('clob', $a_rcp_to),
643  'rcp_cc' => array('clob', $a_rcp_cc),
644  'rcp_bcc' => array('clob', $a_rcp_bcc),
645  'm_status' => array('text', 'read'),
646  'm_type' => array('text', serialize($a_m_type)),
647  'm_email' => array('integer', $a_m_email),
648  'm_subject' => array('text', $a_m_subject),
649  'm_message' => array('clob', $a_m_message),
650  'use_placeholders' => array('integer', $a_use_placeholders),
651  'tpl_ctx_id' => array('text', $a_tpl_context_id),
652  'tpl_ctx_params' => array('blob', @json_encode((array) $a_tpl_context_params))
653  ),
654  array(
655  'mail_id' => array('integer', $a_draft_id)
656  )
657  );
658 
659  return $a_draft_id;
660  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ validateRecipients()

ilMail::validateRecipients (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bc 
)
Parameters
string$a_rcp_to
string$a_rcp_cc
string$a_rcp_bc
Returns
array Returns an empty array if there is no validation issue

Definition at line 1361 of file class.ilMail.php.

References $errors, array, and checkRecipients().

Referenced by sendMail().

1362  {
1363  try {
1364  $errors = array();
1365  $errors = array_merge($errors, $this->checkRecipients($a_rcp_to));
1366  $errors = array_merge($errors, $this->checkRecipients($a_rcp_cc));
1367  $errors = array_merge($errors, $this->checkRecipients($a_rcp_bc));
1368 
1369  if (count($errors) > 0) {
1370  return array_merge(array(array('mail_following_rcp_not_valid')), $errors);
1371  }
1372  } catch (ilMailException $e) {
1373  return array(array('mail_generic_rcp_error', $e->getMessage()));
1374  }
1375 
1376  return array();
1377  }
Class ilMailException.
Create styles array
The data for the language used.
$errors
Definition: index.php:6
checkRecipients($a_recipients)
Check if recipients are valid.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $appendInstallationSignature

ilMail::$appendInstallationSignature = false
protected

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

Referenced by appendInstallationSignature().

◆ $db

ilMail::$db
protected

Definition at line 77 of file class.ilMail.php.

◆ $lng

ilMail::$lng
protected

Definition at line 74 of file class.ilMail.php.

◆ $mail_data

ilMail::$mail_data = array()
protected

◆ $mail_obj_ref_id

ilMail::$mail_obj_ref_id
protected

Definition at line 98 of file class.ilMail.php.

Referenced by getMailObjectReferenceId().

◆ $mail_options

ilMail::$mail_options
protected

Definition at line 83 of file class.ilMail.php.

◆ $mail_to_global_roles

ilMail::$mail_to_global_roles = 0
protected

Definition at line 104 of file class.ilMail.php.

◆ $mailAddressParserFactory

ilMail::$mailAddressParserFactory
private

Definition at line 120 of file class.ilMail.php.

Referenced by __construct().

◆ $mailAddressTypeFactory

ilMail::$mailAddressTypeFactory
private

Definition at line 117 of file class.ilMail.php.

Referenced by __construct().

◆ $mfile

ilMail::$mfile
protected

Definition at line 80 of file class.ilMail.php.

◆ $properties

ilMail::$properties = array()
protected

Definition at line 111 of file class.ilMail.php.

◆ $save_in_sentbox

ilMail::$save_in_sentbox
protected

Definition at line 101 of file class.ilMail.php.

Referenced by getSaveInSentbox().

◆ $soap_enabled

ilMail::$soap_enabled = true
protected

Definition at line 103 of file class.ilMail.php.

Referenced by isSOAPEnabled().

◆ $table_mail

ilMail::$table_mail
protected

Definition at line 89 of file class.ilMail.php.

◆ $table_mail_saved

ilMail::$table_mail_saved
protected

Definition at line 92 of file class.ilMail.php.

◆ $user_id

ilMail::$user_id

Definition at line 86 of file class.ilMail.php.

Referenced by sendInternalMail().

◆ $userInstances

ilMail::$userInstances = array()
staticprotected

Definition at line 114 of file class.ilMail.php.

◆ ILIAS_HOST

◆ MAIL_SUBJECT_PREFIX

const ilMail::MAIL_SUBJECT_PREFIX = '[ILIAS]'

Definition at line 71 of file class.ilMail.php.

Referenced by ilObjMailGUI\populateExternalSettingsForm().


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