本文整理汇总了PHP中TikiMail::setText方法的典型用法代码示例。如果您正苦于以下问题:PHP TikiMail::setText方法的具体用法?PHP TikiMail::setText怎么用?PHP TikiMail::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TikiMail
的用法示例。
在下文中一共展示了TikiMail::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: values
/**
* Send a message to a user
*/
function post_message($user, $from, $to, $cc, $subject, $body, $priority, $replyto_hash = '')
{
global $smarty, $userlib, $prefs;
$subject = strip_tags($subject);
$body = strip_tags($body, '<a><b><img><i>');
// Prevent duplicates
$hash = md5($subject . $body);
if ($this->getOne("select count(*) from `messu_messages` where `user`=? and `user_from`=? and `hash`=?", array($user, $from, $hash))) {
return false;
}
$query = "insert into `messu_messages`(`user`,`user_from`,`user_to`,`user_cc`,`subject`,`body`,`date`,`isRead`,`isReplied`,`isFlagged`,`priority`,`hash`,`replyto_hash`) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
$this->query($query, array($user, $from, $to, $cc, $subject, $body, (int) $this->now, 'n', 'n', 'n', (int) $priority, $hash, $replyto_hash));
// Now check if the user should be notified by email
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $this->httpPrefix() . $foo["path"];
$machine = str_replace('messu-compose', 'messu-mailbox', $machine);
if ($this->get_user_preference($user, 'minPrio', 6) <= $priority) {
if (!isset($_SERVER["SERVER_NAME"])) {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
$email = $userlib->get_user_email($user);
if ($email) {
include_once 'lib/webmail/tikimaillib.php';
$smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
$smarty->assign('mail_machine', $machine);
$smarty->assign('mail_date', $this->now);
$smarty->assign('mail_user', stripslashes($user));
$smarty->assign('mail_from', stripslashes($from));
$smarty->assign('mail_subject', stripslashes($subject));
$smarty->assign('mail_body', stripslashes($body));
$mail = new TikiMail($user);
$lg = $this->get_user_preference($user, 'language', $prefs['site_language']);
$s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl');
$mail->setSubject(sprintf($s, $_SERVER["SERVER_NAME"]));
$mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl');
$mail->setText($mail_data);
if ($userlib->get_user_preference($from, 'email is public', 'n') == 'y') {
$prefs['sender_email'] = $userlib->get_user_email($from);
}
if (strlen($prefs['sender_email']) > 1) {
$mail->setHeader("Reply-To", $prefs['sender_email']);
$mail->setHeader("From", $prefs['sender_email']);
}
if (!$mail->send(array($email), 'mail')) {
return false;
}
//TODO echo $mail->errors;
}
}
return true;
}
示例2: Notify
function Notify($ListUserToAlert, $URI)
{
global $tikilib, $userlib;
if (!is_array($ListUserToAlert)) {
return;
}
$project = $tikilib->get_preference("browsertitle");
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
$URL = $machine . "/" . $URI;
foreach ($ListUserToAlert as $user) {
$email = $userlib->get_user_email($user);
if (!empty($email)) {
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$mail->setText(tra("You are alerted by the server ") . $project . "\n" . tra("You can check the modifications at : ") . $URL);
$mail->setSubject(tra("You are alerted of a change on ") . $project);
$mail->send(array($email));
}
}
}
示例3: payment_behavior_cart_send_confirm_email
function payment_behavior_cart_send_confirm_email($u, $email_template_ids = array())
{
global $prefs, $smarty, $userlib;
require_once 'lib/webmail/tikimaillib.php';
$email = $userlib->get_user_email($u);
if (!$email) {
return false;
}
$smarty->assign("email_template_ids", $email_template_ids);
$mail_subject = $smarty->fetch('mail/cart_order_received_reg_subject.tpl');
$mail_data = $smarty->fetch('mail/cart_order_received_reg.tpl');
$mail = new TikiMail();
$mail->setSubject($mail_subject);
if ($mail_data == strip_tags($mail_data)) {
$mail->setText($mail_data);
} else {
$mail->setHtml($mail_data);
}
$mail->send($email);
return true;
}
示例4: VALUES
$tikilib->query(
"INSERT INTO `tiki_invited` (id_invite, email, firstname, lastname, used) VALUES (?,?,?,?,?)",
array($id, $m['email'], $m['firstname'], $m['lastname'], "no")
);
$_SERVER['SCRIPT_URI'] = empty($_SERVER['SCRIPT_URI']) ? 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] : $_SERVER['SCRIPT_URI'];
foreach ($emails as $m) {
$mail = new TikiMail();
$mail->setFrom($prefs['sender_email']);
$mail->setSubject($_REQUEST["emailsubject"]);
$mail->setCrlf("\n");
$url=str_replace('tiki-invite.php', 'tiki-invited.php', $_SERVER['SCRIPT_URI'])
.'?invite='.$id.'&email='.urlencode($m['email']);
$text=$_text;
$text=str_replace('{link}', $url, $text);
$text=str_replace('{email}', $m['email'], $text);
$text=str_replace('{firstname}', $m['firstname'], $text);
$text=str_replace('{lastname}', $m['lastname'], $text);
$mail->setText($text);
$mail->send(array($m['email']));
}
$smarty->assign('sentresult', true);
}
$smarty->assign('emails', $emails);
}
$smarty->assign('mid', 'tiki-invite.tpl');
$smarty->display("tiki.tpl");
示例5: unsubscribe
function unsubscribe($code, $mailit = false)
{
global $smarty, $prefs, $userlib, $tikilib;
$foo = parse_url($_SERVER["REQUEST_URI"]);
$url_subscribe = $tikilib->httpPrefix() . $foo["path"];
$query = "select * from `tiki_newsletter_subscriptions` where `code`=?";
$result = $this->query($query, array($code));
if (!$result->numRows()) {
return false;
}
$res = $result->fetchRow();
$info = $this->get_newsletter($res["nlId"]);
$smarty->assign('info', $info);
$smarty->assign('code', $res["code"]);
if ($res["isUser"] == 'g') {
$query = "update `tiki_newsletter_subscriptions` set `valid`='x' where `code`=?";
} else {
$query = "delete from `tiki_newsletter_subscriptions` where `code`=?";
}
$result = $this->query($query, array($code), -1, -1, false);
// Now send a bye bye email
$smarty->assign('mail_date', $this->now);
if ($res["isUser"] == "y") {
$user = $res["email"];
$email = $userlib->get_user_email($user);
} else {
$email = $res["email"];
$user = $userlib->get_user_by_email($email);
//global $user is not necessary defined as the user is not necessary logged in
}
$smarty->assign('mail_user', $user);
$smarty->assign('url_subscribe', $url_subscribe);
$lg = !$user ? $prefs['site_language'] : $this->get_user_preference($user, "language", $prefs['site_language']);
if (!isset($_SERVER["SERVER_NAME"])) {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
if ($mailit) {
$mail = new TikiMail();
$mail_data = $smarty->fetchLang($lg, 'mail/newsletter_byebye_subject.tpl');
$mail->setSubject(sprintf($mail_data, $info["name"], $_SERVER["SERVER_NAME"]));
$mail_data = $smarty->fetchLang($lg, 'mail/newsletter_byebye.tpl');
$mail->setText($mail_data);
$mail->send(array($email));
}
/*$this->update_users($res["nlId"]);*/
return $this->get_newsletter($res["nlId"]);
}
示例6: sendMail
/**
*
* Sends a promotional email to the given recipients
* @param string $sender Sender e-Mail address
* @param string|array $recipients List of recipients either as array or comma/semi colon separated string
* @param string $subject E-Mail subject
* @param array $tokenlist
* @internal param string $url_for_friend URL to share
* @return bool true on success / false if the supplied parameters were incorrect/missing or an error occurred sending the mail
*/
function sendMail($sender, $recipients, $subject, $tokenlist = array())
{
global $errors, $prefs, $smarty, $user, $userlib, $logslib;
global $registrationlib;
include_once 'lib/registration/registrationlib.php';
if (empty($sender)) {
$errors[] = tra('Your email is mandatory');
return false;
}
if (function_exists('validate_email')) {
$ok = validate_email($sender, $prefs['validateEmail']);
} else {
$ret = $registrationlib->SnowCheckMail($sender, '', 'mini');
$ok = $ret[0];
}
if ($ok) {
$from = str_replace(array("\r", "\n"), '', $sender);
} else {
$errors[] = tra('Invalid email') . ': ' . $_REQUEST['email'];
return false;
}
$recipients = checkAddresses($recipients);
if ($recipients === false) {
return false;
}
include_once 'lib/webmail/tikimaillib.php';
$smarty->assign_by_ref('mail_site', $_SERVER['SERVER_NAME']);
$applyFrom = !empty($user) && $from == $userlib->get_user_email($user);
$ok = true;
foreach ($recipients as $i => $recipient) {
$mail = new TikiMail();
$mail->setSubject($subject);
if ($applyFrom) {
$mail->setFrom($from);
$mail->setReplyTo("<{$from}>");
}
if (count($tokenlist) > 1) {
$url_for_friend = $tokenlist[$i];
} else {
$url_for_friend = $tokenlist[0];
// only one token if not "subscribing"
}
$smarty->assign('url_for_friend', $url_for_friend);
$txt = $smarty->fetch('mail/share.tpl');
// Rebuild email message texte
$mail->setText($txt);
$mailsent = $mail->send(array($recipient));
if (!$mailsent) {
$errors[] = tra('Error sending mail to') . " {$recipient}";
$logslib->add_log('share', tra('Error sending mail to') . " {$recipient} " . tra('by') . ' ' . $user);
} else {
$logslib->add_log('share', tra('Share page') . ': ' . $url_for_friend . ' ' . tra('to') . ' ' . $recipient . ' ' . tra('by') . ' ' . $user);
}
$ok = $ok && $mailsent;
}
return $ok;
}
示例7: split
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"]);
if (isset($_REQUEST["useHTML"]) && $_REQUEST["useHTML"] == 'on') {
$mail->setHTML($_REQUEST["body"], strip_tags($_REQUEST["body"]));
} else {
$mail->setText($_REQUEST["body"]);
}
$to_array_1 = split('[, ;]', $_REQUEST["to"]);
$to_array = array();
foreach ($to_array_1 as $to_1) {
if (!empty($to_1)) {
$to_array[] = $to_1;
}
}
$to_array = $contactlib->parse_nicknames($to_array);
// Get email addresses not in the address book
$not_contacts = $contactlib->are_contacts($to_array, $user);
if (count($not_contacts) > 0) {
$smarty->assign('notcon', 'y');
} else {
$smarty->assign('notcon', 'n');
示例8: TikiMail
/**
* A default Tikiwiki callback that sends the welcome email on user registraion
* @access private
* @returns true on success, false to halt event proporgation
*/
function callback_tikiwiki_send_email($raisedBy, $data)
{
global $_REQUEST, $_SESSION, $_SERVER, $prefs, $registrationlib_apass, $email_valid, $smarty, $tikilib, $userlib, $Debug;
if ($Debug) {
print "::send_email";
}
$sender_email = $prefs['sender_email'];
$mail_user = $data['user'];
$mail_site = $data['mail_site'];
if ($email_valid != 'no') {
if ($prefs['validateUsers'] == 'y') {
//$apass = addslashes(substr(md5($tikilib->genPass()),0,25));
$apass = $registrationlib_apass;
$foo = parse_url($_SERVER["REQUEST_URI"]);
$foo1 = str_replace("tiki-register", "tiki-login_validate", $foo["path"]);
$machine = $tikilib->httpPrefix() . $foo1;
$smarty->assign('mail_machine', $machine);
$smarty->assign('mail_site', $mail_site);
$smarty->assign('mail_user', $mail_user);
$smarty->assign('mail_apass', $apass);
$registrationlib_apass = "";
$smarty->assign('mail_email', $_REQUEST['email']);
include_once "lib/notifications/notificationemaillib.php";
if (isset($prefs['validateRegistration']) and $prefs['validateRegistration'] == 'y') {
$smarty->assign('msg', $smarty->fetch('mail/user_validation_waiting_msg.tpl'));
if ($sender_email == NULL or !$sender_email) {
include_once 'lib/messu/messulib.php';
$mail_data = $smarty->fetch('mail/moderate_validation_mail.tpl');
$mail_subject = $smarty->fetch('mail/moderate_validation_mail_subject.tpl');
$messulib->post_message($prefs['contact_user'], $prefs['contact_user'], $prefs['contact_user'], '', $mail_subject, $mail_data, 5);
} else {
$mail_data = $smarty->fetch('mail/moderate_validation_mail.tpl');
$mail = new TikiMail();
$mail->setText($mail_data);
$mail_data = $smarty->fetch('mail/moderate_validation_mail_subject.tpl');
$mail->setSubject($mail_data);
if (!$mail->send(array($sender_email))) {
$smarty->assign('msg', tra("The registration mail can't be sent. Contact the administrator"));
}
}
} else {
$mail_data = $smarty->fetch('mail/user_validation_mail.tpl');
$mail = new TikiMail();
$mail->setText($mail_data);
$mail_data = $smarty->fetch('mail/user_validation_mail_subject.tpl');
$mail->setSubject($mail_data);
if (!$mail->send(array($_REQUEST["email"]))) {
$smarty->assign('msg', tra("The registration mail can't be sent. Contact the administrator"));
} else {
$smarty->assign('msg', $smarty->fetch('mail/user_validation_msg.tpl'));
}
}
$smarty->assign('showmsg', 'y');
} else {
$smarty->assign('msg', $smarty->fetch('mail/user_welcome_msg.tpl'));
$smarty->assign('showmsg', 'y');
}
}
return true;
}
示例9: TikiMail
function send_confirm_email($user,$tpl='confirm_user_email')
{
global $smarty, $prefs, $tikilib;
include_once ('lib/webmail/tikimaillib.php');
$languageEmail = $this->get_user_preference($_REQUEST['username'], 'language', $prefs['site_language']);
$apass = $this->renew_user_password($user);
$apass = md5($apass);
$smarty->assign('mail_apass', $apass);
$smarty->assign('mail_pass', $_REQUEST['pass']);
$smarty->assign('mail_ip', $tikilib->get_ip_address());
$smarty->assign('user', $user);
$mail = new TikiMail();
$mail_data = $smarty->fetchLang($languageEmail, "mail/$tpl".'_subject.tpl');
$mail_data = sprintf($mail_data, $_SERVER['SERVER_NAME']);
$mail->setSubject($mail_data);
$foo = parse_url($_SERVER['REQUEST_URI']);
$mail_machine = $tikilib->httpPrefix(true) . str_replace('tiki-login.php', 'tiki-confirm_user_email.php', $foo['path']);
$smarty->assign('mail_machine', $mail_machine);
$mail_data = $smarty->fetchLang($languageEmail, "mail/$tpl.tpl");
$mail->setText($mail_data);
if (!($email = $this->get_user_email($user)) || !$mail->send(array($email))) {
$smarty->assign('msg', tra("The user email confirmation can't be sent. Contact the administrator"));
return false;
} else {
$smarty->assign('msg', 'It is time to confirm your email. You will receive an mail with the instruction to follow');
return true;
}
}
示例10: unsubscribe
function unsubscribe($code)
{
global $smarty;
global $sender_email;
global $userlib;
global $tikilib;
global $language;
$foo = parse_url($_SERVER["REQUEST_URI"]);
$url_subscribe = $tikilib->httpPrefix() . $foo["path"];
$query = "select * from `tiki_event_subscriptions` where `code`=?";
$result = $this->query($query, array($code));
if (!$result->numRows()) {
return false;
}
$res = $result->fetchRow();
$info = $this->get_event($res["evId"]);
$smarty->assign('info', $info);
$smarty->assign('code', $res["code"]);
$query = "delete from `tiki_event_subscriptions` where `code`=?";
$result = $this->query($query, array($code));
// Now send a bye bye email
$smarty->assign('mail_date', date("U"));
$user = $userlib->get_user_by_email($res["email"]);
//global $user is not necessary defined as the user is not necessary logged in
$smarty->assign('mail_user', $user);
$smarty->assign('url_subscribe', $url_subscribe);
$lg = !$user ? $language : $this->get_user_preference($user, "language", $language);
if (!isset($_SERVER["SERVER_NAME"])) {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
$mail = new TikiMail();
$mail_data = $smarty->fetchLang($lg, 'mail/event_byebye_subject.tpl');
$mail->setSubject(sprintf($mail_data, $info["name"], $_SERVER["SERVER_NAME"]));
$mail_data = $smarty->fetchLang($lg, 'mail/event_byebye.tpl');
$mail->setText($mail_data);
$mail->send(array($res["email"]));
$this->update_users($res["evId"]);
return $this->get_event($res["evId"]);
}
示例11: deleteOldFiles
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);
}
}
示例12: tra
//.........这里部分代码省略.........
$profileinstaller->setUserData($_SESSION['shopperinfo']);
$profileinstaller->install($shopperprofile);
// Then set user to shopper ID
$cartuser = $record_profile_items_created[0];
$record_profile_items_created = array();
} else {
$this->empty_cart();
return $invoice;
}
} else {
$cartuser = $user;
}
$userInput = array('user' => $cartuser, 'time' => $tikilib->now, 'total' => $total, 'invoice' => $invoice, 'weight' => $this->get_total_weight());
if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
$orderprofile = Tiki_Profile::fromDb($prefs['payment_cart_anonorders_profile']);
$orderitemprofile = Tiki_Profile::fromDb($prefs['payment_cart_anonorderitems_profile']);
} else {
$orderprofile = Tiki_Profile::fromDb($prefs['payment_cart_orders_profile']);
$orderitemprofile = Tiki_Profile::fromDb($prefs['payment_cart_orderitems_profile']);
}
if ($user && $prefs['payment_cart_orders'] == 'y' || !$user && $prefs['payment_cart_anonymous'] == 'y') {
if (!$orderprofile) {
TikiLib::lib('errorreport')->report(tra('Advanced Shopping Cart setup error: Orders profile missing.'));
return false;
}
$profileinstaller = new Tiki_Profile_Installer();
$profileinstaller->forget($orderprofile);
// profile can be installed multiple times
$profileinstaller->setUserData($userInput);
} else {
$profileinstaller = '';
}
global $record_profile_items_created;
$record_profile_items_created = array();
if ($user && $prefs['payment_cart_orders'] == 'y' || !$user && $prefs['payment_cart_anonymous'] == 'y') {
$profileinstaller->install($orderprofile, 'none');
}
$content = $this->get_content();
foreach ($content as $info) {
if (!isset($info['is_gift_certificate']) || !$info['is_gift_certificate']) {
$process_info = $this->process_item($invoice, $total, $info, $userInput, $cartuser, $profileinstaller, $orderitemprofile);
}
}
$email_template_ids = array();
if (isset($process_info['product_classes']) && is_array($process_info['product_classes'])) {
$product_classes = array_unique($process_info['product_classes']);
} else {
$product_classes = array();
}
foreach ($product_classes as $pc) {
if ($email_template_id = $this->get_tracker_value_custom($prefs['payment_cart_productclasses_tracker_name'], 'Email Template ID', $pc)) {
$email_template_ids[] = $email_template_id;
}
}
if (!empty($record_profile_items_created)) {
if ($total > 0) {
$paymentlib->register_behavior($invoice, 'complete', 'record_cart_order', array($record_profile_items_created));
$paymentlib->register_behavior($invoice, 'cancel', 'cancel_cart_order', array($record_profile_items_created));
if ($user) {
$paymentlib->register_behavior($invoice, 'complete', 'cart_send_confirm_email', array($user, $email_template_ids));
}
} else {
require_once 'lib/payment/behavior/record_cart_order.php';
payment_behavior_record_cart_order($record_profile_items_created);
if ($user) {
require_once 'lib/payment/behavior/cart_send_confirm_email.php';
payment_behavior_cart_send_confirm_email($user, $email_template_ids);
}
}
}
if (!$user || isset($_SESSION['forceanon']) && $_SESSION['forceanon'] == 'y') {
$shopperurl = 'tiki-index.php?page=' . $prefs['payment_cart_anon_reviewpage'] . '&shopper=' . intval($cartuser);
global $tikiroot, $prefs;
$shopperurl = $tikilib->httpPrefix(true) . $tikiroot . $shopperurl;
require_once 'lib/auth/tokens.php';
$tokenlib = AuthTokens::build($prefs);
$shopperurl = $tokenlib->includeToken($shopperurl, array($prefs['payment_cart_anon_group'], 'Anonymous'));
if (!empty($_SESSION['shopperinfo']['email'])) {
require_once 'lib/webmail/tikimaillib.php';
$smarty = TikiLib::lib('smarty');
$smarty->assign('shopperurl', $shopperurl);
$smarty->assign('email_template_ids', $email_template_ids);
$mail_subject = $smarty->fetch('mail/cart_order_received_anon_subject.tpl');
$mail_data = $smarty->fetch('mail/cart_order_received_anon.tpl');
$mail = new TikiMail();
$mail->setSubject($mail_subject);
if ($mail_data == strip_tags($mail_data)) {
$mail->setText($mail_data);
} else {
$mail->setHtml($mail_data);
}
$mail->send($_SESSION['shopperinfo']['email']);
// the field to use probably needs to be configurable as well
}
}
$this->update_gift_certificate($invoice);
$this->update_group_discount($invoice);
$this->empty_cart();
return $invoice;
}
示例13: values
/**
* Send a message to a user with gpg-armor block etc included
* A changed encryption-related version was copied/changed from lib/messu/messulib.pgp
* into lib/openpgp/openpgplib.php for prepending/appending content into
* message body
* @param string $user
* @param string $from
* @param string $to
* @param string $cc
* @param string $subject
* @param string $body
* @param string $prepend_email_body
* @param string $user_pubkeyarmor
* @param string $priority
* @param string $replyto_hash
* @param string $replyto_email
* @param string $bcc_sender
* @access public
* @return boolean true/false
*/
function post_message_with_pgparmor_attachment($user, $from, $to, $cc, $subject, $body, $prepend_email_body, $user_pubkeyarmor, $priority, $replyto_hash = '', $replyto_email = '', $bcc_sender = '')
{
global $prefs;
$userlib = TikiLib::lib('user');
$tikilib = TikiLib::lib('tiki');
$smarty = TikiLib::lib('smarty');
$subject = strip_tags($subject);
$body = strip_tags($body, '<a><b><img><i>');
// Prevent duplicates
$hash = md5($subject . $body);
if ($tikilib->getOne("select count(*) from `messu_messages` where `user`=? and `user_from`=? and `hash`=?", array($user, $from, $hash))) {
return false;
}
$query = "insert into `messu_messages`(`user`,`user_from`,`user_to`,`user_cc`,`subject`,`body`,`date`,`isRead`,`isReplied`,`isFlagged`,`priority`,`hash`,`replyto_hash`) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
$tikilib->query($query, array($user, $from, $to, $cc, $subject, $body, (int) $tikilib->now, 'n', 'n', 'n', (int) $priority, $hash, $replyto_hash));
// Now check if the user should be notified by email
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix(true) . $foo["path"];
$machine = str_replace('messu-compose', 'messu-mailbox', $machine);
if ($tikilib->get_user_preference($user, 'minPrio', 6) <= $priority) {
if (!isset($_SERVER["SERVER_NAME"])) {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
$email = $userlib->get_user_email($user);
if ($email) {
include_once 'lib/webmail/tikimaillib.php';
$smarty->assign('mail_site', $_SERVER["SERVER_NAME"]);
$smarty->assign('mail_machine', $machine);
$smarty->assign('mail_date', $tikilib->now);
$smarty->assign('mail_user', stripslashes($user));
$smarty->assign('mail_from', stripslashes($from));
$smarty->assign('mail_subject', stripslashes($subject));
////////////////////////////////////////////////////////////////////////
// //
// ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION //
// USING lib/openpgp/opepgplib.php //
// //
// prepend original headers into email //
$aux_body = $prepend_email_body . $body;
$body = $aux_body;
// //
////////////////////////////////////////////////////////////////////////
$smarty->assign('mail_body', stripslashes($body));
$mail = new TikiMail($user);
$lg = $tikilib->get_user_preference($user, 'language', $prefs['site_language']);
if (empty($subject)) {
$s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl');
$mail->setSubject(sprintf($s, $_SERVER["SERVER_NAME"]));
} else {
$mail->setSubject($subject);
}
$mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl');
////////////////////////////////////////////////////////////////////////
// //
// ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION //
// USING lib/openpgp/opepgplib.php //
// //
// append pgparmor block and fingerprint into email //
$mail_data .= $user_pubkeyarmor;
// //
////////////////////////////////////////////////////////////////////////
$mail->setText($mail_data);
if ($userlib->user_exists($from)) {
$from_email = $userlib->get_user_email($from);
if ($bcc_sender === 'y' && !empty($from_email)) {
$mail->setBcc($from_email);
}
if ($replyto_email !== 'y' && $userlib->get_user_preference($from, 'email is public', 'n') == 'n') {
$from_email = '';
// empty $from_email if not to be used - saves getting it twice
}
if (!empty($from_email)) {
$mail->setReplyTo($from_email);
}
}
if (!empty($from_email)) {
$mail->setFrom($from_email);
}
if (!$mail->send(array($email), 'mail')) {
return false;
//.........这里部分代码省略.........
示例14: send_replace_item_notifications
public function send_replace_item_notifications($args)
{
global $prefs, $user;
// Don't send a notification if this operation is part of a bulk import
if ($args['bulk_import']) {
return;
}
$trackerId = $args['trackerId'];
$itemId = $args['object'];
$new_values = $args['values'];
$old_values = $args['old_values'];
$the_data = $this->generate_watch_data($old_values, $new_values, $trackerId, $itemId, $args['version']);
if (empty($the_data) && $prefs['tracker_always_notify'] !== 'y') {
return;
}
$tracker_definition = Tracker_Definition::get($trackerId);
if (!$tracker_definition) {
return;
}
$tracker_info = $tracker_definition->getInformation();
$watchers = $this->get_notification_emails($trackerId, $itemId, $tracker_info, $new_values['status'], $old_values['status']);
if (count($watchers) > 0) {
$simpleEmail = isset($tracker_info['simpleEmail']) ? $tracker_info['simpleEmail'] : "n";
$trackerName = $tracker_info['name'];
if (!isset($_SERVER["SERVER_NAME"])) {
$_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"];
}
include_once 'lib/webmail/tikimaillib.php';
if ($simpleEmail == "n") {
$mail_main_value_fieldId = $this->get_main_field($trackerId);
$mail_main_value_field = $tracker_definition->getField($mail_main_value_fieldId);
if ($mail_main_value_field['type'] == 'r') {
// Item Link is special case as field value is not the displayed text. There might be other such field types.
$handler = $this->get_field_handler($mail_main_value_field);
$desc = $handler->getItemLabel($this->get_item_value($trackerId, $itemId, $mail_main_value_fieldId));
} else {
$desc = $this->get_item_value($trackerId, $itemId, $mail_main_value_fieldId);
}
if ($tracker_info['doNotShowEmptyField'] === 'y') {
// remove empty fields if tracker says so
$the_data = preg_replace('/\\[-\\[.*?\\]-\\] -\\[\\(.*?\\)\\]-:\\n\\n----------\\n/', '', $the_data);
}
$smarty = TikiLib::lib('smarty');
$smarty->assign('mail_date', $this->now);
$smarty->assign('mail_user', $user);
$smarty->assign('mail_itemId', $itemId);
$smarty->assign('mail_item_desc', $desc);
$smarty->assign('mail_trackerId', $trackerId);
$smarty->assign('mail_trackerName', $trackerName);
$smarty->assign('server_name', $_SERVER['SERVER_NAME']);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $this->httpPrefix(true) . $foo["path"];
$smarty->assign('mail_machine', $machine);
$parts = explode('/', $foo['path']);
if (count($parts) > 1) {
unset($parts[count($parts) - 1]);
}
$smarty->assign('mail_machine_raw', $this->httpPrefix(true) . implode('/', $parts));
$smarty->assign_by_ref('status', $new_values['status']);
foreach ($watchers as $watcher) {
$watcher['language'] = $this->get_user_preference($watcher['user'], 'language', $prefs['site_language']);
$label = $itemId ? tra('Item Modification', $watcher['language']) : tra('Item creation', $watcher['language']);
$mail_action = "\r\n{$label}\r\n\r\n";
$mail_action .= tra('Tracker', $watcher['language']) . ":\n " . tra($trackerName, $watcher['language']) . "\r\n";
$mail_action .= tra('Item', $watcher['language']) . ":\n {$itemId} {$desc}";
$smarty->assign('mail_action', $mail_action);
$subject = $smarty->fetchLang($watcher['language'], 'mail/tracker_changed_notification_subject.tpl');
list($watcher_data, $watcher_subject) = $this->translate_watch_data($the_data, $subject, $watcher['language']);
$smarty->assign('mail_data', $watcher_data);
if (isset($watcher['action'])) {
$smarty->assign('mail_action', $watcher['action']);
}
$smarty->assign('mail_to_user', $watcher['user']);
$mail_data = $smarty->fetchLang($watcher['language'], 'mail/tracker_changed_notification.tpl');
$mail = new TikiMail($watcher['user']);
$mail->setSubject($watcher_subject);
$mail->setText($mail_data);
$mail->send(array($watcher['email']));
}
} else {
// Use simple email
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $this->httpPrefix(true) . $foo["path"];
$parts = explode('/', $foo['path']);
if (count($parts) > 1) {
unset($parts[count($parts) - 1]);
}
$machine = $this->httpPrefix(true) . implode('/', $parts);
$userlib = TikiLib::lib('user');
if (!empty($user)) {
$my_sender = $userlib->get_user_email($user);
} else {
// look if a email field exists
$fieldId = $this->get_field_id_from_type($trackerId, 'm');
if (!empty($fieldId)) {
$my_sender = $this->get_item_value($trackerId, $itemId, $fieldId);
}
}
// Try to find a Subject in $the_data looking for strings marked "-[Subject]-" TODO: remove the tra (language translation by submitter)
$the_string = '/^\\[-\\[' . tra('Subject') . '\\]-\\] -\\[[^\\]]*\\]-:\\n(.*)/m';
//.........这里部分代码省略.........
示例15: sendStructureEmailNotification
function sendStructureEmailNotification($params)
{
global $tikilib, $smarty, $prefs;
global $structlib;
include_once 'lib/structures/structlib.php';
if ($params['action'] == 'move_up' || $params['action'] == 'move_down') {
$nots = $structlib->get_watches('', $params['parent_id'], false);
} else {
$nots = $structlib->get_watches('', $params['page_ref_id']);
}
if (!empty($nots)) {
$defaultLanguage = $prefs['site_language'];
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix() . dirname($foo["path"]);
$smarty->assign_by_ref('mail_machine', $machine);
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$smarty->assign_by_ref('action', $params['action']);
$smarty->assign_by_ref('page_ref_id', $params['page_ref_id']);
if (!empty($params['name'])) {
$smarty->assign('name', $params['name']);
}
foreach ($nots as $not) {
$mail->setUser($not['user']);
$not['language'] = $tikilib->get_user_preference($not['user'], 'language', $defaultLanguage);
$mail_subject = $smarty->fetchLang($not['language'], 'mail/user_watch_structure_subject.tpl');
$mail_data = $smarty->fetchLang($not['language'], 'mail/user_watch_structure.tpl');
$mail->setSubject($mail_subject);
$mail->setText($mail_data);
$mail->buildMessage();
$mail->send(array($not['email']));
}
}
}