ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMail Class Reference

Class Mail this class handles base functions for mail handling. More...

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

Public Member Functions

 __construct ($a_user_id)
 Constructor setup an mail object public.
 __get ($name)
 Magic interceptor method __get Used to include files / instantiate objects at runtime.
 doesRecipientStillExists ($a_recipient, $a_existing_recipients)
 enableSOAP ($a_status)
 isSOAPEnabled ()
 setSaveInSentbox ($a_save_in_sentbox)
 getSaveInSentbox ()
 setMailSendType ($a_types)
 setMailRcpTo ($a_rcp_to)
 setMailRcpCc ($a_rcp_cc)
 setMailRcpBc ($a_rcp_bc)
 setMailSubject ($a_subject)
 setMailMessage ($a_message)
 readMailObjectReferenceId ()
 read and set mail object id private
 getMailObjectReferenceId ()
 formatNamesForOutput ($users= '')
 Prepends the fullname of each ILIAS login name (is user has a public profile) found in the passed string and brackets the ILIAS login name afterwards.
 getPreviousMail ($a_mail_id)
 getNextMail ($a_mail_id)
 getMailsOfFolder ($a_folder_id, $filter=array())
 get all mails of a specific folder public
 countMailsOfFolder ($a_folder_id)
 count all mails of a specific folder public
 deleteMailsOfFolder ($a_folder_id)
 delete all mails of a specific folder public
 getMailCounterData ()
 get mail counter data returns data array with indexes "total","read","unread" public
 getMail ($a_mail_id)
 get data of one mail public
 markRead ($a_mail_ids)
 mark mails as read public
 markUnread ($a_mail_ids)
 mark mails as unread public
 moveMailsToFolder ($a_mail_ids, $a_folder_id)
 move mail to folder public
 deleteMails ($a_mail_ids)
 delete mail public
 fetchMailData ($a_row)
 fetch all query data from table mail public
 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)
 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)
 save mail in folder private
 replacePlaceholders ($a_message, $a_user_id)
 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)
 send internal message to recipients private
 getUserIds ($a_recipients)
 get user_ids
 checkMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_type)
 check if mail is complete, recipients are valid public
 getEmailsOfRecipients ($a_rcp)
 get email addresses of recipients public
 checkRecipients ($a_recipients, $a_type)
 check if recipients are valid public
 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)
 save post data in table public
 getSavedData ()
 get saved data public
 sendMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bc, $a_m_subject, $a_m_message, $a_attachment, $a_type, $a_use_placeholders=0)
 send external mail using class.ilMimeMail.php
 parseRcptOfMailingLists ($rcpt= '', $maintain_lists=false)
 saveInSentbox ($a_attachment, $a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_type, $a_m_subject, $a_m_message)
 send mime mail using class.ilMimeMail.php
 sendMimeMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_attachments, $a_no_soap=false)
 send mime mail using class.ilMimeMail.php All external mails are send to SOAP::sendMail starting a kind of background process
 getEmailOfSender ()
 get email of sender public
 saveAttachments ($a_attachments)
 set attachments
 getAttachments ()
 get attachments public
 explodeRecipients ($a_recipients, $use_pear=true)
 explode recipient string allowed seperators are ',' ';' ' '
 __getCountRecipient ($rcp, $a_only_email=true)
 __getCountRecipients ($a_to, $a_cc, $a_bcc, $a_only_email=true)
 __getEmailRecipients ($a_rcp)
 __prependMessage ($a_m_message, $rcp_to, $rcp_cc)
 __checkSystemRecipients (&$a_rcp_to)
 __substituteRecipients ($a_rcp, $direction)
 Note: This function can only be used, when ILIAS is configured to not use standards compliant mail addresses.
 appendInstallationSignature ($a_flag=null)
 Setter/Getter for appending the installation signarue.

Static Public Member Functions

static addFullname ($a_email, $a_fullname)
static getIliasMailerAddress ()
 Builds an email address used for system notifications.
static _getUserInternalMailboxAddress ($usr_id, $login=null, $firstname=null, $lastname=null)
 STATIC METHOD.
static _getAutoGeneratedMessageString ($lang=null)
 get auto generated info string
static _getInstallationSignature ()
 Static getter for the installation signature.
static getSubjectPrefix ()
 Get text that will be prepended to auto generated mails.
static getSalutation ($a_usr_id, $a_language=null)
 Get salutation.

Data Fields

 $ilias
 $lng
 $mfile
 $mail_options
 $user_id
 $table_mail
 $table_mail_saved
 $mail_counter
 $mail_data
 $mail_obj_ref_id
 $mail_send_type
 $save_in_sentbox
 $mail_rcp_to
 $mail_rcp_cc
 $mail_rcp_bc
 $mail_subject
 $mail_message
 $mail_use_placeholders = 0
 $soap_enabled = true
 $mail_to_global_roles = 0
const ILIAS_HOST = 'ilias'

Static Protected Member Functions

static getCachedUserInstance ($a_usr_id)
 Returns a cached instance of ilObjUser.

Protected Attributes

 $appendInstallationSignature = false
 $properties = array()

Static Protected Attributes

static $userInstances = array()

Private Member Functions

 setUsePear ($bool)
 getUsePear ()
 validatePear ($a_recipients)

Private Attributes

 $use_pear = true

Detailed Description

Class Mail this class handles base functions for mail handling.

RFC 822 compliant e-mail addresses

If ILIAS is configured to use standards compliant e-mail addresses, then this 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 e-mail to the user with the login john.doe and e-mail 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 E-Mail address:

  • The local-part must not start with a "#" character
  • The domain must be specified and it must not have the value "ilias"

Non-compliant e-mail addresses

If ILIAS is not configured to use standards compliant e-mail addresses, then the following description applies:

Examples: The following mailbox addresses work for sending an e-mail to the user with the login john.doe, who is member of the course "French Course". Assuming that the member role of the course object has the name "il_crs_member_998" and the object ID "1000".

john.doe #il_crs_member_998 #il_role_1000 jd@ma.nosp@m.il.c.nosp@m.om

Syntax: The following syntax rule 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 must be omitted.
  • The local-part must not start with a "#" character

Role object mailbox address:

  • The local part denotes the title of an ILIAS role.
  • The local-part must start with a "#" character.
  • The domain must be omitted.
  • If the local-part start 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".

External E-Mail 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:
class.ilMail.php 61636 2016-02-29 08:30:13Z gitmgr

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

Constructor & Destructor Documentation

ilMail::__construct (   $a_user_id)

Constructor setup an mail object public.

Parameters
integeruser_id

Reimplemented in ilFormatMail.

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

References $ilias, $ilUser, $lng, readMailObjectReferenceId(), and setSaveInSentbox().

{
require_once "./Services/Mail/classes/class.ilFileDataMail.php";
require_once "Services/Mail/classes/class.ilMailOptions.php";
global $ilias, $lng, $ilUser;
$lng->loadLanguageModule("mail");
// Initiate variables
$this->ilias =& $ilias;
$this->lng =& $lng;
$this->table_mail = 'mail';
$this->table_mail_saved = 'mail_saved';
$this->user_id = $a_user_id;
$this->mfile = new ilFileDataMail($this->user_id);
$this->mail_options = new ilMailOptions($a_user_id);
// DEFAULT: sent mail aren't stored insentbox of user.
$this->setSaveInSentbox(false);
// GET REFERENCE ID OF MAIL OBJECT
}

+ Here is the call graph for this function:

Member Function Documentation

ilMail::__checkSystemRecipients ( $a_rcp_to)

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

References ilObjUser\_getAllUserLogins().

Referenced by sendMail().

{
if (preg_match("/@all/",$a_rcp_to))
{
// GET ALL LOGINS
$all = ilObjUser::_getAllUserLogins($this->ilias);
$a_rcp_to = preg_replace("/@all/",implode(',',$all),$a_rcp_to);
}
return;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::__get (   $name)

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

Parameters
stringThe name of the class property

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

References $ilUser.

{
global $ilUser;
if(isset($this->properties[$name]))
{
return $this->properties[$name];
}
// Used to include files / instantiate objects at runtime
if($name == 'mlists')
{
if(is_object($ilUser))
{
require_once 'Services/Contact/classes/class.ilMailingLists.php';
$this->properties[$name] = new ilMailingLists($ilUser);
return $this->properties[$name];
}
}
}
ilMail::__getCountRecipient (   $rcp,
  $a_only_email = true 
)

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

References __substituteRecipients(), ilObjUser\_lookupId(), explodeRecipients(), getUsePear(), and validatePear().

Referenced by __getCountRecipients().

{
$counter = 0;
$this->validatePear($rcp);
if (ilMail::_usePearMail() && $this->getUsePear())
{
$tmp_rcp = $this->explodeRecipients($rcp);
if (! is_a($tmp_rcp, 'PEAR_Error'))
{
foreach ($tmp_rcp as $to)
{
if ($a_only_email)
{
// Fixed mantis bug #5875
if(ilObjUser::_lookupId($to->mailbox.'@'.$to->host))
{
continue;
}
// Addresses which aren't on the self::ILIAS_HOST host, and
// which have a mailbox which does not start with '#',
// are external e-mail addresses
if ($to->host != self::ILIAS_HOST && substr($to->mailbox,0,1) != '#')
{
++$counter;
}
}
else
{
++$counter;
}
}
}
}
else
{
foreach ($this->explodeRecipients($rcp,$this->getUsePear()) as $to)
{
if ($a_only_email)
{
$to = $this->__substituteRecipients($to,"resubstitute");
if (strpos($to,'@'))
{
// Fixed mantis bug #5875
{
continue;
}
++$counter;
}
}
else
{
++$counter;
}
}
}
return $counter;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::__getCountRecipients (   $a_to,
  $a_cc,
  $a_bcc,
  $a_only_email = true 
)

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

References __getCountRecipient().

Referenced by sendMail().

{
return $this->__getCountRecipient($a_to,$a_only_email)
+ $this->__getCountRecipient($a_cc,$a_only_email)
+ $this->__getCountRecipient($a_bcc,$a_only_email);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::__getEmailRecipients (   $a_rcp)

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

References __substituteRecipients(), ilObjUser\_lookupId(), and explodeRecipients().

Referenced by sendMail().

{
if (ilMail::_usePearMail())
{
$rcp = array();
$tmp_rcp = $this->explodeRecipients($a_rcp);
if (! is_a($tmp_rcp, 'PEAR_Error'))
{
foreach ($tmp_rcp as $to)
{
if(substr($to->mailbox,0,1) != '#' && $to->host != self::ILIAS_HOST)
{
// Fixed mantis bug #5875
if(ilObjUser::_lookupId($to->mailbox.'@'.$to->host))
{
continue;
}
$rcp[] = $to->mailbox.'@'.$to->host;
}
}
}
return implode(',',$rcp);
}
else
{
foreach ($this->explodeRecipients($a_rcp) as $to)
{
$to = $this->__substituteRecipients($to,"resubstitute");
if(strpos($to,'@'))
{
// Fixed mantis bug #5875
{
continue;
}
$rcp[] = $to;
}
}
return implode(',',$rcp ? $rcp : array());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::__prependMessage (   $a_m_message,
  $rcp_to,
  $rcp_cc 
)

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

{
$inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 3";
$message = $inst_name." To:".$rcp_to."\n";
if ($rcp_cc)
{
$message .= "Cc: ".$rcp_cc;
}
$message .= "\n\n";
$message .= $a_m_message;
return $message;
}
ilMail::__substituteRecipients (   $a_rcp,
  $direction 
)

Note: This function can only be used, when ILIAS is configured to not use standards compliant mail addresses.

If standards compliant mail addresses are used, substitution is not supported, because then we do the parsing of mail addresses using the Pear Mail Extension.

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

References ilObjUser\_loginExists(), and explodeRecipients().

Referenced by __getCountRecipient(), __getEmailRecipients(), distributeMail(), and sendMail().

{
$new_name = array();
$tmp_names = $this->explodeRecipients($a_rcp);
foreach($tmp_names as $name)
{
if(strpos($name,"#") === 0)
{
$new_name[] = $name;
continue;
}
switch($direction)
{
case "substitute":
if(strpos($name,"@") and ilObjUser::_loginExists($name))
{
$new_name[] = preg_replace("/@/","�#�",$name);
}
else
{
$new_name[] = $name;
}
break;
case "resubstitute":
if(stristr($name,"�#�"))
{
$new_name[] = preg_replace("/�#�/","@",$name);
}
else
{
$new_name[] = $name;
}
break;
}
}
return implode(",",$new_name);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

get auto generated info string

public

Parameters
stringlanguage

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

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

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

{
global $ilSetting;
if(!$lang)
{
include_once('./Services/Language/classes/class.ilLanguageFactory.php');
}
$http_path = ilUtil::_getHttpPath();
$lang->loadLanguageModule('mail');
return sprintf($lang->txt('mail_auto_generated_info'),
$ilSetting->get('inst_name','ILIAS 5'),
$http_path)."\n\n";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilMail::_getInstallationSignature ( )
static

Static getter for the installation signature.

public

Returns
string The installation mail signature

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

References ilUtil\_getHttpPath(), and ILIAS_WEB_DIR.

Referenced by ilForum\__formatMessage(), ilSystemNotification\compose(), ilPaymentNotification\send(), ilMailSummaryNotification\send(), ilCronDeleteInactiveUserReminderMailNotification\send(), sendMail(), and ilObjSurveyGUI\sendUserResultsMail().

{
global $ilClientIniFile;
$signature = "\n\n* * * * *\n";
$signature .= $ilClientIniFile->readVariable('client', 'name')."\n";
if(strlen($desc = $ilClientIniFile->readVariable('client', 'description')))
{
$signature .= $desc."\n";
}
$signature .= ilUtil::_getHttpPath();
$clientdirs = glob(ILIAS_WEB_DIR."/*", GLOB_ONLYDIR);
if(is_array($clientdirs) && count($clientdirs) > 1)
{
// #18051
$signature .= '/login.php?client_id='.CLIENT_ID;
}
$signature .= "\n\n";
return $signature;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilMail::_getUserInternalMailboxAddress (   $usr_id,
  $login = null,
  $firstname = null,
  $lastname = null 
)
static

STATIC METHOD.

Returns the internal mailbox address for the specified user.

This functions (may) perform faster, if the login, firstname and lastname are supplied as parameters aloing with the $usr_id.

Parameters
usr_idthe usr_id of the user
loginoptional, but if you supply it, you have to supply the firstname and the lastname as well
firstnameoptional
lastnamepublic

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

References getCachedUserInstance().

{
if (ilMail::_usePearMail())
{
if ($login == null)
{
require_once './Services/User/classes/class.ilObjUser.php';
$usr_obj = self::getCachedUserInstance($usr_id);
$login = $usr_obj->getLogin();
$firstname = $usr_obj->getFirstname();
$lastname = $usr_obj->getLastname();
}
// The following line of code creates a properly formatted mailbox
// address. Unfortunately, it does not work, because ILIAS removes
// everything between '<' '>' characters
// Therefore, we just return the login - sic.
// FIXME - Make this work in a future release
/*
return preg_replace('/[()<>@,;:\\".\[\]]/','',$firstname.' '.$lastname).' <'.$login.'>';
*/
return $login.'hhho';
}
else
{
return $login;
}
}

+ Here is the call graph for this function:

static ilMail::addFullname (   $a_email,
  $a_fullname 
)
static
Parameters
string$a_email
string$a_fullname
Returns
string

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

References ilMimeMail\_mimeEncode().

{
include_once 'Services/Mail/classes/class.ilMimeMail.php';
return ilMimeMail::_mimeEncode($a_fullname).' <'.$a_email.'>';
}

+ Here is the call graph for this function:

ilMail::appendInstallationSignature (   $a_flag = null)

Setter/Getter for appending the installation signarue.

public

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

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

References $appendInstallationSignature.

Referenced by sendMail().

{
if(null === $a_flag) {
}
$this->appendInstallationSignature = $a_flag;
return $this;
}

+ Here is the caller graph for this function:

ilMail::checkMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_m_subject,
  $a_m_message,
  $a_type 
)

check if mail is complete, recipients are valid public

Parameters
stringrcp_to
stringrcp_cc
stringrcp_bcc
stringm_subject
stringm_message
Returns
string error message

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

Referenced by sendMail().

{
$error_message = '';
$a_m_subject = trim($a_m_subject);
$a_rcp_to = trim($a_rcp_to);
if (empty($a_m_subject))
{
$error_message .= $error_message ? "<br>" : '';
$error_message .= $this->lng->txt("mail_add_subject");
}
if (empty($a_rcp_to))
{
$error_message .= $error_message ? "<br>" : '';
$error_message .= $this->lng->txt("mail_add_recipient");
}
return $error_message;
}

+ Here is the caller graph for this function:

ilMail::checkRecipients (   $a_recipients,
  $a_type 
)

check if recipients are valid public

Parameters
stringstring with login names or group names (start with #)
Returns
Returns an empty string, if all recipients are okay. Returns a string with invalid recipients, if some are not okay.

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

References $user_id, explodeRecipients(), getUsePear(), ilObjUser\getUserIdByLogin(), ilUtil\groupNameExists(), ILIAS_HOST, ilUtil\is_email(), and validatePear().

Referenced by sendMail().

{
global $rbacsystem,$rbacreview;
$wrong_rcps = '';
$this->validatePear($a_recipients);
if (ilMail::_usePearMail() && $this->getUsePear())
{
$tmp_rcp = $this->explodeRecipients($a_recipients, $this->getUsePear());
if (is_a($tmp_rcp, 'PEAR_Error'))
{
$colon_pos = strpos($tmp_rcp->message, ':');
$wrong_rcps = '<br />'.(($colon_pos === false) ? $tmp_rcp->message : substr($tmp_rcp->message, $colon_pos+2));
}
else
{
foreach ($tmp_rcp as $rcp)
{
// NO ROLE MAIL ADDRESS
if (substr($rcp->mailbox,0,1) != '#')
{
// ALL RECIPIENTS MUST EITHER HAVE A VALID LOGIN OR A VALID EMAIL
$user_id = ($rcp->host == self::ILIAS_HOST) ? ilObjUser::getUserIdByLogin(addslashes($rcp->mailbox)) : false;
if ($user_id == false && $rcp->host == self::ILIAS_HOST)
{
$wrong_rcps .= "<br />".htmlentities($rcp->mailbox);
continue;
}
// CHECK IF USER CAN RECEIVE MAIL
if ($user_id)
{
if(!$rbacsystem->checkAccessOfUser($user_id, "internal_mail", $this->getMailObjectReferenceId()))
{
$wrong_rcps .= "<br />".htmlentities($rcp->mailbox).
" (".$this->lng->txt("user_cant_receive_mail").")";
continue;
}
}
}
else if (substr($rcp->mailbox, 0, 7) == '#il_ml_')
{
if (!$this->mlists->mailingListExists($rcp->mailbox))
{
$wrong_rcps .= "<br />".htmlentities($rcp->mailbox).
" (".$this->lng->txt("mail_no_valid_mailing_list").")";
}
continue;
}
else
{
$role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.'@'.$rcp->host);
if(!$this->mail_to_global_roles && is_array($role_ids))
{
foreach($role_ids as $role_id)
{
if($rbacreview->isGlobalRole($role_id))
{
include_once('Services/Mail/exceptions/class.ilMailException.php');
throw new ilMailException('mail_to_global_roles_not_allowed');
}
}
}
if (count($role_ids) == 0)
{
$wrong_rcps .= '<br />'.htmlentities($rcp->mailbox).
' ('.$this->lng->txt('mail_no_recipient_found').')';
continue;
}
else if (count($role_ids) > 1)
{
$wrong_rcps .= '<br/>'.htmlentities($rcp->mailbox).
' ('.sprintf($this->lng->txt('mail_multiple_recipients_found'), implode(',', $role_ids)).')';
}
}
}
}
}
else // NO PEAR
{
$tmp_rcp = $this->explodeRecipients($a_recipients, $this->getUsePear());
foreach ($tmp_rcp as $rcp)
{
if (empty($rcp))
{
continue;
}
// NO GROUP
if (substr($rcp,0,1) != '#')
{
// ALL RECIPIENTS MUST EITHER HAVE A VALID LOGIN OR A VALID EMAIL
if (!ilObjUser::getUserIdByLogin(addslashes($rcp)) and
{
$wrong_rcps .= "<br />".htmlentities($rcp);
continue;
}
// CHECK IF USER CAN RECEIVE MAIL
if ($user_id = ilObjUser::getUserIdByLogin(addslashes($rcp)))
{
if(!$rbacsystem->checkAccessOfUser($user_id, "internal_mail", $this->getMailObjectReferenceId()))
{
$wrong_rcps .= "<br />".htmlentities($rcp).
" (".$this->lng->txt("user_cant_receive_mail").")";
continue;
}
}
}
else if (substr($rcp, 0, 7) == '#il_ml_')
{
if (!$this->mlists->mailingListExists($rcp))
{
$wrong_rcps .= "<br />".htmlentities($rcp).
" (".$this->lng->txt("mail_no_valid_mailing_list").")";
}
continue;
}
else if (ilUtil::groupNameExists(addslashes(substr($rcp,1))))
{
continue;
}
else if (!$rbacreview->roleExists(addslashes(substr($rcp,1))))
{
$wrong_rcps .= "<br />".htmlentities($rcp).
" (".$this->lng->txt("mail_no_valid_group_role").")";
continue;
}
else if (!$this->mail_to_global_roles)
{
$role_id = $rbacreview->roleExists(addslashes(substr($rcp,1)));
if((int)$role_id && $rbacreview->isGlobalRole($role_id))
{
include_once('Services/Mail/exceptions/class.ilMailException.php');
throw new ilMailException('mail_to_global_roles_not_allowed');
}
}
}
}
return $wrong_rcps;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::countMailsOfFolder (   $a_folder_id)

count all mails of a specific folder public

Parameters
integerid of folder
Returns
bool number of mails

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

References $ilDB, and $res.

{
global $ilDB;
$res = $ilDB->queryf("
SELECT COUNT(*) FROM ". $this->table_mail ."
WHERE user_id = %s
AND folder_id = %s",
array('integer', 'integer'),
array($this->user_id, $a_folder_id));
return $res->numRows();
}
ilMail::deleteMails (   $a_mail_ids)

delete mail public

Parameters
arraymail ids
Returns
bool

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

References $ilDB.

Referenced by deleteMailsOfFolder(), and sendMail().

{
global $ilDB;
foreach ($a_mail_ids as $id)
{
$statement = $ilDB->manipulateF("
DELETE FROM ". $this->table_mail ."
WHERE user_id = %s
AND mail_id = %s ",
array('integer', 'integer'),
array($this->user_id, $id));
$this->mfile->deassignAttachmentFromDirectory($id);
}
return true;
}

+ Here is the caller graph for this function:

ilMail::deleteMailsOfFolder (   $a_folder_id)

delete all mails of a specific folder public

Parameters
integerid of folder

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

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

{
if ($a_folder_id)
{
global $ilDB;
/*$statement = $ilDB->manipulateF("
DELETE FROM ". $this->table_mail ."
WHERE user_id = %s
AND folder_id = %s",
array('integer', 'integer'),
array($this->user_id, $a_folder_id));*/
$mails = $this->getMailsOfFolder($a_folder_id);
foreach((array)$mails as $mail_data)
{
$this->deleteMails(array($mail_data['mail_id']));
}
return true;
}
return false;
}

+ Here is the call graph for this function:

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 
)

send internal message to recipients private

Parameters
stringto
stringcc
stringbcc
stringsubject
stringmessage
arrayattachments
integerid of mail which is stored in sentbox
array'normal' and/or 'system' and/or 'email'
Returns
bool

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

References $log, __substituteRecipients(), getCachedUserInstance(), getUserIds(), replacePlaceholders(), sendInternalMail(), and sendMimeMail().

Referenced by sendMail().

{
global $log;
include_once 'Services/Mail/classes/class.ilMailbox.php';
include_once './Services/User/classes/class.ilObjUser.php';
if (!ilMail::_usePearMail())
{
// REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
$a_rcp_to = $this->__substituteRecipients($a_rcp_to, 'resubstitute');
$a_rcp_cc = $this->__substituteRecipients($a_rcp_cc, 'resubstitute');
$a_rcp_bcc = $this->__substituteRecipients($a_rcp_bcc, 'resubstitute');
}
$mbox = new ilMailbox();
if (!$a_use_placeholders) # No Placeholders
{
$rcp_ids = $this->getUserIds(trim($a_rcp_to).','.trim($a_rcp_cc).','.trim($a_rcp_bcc));
$as_email = array();
foreach($rcp_ids as $id)
{
$tmp_mail_options = new ilMailOptions($id);
// DETERMINE IF THE USER CAN READ INTERNAL MAILS
$tmp_user = self::getCachedUserInstance($id);
$user_is_active = $tmp_user->getActive();
$user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
// CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
if (in_array('system', $a_type) && !$user_can_read_internal_mails)
{
continue;
}
// CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS/HER MAIL
// SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
// Do not send external mails to inactive users!!!
if($user_is_active)
{
if (!$user_can_read_internal_mails ||
$tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
{
$as_email[] = $tmp_user->getEmail();
continue;
}
if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
{
$as_email[] = $tmp_user->getEmail();
}
}
$mbox->setUserId($id);
$inbox_id = $mbox->getInboxFolder();
$mail_id = $this->sendInternalMail($inbox_id, $this->user_id,
$a_attachments, $a_rcp_to,
$a_rcp_cc, '', 'unread', $a_type,
0, $a_subject, $a_message, $id, 0);
if ($a_attachments)
{
$this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
}
}
// SEND EMAIL TO ALL USERS WHO DECIDED 'email' or 'both'
$to = array();
$bcc = array();
if(count($as_email) == 1)
{
$to[] = $as_email[0];
}
else
{
foreach ($as_email as $email)
{
$bcc[] = $email;
}
}
if(count($to) > 0 || count($bcc) > 0)
{
$this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $a_message, $a_attachments);
}
}
else # Use Placeholders
{
// to
$rcp_ids_replace = $this->getUserIds(trim($a_rcp_to));
// cc / bcc
$rcp_ids_no_replace = $this->getUserIds(trim($a_rcp_cc).','.trim($a_rcp_bcc));
$as_email = array();
// to
foreach($rcp_ids_replace as $id)
{
$tmp_mail_options = new ilMailOptions($id);
// DETERMINE IF THE USER CAN READ INTERNAL MAILS
$tmp_user = self::getCachedUserInstance($id);
$user_is_active = $tmp_user->getActive();
$user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
// CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
if (in_array('system', $a_type) && !$user_can_read_internal_mails)
{
continue;
}
// CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
// SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
// Do not send external mails to inactive users!!!
if($user_is_active)
{
if (!$user_can_read_internal_mails ||
$tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
{
$as_email[$tmp_user->getId()] = $tmp_user->getEmail();
continue;
}
if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
{
$as_email[$tmp_user->getId()] = $tmp_user->getEmail();
}
}
$mbox->setUserId($id);
$inbox_id = $mbox->getInboxFolder();
$mail_id = $this->sendInternalMail($inbox_id, $this->user_id,
$a_attachments, $a_rcp_to,
$a_rcp_cc, '', 'unread', $a_type,
0, $a_subject, $a_message, $id, 1);
if ($a_attachments)
{
$this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
}
}
if (count($as_email))
{
foreach ($as_email as $id => $email)
{
$this->sendMimeMail($email, '', '', $a_subject, $this->replacePlaceholders($a_message, $id), $a_attachments);
}
}
$as_email = array();
// cc / bcc
foreach($rcp_ids_no_replace as $id)
{
$tmp_mail_options = new ilMailOptions($id);
// DETERMINE IF THE USER CAN READ INTERNAL MAILS
$tmp_user = self::getCachedUserInstance($id);
$user_is_active = $tmp_user->getActive();
$user_can_read_internal_mails = !$tmp_user->hasToAcceptTermsOfService() && $tmp_user->checkTimeLimit();
// Do not send external mails to inactive users!!!
if($user_is_active)
{
// CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
if (in_array('system', $a_type) && !$user_can_read_internal_mails)
{
continue;
}
// CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
// SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
if (!$user_can_read_internal_mails ||
$tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
{
$as_email[] = $tmp_user->getEmail();
continue;
}
if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
{
$as_email[] = $tmp_user->getEmail();
}
}
$mbox->setUserId($id);
$inbox_id = $mbox->getInboxFolder();
$mail_id = $this->sendInternalMail($inbox_id, $this->user_id,
$a_attachments, $a_rcp_to,
$a_rcp_cc, '', 'unread', $a_type,
0, $a_subject, $a_message, $id, 0);
if ($a_attachments)
{
$this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
}
}
if (count($as_email))
{
$this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $a_message, $a_attachments);
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::doesRecipientStillExists (   $a_recipient,
  $a_existing_recipients 
)

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

References explodeRecipients().

{
if(self::_usePearMail())
{
$recipients = $this->explodeRecipients($a_existing_recipients);
if(is_a($recipients, 'PEAR_Error'))
{
return false;
}
else
{
foreach($recipients as $rcp)
{
if (substr($rcp->mailbox, 0, 1) != '#')
{
if(trim($rcp->mailbox) == trim($a_recipient) ||
trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
{
return true;
}
}
else if (substr($rcp->mailbox, 0, 7) == '#il_ml_')
{
if(trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
{
return true;
}
}
else
{
if(trim($rcp->mailbox.'@'.$rcp->host) == trim($a_recipient))
{
return true;
}
}
}
}
}
else
{
$recipients = $this->explodeRecipients($a_existing_recipients);
if(count($recipients))
{
foreach($recipients as $recipient)
{
if(trim($recipient) == trim($a_recipient))
{
return true;
}
}
}
}
return false;
}

+ Here is the call graph for this function:

ilMail::enableSOAP (   $a_status)

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

Referenced by ilMembershipCronNotifications\sendMail().

{
$this->soap_enabled = $a_status;
}

+ Here is the caller graph for this function:

ilMail::explodeRecipients (   $a_recipients,
  $use_pear = true 
)

explode recipient string allowed seperators are ',' ';' ' '

Returns an array with recipient objects

private

Returns
array with recipient objects. array[i]->mailbox gets the mailbox of the recipient. array[i]->host gets the host of the recipients. Returns a PEAR_Error object, if exploding failed. Use is_a() to test, if the return value is a PEAR_Error, then use $rcp->message to retrieve the error message.

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

References $use_pear.

Referenced by __getCountRecipient(), __getEmailRecipients(), __substituteRecipients(), checkRecipients(), doesRecipientStillExists(), getEmailsOfRecipients(), getUserIds(), parseRcptOfMailingLists(), and validatePear().

{
$a_recipients = trim($a_recipients);
// WHITESPACE IS NOT ALLOWED AS SEPERATOR
#$a_recipients = preg_replace("/ /",",",$a_recipients);
$a_recipients = preg_replace("/;/",",",$a_recipients);
if (ilMail::_usePearMail() && $use_pear == true)
{
if (strlen(trim($a_recipients)) > 0)
{
require_once './Services/PEAR/lib/Mail/RFC822.php';
$parser = new Mail_RFC822();
return $parser->parseAddressList($a_recipients, self::ILIAS_HOST, false, true);
} else {
return array();
}
}
else
{
foreach(explode(',',$a_recipients) as $tmp_rec)
{
if($tmp_rec)
{
$rcps[] = trim($tmp_rec);
}
}
return is_array($rcps) ? $rcps : array();
}
}

+ Here is the caller graph for this function:

ilMail::fetchMailData (   $a_row)

fetch all query data from table mail public

Parameters
objectobject of query
Returns
array array of query data

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

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

{
if (!$a_row) return;
return array(
"mail_id" => $a_row->mail_id,
"user_id" => $a_row->user_id,
"folder_id" => $a_row->folder_id,
"sender_id" => $a_row->sender_id,
"attachments" => unserialize(stripslashes($a_row->attachments)),
"send_time" => $a_row->send_time,
"rcp_to" => $a_row->rcp_to,
"rcp_cc" => $a_row->rcp_cc,
"rcp_bcc" => $a_row->rcp_bcc,
"m_status" => $a_row->m_status,
"m_type" => unserialize(stripslashes($a_row->m_type)),
"m_email" => $a_row->m_email,
"m_subject" => $a_row->m_subject,
"m_message" => $a_row->m_message,
"import_name" => $a_row->import_name,
"use_placeholders"=> $a_row->use_placeholders);
}

+ Here is the caller graph for this function:

ilMail::formatNamesForOutput (   $users = '')

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

Parameters
string$usersString containing to, cc or bcc recipients
Returns
string Formatted names

public

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

References ilObjUser\_lookupId(), ilObjUser\_lookupPref(), and getCachedUserInstance().

{
$users = trim($users);
if($users)
{
if(strstr($users, ','))
{
$rcp_to_array = array();
$recipients = explode(',', $users);
foreach($recipients as $recipient)
{
$recipient = trim($recipient);
if($uid = ilObjUser::_lookupId($recipient))
{
if (in_array(ilObjUser::_lookupPref($uid, 'public_profile'), array("y", "g")))
{
$tmp_obj = self::getCachedUserInstance($uid);
$rcp_to_array[] = $tmp_obj->getFullname().' ['.$recipient.']';
}
else
{
$rcp_to_array[] = $recipient;
}
}
else
{
$rcp_to_array[] = $recipient;
}
}
return trim(implode(', ', $rcp_to_array));
}
else
{
if($uid = ilObjUser::_lookupId($users))
{
if (in_array(ilObjUser::_lookupPref($uid, 'public_profile'), array("y", "g")))
{
$tmp_obj = self::getCachedUserInstance($uid);
return $tmp_obj->getFullname().' ['.$users.']';
}
else
{
return $users;
}
}
else
{
return $users;
}
}
}
else
{
return $this->lng->txt('not_available');
}
}

+ Here is the call graph for this function:

ilMail::getAttachments ( )

get attachments public

Returns
array array of attachments

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

{
return $this->mail_data["attachments"] ? $this->mail_data["attachments"] : array();
}
static ilMail::getCachedUserInstance (   $a_usr_id)
staticprotected

Returns a cached instance of ilObjUser.

Parameters
integer$a_usr_id
Returns
ilObjUser

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

Referenced by _getUserInternalMailboxAddress(), distributeMail(), formatNamesForOutput(), getEmailOfSender(), getEmailsOfRecipients(), and replacePlaceholders().

{
if(isset(self::$userInstances[$a_usr_id]))
{
return self::$userInstances[$a_usr_id];
}
self::$userInstances[$a_usr_id] = new ilObjUser($a_usr_id);
return self::$userInstances[$a_usr_id];
}

+ Here is the caller graph for this function:

ilMail::getEmailOfSender ( )

get email of sender public

Returns
string email

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

References getCachedUserInstance(), and ilUtil\is_email().

{
$umail = self::getCachedUserInstance($this->user_id);
$sender = $umail->getEmail();
if (ilUtil::is_email($sender))
{
return $sender;
}
else
{
return '';
}
}

+ Here is the call graph for this function:

ilMail::getEmailsOfRecipients (   $a_rcp)

get email addresses of recipients public

Parameters
stringstring with login names or group names (start with #) or email address
Returns
string seperated by ','

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

References $ref_id, ilObject\_getAllReferences(), ilObjGroup\_lookupIdByTitle(), explodeRecipients(), getCachedUserInstance(), ilObjectFactory\getInstanceByRefId(), getUsePear(), ilObjUser\getUserIdByLogin(), and validatePear().

{
global $rbacreview;
$addresses = array();
$this->validatePear($a_rcp);
if (ilMail::_usePearMail() && $this->getUsePear())
{
$tmp_rcp = $this->explodeRecipients($a_rcp);
if (! is_a($tmp_rcp, 'PEAR_Error'))
{
foreach ($tmp_rcp as $rcp)
{
// NO GROUP
if (substr($rcp->mailbox,0,1) != '#')
{
if (strtolower($rcp->host) != self::ILIAS_HOST)
{
$addresses[] = $rcp->mailbox.'@'.$rcp->host;
continue;
}
if ($id = ilObjUser::getUserIdByLogin(addslashes($rcp->mailbox)))
{
$tmp_user = self::getCachedUserInstance($id);
$addresses[] = $tmp_user->getEmail();
continue;
}
}
else
{
// Roles
$role_ids = $rbacreview->searchRolesByMailboxAddressList($rcp->mailbox.'@'.$rcp->host);
foreach($role_ids as $role_id)
{
foreach($rbacreview->assignedUsers($role_id) as $usr_id)
{
$tmp_user = self::getCachedUserInstance($usr_id);
$addresses[] = $tmp_user->getEmail();
}
}
}
}
}
}
else
{
$tmp_rcp = $this->explodeRecipients($a_rcp, $this->getUsePear());
foreach ($tmp_rcp as $rcp)
{
// NO GROUP
if (substr($rcp,0,1) != '#')
{
if (strpos($rcp,'@'))
{
$addresses[] = $rcp;
continue;
}
if ($id = ilObjUser::getUserIdByLogin(addslashes($rcp)))
{
$tmp_user = self::getCachedUserInstance($id);
$addresses[] = $tmp_user->getEmail();
continue;
}
}
else
{
// GROUP THINGS
include_once("./Services/Object/classes/class.ilObjectFactory.php");
include_once('./Modules/Group/classes/class.ilObjGroup.php');
// Fix
foreach(ilObjGroup::_getAllReferences(ilObjGroup::_lookupIdByTitle(addslashes(substr($rcp,1)))) as $ref_id)
{
$grp_object = ilObjectFactory::getInstanceByRefId($ref_id);
break;
}
// GET EMAIL OF MEMBERS AND STORE THEM IN $addresses
foreach ($grp_object->getGroupMemberIds() as $id)
{
$tmp_user = self::getCachedUserInstance($id);
$addresses[] = $tmp_user->getEmail();
}
}
}
}
return $addresses;
}

+ Here is the call graph for this function:

static ilMail::getIliasMailerAddress ( )
static

Builds an email address used for system notifications.

public

Returns
string

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

References $ilSetting, ilMimeMail\_mimeEncode(), and ilUtil\is_email().

Referenced by ilMailSummaryNotification\send(), ilPasswordAssistanceGUI\sendPasswordAssistanceMail(), and ilPasswordAssistanceGUI\sendUsernameAssistanceMail().

{
global $ilSetting;
include_once 'Services/Mail/classes/class.ilMimeMail.php';
$no_reply_adress = trim($ilSetting->get('mail_external_sender_noreply'));
if(strlen($no_reply_adress))
{
if(strpos($no_reply_adress, '@') === false)
$no_reply_adress = 'noreply@'.$no_reply_adress;
if(!ilUtil::is_email($no_reply_adress))
{
$no_reply_adress = 'noreply@'.$_SERVER['SERVER_NAME'];
}
$sender = ilMimeMail::_mimeEncode(self::_getIliasMailerName()).
' <'.$no_reply_adress.'>';
}
else
{
$sender = ilMimeMail::_mimeEncode(self::_getIliasMailerName()).
' <noreply@'.$_SERVER['SERVER_NAME'].'>';
}
return $sender;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::getMail (   $a_mail_id)

get data of one mail public

Parameters
intmail_id
Returns
array mail_data

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

References $ilDB, $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

{
global $ilDB;
$res = $ilDB->queryf("
SELECT * FROM ". $this->table_mail ."
WHERE user_id = %s
AND mail_id = %s",
array('integer', 'integer'),
array($this->user_id, $a_mail_id));
$this->mail_data =$this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
}

+ Here is the call graph for this function:

ilMail::getMailCounterData ( )

get mail counter data returns data array with indexes "total","read","unread" public

Returns
array mail_counter data

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

{
return is_array($this->mail_counter) ? $this->mail_counter : array(
"total" => 0,
"read" => 0,
"unread" => 0);
}
ilMail::getMailObjectReferenceId ( )

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

References $mail_obj_ref_id.

ilMail::getMailsOfFolder (   $a_folder_id,
  $filter = array() 
)

get all mails of a specific folder public

@param      integer id of folder
Parameters
arrayoptional filter array
Returns
array mails

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

References $ilDB, $query, $res, $row, and fetchMailData().

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

{
global $ilDB;
$this->mail_counter = array();
$this->mail_counter['read'] = 0;
$this->mail_counter['unread'] = 0;
$query = "SELECT sender_id, m_subject, mail_id, m_status, send_time FROM ". $this->table_mail ."
LEFT JOIN object_data ON obj_id = sender_id
WHERE user_id = %s
AND folder_id = %s
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)) ";
if($filter['status'])
{
$query .= ' AND m_status = '.$ilDB->quote($filter['status'], 'text');
}
if($filter['type'])
{
$query .= ' AND '.$ilDB->like('m_type', 'text', '%%:"'.$filter['type'].'"%%', false);
}
$query .= " ORDER BY send_time DESC";
$res = $ilDB->queryf($query,
array('integer', 'integer'),
array($this->user_id, $a_folder_id));
while ($row = $ilDB->fetchObject($res))
{
$tmp = $this->fetchMailData($row);
if($tmp['m_status'] == 'read')
{
++$this->mail_counter['read'];
}
if($tmp['m_status'] == 'unread')
{
++$this->mail_counter['unread'];
}
$output[] = $tmp;
}
$this->mail_counter['total'] = count($output);
return $output ? $output : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::getNextMail (   $a_mail_id)

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

References $ilDB, $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

{
global $ilDB;
$ilDB->setLimit(1);
$res = $ilDB->queryf("
SELECT b.* FROM " . $this->table_mail ." a
INNER JOIN ".$this->table_mail ." b ON b.folder_id = a.folder_id
AND b.user_id = a.user_id AND b.send_time < a.send_time
WHERE a.user_id = %s
AND a.mail_id = %s ORDER BY b.send_time DESC",
array('integer', 'integer'),
array($this->user_id, $a_mail_id));
$this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
}

+ Here is the call graph for this function:

ilMail::getPreviousMail (   $a_mail_id)

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

References $ilDB, $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

{
global $ilDB;
$ilDB->setLimit(1);
$res = $ilDB->queryf("
SELECT b.* FROM " . $this->table_mail ." a
INNER JOIN ".$this->table_mail ." b ON b.folder_id = a.folder_id
AND b.user_id = a.user_id AND b.send_time > a.send_time
WHERE a.user_id = %s
AND a.mail_id = %s ORDER BY b.send_time ASC",
array('integer', 'integer'),
array($this->user_id, $a_mail_id));
$this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
}

+ Here is the call graph for this function:

static ilMail::getSalutation (   $a_usr_id,
  $a_language = null 
)
static

Get salutation.

Parameters
int$a_usr_id
Returns

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

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

Referenced by ilForum\__formatMessage(), ilTestManScoringParticipantNotification\buildBody(), ilSystemNotification\compose(), ilForum\formatNotification(), ilForum\formatPostActivationNotification(), ilPaymentNotification\send(), ilMailSummaryNotification\send(), ilRegistrationMailNotification\send(), ilLMMailNotification\send(), ilSessionMembershipMailNotification\send(), ilGroupMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilDiskQuotaSummaryNotification\send(), ilExerciseMailNotification\send(), ilCalendarMailNotification\send(), ilTestMailNotification\sendAdvancedNotification(), ilTestMailNotification\sendSimpleNotification(), and ilObjSurveyGUI\sendUserResultsMail().

{
global $lng;
$lang = $a_language ? $a_language : $lng;
$lang->loadLanguageModule('mail');
$gender = ilObjUser::_lookupGender($a_usr_id);
$gender = $gender ? $gender : 'n';
$name = ilObjUser::_lookupName($a_usr_id);
if(!strlen($name['firstname']))
{
return $lang->txt('mail_salutation_anonymous').',';
}
return $lang->txt('mail_salutation_'.$gender).' '.
($name['title'] ? $name['title'].' ' : '').
($name['firstname'] ? $name['firstname'].' ' : '').
$name['lastname'].',';
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::getSavedData ( )

get saved data public

Returns
array of saved data

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

References $ilDB, $mail_data, $res, DB_FETCHMODE_OBJECT, and fetchMailData().

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

{
global $ilDB;
$res = $ilDB->queryf('
SELECT * FROM '. $this->table_mail_saved .'
WHERE user_id = %s',
array('integer'),
array($this->user_id));
$this->mail_data = $this->fetchMailData($res->fetchRow(DB_FETCHMODE_OBJECT));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::getSaveInSentbox ( )

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

References $save_in_sentbox.

Referenced by sendMail().

+ Here is the caller graph for this function:

static ilMail::getSubjectPrefix ( )
static

Get text that will be prepended to auto generated mails.

Returns
string subject prefix

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

References $ilSetting.

Referenced by sendMimeMail(), and ilMimeMail\Subject().

{
global $ilSetting;
static $prefix = null;
return $prefix == null ? $ilSetting->get('mail_subject_prefix','') : $prefix;
}

+ Here is the caller graph for this function:

ilMail::getUsePear ( )
private

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

References $use_pear.

Referenced by __getCountRecipient(), checkRecipients(), getEmailsOfRecipients(), and getUserIds().

{
}

+ Here is the caller graph for this function:

ilMail::getUserIds (   $a_recipients)

get user_ids

Parameters
stringrecipients seperated by ','
Returns
string error message

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

References $log, $ref_id, ilObject\_getAllReferences(), ilObjUser\_lookupId(), ilObjGroup\_lookupIdByTitle(), explodeRecipients(), ilObjectFactory\getInstanceByRefId(), getUsePear(), ilObjUser\getUserIdByLogin(), ilUtil\groupNameExists(), ILIAS_HOST, and validatePear().

Referenced by distributeMail().

{
global $log, $rbacreview;
$ids = array();
$this->validatePear($a_recipients);
if (ilMail::_usePearMail() && $this->getUsePear() == true)
{
$tmp_names = $this->explodeRecipients($a_recipients );
if (! is_a($tmp_names, 'PEAR_Error'))
{
for ($i = 0;$i < count($tmp_names); $i++)
{
if ( substr($tmp_names[$i]->mailbox,0,1) === '#' ||
(substr($tmp_names[$i]->mailbox,0,1) === '"' &&
substr($tmp_names[$i]->mailbox,1,1) === '#' ) )
{
$role_ids = $rbacreview->searchRolesByMailboxAddressList($tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
foreach($role_ids as $role_id)
{
foreach($rbacreview->assignedUsers($role_id) as $usr_id)
{
$ids[] = $usr_id;
}
}
}
else if (strtolower($tmp_names[$i]->host) == self::ILIAS_HOST)
{
if ($id = ilObjUser::getUserIdByLogin(addslashes($tmp_names[$i]->mailbox)))
{
//$log->write('class.ilMail->getUserIds() recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host.' user_id:'.$id);
$ids[] = $id;
}
else
{
//$log->write('class.ilMail->getUserIds() no user account found for recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
}
}
else
{
// Fixed mantis bug #5875
if($id = ilObjUser::_lookupId($tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host))
{
$ids[] = $id;
}
else
{
//$log->write('class.ilMail->getUserIds() external recipient:'.$tmp_names[$i]->mailbox.'@'.$tmp_names[$i]->host);
}
}
}
}
else
{
//$log->write('class.ilMail->getUserIds() illegal recipients:'.$a_recipients);
}
}
else
{
$tmp_names = $this->explodeRecipients($a_recipients, $this->getUsePear());
for ($i = 0;$i < count($tmp_names); $i++)
{
if (substr($tmp_names[$i],0,1) == '#')
{
if(ilUtil::groupNameExists(addslashes(substr($tmp_names[$i],1))))
{
include_once("./Services/Object/classes/class.ilObjectFactory.php");
include_once('./Modules/Group/classes/class.ilObjGroup.php');
foreach(ilObject::_getAllReferences(ilObjGroup::_lookupIdByTitle(addslashes(substr($tmp_names[$i],1)))) as $ref_id)
{
$grp_object = ilObjectFactory::getInstanceByRefId($ref_id);
break;
}
// STORE MEMBER IDS IN $ids
foreach ($grp_object->getGroupMemberIds() as $id)
{
$ids[] = $id;
}
}
// is role: get role ids
elseif($role_id = $rbacreview->roleExists(addslashes(substr($tmp_names[$i],1))))
{
foreach($rbacreview->assignedUsers($role_id) as $usr_id)
{
$ids[] = $usr_id;
}
}
}
else if (!empty($tmp_names[$i]))
{
if ($id = ilObjUser::getUserIdByLogin(addslashes($tmp_names[$i])))
{
$ids[] = $id;
}
}
}
}
return array_unique($ids);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::isSOAPEnabled ( )

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

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

Referenced by sendMimeMail().

{
global $ilSetting;
if(!extension_loaded('curl') || !$ilSetting->get('soap_user_administration'))
{
return false;
}
// Prevent using SOAP in cron context
{
return false;
}
return (bool) $this->soap_enabled;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::markRead (   $a_mail_ids)

mark mails as read public

Parameters
arraymail ids
Returns
bool

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

References $ilDB, $in, $query, and $res.

{
global $ilDB;
$data = array();
$data_types = array();
$query = "UPDATE ". $this->table_mail ."
SET m_status = %s
WHERE user_id = %s ";
array_push($data_types, 'text', 'integer');
array_push($data, 'read', $this->user_id);
$cnt_mail_ids = count($a_mail_ids);
if (is_array($a_mail_ids) &&
count($a_mail_ids) > 0)
{
$in = 'mail_id IN (';
$counter = 0;
foreach($a_mail_ids as $a_mail_id)
{
array_push($data, $a_mail_id);
array_push($data_types, 'integer');
if($counter > 0) $in .= ',';
$in .= '%s';
++$counter;
}
$in .= ')';
$query .= ' AND '.$in;
}
$res = $ilDB->manipulateF($query, $data_types, $data);
return true;
}
ilMail::markUnread (   $a_mail_ids)

mark mails as unread public

Parameters
arraymail ids
Returns
bool

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

References $ilDB, $in, and $query.

{
global $ilDB;
$data = array();
$data_types = array();
$query = "UPDATE ". $this->table_mail ."
SET m_status = %s
WHERE user_id = %s ";
array_push($data_types, 'text', 'integer');
array_push($data, 'unread', $this->user_id);
$cnt_mail_ids = count($a_mail_ids);
if (is_array($a_mail_ids) &&
count($a_mail_ids) > 0)
{
$in = 'mail_id IN (';
$counter = 0;
foreach($a_mail_ids as $a_mail_id)
{
array_push($data, $a_mail_id);
array_push($data_types, 'integer');
if($counter > 0) $in .= ',';
$in .= '%s';
++$counter;
}
$in .= ')';
$query .= ' AND '.$in;
}
$statement = $ilDB->manipulateF($query, $data_types, $data);
return true;
}
ilMail::moveMailsToFolder (   $a_mail_ids,
  $a_folder_id 
)

move mail to folder public

Parameters
arraymail ids
intfolder_id
Returns
bool

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

References $ilDB, $in, and $query.

{
global $ilDB;
$data = array();
$data_types = array();
$query = "UPDATE ". $this->table_mail ."
SET folder_id = %s
WHERE user_id = %s ";
array_push($data_types, 'text', 'integer');
array_push($data, $a_folder_id, $this->user_id);
$cnt_mail_ids = count($a_mail_ids);
if (is_array($a_mail_ids) &&
count($a_mail_ids) > 0)
{
$in = 'mail_id IN (';
$counter = 0;
foreach($a_mail_ids as $a_mail_id)
{
array_push($data, $a_mail_id);
array_push($data_types, 'integer');
if($counter > 0) $in .= ',';
$in .= '%s';
++$counter;
}
$in .= ')';
$query .= ' AND '.$in;
}
$statement = $ilDB->manipulateF($query, $data_types, $data);
return true;
}
ilMail::parseRcptOfMailingLists (   $rcpt = '',
  $maintain_lists = false 
)

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

References explodeRecipients().

Referenced by sendMail().

{
if ($rcpt == '')
{
if(!$maintain_lists)
{
return $rcpt;
}
else
{
return array();
}
}
//@todo check rcp pear validation
$arrRcpt = $this->explodeRecipients(trim($rcpt));
if (!is_array($arrRcpt) || empty($arrRcpt))
{
if(!$maintain_lists)
{
return $rcpt;
}
else
{
return array();
}
}
$new_rcpt = array();
foreach ($arrRcpt as $item)
{
if (ilMail::_usePearMail())
{
if (substr($item->mailbox, 0, 7) == '#il_ml_')
{
if ($this->mlists->mailingListExists($item->mailbox))
{
foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
{
if(!$maintain_lists)
{
$new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
}
else
{
$new_rcpt[$item->mailbox][] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
}
}
}
}
else
{
$tmp_rcpt = '';
if($item->host == self::ILIAS_HOST)
{
$tmp_rcpt = $item->mailbox;
}
else
{
$tmp_rcpt = $item->mailbox.'@'.$item->host;
}
if(!$maintain_lists)
{
$new_rcpt[] = $tmp_rcpt;
}
else
{
$new_rcpt[0][] = $tmp_rcpt;
}
}
}
else
{
if (substr($item, 0, 7) == '#il_ml_')
{
if ($this->mlists->mailingListExists($item))
{
foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
{
if(!$maintain_lists)
{
$new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
}
else
{
$new_rcpt[$item][] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
}
}
}
}
else
{
if(!$maintain_lists)
{
$new_rcpt[] = $item;
}
else
{
$new_rcpt[0][] = $item;
}
}
}
}
if(!$maintain_lists)
{
return implode(',', $new_rcpt);
}
else
{
return $new_rcpt;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::readMailObjectReferenceId ( )

read and set mail object id private

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

References ilMailGlobalServices\getMailObjectRefId().

Referenced by __construct().

{
include_once 'Services/Mail/classes/class.ilMailGlobalServices.php';
$this->mail_obj_ref_id = ilMailGlobalServices::getMailObjectRefId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::replacePlaceholders (   $a_message,
  $a_user_id 
)

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

References $lng, and getCachedUserInstance().

Referenced by distributeMail(), and sendInternalMail().

{
global $lng;
$user = self::getCachedUserInstance($a_user_id);
// determine salutation
switch ($user->getGender())
{
case 'f': $gender_salut = $lng->txt('salutation_f');
break;
case 'm': $gender_salut = $lng->txt('salutation_m');
break;
}
$a_message = str_replace('[MAIL_SALUTATION]', $gender_salut, $a_message);
$a_message = str_replace('[LOGIN]', $user->getLogin(), $a_message);
$a_message = str_replace('[FIRST_NAME]', $user->getFirstname(), $a_message);
$a_message = str_replace('[LAST_NAME]', $user->getLastname(), $a_message);
$a_message = str_replace('[ILIAS_URL]', ILIAS_HTTP_PATH.'/login.php?client_id='.CLIENT_ID, $a_message);
$a_message = str_replace('[CLIENT_NAME]', CLIENT_NAME, $a_message);
return $a_message;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::saveAttachments (   $a_attachments)

set attachments

Parameters
arrayarray of attachments public
Returns
bool

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

References $ilDB.

{
global $ilDB;
$ilDB->update($this->table_mail_saved,
array
(
'attachments' => array('clob', serialize($a_attachments))
),
array
(
'user_id' => array('integer', $this->user_id)
)
);
return true;
}
ilMail::saveInSentbox (   $a_attachment,
  $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_type,
  $a_m_subject,
  $a_m_message 
)

send mime mail using class.ilMimeMail.php

Parameters
arrayattachments
stringto
stringcc
stringbcc
stringtype
stringsubject
stringmessage public
Returns
int mail id
Todo:
: mjansen 23.12.2011 Why is $a_as_email undefined here?

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

References sendInternalMail().

Referenced by sendMail().

{
include_once "Services/Mail/classes/class.ilMailbox.php";
$mbox = new ilMailbox($this->user_id);
$sent_id = $mbox->getSentFolder();
return $this->sendInternalMail($sent_id,$this->user_id,$a_attachment,$a_rcp_to,$a_rcp_cc,
$a_rcp_bcc,'read',$a_type,$a_as_email,$a_m_subject,$a_m_message,$this->user_id, 0);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

save post data in table public

Parameters
intuser_id
arrayattachments
stringto
stringcc
stringbcc
arraytype of mail (system,normal,email)
intas email (1,0)
stringsubject
stringmessage
intuse placeholders
Returns
bool

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

References $ilDB, and getSavedData().

Referenced by ilObjUserFolderGUI\mailObject().

{
global $ilDB;
if(!$a_attachments) $a_attachments = NULL;
if(!$a_rcp_to) $a_rcp_to = NULL;
if(!$a_rcp_cc) $a_rcp_cc = NULL;
if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
if(!$a_m_type) $a_m_type = NULL;
if(!$a_m_email) $a_m_email = NULL;
if(!$a_m_message) $a_m_message = NULL;
if(!$a_use_placeholders) $a_use_placeholders = '0';
$statement = $ilDB->manipulateF('
DELETE FROM '. $this->table_mail_saved .'
WHERE user_id = %s',
array('integer'), array($this->user_id));
$ilDB->insert($this->table_mail_saved, array(
'user_id' => array('integer', $a_user_id),
'attachments' => array('clob', serialize($a_attachments)),
'rcp_to' => array('clob', $a_rcp_to),
'rcp_cc' => array('clob', $a_rcp_cc),
'rcp_bcc' => array('clob', $a_rcp_bcc),
'm_type' => array('text', serialize($a_m_type)),
'm_email' => array('integer', $a_m_email),
'm_subject' => array('text', $a_m_subject),
'm_message' => array('clob', $a_m_message),
'use_placeholders' => array('integer', $a_use_placeholders),
));
$this->getSavedData();
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

save mail in folder private

Parameters
integerid of folder
integersender_id
arrayattachments
stringto
stringcc
stringbcc
stringstatus
stringtype of mail (system,normal)
integeras email (1,0)
stringsubject
stringmessage
integeruser_id
Returns
integer mail_id

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

References $ilDB, $log, $user_id, and replacePlaceholders().

Referenced by distributeMail(), and saveInSentbox().

{
$a_user_id = $a_user_id ? $a_user_id : $this->user_id;
global $ilDB, $log;
//$log->write('class.ilMail->sendInternalMail to user_id:'.$a_rcp_to.' '.$a_m_message);
if ($a_use_placeholders)
{
$a_m_message = $this->replacePlaceholders($a_m_message, $a_user_id);
}
else
{
$a_use_placeholders = '0';
}
if(!$a_user_id) $a_user_id = '0';
if(!$a_folder_id) $a_folder_id = '0';
if(!$a_sender_id) $a_sender_id = NULL;
if(!$a_attachments) $a_attachments = NULL;
if(!$a_rcp_to) $a_rcp_to = NULL;
if(!$a_rcp_cc) $a_rcp_cc = NULL;
if(!$a_rcp_bcc) $a_rcp_bcc = NULL;
if(!$a_status) $a_status = NULL;
if(!$a_m_type) $a_m_type = NULL;
if(!$a_m_email) $a_m_email = NULL;
if(!$a_m_subject) $a_m_subject = NULL;
if(!$a_m_message) $a_m_message = NULL;
$next_id = $ilDB->nextId($this->table_mail);
$ilDB->insert($this->table_mail, array(
'mail_id' => array('integer', $next_id),
'user_id' => array('integer', $a_user_id),
'folder_id' => array('integer', $a_folder_id),
'sender_id' => array('integer', $a_sender_id),
'attachments' => array('clob', serialize($a_attachments)),
'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
'rcp_to' => array('clob', $a_rcp_to),
'rcp_cc' => array('clob', $a_rcp_cc),
'rcp_bcc' => array('clob', $a_rcp_bcc),
'm_status' => array('text', $a_status),
'm_type' => array('text', serialize($a_m_type)),
'm_email' => array('integer', $a_m_email),
'm_subject' => array('text', $a_m_subject),
'm_message' => array('clob', $a_m_message)
));
return $next_id; //$ilDB->getLastInsertId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

send external mail using class.ilMimeMail.php

Parameters
stringto
stringcc
stringbcc
stringsubject
stringmessage
arrayattachments
arraytype (normal and/or system and/or email)
integeralso as email (0,1) public
Returns
array of saved data

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

References $lng, $log, __checkSystemRecipients(), __getCountRecipients(), __getEmailRecipients(), __substituteRecipients(), _getInstallationSignature(), appendInstallationSignature(), checkMail(), checkRecipients(), deleteMails(), distributeMail(), getSaveInSentbox(), ilMailingList\MODE_TEMPORARY, parseRcptOfMailingLists(), saveInSentbox(), and sendMimeMail().

{
global $lng,$rbacsystem,$log;
//$log->write('class.ilMail.sendMail '.$a_rcp_to.' '.$a_m_subject);
$this->mail_to_global_roles = true;
if($this->user_id != ANONYMOUS_USER_ID)
{
$this->mail_to_global_roles = $rbacsystem->checkAccessOfUser($this->user_id, 'mail_to_global_roles', $this->mail_obj_ref_id);
}
$error_message = '';
$message = '';
if (in_array("system",$a_type))
{
$this->__checkSystemRecipients($a_rcp_to);
$a_type = array('system');
}
if ($a_attachment)
{
if (!$this->mfile->checkFilesExist($a_attachment))
{
return "YOUR LIST OF ATTACHMENTS IS NOT VALID, PLEASE EDIT THE LIST";
}
}
// CHECK NECESSARY MAIL DATA FOR ALL TYPES
if ($error_message = $this->checkMail($a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_m_subject,$a_m_message,$a_type))
{
return $error_message;
}
try
{
// check recipients
if ($error_message = $this->checkRecipients($a_rcp_to,$a_type))
{
$message .= $error_message;
}
if ($error_message = $this->checkRecipients($a_rcp_cc,$a_type))
{
$message .= $error_message;
}
if ($error_message = $this->checkRecipients($a_rcp_bc,$a_type))
{
$message .= $error_message;
}
}
catch(ilMailException $e)
{
return $this->lng->txt($e->getMessage());
}
// if there was an error
if (!empty($message))
{
return $this->lng->txt("mail_following_rcp_not_valid").$message;
}
// ACTIONS FOR ALL TYPES
// GET RCPT OF MAILING LISTS
$rcp_to_list = $this->parseRcptOfMailingLists($a_rcp_to, true);
$rcp_cc_list = $this->parseRcptOfMailingLists($a_rcp_cc, true);
$rcp_bc_list = $this->parseRcptOfMailingLists($a_rcp_bc, true);
$rcp_to = $rcp_cc = $rcp_bc = array();
foreach($rcp_to_list as $mlist_id => $mlist_rec)
{
if($mlist_id)
{
// internal mailing lists are sent as bcc
$mlist_id = substr($mlist_id, 7);
if($this->mlists->get($mlist_id)->getMode() == ilMailingList::MODE_TEMPORARY)
{
$rcp_bc = array_merge($rcp_bc, $mlist_rec);
continue;
}
}
$rcp_to = array_merge($rcp_to, $mlist_rec);
}
foreach($rcp_cc_list as $mlist_id => $mlist_rec)
{
if($mlist_id)
{
// internal mailing lists are sent as bcc
$mlist_id = substr($mlist_id, 7);
if($this->mlists->get($mlist_id)->getMode() == ilMailingList::MODE_TEMPORARY)
{
$rcp_bc = array_merge($rcp_bc, $mlist_rec);
continue;
}
}
$rcp_cc = array_merge($rcp_cc, $mlist_rec);
}
foreach($rcp_bc_list as $mlist_id => $mlist_rec)
{
$rcp_bc = array_merge($rcp_bc, $mlist_rec);
}
$rcp_to = implode(',', $rcp_to);
$rcp_cc = implode(',', $rcp_cc);
$rcp_bc = implode(',', $rcp_bc);
if (! ilMail::_usePearMail() )
{
// REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
$rcp_to = $this->__substituteRecipients($rcp_to,"substitute");
$rcp_cc = $this->__substituteRecipients($rcp_cc,"substitute");
$rcp_bc = $this->__substituteRecipients($rcp_bc,"substitute");
}
// COUNT EMAILS
$c_emails = $this->__getCountRecipients($rcp_to,$rcp_cc,$rcp_bc,true);
$c_rcp = $this->__getCountRecipients($rcp_to,$rcp_cc,$rcp_bc,false);
// currently disabled..
/*
if (count($c_emails))
{
if (!$this->getEmailOfSender())
{
return $lng->txt("mail_check_your_email_addr");
}
}
*/
// check smtp permission
if($c_emails && $this->user_id != ANONYMOUS_USER_ID &&
!$rbacsystem->checkAccessOfUser($this->user_id, 'smtp_mail', $this->mail_obj_ref_id))
{
return $this->lng->txt('mail_no_permissions_write_smtp');
}
{
}
// save mail in sent box
$sent_id = $this->saveInSentbox($a_attachment,$a_rcp_to,$a_rcp_cc,$a_rcp_bc,$a_type,
$a_m_subject,$a_m_message);
if($a_attachment)
{
$this->mfile->assignAttachmentsToDirectory($sent_id,$sent_id);
if ($error = $this->mfile->saveFiles($sent_id,$a_attachment))
{
return $error;
}
}
// FILTER EMAILS
// IF EMAIL RECIPIENT
if($c_emails)
{
$this->sendMimeMail($this->__getEmailRecipients($rcp_to),
$this->__getEmailRecipients($rcp_cc),
$this->__getEmailRecipients($rcp_bc),
$a_m_subject,
$a_m_message,
$a_attachment,
0);
}
if (in_array('system',$a_type))
{
if (!$this->distributeMail($rcp_to,$rcp_cc,$rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$sent_id,$a_type,'system', $a_use_placeholders))
{
return $lng->txt("mail_send_error");
}
}
// ACTIONS FOR TYPE SYSTEM AND NORMAL
if (in_array('normal',$a_type))
{
// TRY BOTH internal and email (depends on user settings)
if (!$this->distributeMail($rcp_to,$rcp_cc,$rcp_bc,$a_m_subject,$a_m_message,$a_attachment,$sent_id,$a_type,'normal', $a_use_placeholders))
{
return $lng->txt("mail_send_error");
}
}
// Temporary bugfix
if (!$this->getSaveInSentbox())
{
$this->deleteMails(array($sent_id));
}
return '';
}

+ Here is the call graph for this function:

ilMail::sendMimeMail (   $a_rcp_to,
  $a_rcp_cc,
  $a_rcp_bcc,
  $a_m_subject,
  $a_m_message,
  $a_attachments,
  $a_no_soap = false 
)

send mime mail using class.ilMimeMail.php All external mails are send to SOAP::sendMail starting a kind of background process

Parameters
stringof recipients
stringof recipients
stringof recipients
stringsubject
stringmessage
arrayattachments
boolprevent soap public
Returns
array of saved data

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

References $_COOKIE, getSubjectPrefix(), and isSOAPEnabled().

Referenced by distributeMail(), and sendMail().

{
include_once "Services/Mail/classes/class.ilMimeMail.php";
#var_dump("<pre>",$a_rcp_to,$a_rcp_cc,$a_rcp_bcc,$a_m_subject,$a_m_message,$a_attachments,"<pre>");
#$inst_name = $this->ilias->getSetting("inst_name") ? $this->ilias->getSetting("inst_name") : "ILIAS 4";
#$a_m_subject = "[".$inst_name."] ".$a_m_subject;
$a_m_subject = self::getSubjectPrefix().' '.$a_m_subject;
$sender = $this->getMimeMailSender();
// #10854
if($this->isSOAPEnabled() && !$a_no_soap)
{
// Send per soap
include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
$soap_client = new ilSoapClient();
$soap_client->setResponseTimeout(1);
$soap_client->enableWSDL(true);
$soap_client->init();
$attachments = array();
$a_attachments = $a_attachments ? $a_attachments : array();
foreach($a_attachments as $attachment)
{
$attachments[] = $this->mfile->getAbsolutePath($attachment);
}
// mjansen: switched separator from "," to "#:#" because of mantis bug #6039
$attachments = implode('#:#',$attachments);
// mjansen: use "#:#" as leading delimiter
if(strlen($attachments))
$attachments = "#:#".$attachments;
$soap_client->call('sendMail',array(session_id().'::'.$_COOKIE['ilClientId'], // session id
$a_rcp_to,
$a_rcp_cc,
$a_rcp_bcc,
$sender,
$a_m_subject,
$a_m_message,
$attachments));
return true;
}
else
{
// send direct
include_once "Services/Mail/classes/class.ilMimeMail.php";
$mmail = new ilMimeMail();
$mmail->autoCheck(false);
$mmail->From($sender);
$mmail->To($a_rcp_to);
// Add installation name to subject
$mmail->Subject($a_m_subject);
$mmail->Body($a_m_message);
if ($a_rcp_cc)
{
$mmail->Cc($a_rcp_cc);
}
if ($a_rcp_bcc)
{
$mmail->Bcc($a_rcp_bcc);
}
if (is_array($a_attachments))
{
foreach ($a_attachments as $attachment)
{
$mmail->Attach($this->mfile->getAbsolutePath($attachment), '', 'inline', $attachment);
}
}
$mmail->Send();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMail::setMailMessage (   $a_message)

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

{
$this->mail_message = $a_message;
}
ilMail::setMailRcpBc (   $a_rcp_bc)

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

{
$this->mail_rcp_bc = $a_rcp_bc;
}
ilMail::setMailRcpCc (   $a_rcp_cc)

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

{
$this->mail_rcp_cc = $a_rcp_cc;
}
ilMail::setMailRcpTo (   $a_rcp_to)

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

{
$this->mail_rcp_to = $a_rcp_to;
}
ilMail::setMailSendType (   $a_types)

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

{
$this->mail_send_type = $a_types;
}
ilMail::setMailSubject (   $a_subject)

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

{
$this->mail_subject = $a_subject;
}
ilMail::setSaveInSentbox (   $a_save_in_sentbox)

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

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

{
$this->save_in_sentbox = $a_save_in_sentbox;
}

+ Here is the caller graph for this function:

ilMail::setUsePear (   $bool)
private

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

Referenced by validatePear().

{
$this->use_pear = $bool;
}

+ Here is the caller graph for this function:

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 
)

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

References $ilDB.

{
global $ilDB;
$ilDB->update($this->table_mail,
array(
'folder_id' => array('integer', $a_folder_id),
'attachments' => array('clob', serialize($a_attachments)),
'send_time' => array('timestamp', date('Y-m-d H:i:s', time())),
'rcp_to' => array('clob', $a_rcp_to),
'rcp_cc' => array('clob', $a_rcp_cc),
'rcp_bcc' => array('clob', $a_rcp_bcc),
'm_status' => array('text', 'read'),
'm_type' => array('text', serialize($a_m_type)),
'm_email' => array('integer', $a_m_email),
'm_subject' => array('text', $a_m_subject),
'm_message' => array('clob', $a_m_message),
'use_placeholders' => array('integer', $a_use_placeholders)
),
array(
'mail_id' => array('integer', $a_draft_id)
)
);
return $a_draft_id;
}
ilMail::validatePear (   $a_recipients)
private
Parameters
<type>$a_recipients

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

References explodeRecipients(), and setUsePear().

Referenced by __getCountRecipient(), checkRecipients(), getEmailsOfRecipients(), and getUserIds().

{
if(ilMail::_usePearMail())
{
$this->setUsePear(true);
$tmp_names = $this->explodeRecipients($a_recipients, true);
if(is_a($tmp_names, 'PEAR_Error'))
{
$this->setUsePear(false);
}
}
else
{
$this->setUsePear(false);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilMail::$appendInstallationSignature = false
protected

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

Referenced by appendInstallationSignature().

ilMail::$ilias

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

Referenced by __construct().

ilMail::$lng

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

Referenced by __construct(), getSalutation(), replacePlaceholders(), and sendMail().

ilMail::$mail_counter

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

ilMail::$mail_message

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

ilMail::$mail_obj_ref_id

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

Referenced by getMailObjectReferenceId().

ilMail::$mail_options

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

ilMail::$mail_rcp_bc

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

ilMail::$mail_rcp_cc

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

ilMail::$mail_rcp_to

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

ilMail::$mail_send_type

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

ilMail::$mail_subject

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

ilMail::$mail_to_global_roles = 0

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

ilMail::$mail_use_placeholders = 0

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

ilMail::$mfile

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

ilMail::$properties = array()
protected

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

ilMail::$save_in_sentbox

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

Referenced by getSaveInSentbox().

ilMail::$soap_enabled = true

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

Referenced by isSOAPEnabled().

ilMail::$table_mail

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

ilMail::$table_mail_saved

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

ilMail::$use_pear = true
private

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

Referenced by explodeRecipients(), and getUsePear().

ilMail::$user_id

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

Referenced by checkRecipients(), and sendInternalMail().

ilMail::$userInstances = array()
staticprotected

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

const ilMail::ILIAS_HOST = 'ilias'

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