Пример #1
0
 private function __handlePreferences($prefs, $row)
 {
     include_once "Services/Mail/classes/class.ilMailOptions.php";
     $mailOptions = new ilMailOptions($row["usr_id"]);
     $prefs["mail_incoming_type"] = $mailOptions->getIncomingType();
     $prefs["mail_signature"] = $mailOptions->getSignature();
     $prefs["mail_linebreak"] = $mailOptions->getLinebreak();
     if (count($prefs)) {
         $this->xmlStartTag("Prefs");
         foreach ($prefs as $key => $value) {
             if (ilUserXMLWriter::isPrefExportable($key)) {
                 $this->xmlElement("Pref", array("key" => $key), $value);
             }
         }
         $this->xmlEndTag("Prefs");
     }
 }
 private function updateMailPreferences($usr_id)
 {
     if (array_key_exists("mail_incoming_type", $this->prefs) || array_key_exists("mail_signature", $this->prefs) || array_key_exists("mail_linebreak", $this->prefs)) {
         include_once "Services/Mail/classes/class.ilMailOptions.php";
         $mailOptions = new ilMailOptions($usr_id);
         $mailOptions->updateOptions(array_key_exists("mail_signature", $this->prefs) ? $this->prefs["mail_signature"] : $mailOptions->getSignature(), array_key_exists("mail_linebreak", $this->prefs) ? $this->prefs["mail_linebreak"] : $mailOptions->getLinebreak(), array_key_exists("mail_incoming_type", $this->prefs) ? $this->prefs["mail_incoming_type"] : $mailOptions->getIncomingType(), $mailOptions->getCronjobNotification());
     }
 }
Пример #3
0
 /**
  * send internal message to recipients
  * @access	private
  * @param    string to
  * @param    string cc
  * @param    string bcc
  * @param    string subject
  * @param    string message
  * @param    array attachments
  * @param    integer id of mail which is stored in sentbox
  * @param    array 'normal' and/or 'system' and/or 'email'
  * @return	bool
  */
 function distributeMail($a_rcp_to, $a_rcp_cc, $a_rcp_bcc, $a_subject, $a_message, $a_attachments, $sent_mail_id, $a_type, $a_action, $a_use_placeholders = 0)
 {
     global $log;
     include_once 'Services/Mail/classes/class.ilMailbox.php';
     include_once './Services/User/classes/class.ilObjUser.php';
     if (!ilMail::_usePearMail()) {
         // REPLACE ALL LOGIN NAMES WITH '@' BY ANOTHER CHARACTER
         $a_rcp_to = $this->__substituteRecipients($a_rcp_to, 'resubstitute');
         $a_rcp_cc = $this->__substituteRecipients($a_rcp_cc, 'resubstitute');
         $a_rcp_bcc = $this->__substituteRecipients($a_rcp_bcc, 'resubstitute');
     }
     $mbox = new ilMailbox();
     if (!$a_use_placeholders) {
         $rcp_ids = $this->getUserIds(trim($a_rcp_to) . ',' . trim($a_rcp_cc) . ',' . trim($a_rcp_bcc));
         $as_email = array();
         foreach ($rcp_ids as $id) {
             $tmp_mail_options = new ilMailOptions($id);
             // DETERMINE IF THE USER CAN READ INTERNAL MAILS
             $tmp_user = self::getCachedUserInstance($id);
             $user_is_active = $tmp_user->getActive();
             $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() && $tmp_user->checkTimeLimit();
             // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
             if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
                 continue;
             }
             // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS/HER MAIL
             // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
             // Do not send external mails to inactive users!!!
             if ($user_is_active) {
                 if (!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL) {
                     $as_email[] = $tmp_user->getEmail();
                     continue;
                 }
                 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH) {
                     $as_email[] = $tmp_user->getEmail();
                 }
             }
             $mbox->setUserId($id);
             $inbox_id = $mbox->getInboxFolder();
             $mail_id = $this->sendInternalMail($inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, '', 'unread', $a_type, 0, $a_subject, $a_message, $id, 0);
             if ($a_attachments) {
                 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
             }
         }
         // SEND EMAIL TO ALL USERS WHO DECIDED 'email' or 'both'
         $to = array();
         $bcc = array();
         if (count($as_email) == 1) {
             $to[] = $as_email[0];
         } else {
             foreach ($as_email as $email) {
                 $bcc[] = $email;
             }
         }
         if (count($to) > 0 || count($bcc) > 0) {
             $this->sendMimeMail(implode(',', $to), '', implode(',', $bcc), $a_subject, $a_message, $a_attachments);
         }
     } else {
         // to
         $rcp_ids_replace = $this->getUserIds(trim($a_rcp_to));
         // cc / bcc
         $rcp_ids_no_replace = $this->getUserIds(trim($a_rcp_cc) . ',' . trim($a_rcp_bcc));
         $as_email = array();
         // to
         foreach ($rcp_ids_replace as $id) {
             $tmp_mail_options = new ilMailOptions($id);
             // DETERMINE IF THE USER CAN READ INTERNAL MAILS
             $tmp_user = self::getCachedUserInstance($id);
             $user_is_active = $tmp_user->getActive();
             $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() && $tmp_user->checkTimeLimit();
             // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
             if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
                 continue;
             }
             // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
             // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
             // Do not send external mails to inactive users!!!
             if ($user_is_active) {
                 if (!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL) {
                     $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
                     continue;
                 }
                 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH) {
                     $as_email[$tmp_user->getId()] = $tmp_user->getEmail();
                 }
             }
             $mbox->setUserId($id);
             $inbox_id = $mbox->getInboxFolder();
             $mail_id = $this->sendInternalMail($inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, '', 'unread', $a_type, 0, $a_subject, $a_message, $id, 1);
             if ($a_attachments) {
                 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
             }
         }
         if (count($as_email)) {
             foreach ($as_email as $id => $email) {
                 $this->sendMimeMail($email, '', '', $a_subject, $this->replacePlaceholders($a_message, $id), $a_attachments);
             }
         }
         $as_email = array();
         // cc / bcc
         foreach ($rcp_ids_no_replace as $id) {
             $tmp_mail_options = new ilMailOptions($id);
             // DETERMINE IF THE USER CAN READ INTERNAL MAILS
             $tmp_user = self::getCachedUserInstance($id);
             $user_is_active = $tmp_user->getActive();
             $user_can_read_internal_mails = $tmp_user->hasAcceptedUserAgreement() && $tmp_user->checkTimeLimit();
             // Do not send external mails to inactive users!!!
             if ($user_is_active) {
                 // CONTINUE IF SYSTEM MESSAGE AND USER CAN'T READ INTERNAL MAILS
                 if (in_array('system', $a_type) && !$user_can_read_internal_mails) {
                     continue;
                 }
                 // CONTINUE IF USER CAN'T READ INTERNAL MAILS OR IF HE/SHE WANTS HIS MAIL
                 // SENT TO HIS/HER EXTERNAL E-MAIL ADDRESS ONLY
                 if (!$user_can_read_internal_mails || $tmp_mail_options->getIncomingType() == $this->mail_options->EMAIL) {
                     $as_email[] = $tmp_user->getEmail();
                     continue;
                 }
                 if ($tmp_mail_options->getIncomingType() == $this->mail_options->BOTH) {
                     $as_email[] = $tmp_user->getEmail();
                 }
             }
             $mbox->setUserId($id);
             $inbox_id = $mbox->getInboxFolder();
             $mail_id = $this->sendInternalMail($inbox_id, $this->user_id, $a_attachments, $a_rcp_to, $a_rcp_cc, '', 'unread', $a_type, 0, $a_subject, $a_message, $id, 0);
             if ($a_attachments) {
                 $this->mfile->assignAttachmentsToDirectory($mail_id, $sent_mail_id, $a_attachments);
             }
         }
         if (count($as_email)) {
             $this->sendMimeMail('', '', implode(',', $as_email), $a_subject, $a_message, $a_attachments);
         }
     }
     return true;
 }
 /** 
  * Fetches data from model and loads this data into form
  */
 private function setMailOptionsValuesByDB()
 {
     global $ilUser, $ilSetting;
     require_once 'Services/Mail/classes/class.ilMailOptions.php';
     $mailOptions = new ilMailOptions($ilUser->getId());
     $data = array('linebreak' => $mailOptions->getLinebreak(), 'signature' => $mailOptions->getSignature(), 'cronjob_notification' => $mailOptions->getCronjobNotification());
     if ($ilSetting->get('usr_settings_hide_mail_incoming_mail') != '1') {
         $data['incoming_type'] = $mailOptions->getIncomingType();
     }
     $this->form->setValuesByArray($data);
 }