ILIAS  eassessment Revision 61809
 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

 ilMail ($a_user_id)
 Constructor setup an mail object public.
 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= '')
 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
 addFullname ($a_email)
 add user fullname to mail 'From'
 getMimeMailSender ()
 Returns the sender of the mime mail.
 sendMimeMail ($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_m_subject, $a_m_message, $a_attachments)
 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 getIliasMailerAddress ()
 Builds an email address used for system notifications.
static _getUserInternalMailboxAddress ($usr_id, $login=null, $firstname=null, $lastname=null)
 STATIC METHOD.
static _usePearMail ()
 STATIC METHOD.
static _getAutoGeneratedMessageString ($lang=null)
 get auto generated info string
static _getIliasMailerName ()
 Get the name used for mails sent by the anonymous user.
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

Protected Attributes

 $mlists = null
 $appendInstallationSignature = false

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 31725 2011-11-17 09:40:21Z hschottm

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

Member Function Documentation

ilMail::__checkSystemRecipients ( $a_rcp_to)

Definition at line 2395 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::__getCountRecipient (   $rcp,
  $a_only_email = true 
)

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

References __substituteRecipients(), ilObjUser\_lookupId(), _usePearMail(), 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 ilias host, and
// which have a mailbox which does not start with '#',
// are external e-mail addresses
if ($to->host != 'ilias' && 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 2327 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 2334 of file class.ilMail.php.

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

Referenced by sendMail().

{
{
$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 != 'ilias')
{
// 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 2378 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 2414 of file class.ilMail.php.

References $name, 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 2537 of file class.ilMail.php.

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

Referenced by ilECSAppEventListener\_sendNotification(), ilECSAppEventListener\handleEvent(), ilMailSummaryNotification\send(), ilECSContentWriter\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 4'),
$http_path."\n\n");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilMail::_getIliasMailerName ( )
static

Get the name used for mails sent by the anonymous user.

public

Returns
string Name of sender

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

Referenced by ilMailFolderTableGUI\fetchTableData(), ilPDMailBlockGUI\fillRow(), ilPDMailGUI\getPDMailHTML(), ilMailFolderGUI\printMail(), and ilMailFolderGUI\showMail().

{
return 'ILIAS';
}

+ 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 2594 of file class.ilMail.php.

References $desc, ilUtil\_getHttpPath(), and ILIAS_WEB_DIR.

Referenced by ilMailSummaryNotification\send(), and sendMail().

{
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)
{
$signature .= '/?client_id='.CLIENT_ID;
}
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 2471 of file class.ilMail.php.

References $usr_id, and _usePearMail().

{
{
if ($login == null)
{
require_once './Services/User/classes/class.ilObjUser.php';
$usr_obj = new ilObjUser($usr_id);
$usr_obj->read();
$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::_usePearMail ( )
static

STATIC METHOD.

Returns true, if Pear Mail shall be used for resolving mail addresses.

public

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

References $ilias, and $log.

Referenced by __getCountRecipient(), __getEmailRecipients(), _getUserInternalMailboxAddress(), checkRecipients(), distributeMail(), explodeRecipients(), getEmailsOfRecipients(), ilRbacReview\getRoleMailboxAddress(), getUserIds(), ilUtil\is_email(), ilObjiLincCourseGUI\mailMembersObject(), ilObjGroupGUI\mailMembersObject(), ilObjCourseGUI\mailMembersObject(), parseRcptOfMailingLists(), ilRbacReview\searchRolesByMailboxAddressList(), sendMail(), and validatePear().

{
global $ilias;
$result = false;
if ($ilias->getSetting('pear_mail_enable') == true)
{
// Note: We use the include statement to determine whether PEAR MAIL is
// installed. We use the @ operator to prevent PHP from issuing a
// warning while we test for PEAR MAIL.
$is_pear_mail_installed = @include_once 'Mail/RFC822.php';
if ($is_pear_mail_installed) {
$result = true;
} else {
// Disable Pear Mail, when we detect that it is not
// installed
global $log;
$log->write("WARNING: ilMail::_userPearMail disabled Pear Mail support, because include 'Mail/RFC822.php' failed.");
$ilias->setSetting('pear_mail_enable', false);
}
}
return $result;
}

+ Here is the caller graph for this function:

ilMail::addFullname (   $a_email)

add user fullname to mail 'From'

Parameters
stringemail of sender
Returns
string 'From' field

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

References ilMimeMail\_mimeEncode().

Referenced by getMimeMailSender().

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

+ Here is the call graph for this function:

+ Here is the caller 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 2575 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 1389 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 1515 of file class.ilMail.php.

References $user_id, _usePearMail(), explodeRecipients(), getUsePear(), ilObjUser\getUserIdByLogin(), ilUtil\groupNameExists(), 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 == 'ilias') ? ilObjUser::getUserIdByLogin(addslashes($rcp->mailbox)) : false;
if ($user_id == false && $rcp->host == 'ilias')
{
$wrong_rcps .= "<br />".htmlentities($rcp->mailbox);
continue;
}
// CHECK IF USER CAN RECEIVE MAIL
if ($user_id)
{
if(!$rbacsystem->checkAccessOfUser($user_id, "mail_visible", $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, "mail_visible", $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 1063 of file class.ilMail.php.

References $log, __substituteRecipients(), ilObjUser\_lookupEmail(), _usePearMail(), 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';
{
// 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_bc = $this->__substituteRecipients($a_rcp_bc, '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 =& new ilObjUser($id);
$tmp_user->read();
$user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() &&
$tmp_user->getActive() &&
$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
if (!$user_can_read_internal_mails ||
$tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
{
$as_email[] = $id;
continue;
}
if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
{
$as_email[] = $id;
}
$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[] = ilObjUser::_lookupEmail($as_email[0]);
}
else
{
foreach ($as_email as $id)
{
$bcc[] = ilObjUser::_lookupEmail($id);
}
}
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 =& new ilObjUser($id);
$tmp_user->read();
$user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() &&
$tmp_user->getActive() &&
$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
if (!$user_can_read_internal_mails ||
$tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
{
$as_email[] = $id;
continue;
}
if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
{
$as_email[] = $id;
}
$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)
{
$this->sendMimeMail(ilObjUser::_lookupEmail($id), '', '', $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 =& new ilObjUser($id);
$tmp_user->read();
$user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement()
&& $tmp_user->getActive() && $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
if (!$user_can_read_internal_mails ||
$tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL)
{
$as_email[] = $id;
continue;
}
if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH)
{
$as_email[] = $id;
}
$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))
{
foreach ($as_email as $id)
{
$this->sendMimeMail(ilObjUser::_lookupEmail($id), '', '', $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 271 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 334 of file class.ilMail.php.

{
$this->soap_enabled = $a_status;
}
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 2231 of file class.ilMail.php.

References $use_pear, and _usePearMail().

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

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

+ Here is the call graph for this function:

+ 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 467 of file class.ilMail.php.

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

{
$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))
{
$tmp_obj = new ilObjUser($uid);
if (in_array(ilObjUser::_lookupPref($uid, 'public_profile'), array("y", "g")))
{
$rcp_to_array[] = $tmp_obj->getFullname().' ['.$recipient.']';
}
else
{
$rcp_to_array[] = $recipient;
}
unset($tmp_obj);
}
else
{
$rcp_to_array[] = $recipient;
}
}
return trim(implode(', ', $rcp_to_array));
}
else
{
if($uid = ilObjUser::_lookupId($users))
{
$tmp_obj = new ilObjUser($uid);
if (in_array(ilObjUser::_lookupPref($uid, 'public_profile'), array("y", "g")))
{
return $tmp_obj->getFullname().' ['.$users.']';
}
else
{
unset($tmp_obj);
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 2213 of file class.ilMail.php.

{
return $this->mail_data["attachments"] ? $this->mail_data["attachments"] : array();
}
ilMail::getEmailOfSender ( )

get email of sender public

Returns
string email

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

References ilUtil\is_email().

Referenced by getMimeMailSender().

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

+ Here is the call graph for this function:

+ Here is the caller 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 1417 of file class.ilMail.php.

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

{
$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) != 'ilias')
{
$addresses[] = $rcp->mailbox.'@'.$rcp->host;
continue;
}
if ($id = ilObjUser::getUserIdByLogin(addslashes($rcp->mailbox)))
{
$tmp_user = new ilObjUser($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 = new ilObjUser($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 = new ilObjUser($id);
$addresses[] = $tmp_user->getEmail();
continue;
}
}
else
{
// GROUP THINGS
include_once("./classes/class.ilObjectFactory.php");
include_once('./Modules/Group/classes/class.ilObjGroup.php');
// Fix
foreach(ilObjGroup::_getAllReferences(ilObjGroup::_lookupIdByTitle(addslashes(substr($tmp_names[$i],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 = new ilObjUser($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 2042 of file class.ilMail.php.

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

Referenced by getMimeMailSender(), and ilMailSummaryNotification\send().

{
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 452 of file class.ilMail.php.

References $mail_obj_ref_id.

Referenced by ilUsersOnlineBlockGUI\getListRowData().

+ Here is the caller graph for this function:

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

Returns the sender of the mime mail.

Returns
string sender of the mime mail

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

References addFullname(), getEmailOfSender(), and getIliasMailerAddress().

Referenced by sendMimeMail().

{
include_once "Services/Mail/classes/class.ilMimeMail.php";
if($this->user_id != ANONYMOUS_USER_ID)
{
$sender = $this->addFullname($this->getEmailOfSender());
}
else
{
}
return $sender;
}

+ 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 2633 of file class.ilMail.php.

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

Referenced by ilMailSummaryNotification\send(), ilRegistrationMailNotification\send(), ilGroupMembershipMailNotification\send(), ilCourseMembershipMailNotification\send(), ilDiskQuotaSummaryNotification\send(), ilExerciseMailNotification\send(), and ilCalendarMailNotification\send().

{
global $lng;
$lang = $a_language ? $a_language : $lng;
$gender = ilObjUser::_lookupGender($a_usr_id);
$gender = $gender ? $gender : 'n';
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 1731 of file class.ilMail.php.

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

Referenced by 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 356 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 2620 of file class.ilMail.php.

References $ilSetting.

Referenced by sendMimeMail().

{
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 2658 of file class.ilMail.php.

References $use_pear.

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

{
}

+ 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 1277 of file class.ilMail.php.

References $log, $ref_id, $usr_id, ilObject\_getAllReferences(), ilObjUser\_lookupId(), ilObjGroup\_lookupIdByTitle(), _usePearMail(), explodeRecipients(), ilObjectFactory\getInstanceByRefId(), getUsePear(), ilObjUser\getUserIdByLogin(), ilUtil\groupNameExists(), 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) == 'ilias')
{
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("./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::ilMail (   $a_user_id)

Constructor setup an mail object public.

Parameters
integeruser_id

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

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

Referenced by ilFormatMail\ilFormatMail().

{
require_once "classes/class.ilFileDataMail.php";
require_once "Services/Mail/classes/class.ilMailOptions.php";
require_once "Services/Contact/classes/class.ilMailingLists.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);
if(is_object($ilUser))
{
$this->mlists = new ilMailingLists($ilUser);
}
// 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:

+ Here is the caller graph for this function:

ilMail::isSOAPEnabled ( )

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

References $ilSetting, and $soap_enabled.

Referenced by sendMimeMail().

{
global $ilSetting;
if(!extension_loaded('curl') || !$ilSetting->get('soap_user_administration'))
{
return false;
}
return (bool) $this->soap_enabled;
}

+ 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 $data, $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 $data, $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 $data, $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 = '')

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

References _usePearMail(), and explodeRecipients().

Referenced by sendMail().

{
if ($rcpt == '') return $rcpt;
$arrRcpt = $this->explodeRecipients(trim($rcpt));
if (!is_array($arrRcpt) || empty($arrRcpt)) return $rcpt;
$new_rcpt = array();
foreach ($arrRcpt as $item)
{
{
if (substr($item->mailbox, 0, 7) == '#il_ml_')
{
if ($this->mlists->mailingListExists($item->mailbox))
{
foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
{
$new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
}
}
}
else
{
$new_rcpt[] = $item->mailbox.'@'.$item->host;
}
}
else
{
if (substr($item, 0, 7) == '#il_ml_')
{
if ($this->mlists->mailingListExists($item))
{
foreach ($this->mlists->getCurrentMailingList()->getAssignedEntries() as $entry)
{
$new_rcpt[] = ($entry['login'] != '' ? $entry['login'] : $entry['email']);
}
}
}
else
{
$new_rcpt[] = $item;
}
}
}
return implode(',', $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 425 of file class.ilMail.php.

References $ilDB, $res, $row, and DB_FETCHMODE_ASSOC.

Referenced by ilMail().

{
global $ilDB;
// mail settings id is set by a constant in ilias.ini. Keep the select for some time until everyone has updated his ilias.ini
if (!MAIL_SETTINGS_ID)
{
$res = $ilDB->queryf('
SELECT object_reference.ref_id FROM object_reference, tree, object_data
WHERE tree.parent = %s
AND object_data.type = %s
AND object_reference.ref_id = tree.child
AND object_reference.obj_id = object_data.obj_id',
array('integer', 'text'),
array(SYSTEM_FOLDER_ID, 'mail'));
while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
{
$this->mail_obj_ref_id = $row["ref_id"];
}
}
else
{
$this->mail_obj_ref_id = MAIL_SETTINGS_ID;
}
}

+ 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.

Referenced by distributeMail(), and sendInternalMail().

{
global $lng;
$user = new ilObjUser($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);
unset($user);
return $a_message;
}

+ Here is the caller graph for this function:

ilMail::saveAttachments (   $a_attachments)

set attachments

Parameters
arrayarray of attachments public
Returns
bool

Definition at line 2190 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

Definition at line 1983 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 1679 of file class.ilMail.php.

References $ilDB, and getSavedData().

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

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 1759 of file class.ilMail.php.

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

{
global $lng,$rbacsystem,$log;
//$log->write('class.ilMail.sendMail '.$a_rcp_to.' '.$a_m_subject);
$this->mail_to_global_roles = $rbacsystem->checkAccess('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;
}
// CHECK FOR SYSTEM MAIL
if (in_array('system',$a_type))
{
if (!empty($a_attachment))
{
return $lng->txt("mail_no_attach_allowed");
}
}
// ACTIONS FOR ALL TYPES
// GET RCPT OF MAILING LISTS
$rcp_to = $this->parseRcptOfMailingLists($a_rcp_to);
$rcp_cc = $this->parseRcptOfMailingLists($a_rcp_cc);
$rcp_bc = $this->parseRcptOfMailingLists($a_rcp_bc);
{
// 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->checkAccess('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 
)

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 public
Returns
array of saved data

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

References $_COOKIE, getMimeMailSender(), 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();
if($this->isSOAPEnabled())
{
// Send per soap
include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
$soap_client = new ilSoapClient();
$soap_client->setTimeout(1);
$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($_COOKIE['PHPSESSID'].'::'.$_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));
}
}
$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 416 of file class.ilMail.php.

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

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

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

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

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

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

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

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

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

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

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

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

Referenced by ilMail().

{
$this->save_in_sentbox = $a_save_in_sentbox;
}

+ Here is the caller graph for this function:

ilMail::setUsePear (   $bool)
private

Definition at line 2654 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 2668 of file class.ilMail.php.

References _usePearMail(), explodeRecipients(), getUsePear(), and setUsePear().

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

{
{
$this->setUsePear(true);
$tmp_names = $this->explodeRecipients($a_recipients, $this->getUsePear());
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 232 of file class.ilMail.php.

Referenced by appendInstallationSignature().

ilMail::$ilias

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

Referenced by _usePearMail(), and ilMail().

ilMail::$lng

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

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

ilMail::$mail_counter

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

ilMail::$mail_message

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

ilMail::$mail_obj_ref_id

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

Referenced by getMailObjectReferenceId().

ilMail::$mail_options

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

ilMail::$mail_rcp_bc

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

ilMail::$mail_rcp_cc

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

ilMail::$mail_rcp_to

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

ilMail::$mail_send_type

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

ilMail::$mail_subject

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

ilMail::$mail_to_global_roles = 0

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

ilMail::$mail_use_placeholders = 0

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

ilMail::$mfile

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

ilMail::$mlists = null
protected

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

ilMail::$save_in_sentbox

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

Referenced by getSaveInSentbox().

ilMail::$soap_enabled = true

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

Referenced by isSOAPEnabled().

ilMail::$table_mail

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

ilMail::$table_mail_saved

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

ilMail::$use_pear = true
private

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

Referenced by explodeRecipients(), and getUsePear().

ilMail::$user_id

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

Referenced by checkRecipients(), and sendInternalMail().


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