Public Member Functions | Static Public Member Functions | Data Fields | Private Attributes

ilMail Class Reference

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

Inheritance 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 ()
 formatNotificationSubject ()
 formatNotificationMessage ($user_id, $mail_data=array())
 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)
 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'
 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)
 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.

Static Public Member Functions

static _getUserInternalMailboxAddress ($usr_id, $login=null, $firstname=null, $lastname=null)
 STATIC METHOD.
static _usePearMail ()
 STATIC METHOD.
static _getAnonymousName ()

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

Private Attributes

 $mlists = null

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@mail.com. 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@mail.com John Doe <jd@mail.com>

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:

Role object mailbox address:

External E-Mail address:

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@mail.com

Syntax: The following syntax rule is relevant for the semantics described below:

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

Semantics: User account mailbox address:

Role object mailbox address:

External E-Mail address:

Author:
Stefan Meyer <smeyer@databay.de>
Version:
Id:
class.ilMail.php 17877 2008-11-11 13:17:45Z mjansen

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


Member Function Documentation

ilMail::__checkSystemRecipients ( &$  a_rcp_to  ) 

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

References _usePearMail(), and explodeRecipients().

Referenced by __getCountRecipients().

        {
                $counter = 0;

                if (ilMail::_usePearMail())
                {
                        $tmp_rcp = $this->explodeRecipients($rcp);
                        if (! is_a($tmp_rcp, 'PEAR_Error'))
                        {
                                foreach ($tmp_rcp as $to)
                                {
                                        if ($a_only_email)
                                        {
                                                // 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) as $to)
                        {
                                if ($a_only_email)
                                {
                                        if (strpos($to,'@'))
                                        {
                                                ++$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 2072 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 2079 of file class.ilMail.php.

References _usePearMail(), 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 != 'ilias')
                                        {
                                                $rcp[] = $to->mailbox.'@'.$to->host;
                                        }
                                }
                        }
                        return implode(',',$rcp);
                }
                else
                {
                        foreach ($this->explodeRecipients($a_rcp) as $to)
                        {
                                if(strpos($to,'@'))
                                {
                                        $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 2110 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 2146 of file class.ilMail.php.

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

Referenced by 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::_getAnonymousName (  )  [static]

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

Referenced by ilPDMailBlockGUI::fillRow(), ilPDMailGUI::getPDMailHTML(), ilMailFolderGUI::printMail(), ilMailFolderGUI::showFolder(), and ilMailFolderGUI::showMail().

        {               
                return 'ILIAS';
        }

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_id the usr_id of the user
login optional, but if you supply it, you have to supply the firstname and the lastname as well
firstname optional
lastname public

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

References _usePearMail().

Referenced by ilUsersOnlineBlockGUI::getListRowData().

                                                                                                                     {
                if (ilMail::_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();
                        }
                        return preg_replace('/[()<>@,;:\\".\[\]]/','',$firstname.' '.$lastname).' <'.$login.'>';
                }
                else
                {
                        return $login;
                }
        }

Here is the call graph for this function:

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

References $ilias, and $log.

Referenced by __getCountRecipient(), __getEmailRecipients(), _getUserInternalMailboxAddress(), checkRecipients(), distributeMail(), explodeRecipients(), getEmailsOfRecipients(), ilRbacReview::getRoleMailboxAddress(), getUserIds(), parseRcptOfMailingLists(), ilRbacReview::searchRolesByMailboxAddressList(), and sendMail().

                                              {
                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:
string email of sender
Returns:
string 'From' field

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

References ilMimeMail::_mimeEncode().

Referenced by sendMimeMail().

        {
                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::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:
string rcp_to
string rcp_cc
string rcp_bcc
string m_subject
string m_message
Returns:
string error message

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

Referenced by sendMail().

        {
                $error_message = '';

                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:
string string 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 1387 of file class.ilMail.php.

References $user_id, _usePearMail(), explodeRecipients(), ilObjUser::getUserIdByLogin(), ilUtil::groupNameExists(), and ilUtil::is_email().

Referenced by sendMail().

        {
                global $rbacsystem,$rbacreview;
                $wrong_rcps = '';

                if (ilMail::_usePearMail())
                {
                        $tmp_rcp = $this->explodeRecipients($a_recipients);
                        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 (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
                {
                        $tmp_rcp = $this->explodeRecipients($a_recipients);

                        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
                                                !ilUtil::is_email($rcp))
                                        {
                                                $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;
                                }                               
                        }
                }
                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:
integer id of folder
Returns:
bool number of mails

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

References $res.

        {
                global $ilDB;           

                $query = "SELECT COUNT(*) FROM $this->table_mail ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id) ." ".
                        "AND folder_id = ".$ilDB->quote($a_folder_id)." ";
                
                if (is_object($res = $this->ilias->db->query($query)))
                {
                        return $res->numRows(); 
                }
                
                return 0;
        }

ilMail::deleteMails ( a_mail_ids  ) 

delete mail public

Parameters:
array mail ids
Returns:
bool

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

References $res.

Referenced by sendMail().

        {
                global $ilDB;
                
                foreach ($a_mail_ids as $id)
                {
                        $query = "DELETE FROM $this->table_mail ".
                                "WHERE user_id = ".$ilDB->quote($this->user_id)." ".
                                "AND mail_id = ".$ilDB->quote($id)." ";
                        $res = $this->ilias->db->query($query);
                        $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:
integer id of folder

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

References $res.

        {
                if ($a_folder_id)
                {               
                        global $ilDB;
        
                        $query = "DELETE FROM $this->table_mail ".
                                "WHERE user_id = ".$ilDB->quote($this->user_id) ." ".
                                "AND folder_id = ".$ilDB->quote($a_folder_id)." ";
                        
                        $res = $this->ilias->db->query($query);
                        
                        return true;
                }
                
                return false;
        }

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:
string to
string cc
string bcc
string subject
string message
array attachments
integer id of mail which is stored in sentbox
array 'normal' and/or 'system' and/or 'email'
Returns:
bool

Definition at line 950 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';

                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_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 262 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 325 of file class.ilMail.php.

        {
                $this->soap_enabled = $a_status;
        }

ilMail::explodeRecipients ( a_recipients  ) 

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

References _usePearMail().

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

        {
                if (ilMail::_usePearMail())
                {
                        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:
object object of query
Returns:
array array of query data

Definition at line 795 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"          => stripslashes($a_row->rcp_to),
                        "rcp_cc"          => stripslashes($a_row->rcp_cc),
                        "rcp_bcc"         => stripslashes($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"       => stripslashes($a_row->m_subject),
                        "m_message"       => stripslashes($a_row->m_message),                   
                        "import_name"     => stripslashes($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 $users String containing to, cc or bcc recipients
Returns:
string Formatted names

public

Definition at line 485 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(ilObjUser::_lookupPref($uid, 'public_profile') == 'y')
                                                {                                                               
                                                        $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(ilObjUser::_lookupPref($uid, 'public_profile') == 'y')
                                        {
                                                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::formatNotificationMessage ( user_id,
mail_data = array() 
)

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

References $lng, $mail_data, $tpl, $user_id, ilFormat::formatDate(), and replacePlaceholders().

        {
                global $tpl, $lng;
                
                $tpl =& new ilTemplate('tpl.mail_notifications.html', true, true, 'Services/Mail');
                
                $tpl->setVariable('TXT_RECEIVED_MAILS', sprintf($this->lng->txt('mail_received_x_new_mails'), count($mail_data)));
                                
                $counter = 0;
                foreach ($mail_data as $mail)
                {
                        $tpl->setCurrentBlock('mails');
                        $tpl->setVariable('NR', $counter + 1);                  
                        $tpl->setVariable('TXT_SENT', $this->lng->txt('sent'));
                        $tpl->setVariable('SEND_TIME', ilFormat::formatDate($mail['send_time']));
                        $tpl->setVariable('TXT_SUBJECT', $this->lng->txt('subject'));
                        $tpl->setVariable('SUBJECT', $mail['m_subject']);               
                        $tpl->parseCurrentBlock();
                        
                        ++$counter;     
                }               
                
                $message = $this->replacePlaceholders($tpl->get(), $user_id);           
                
                return $message;
        }

Here is the call graph for this function:

ilMail::formatNotificationSubject (  ) 

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

        {
                return $this->lng->txt('mail_notification_subject');
        }

ilMail::getAttachments (  ) 

get attachments public

Returns:
array array of attachments

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

References ilUtil::is_email().

Referenced by sendMimeMail().

        {
                $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:
string string with login names or group names (start with #) or email address
Returns:
string seperated by ','

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

References $ref_id, ilObject::_getAllReferences(), ilObjGroup::_lookupIdByTitle(), _usePearMail(), explodeRecipients(), ilObjectFactory::getInstanceByRefId(), and ilObjUser::getUserIdByLogin().

        {
                $addresses = array();

                if (ilMail::_usePearMail())
                {
                        $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);
        
                        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('./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:

ilMail::getMail ( a_mail_id  ) 

get data of one mail public

Parameters:
int mail_id
Returns:
array mail_data

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

References fetchMailData().

        {
                global $ilDB;
                
                $query = "SELECT * FROM $this->table_mail ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ".
                        "AND mail_id = ".$ilDB->quote($a_mail_id)." ";
                
                $this->mail_data = $this->fetchMailData($this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT));
                
                return $this->mail_data; 
        }

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

        {
                return $this->mail_obj_ref_id;
        }

ilMail::getMailsOfFolder ( a_folder_id  ) 

get all mails of a specific folder public

Parameters:
integer id of folder
Returns:
array mails

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

References $res, fetchMailData(), and ilObjectFactory::ObjectIdExists().

        {
                global $ilDB;
                
                $this->mail_counter = array();
                $this->mail_counter["read"] = 0;
                $this->mail_counter["unread"] = 0;

                $query = "SELECT * FROM $this->table_mail ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id) ." ".
                        "AND folder_id = ".$ilDB->quote($a_folder_id)." ORDER BY send_time DESC";
                
                $res = $this->ilias->db->query($query);

                while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if($row->sender_id and !ilObjectFactory::ObjectIdExists($row->sender_id))
                        {
                                continue;
                        }
                        $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:

ilMail::getNextMail ( a_mail_id  ) 

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

References fetchMailData().

        {
                global $ilDB;
                
                $query = "SELECT b.* FROM " . $this->table_mail ." AS a ".
                                 "INNER JOIN ".$this->table_mail ." AS 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 = ".$ilDB->quote($this->user_id) ." ".                                 
                                 "AND a.mail_id = ".$ilDB->quote($a_mail_id)." ORDER BY b.send_time DESC LIMIT 1";
                
                $this->mail_data = $this->fetchMailData($this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT));
                
                return $this->mail_data;
        }

Here is the call graph for this function:

ilMail::getPreviousMail ( a_mail_id  ) 

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

References fetchMailData().

        {
                global $ilDB;
                
                $query = "SELECT b.* FROM " . $this->table_mail ." AS a ".
                                 "INNER JOIN ".$this->table_mail ." AS 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 = ".$ilDB->quote($this->user_id) ." ".                                 
                                 "AND a.mail_id = ".$ilDB->quote($a_mail_id)." ORDER BY b.send_time ASC LIMIT 1";
                
                $this->mail_data = $this->fetchMailData($this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT));
                
                return $this->mail_data; 
        }

Here is the call graph for this function:

ilMail::getSavedData (  ) 

get saved data public

Returns:
array of saved data

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

References fetchMailData().

Referenced by savePostData().

        {
                global $ilDB;
                
                $query = "SELECT * FROM $this->table_mail_saved ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ";

                $this->mail_data = $this->fetchMailData($this->ilias->db->getRow($query, DB_FETCHMODE_OBJECT));

                return $this->mail_data;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilMail::getSaveInSentbox (  ) 

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

Referenced by sendMail().

        {
                return $this->save_in_sentbox;
        }

Here is the caller graph for this function:

ilMail::getUserIds ( a_recipients  ) 

get user_ids

Parameters:
string recipients seperated by ','
Returns:
string error message

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

References $log, $ref_id, ilObject::_getAllReferences(), ilObjGroup::_lookupIdByTitle(), _usePearMail(), explodeRecipients(), ilObjectFactory::getInstanceByRefId(), ilObjUser::getUserIdByLogin(), and ilUtil::groupNameExists().

Referenced by distributeMail().

        {
                global $log, $rbacreview;
                $ids = array();

                if (ilMail::_usePearMail())
                {
                        $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) === '#')
                                        {
                                                $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
                                        {
                                                //$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);
                        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('./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:
integer user_id

Definition at line 235 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/Mail/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);
                $this->mlists = new ilMailingLists($ilUser);

                // DEFAULT: sent mail aren't stored insentbox of user.
                $this->setSaveInSentbox(false);

                // GET REFERENCE ID OF MAIL OBJECT
                $this->readMailObjectReferenceId();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilMail::isSOAPEnabled (  ) 

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

Referenced by sendMimeMail().

        {
                if(!extension_loaded('curl'))
                {
                        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:
array mail ids
Returns:
bool

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

References $res, and ilUtil::quoteArray().

        {
                global $ilDB;
                // CREATE IN STATEMENT
                $in = "(". implode(",",ilUtil::quoteArray($a_mail_ids)) . ")";
                
                $query = "UPDATE $this->table_mail ".
                        "SET m_status = 'read' ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ".
                        "AND mail_id IN $in";

                $res = $this->ilias->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilMail::markUnread ( a_mail_ids  ) 

mark mails as unread public

Parameters:
array mail ids
Returns:
bool

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

References $res, and ilUtil::quoteArray().

        {
                global $ilDB;
                // CREATE IN STATEMENT
                $in = "(". implode(",",ilUtil::quoteArray($a_mail_ids)) . ")";
                
                $query = "UPDATE $this->table_mail ".
                        "SET m_status = 'unread' ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ".
                        "AND mail_id IN $in";

                $res = $this->ilias->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilMail::moveMailsToFolder ( a_mail_ids,
a_folder_id 
)

move mail to folder public

Parameters:
array mail ids
int folder_id
Returns:
bool

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

References $res, and ilUtil::quoteArray().

        {
                global $ilDB;
                // CREATE IN STATEMENT
                $in = "(". implode(",",ilUtil::quoteArray($a_mail_ids)) . ")";

                $query = "UPDATE $this->table_mail ".
                        "SET folder_id = ".$ilDB->quote($a_folder_id)." ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ".
                        "AND mail_id IN $in";

                $res = $this->ilias->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilMail::parseRcptOfMailingLists ( rcpt = ''  ) 

Definition at line 1735 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 (ilMail::_usePearMail())
                        {
                                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 413 of file class.ilMail.php.

References $res.

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)
                {
                        $query = "SELECT object_reference.ref_id FROM object_reference,tree,object_data ".
                                        "WHERE tree.parent = ".$ilDB->quote(SYSTEM_FOLDER_ID)." ".
                                        "AND object_data.type = 'mail' ".
                                        "AND object_reference.ref_id = tree.child ".
                                        "AND object_reference.obj_id = object_data.obj_id";
                        $res = $this->ilias->db->query($query);

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

References $lng, and $user.

Referenced by distributeMail(), formatNotificationMessage(), 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:
array array of attachments public
Returns:
bool

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

References $res.

        {
                global $ilDB;
                
                $query = "UPDATE $this->table_mail_saved ".
                        "SET attachments = '".addslashes(serialize($a_attachments))."' ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ";

                $res = $this->ilias->db->query($query);

                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:
array attachments
string to
string cc
string bcc
string type
string subject
string message public
Returns:
int mail id

Definition at line 1797 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:
int user_id
array attachments
string to
string cc
string bcc
array type of mail (system,normal,email)
int as email (1,0)
string subject
string message
int use placeholders
Returns:
bool

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

References $res, and getSavedData().

        {
                global $ilDB;
                
                $query = "DELETE FROM $this->table_mail_saved ".
                        "WHERE user_id = ".$ilDB->quote($this->user_id)." ";
                $res = $this->ilias->db->query($query);

                $query = "INSERT INTO $this->table_mail_saved ".
                        "SET user_id = ".$ilDB->quote($a_user_id).",".
                        "attachments = '".addslashes(serialize($a_attachments))."',".
                        "rcp_to = ".$ilDB->quote($a_rcp_to).",".
                        "rcp_cc = ".$ilDB->quote($a_rcp_cc).",".
                        "rcp_bcc = ".$ilDB->quote($a_rcp_bcc).",".
                        "m_type = '".addslashes(serialize($a_m_type))."',".
                        "m_email = '',".
                        "m_subject = ".$ilDB->quote($a_m_subject).",".
                        "m_message = ".$ilDB->quote($a_m_message).",".
                        "use_placeholders = ".$ilDB->quote($a_use_placeholders)."";
                $res = $this->ilias->db->query($query);

                $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:
integer id of folder
integer sender_id
array attachments
string to
string cc
string bcc
string status
string type of mail (system,normal)
integer as email (1,0)
string subject
string message
integer user_id
Returns:
integer mail_id

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

References $log, $res, 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);

                $query = "INSERT INTO $this->table_mail ".
                        "SET user_id = ".$ilDB->quote($a_user_id).",".
                        "folder_id = ".$ilDB->quote($a_folder_id).",".
                        "sender_id = ".$ilDB->quote($a_sender_id).",".
                        "attachments = '".addslashes(serialize($a_attachments))."',".
                        "send_time = now(),".
                        "rcp_to = ".$ilDB->quote($a_rcp_to).",".
                        "rcp_cc = ".$ilDB->quote($a_rcp_cc).",".
                        "rcp_bcc = ".$ilDB->quote($a_rcp_bcc).",".
                        "m_status = ".$ilDB->quote($a_status).",".
                        "m_type = '".addslashes(serialize($a_m_type))."',".
                        "m_email = ".$ilDB->quote($a_m_email).",".
                        "m_subject = ".$ilDB->quote($a_m_subject).",".
                        "m_message = ".$ilDB->quote($a_m_message)." ";

                $res = $this->ilias->db->query($query);
                $query = "SELECT LAST_INSERT_ID() as id";
                $row = $this->ilias->db->getRow($query,DB_FETCHMODE_ASSOC);

                return $row["id"];
        }

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:
string to
string cc
string bcc
string subject
string message
array attachments
array type (normal and/or system and/or email)
integer also as email (0,1) public
Returns:
array of saved data

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

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

        {
                global $lng,$rbacsystem,$log;
                //$log->write('class.ilMail.sendMail '.$a_rcp_to.' '.$a_m_subject);
                $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;
                }
                // 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;
                }
                // 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);

                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->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:
string of recipients
string of recipients
string of recipients
string subject
string message
array attachments public
Returns:
array of saved data

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

References ilMimeMail::_mimeEncode(), addFullname(), getEmailOfSender(), and isSOAPEnabled().

Referenced by distributeMail(), and sendMail().

        {
                #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 3";
                $a_m_subject = "[".$inst_name."] ".$a_m_subject;
                
                if($this->user_id != ANONYMOUS_USER_ID)
                {
                        $sender = $this->addFullname($this->getEmailOfSender());        
                }
                else
                {
                        if(trim($this->ilias->getSetting('mail_external_sender_noreply')) != '')
                        {
                                include_once "Services/Mail/classes/class.ilMimeMail.php";
                                $sender = ilMimeMail::_mimeEncode(self::_getAnonymousName()).
                                                  '<noreply@'.trim($this->ilias->getSetting('mail_external_sender_noreply')).'>';
                        }
                        else
                        {
                                include_once "Services/Mail/classes/class.ilMimeMail.php";
                                $sender = ilMimeMail::_mimeEncode(self::_getAnonymousName()).
                                                  '<noreply@'.$_SERVER['SERVER_NAME'].'>';
                        }
                }

                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);
                        }
                        $attachments = implode(',',$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 404 of file class.ilMail.php.

        {
                $this->mail_message = $a_message;
        }

ilMail::setMailRcpBc ( a_rcp_bc  ) 

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

        {
                $this->mail_rcp_bc = $a_rcp_bc;
        }

ilMail::setMailRcpCc ( a_rcp_cc  ) 

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

        {
                $this->mail_rcp_cc = $a_rcp_cc;
        }

ilMail::setMailRcpTo ( a_rcp_to  ) 

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

        {
                $this->mail_rcp_to = $a_rcp_to;
        }

ilMail::setMailSendType ( a_types  ) 

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

        {
                $this->mail_send_type = $a_types;
        }

ilMail::setMailSubject ( a_subject  ) 

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

        {
                $this->mail_subject = $a_subject;
        }

ilMail::setSaveInSentbox ( a_save_in_sentbox  ) 

Definition at line 339 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::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 818 of file class.ilMail.php.

References $res.

        {
                global $ilDB;
                
                $query = "UPDATE $this->table_mail ".
                        "SET folder_id = ".$ilDB->quote($a_folder_id).",".
                        "attachments = '".addslashes(serialize($a_attachments))."',".
                        "send_time = now(),".
                        "rcp_to = ".$ilDB->quote($a_rcp_to).",".
                        "rcp_cc = ".$ilDB->quote($a_rcp_cc).",".
                        "rcp_bcc = ".$ilDB->quote($a_rcp_bcc).",".
                        "m_status = 'read',".
                        "m_type = '".addslashes(serialize($a_m_type))."',".
                        "m_email = ".$ilDB->quote($a_m_email).",".
                        "m_subject = ".$ilDB->quote($a_m_subject).",".
                        "m_message = ".$ilDB->quote($a_m_message).",".
                        "use_placeholders = ".$ilDB->quote($a_use_placeholders)." ".
                        "WHERE mail_id = ".$ilDB->quote($a_draft_id)."";
                        
                $res = $this->ilias->db->query($query);

                return $a_draft_id;
        }


Field Documentation

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 formatNotificationMessage(), ilMail(), replacePlaceholders(), and sendMail().

ilMail::$mail_counter

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

ilMail::$mail_data

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

Referenced by formatNotificationMessage().

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.

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_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 [private]

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

ilMail::$save_in_sentbox

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

ilMail::$soap_enabled = true

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

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::$user_id

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

Referenced by checkRecipients(), and formatNotificationMessage().


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