コード例 #1
0
 $smarty->assign('attaching', 'n');
 if (isset($_REQUEST["send"])) {
     $mail = new TikiMail($user);
     $email = $userlib->get_user_email($user);
     $mail->setFrom($email);
     if (!empty($_REQUEST["cc"])) {
         $mail->setCc($_REQUEST["cc"]);
     }
     if (!empty($_REQUEST["bcc"])) {
         $mail->setBcc($_REQUEST["bcc"]);
     }
     $mail->setSubject($_REQUEST["subject"]);
     if ($_REQUEST["attach1"]) {
         check_ticket('webmail');
         $a1 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach1file"]);
         $mail->addAttachment($a1, $_REQUEST["attach1"], $_REQUEST["attach1type"]);
         @unlink('temp/mail_attachs/' . $_REQUEST["attach1file"]);
     }
     if ($_REQUEST["attach2"]) {
         check_ticket('webmail');
         $a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach2file"]);
         $mail->addAttachment($a2, $_REQUEST["attach2"], $_REQUEST["attach2type"]);
         @unlink('temp/mail_attachs/' . $_REQUEST["attach2file"]);
     }
     if ($_REQUEST["attach3"]) {
         check_ticket('webmail');
         $a3 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach3file"]);
         $mail->addAttachment($a3, $_REQUEST["attach3"], $_REQUEST["attach3type"]);
         @unlink('temp/mail_attachs/' . $_REQUEST["attach3file"]);
     }
     $mail->setSMTPParams($current["smtp"], $current["smtpPort"], '', $current["useAuth"], $current["username"], $current["pass"]);
コード例 #2
0
/** \brief send the email notifications dealing with the forum changes to
 * \brief outbound address + admin notification addresses / forum admin email + watching users addresses
 * \param $event = 'forum_post_topic' or 'forum_post_thread'
 * \param $object = forumId watch if forum_post_topic or topicId watch if forum_post_thread
 * \param $threadId = topicId if forum_post_thread
 * \param $title of the message
 * \param $topicName name of the parent topic
 */
function sendForumEmailNotification($event, $object, $forum_info, $title, $data, $author, $topicName, $messageId = '', $inReplyTo = '', $threadId, $parentId = '')
{
    global $tikilib, $feature_user_watches, $smarty, $userlib, $sender_email;
    // Per-forum From address overrides global default.
    if ($forum_info['outbound_from']) {
        $my_sender = '"' . "{$author}" . '" <' . $forum_info['outbound_from'] . '>';
    } else {
        $my_sender = $sender_email;
    }
    //outbound email ->  will be sent in utf8 - from sender_email
    if ($forum_info['outbound_address']) {
        include_once 'lib/webmail/tikimaillib.php';
        $mail = new TikiMail();
        $mail->setSubject($title);
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
        $reply_link = "\n\n----\n\nReply Link: <" . $machine . "tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_reply_threadId={$object}&comments_parentId={$threadId}&post_reply=1#form>\n";
        if (array_key_exists('outbound_mails_reply_link', $forum_info) && $forum_info['outbound_mails_reply_link']) {
            $mail->setText($title . "\n" . $data . $reply_link);
        } else {
            $mail->setText($title . "\n" . $data);
        }
        $mail->setHeader("Reply-To", $my_sender);
        $mail->setHeader("From", $my_sender);
        $mail->setSubject($topicName);
        if ($inReplyTo) {
            $mail->setHeader("In-Reply-To", "<" . $inReplyTo . ">");
        }
        global $commentslib;
        $attachments = $commentslib->get_thread_attachments($object, 0);
        if (count($attachments) > 0) {
            foreach ($attachments as $att) {
                $att_data = $commentslib->get_thread_attachment($att['attId']);
                $file = $mail->getFile($att_data['dir'] . $att_data['path']);
                $mail->addAttachment($file, $att_data['filename'], $att_data['filetype']);
            }
        }
        $mail->buildMessage();
        // Message-ID is set below buildMessage because otherwise lib/webmail/htmlMimeMail.php will over-write it.
        $mail->setHeader("Message-ID", "<" . $messageId . ">");
        $mail->send(array($forum_info['outbound_address']));
    }
    $nots = array();
    $defaultLanguage = $tikilib->get_preference("language", "en");
    // Users watching this forum or this post
    if ($feature_user_watches == 'y') {
        $nots = $tikilib->get_event_watches($event, $object);
        for ($i = count($nots) - 1; $i >= 0; --$i) {
            $nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
        }
    }
    // Special forward address
    //TODO: merge or use the admin notification feature
    if ($forum_info["useMail"] == 'y') {
        $not['email'] = $forum_info['mail'];
        if ($not['user'] = $userlib->get_user_by_email($forum_info['mail'])) {
            $not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage);
        } else {
            $not['language'] = $defaultLanguage;
        }
        $nots[] = $not;
    }
    if (count($nots)) {
        include_once 'lib/webmail/tikimaillib.php';
        $mail = new TikiMail();
        $smarty->assign('mail_forum', $forum_info["name"]);
        $smarty->assign('mail_title', $title);
        $smarty->assign('mail_date', date("U"));
        $smarty->assign('mail_message', $data);
        $smarty->assign('mail_author', $author);
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix() . dirname($foo["path"]);
        $machine = preg_replace("!/\$!", "", $machine);
        // just incase
        $smarty->assign('mail_machine', $machine);
        $smarty->assign('forumId', $forum_info["forumId"]);
        if ($event == "forum_post_topic") {
            $smarty->assign('new_topic', 'y');
            $smarty->assign('topicId', $threadId);
        } else {
            $smarty->assign('topicId', $object);
        }
        $smarty->assign('mail_topic', $topicName);
        foreach ($nots as $not) {
            $mail->setUser($not['user']);
            $mail_data = $smarty->fetchLang($not['language'], "mail/notification_subject.tpl");
            $mail->setSubject($mail_data);
            $mail_data = $smarty->fetchLang($not['language'], "mail/forum_post_notification.tpl");
            $mail->setText($mail_data);
            $mail->buildMessage();
            $mail->send(array($not['email']));
        }
    }
}
コード例 #3
0
ファイル: tiki-webmail.php プロジェクト: ameoba32/tiki
 $smarty->assign('sent', 'n');
 $smarty->assign('attaching', 'n');
 if (isset($_REQUEST['send'])) {
     $email = empty($current['fromEmail']) ? $userlib->get_user_email($user) : $current['fromEmail'];
     $mail = new TikiMail($user, $email);
     if (!empty($_REQUEST['cc'])) {
         $mail->setCc($_REQUEST['cc']);
     }
     if (!empty($_REQUEST['bcc'])) {
         $mail->setBcc($_REQUEST['bcc']);
     }
     $mail->setSubject($_REQUEST['subject']);
     if ($_REQUEST['attach1']) {
         check_ticket('webmail');
         $a1 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach1file']);
         $mail->addAttachment($a1, $_REQUEST['attach1'], $_REQUEST['attach1type']);
         @unlink('temp/mail_attachs/' . $_REQUEST['attach1file']);
     }
     if ($_REQUEST['attach2']) {
         check_ticket('webmail');
         $a2 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach2file']);
         $mail->addAttachment($a2, $_REQUEST['attach2'], $_REQUEST['attach2type']);
         @unlink('temp/mail_attachs/' . $_REQUEST['attach2file']);
     }
     if ($_REQUEST['attach3']) {
         check_ticket('webmail');
         $a3 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach3file']);
         $mail->addAttachment($a3, $_REQUEST['attach3'], $_REQUEST['attach3type']);
         @unlink('temp/mail_attachs/' . $_REQUEST['attach3file']);
     }
     if ($_REQUEST['fattId']) {
コード例 #4
0
 function deleteOldFiles()
 {
     global $prefs, $smarty;
     include_once 'lib/webmail/tikimaillib.php';
     $query = 'select * from `tiki_files` where `deleteAfter` < ' . $this->now . ' - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
     $files = $this->fetchAll($query, array());
     foreach ($files as $fileInfo) {
         if (empty($galInfo) || $galInfo['galleryId'] != $fileInfo['galleryId']) {
             $galInfo = $this->get_file_gallery_info($fileInfo['galleryId']);
             if (!empty($prefs['fgal_delete_after_email'])) {
                 $smarty->assign_by_ref('galInfo', $galInfo);
             }
         }
         if (!empty($prefs['fgal_delete_after_email'])) {
             $savedir = $this->get_gallery_save_dir($galInfo['galleryId'], $galInfo);
             $fileInfo['data'] = file_get_contents($savedir . $fileInfo['path']);
             $smarty->assign_by_ref('fileInfo', $fileInfo);
             $mail = new TikiMail();
             $mail->setSubject(tra('Old File deleted:', $prefs['site_language']) . ' ' . $fileInfo['filename']);
             $mail->setText($smarty->fetchLang($prefs['site_language'], 'mail/fgal_old_file_deleted.tpl'));
             $mail->addAttachment($fileInfo['data'], $fileInfo['filename'], $fileInfo['filetype']);
             $to = preg_split('/ *, */', $prefs['fgal_delete_after_email']);
             $mail->send($to);
         }
         $this->remove_file($fileInfo, $galInfo, false);
     }
 }
コード例 #5
0
ファイル: filegallib.php プロジェクト: rjsmelo/tiki
 function deleteOldFiles()
 {
     global $prefs;
     $smarty = TikiLib::lib('smarty');
     include_once 'lib/webmail/tikimaillib.php';
     $query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
     $files = $this->fetchAll($query, array($this->now));
     foreach ($files as $fileInfo) {
         $definition = $this->getGalleryDefinition($fileInfo['galleryId']);
         $galInfo = $definition->getInfo();
         if (!empty($prefs['fgal_delete_after_email'])) {
             $wrapper = $definition->getFileWrapper($fileInfo['data'], $fileInfo['path']);
             $fileInfo['data'] = $wrapper->getContent();
             $smarty->assign('fileInfo', $fileInfo);
             $smarty->assign('galInfo', $galInfo);
             $mail = new TikiMail();
             $mail->setSubject(tra('Old File deleted:', $prefs['site_language']) . ' ' . $fileInfo['filename']);
             $mail->setText($smarty->fetchLang($prefs['site_language'], 'mail/fgal_old_file_deleted.tpl'));
             $mail->addAttachment($fileInfo['data'], $fileInfo['filename'], $fileInfo['filetype']);
             $to = preg_split('/ *, */', $prefs['fgal_delete_after_email']);
             $mail->send($to);
         }
         $this->remove_file($fileInfo, $galInfo, false);
     }
 }
コード例 #6
0
     if ($tikilib->page_exists($page)) {
         // Check permissions
         $chkUser = $aux["sender"]["user"];
         if ($acc["anonymous"] == 'n' && !$userlib->user_has_permission($chkUser, 'tiki_p_admin')) {
             if (!$wikilib->user_has_perm_on_object($chkUser, $page, 'wiki page', 'tiki_p_view')) {
                 $errorMsg = $chkUser . " cannot view the page: " . $page . "<br />";
                 $logslib->add_log('mailin', mailin_preplog($errorMsg), $logUser);
                 $content .= $errorMsg;
                 $processEmail = false;
             }
         }
         if ($processEmail) {
             $mail->setSubject($page);
             $info = $tikilib->get_page_info($page);
             $data = $tikilib->parse_data($info["data"]);
             $mail->addAttachment($info['data'], 'source.txt', 'plain/txt');
             $mail->setHTML($data, strip_tags($data));
         }
     } else {
         $l = $prefs['language'];
         $mail_data = $smarty->fetchLang($l, "mail/mailin_reply_subject.tpl");
         $mail->setSubject($mail_data . $page);
     }
     if ($processEmail) {
         $res = $mail->send(array($email_from), 'mail');
         $content .= "Response sent<br />";
         $hasError = false;
     }
 } elseif ($acc['type'] == 'wiki-put' || $acc['type'] == 'wiki' && $method == "PUT") {
     //////////////
     //	wiki-put, wiki PUT: Send a wiki page. User emails page to System
コード例 #7
0
/** \brief send the email notifications dealing with the forum changes to
 * \brief outbound address + admin notification addresses / forum admin email + watching users addresses
 * \param $event = 'forum_post_topic' or 'forum_post_thread'
 * \param $object = forumId watch if forum_post_topic or topicId watch if forum_post_thread
 * \param $threadId = topicId if forum_post_thread
 * \param $title of the message
 * \param $topicName name of the parent topic
 */
function sendForumEmailNotification($event, $object, $forum_info, $title, $data, $author, $topicName, $messageId = '', $inReplyTo = '', $threadId, $parentId, $contributions = '', $postId = '')
{
    global $tikilib, $prefs, $smarty, $userlib;
    // Per-forum From address overrides global default.
    if ($forum_info['outbound_from']) {
        $author = $userlib->clean_user($author);
        $my_sender = '"' . "{$author}" . '" <' . $forum_info['outbound_from'] . '>';
    } else {
        $my_sender = $prefs['sender_email'];
    }
    //outbound email ->  will be sent in utf8 - from sender_email
    if ($forum_info['outbound_address']) {
        include_once 'lib/webmail/tikimaillib.php';
        $mail = new TikiMail();
        $mail->setSubject($title);
        if (!empty($forum_info['outbound_mails_reply_link']) && $forum_info['outbound_mails_reply_link'] == 'y') {
            $foo = parse_url($_SERVER["REQUEST_URI"]);
            $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
            if ($event == 'forum_post_topic') {
                $reply_link = "{$machine}/tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_parentId={$threadId}#form";
            } else {
                $reply_link = "{$machine}/tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_reply_threadId={$object}&comments_parentId={$threadId}&post_reply=1#form";
            }
        } else {
            $reply_link = '';
        }
        $smarty->assign('title', $title);
        $smarty->assign('data', $data);
        $smarty->assign('reply_link', $reply_link);
        $smarty->assign('author', $author);
        $mail_data = $smarty->fetch("mail/forum_outbound.tpl");
        $mail->setText($mail_data);
        $mail->setReplyTo($my_sender);
        $mail->setFrom($my_sender);
        $mail->setSubject($topicName);
        if ($inReplyTo) {
            $mail->setHeader("In-Reply-To", "<" . $inReplyTo . ">");
        }
        global $commentslib;
        $attachments = $commentslib->get_thread_attachments($event == 'forum_post_topic' ? $threadId : $object, 0);
        if (count($attachments) > 0) {
            foreach ($attachments as $att) {
                $att_data = $commentslib->get_thread_attachment($att['attId']);
                if ($att_data['dir'] . $att_data['path'] == "") {
                    // no path to file on disk
                    $file = $att_data['data'];
                    // read file from database
                } else {
                    $file = $mail->getFile($att_data['dir'] . $att_data['path']);
                    // read file from disk
                }
                $mail->addAttachment($file, $att_data['filename'], $att_data['filetype']);
            }
        }
        // Message-ID is set below buildMessage because otherwise lib/webmail/htmlMimeMail.php will over-write it.
        $mail->setHeader("Message-ID", "<" . $messageId . ">");
        $mail->send(array($forum_info['outbound_address']));
    }
    $nots = array();
    $defaultLanguage = $prefs['site_language'];
    // Users watching this forum or this post
    if ($prefs['feature_user_watches'] == 'y' || $prefs['feature_group_watches'] == 'y') {
        $nots_raw = $tikilib->get_event_watches($event, $event == 'forum_post_topic' ? $forum_info['forumId'] : $threadId, $forum_info);
        $nots = array();
        $users = array();
        foreach ($nots_raw as $n) {
            if ($n['user'] != $author && !in_array($n['user'], $users)) {
                // make sure user receive only one notification even if he is monitoring both the topic and thread
                $n['language'] = $tikilib->get_user_preference($n['user'], "language", $defaultLanguage);
                $nots[] = $n;
                $users[] = $n['user'];
            }
        }
    }
    // Special forward address
    //TODO: merge or use the admin notification feature
    if ($forum_info["useMail"] == 'y') {
        $not['email'] = $forum_info['mail'];
        if ($not['user'] = $userlib->get_user_by_email($forum_info['mail'])) {
            $not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage);
        } else {
            $not['language'] = $defaultLanguage;
        }
        $nots[] = $not;
    }
    if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
        $reportsManager = Reports_Factory::build('Reports_Manager');
        $reportsManager->addToCache($nots, array("event" => $event, "forumId" => $forum_info['forumId'], "forumName" => $forum_info['name'], "topicId" => $threadId, "threadId" => $postId, "threadName" => $topicName, "user" => $author));
    }
    if (count($nots)) {
        include_once 'lib/webmail/tikimaillib.php';
        $smarty->assign('mail_forum', $forum_info["name"]);
        $smarty->assign('mail_title', $title);
        $smarty->assign('mail_date', $tikilib->now);
        $smarty->assign('mail_message', $data);
        $smarty->assign('mail_author', $author);
        if ($prefs['feature_contribution'] == 'y' && !empty($contributions)) {
            global $contributionlib;
            include_once 'lib/contribution/contributionlib.php';
            $smarty->assign('mail_contributions', $contributionlib->print_contributions($contributions));
        }
        $foo = parse_url($_SERVER["REQUEST_URI"]);
        $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
        $machine = preg_replace("!/\$!", "", $machine);
        // just incase
        $smarty->assign('mail_machine', $machine);
        $smarty->assign('forumId', $forum_info["forumId"]);
        if ($event == "forum_post_topic") {
            $smarty->assign('new_topic', 'y');
        } else {
            $smarty->assign('threadId', $object);
        }
        $smarty->assign('topicId', $threadId);
        $smarty->assign('mail_topic', $topicName);
        foreach ($nots as $not) {
            $mail = new TikiMail();
            $mail->setUser($not['user']);
            $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_forum_subject.tpl");
            $mail->setSubject($mail_data);
            $mail_data = $smarty->fetchLang($not['language'], "mail/forum_post_notification.tpl");
            $mail->setText($mail_data);
            $mail->send(array($not['email']));
        }
    }
}
コード例 #8
0
		$email = empty($current['fromEmail']) ? $userlib->get_user_email($user) : $current['fromEmail'];
		$mail = new TikiMail($user, $email);

		if (!empty($_REQUEST['cc'])) {
			$mail->setCc($_REQUEST['cc']);
		}
		if (!empty($_REQUEST['bcc'])) {
			$mail->setBcc($_REQUEST['bcc']);
		}
		$mail->setSubject($_REQUEST['subject']);

		if ($_REQUEST['attach1']) {
			check_ticket('webmail');
			$a1 = $mail->getFile('temp/mail_attachs/' . $_REQUEST['attach1file']);

			$mail->addAttachment($a1, $_REQUEST['attach1'], $_REQUEST['attach1type']);
			@unlink('temp/mail_attachs/' . $_REQUEST['attach1file']);
		}

		if ($_REQUEST['attach2']) {
			check_ticket('webmail');
			$a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST['attach2file']);

			$mail->addAttachment($a2, $_REQUEST['attach2'], $_REQUEST['attach2type']);
			@unlink('temp/mail_attachs/' . $_REQUEST['attach2file']);
		}

		if ($_REQUEST['attach3']) {
			check_ticket('webmail');
			$a3 = $mail->getFile('temp/mail_attachs/' . $_REQUEST['attach3file']);