コード例 #1
0
ファイル: ForumBulkMail.php プロジェクト: ratbird/hope
 /**
  * Sends the collected messages from sendingMail as e-mail.
  */
 function bulkSend()
 {
     // if nothing to do, return
     if (empty($this->bulk_mail)) {
         return;
     }
     // send a mail, for each language one
     foreach ($this->bulk_mail as $lang_data) {
         foreach ($lang_data as $data) {
             $mail = new StudipMail();
             $mail->setSubject($data['title']);
             foreach ($data['users'] as $user_id => $to) {
                 $mail->addRecipient($to, get_fullname($user_id), 'Bcc');
             }
             $mail->setReplyToEmail('')->setBodyText($data['text']);
             if (strlen($data['reply_to'])) {
                 $mail->setSenderEmail($data['reply_to'])->setSenderName($snd_fullname);
             }
             $user_cfg = UserConfig::get($user_id);
             if ($user_cfg->getValue('MAIL_AS_HTML')) {
                 $mail->setBodyHtml($mailhtml);
             }
             if ($GLOBALS["ENABLE_EMAIL_ATTACHMENTS"]) {
                 foreach (get_message_attachments($data['message_id']) as $attachment) {
                     $mail->addStudipAttachment($attachment['dokument_id']);
                 }
             }
             $mail->send();
         }
     }
 }
コード例 #2
0
ファイル: messaging.inc.php プロジェクト: ratbird/hope
 /**
  *
  * @param $rec_user_id
  * @param $snd_user_id
  * @param $message
  * @param $subject
  * @param $message_id
  */
 function sendingEmail($rec_user_id, $snd_user_id, $message, $subject, $message_id)
 {
     $receiver = User::find($rec_user_id);
     $to = $receiver->Email;
     // do not try to send mails to users without a mail address
     if (!$to) {
         return;
     }
     $rec_fullname = $receiver->getFullName();
     setTempLanguage($rec_user_id);
     $title = "[Stud.IP - " . $GLOBALS['UNI_NAME_CLEAN'] . "] " . kill_format(str_replace(array("\r", "\n"), '', $subject));
     if ($snd_user_id != "____%system%____") {
         $sender = User::find($snd_user_id);
         $snd_fullname = $sender->getFullName();
         $reply_to = $sender->Email;
     }
     $template = $GLOBALS['template_factory']->open('mail/text');
     $template->set_attribute('message', kill_format($message));
     $template->set_attribute('rec_fullname', $rec_fullname);
     $mailmessage = $template->render();
     $template = $GLOBALS['template_factory']->open('mail/html');
     $template->set_attribute('lang', getUserLanguagePath($rec_user_id));
     $template->set_attribute('message', $message);
     $template->set_attribute('rec_fullname', $rec_fullname);
     $mailhtml = $template->render();
     restoreLanguage();
     // Now, let us send the message
     $mail = new StudipMail();
     $mail->setSubject($title)->addRecipient($to, $rec_fullname)->setReplyToEmail('')->setBodyText($mailmessage);
     if (strlen($reply_to)) {
         $mail->setSenderEmail($reply_to)->setSenderName($snd_fullname);
     }
     $user_cfg = UserConfig::get($rec_user_id);
     if ($user_cfg->getValue('MAIL_AS_HTML')) {
         $mail->setBodyHtml($mailhtml);
     }
     if ($GLOBALS['ENABLE_EMAIL_ATTACHMENTS']) {
         foreach (get_message_attachments($message_id) as $attachment) {
             $mail->addStudipAttachment($attachment['dokument_id']);
         }
     }
     if (!get_config("MAILQUEUE_ENABLE")) {
         $mail->send();
     } else {
         MailQueueEntry::add($mail, $message_id, $rec_user_id);
     }
 }
コード例 #3
0
 public function triggerImport()
 {
     $processes = FleximportProcess::findBySQL("triggered_by_cronjob = '1' ORDER BY name ASC");
     if ($GLOBALS['FLEXIMPORT_IS_CRONJOB']) {
         echo "Starting Import at " . date("c") . "\n\n";
     }
     foreach ($processes as $process) {
         foreach ($process->tables as $table) {
             //import data if needed
             $table->fetchData();
         }
     }
     if ($GLOBALS['FLEXIMPORT_IS_CRONJOB']) {
         echo "Fetching data finished at " . date("c") . "\n";
     }
     $protocol = array();
     foreach ($processes as $process) {
         foreach ($process->tables as $table) {
             if ($GLOBALS['FLEXIMPORT_IS_CRONJOB']) {
                 echo "\nStarting Import of " . $table['name'] . " at " . date("c") . "\n";
             }
             $protocol = array_merge($protocol, $table->doImport());
         }
     }
     if (count($protocol) && $GLOBALS['FLEXIMPORT_IS_CRONJOB'] && FleximportConfig::get("REPORT_CRONJOB_ERRORS")) {
         $message = _("Es hat folgende Probleme beim Import gegeben:");
         $message .= "\n" . implode("\n", $protocol);
         $mail = new StudipMail();
         $mail->setSubject(_("Fleximport Fehlerbericht von Stud.IP"));
         $mail->setBodyText($message);
         $emails = preg_split("/\\s*[,;\\s]+\\s*/", FleximportConfig::get("REPORT_CRONJOB_ERRORS"), null, PREG_SPLIT_NO_EMPTY);
         foreach ($emails as $email) {
             $mail->addRecipient($email);
         }
         $mail->send();
     }
     if ($GLOBALS['FLEXIMPORT_IS_CRONJOB']) {
         echo implode("\n", $protocol);
     }
     if ($GLOBALS['FLEXIMPORT_IS_CRONJOB']) {
         echo "\nImport ends at " . date("c") . "\n";
     }
 }