本文整理汇总了PHP中TikiMail::setHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP TikiMail::setHtml方法的具体用法?PHP TikiMail::setHtml怎么用?PHP TikiMail::setHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TikiMail
的用法示例。
在下文中一共展示了TikiMail::setHtml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: plugin_pending_notification
/**
* Send notification by email that a plugin is waiting to be
* approved to everyone with permission to approve it.
*
* @param string $plugin_name
* @param string $body plugin body
* @param array $arguments plugin arguments
* @param array $context object type and id
* @return void
*/
private function plugin_pending_notification($plugin_name, $body, $arguments, $context)
{
require_once 'lib/webmail/tikimaillib.php';
global $prefs, $base_url;
$mail = new TikiMail(null, $prefs['sender_email']);
$mail->setSubject(tr("Plugin %0 pending approval", $plugin_name));
$smarty = TikiLib::lib('smarty');
$smarty->assign('plugin_name', $plugin_name);
$smarty->assign('type', $context['type']);
$smarty->assign('objectId', $context['object']);
$smarty->assign('arguments', $arguments);
$smarty->assign('body', $body);
$mail->setHtml(nl2br($smarty->fetch('mail/plugin_pending_notification.tpl')));
$recipients = $this->plugin_get_email_users_with_perm();
$mail->setBcc($recipients);
if (!empty($prefs['sender_email'])) {
$mail->send(array($prefs['sender_email']));
} elseif ($admin_email = TikiLib::lib('user')->get_user_email('admin')) {
$recipients = array_diff($recipients, array($admin_email));
$mail->setBcc($recipients);
$mail->send(array($admin_email));
}
}
示例3: tra
function action_email_wikipage($input)
{
Services_Exception_Disabled::check('feature_wiki');
Services_Exception_Denied::checkGlobal('admin_users');
$check = Services_Exception_BadRequest::checkAccess();
//first pass - show confirm popup
if (!empty($check['ticket'])) {
$users = $input->asArray('checked');
if (count($users) > 0) {
//provide redirect if js is not enabled
$referer = Services_Utilities_Controller::noJsPath();
return ['title' => tra('Send wiki page content by email to selected users'), 'confirmAction' => $input->action->word(), 'confirmController' => 'user', 'customMsg' => tra('For these selected users:'), 'items' => $users, 'extra' => ['referer' => $referer], 'ticket' => $check['ticket'], 'modal' => '1', 'confirm' => 'y'];
} else {
throw new Services_Exception(tra('No users were selected. Please select one or more users.'), 409);
}
//after confirm submit - perform action and return success feedback
} elseif ($check === true && $_SERVER['REQUEST_METHOD'] === 'POST') {
$wikiTpl = $input['wikiTpl'];
$tikilib = TikiLib::lib('tiki');
$pageinfo = $tikilib->get_page_info($wikiTpl);
if (!$pageinfo) {
throw new Services_Exception_NotFound(tra('Page not found'));
}
if (empty($pageinfo['description'])) {
throw new Services_Exception(tra('The page does not have a description, which is mandatory to perform this action.'));
}
$bcc = $input['bcc'];
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
if (!empty($bcc)) {
if (!validate_email($bcc)) {
throw new Services_Exception(tra('Invalid bcc email address.'));
}
$mail->setBcc($bcc);
$bccmsg = tr('and blind copied to %0', $bcc);
}
$foo = parse_url($_SERVER['REQUEST_URI']);
$machine = $tikilib->httpPrefix(true) . dirname($foo['path']);
$machine = preg_replace('!/$!', '', $machine);
// just in case
global $smarty, $user;
$smarty->assign_by_ref('mail_machine', $machine);
$users = json_decode($input['items'], true);
$logslib = TikiLib::lib('logs');
foreach ($users as $mail_user) {
$smarty->assign_by_ref('user', $mail_user);
$mail->setUser($mail_user);
$mail->setSubject($pageinfo['description']);
$text = $smarty->fetch('wiki:' . $wikiTpl);
if (empty($text)) {
throw new Services_Exception(tra('The template page has no text or it cannot be extracted.'));
}
$mail->setHtml($text);
if (!$mail->send($this->lib->get_user_email($mail_user))) {
$errormsg = tra('Unable to send mail');
if (Perms::get()->admin) {
$mailerrors = print_r($mail->errors, true);
$errormsg .= $mailerrors;
}
throw new Services_Exception($errormsg);
} else {
if (!empty($bcc)) {
$logmsg = sprintf(tra('Mail sent to user %s'), $mail_user);
}
$logmsg = !empty($bccmsg) ? $logmsg . ' ' . $bccmsg : $logmsg;
if (!empty($msg)) {
$logslib->add_log('adminusers', $logmsg, $user);
}
}
$smarty->assign_by_ref('user', $user);
}
//return to page
//if javascript is not enabled
$extra = json_decode($input['extra'], true);
if (!empty($extra['referer'])) {
$this->access->redirect($extra['referer'], tra('Page sent'), null, 'feedback');
}
$msg = count($users) === 1 ? tr('The page %0 has been emailed to the following user:', $wikiTpl) : tr('The page %0 has been emailed to the following users:', $wikiTpl);
$toMsg = !empty($bcc) ? tr('And blind copied to %0.', $bcc) : '';
return ['extra' => 'post', 'feedback' => ['ajaxtype' => 'feedback', 'ajaxheading' => tra('Success'), 'ajaxitems' => $users, 'ajaxmsg' => $msg, 'ajaxtoMsg' => $toMsg, 'modal' => '1']];
}
}
示例4: array
}
$mail->setFrom($tikilib->get_preference("sender_email", ""));
$mail->setSubject($_REQUEST["subject"]);
// htmlMimeMail memorised the encoded subject
$languageEmail = !$userEmail ? $language : $tikilib->get_user_preference($userEmail, "language", $language);
if ($nl_info["unsubMsg"] == 'y') {
$unsubmsg = $nllib->get_unsub_msg($_REQUEST["nlId"], $userEmail, $languageEmail, $us["code"], $userEmail);
if (stristr($html, "</body>") === false) {
$msg = $html . nl2br($unsubmsg);
} else {
$msg = str_replace("</body>", nl2br($unsubmsg) . "</body>", $html);
}
} else {
$msg = $html;
}
$mail->setHtml($msg, $txt . strip_tags($unsubmsg));
$mail->buildMessage();
if ($mail->send(array($email))) {
$sent++;
} else {
$errors[] = array("user" => $userEmail, "email" => $email);
}
}
$smarty->assign('sent', $sent);
$smarty->assign('emited', 'y');
if (count($errors) > 0) {
$smarty->assign_by_ref('errors', $errors);
}
$nllib->replace_edition($_REQUEST["nlId"], $_REQUEST["subject"], $_REQUEST["data"], $sent);
}
if (!isset($_REQUEST["sort_mode"])) {
示例5: foreach
$i = 0;
foreach ($listevents as $leDay) {
foreach ($leDay as $le) {
$id = 'c' . $le['calitemId'];
if ($id == 'c0') {
$id = 'r' . $le['recurrenceId'];
}
if (!array_key_exists($id, $absent_tmp)) {
$absent_tmp[$id]['startTimeStamp'] = $le['startTimeStamp'];
$absent_tmp[$id]['endTimeStamp'] = $le['endTimeStamp'];
$absent_tmp[$id]['name'] = $le['name'];
$absent_tmp[$id]['description'] = $le['description'];
}
}
}
$absent = array();
foreach ($absent_tmp as $vi) {
$absent[] = $vi;
}
$smarty->assign('absent', $absent);
$mail = new TikiMail();
$mail_data = $smarty->fetch("mail/weekly_calendar_subject.tpl");
$mail->setSubject($mail_data);
$mail_data = $smarty->fetch("mail/weekly_calendar_email.tpl");
$mail->setHtml($mail_data, strip_tags($mail_data));
$mail->buildMessage();
$mail->send(array($prefs['weekly_calendar_to_email']));
//$smarty->display("mail/weekly_calendar_subject.tpl");
//$smarty->display("mail/weekly_calendar_email.tpl");
header('Location: tiki-calendar.php?todate=' . $start_date);
exit;
示例6: mailTodo
/**
* @param $todo
* @param $to
* @param string $default_subject
* @param string $default_body
*/
function mailTodo($todo, $to, $default_subject = 'Change notification', $default_body = '')
{
global $prefs;
$userlib = TikiLib::lib('user');
$tikilib = TikiLib::lib('tiki');
$smarty = TikiLib::lib('smarty');
if (empty($to['email']) && !empty($to['user'])) {
$to['email'] = $userlib->get_user_email($to['user']);
}
if (empty($to['email'])) {
return;
}
$lang = empty($to['user']) ? $prefs['site_language'] : $tikilib->get_user_preference($u, 'language', $prefs['site_language']);
if (empty($todo['to']['subject'])) {
$todo['to']['subject'] = tra($default_subject, $lang);
}
if (empty($todo['to']['body'])) {
$todo['to']['body'] = tra($default_body, $lang);
} else {
$todo['to']['body'] = $smarty->fetchLang($lang, $todo['to']['body']);
}
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail(empty($to['user']) ? null : $to['user']);
$mail->setSubject($todo['to']['subject']);
$mail->setHtml($todo['to']['body']);
$mail->send(array($to['email']));
}
示例7: wikiplugin_tracker
//.........这里部分代码省略.........
$emailOptions[1][$key] = $trklib->get_item_value($trackerId, $rid, $email);
}
}
}
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$mail->setFrom($emailOptions[0]);
if (!empty($emailOptions[2])) {
//tpl
$emailOptions[2] = preg_split('/ *, */', $emailOptions[2]);
foreach ($emailOptions[2] as $ieo => $eo) {
if (!preg_match('/\\.tpl$/', $eo)) {
$emailOptions[2][$ieo] = $eo . '.tpl';
}
$tplSubject[$ieo] = str_replace('.tpl', '_subject.tpl', $emailOptions[2][$ieo]);
}
} else {
$emailOptions[2] = array('tracker_changed_notification.tpl');
}
if (empty($tplSubject)) {
$tplSubject = array('tracker_changed_notification_subject.tpl');
}
$itpl = 0;
$smarty->assign('mail_date', $tikilib->now);
$smarty->assign('mail_itemId', $rid);
foreach ($emailOptions[1] as $ieo => $ueo) {
@($mail_data = $smarty->fetch('mail/' . $tplSubject[$itpl]));
if (empty($mail_data)) {
$mail_data = tra('Tracker was modified at ') . $_SERVER["SERVER_NAME"];
}
$mail->setSubject($mail_data);
$mail_data = $smarty->fetch('mail/' . $emailOptions[2][$itpl]);
if ($emailformat == 'html') {
$mail->setHtml($mail_data);
} else {
$mail->setText($mail_data);
}
try {
$mail->send($ueo);
$title = 'mail';
} catch (Zend_Mail_Exception $e) {
$title = 'mail error';
}
if ($title == 'mail error') {
// Log the email error at the tiki syslog
$logslib = TikiLib::lib('logs');
$logslib->add_log('mail error', 'plugin tracker email error / ' . $emailOptions[1][$ieo] . ' / item' . $rid);
} elseif ($title == 'mail' && $prefs['log_mail'] == 'y') {
// Log the email at the tiki syslog
$logslib = TikiLib::lib('logs');
$logslib->add_log('mail', 'plugin tracker email sent / ' . $emailOptions[1][$ieo] . ' / item' . $rid);
}
if (isset($tplSubject[$itpl + 1])) {
++$itpl;
}
}
}
if (empty($url)) {
if (!empty($_REQUEST['ajax_add'])) {
// called by tracker ItemLink fields when adding new list items
while (ob_get_level()) {
ob_end_clean();
}
if ($prefs['feature_obzip'] == 'y') {
ob_start('ob_gzhandler');
} else {
示例8: 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;
}
示例9: sendEmailNotification
/**
*\brief Send email notification to a list of emails or a list of (email, user) in a charset+language associated with each email
* \param $watches : bidimensional array of watches. Each watch has user, language, email and watchId keys.
* \param $dummy: unused
* \param $subjectTpl: subject template file or null (ex: "submission_notifcation.tpl")
* \param $subjectParam: le param to be inserted in the subject or null
* \param $txtTpl : texte template file (ex: "submission_notifcation.tpl")
* \param $from email from to not the default one
* \ $smarty is supposed to be already built to fit $txtTpl
* \return the nb of sent emails
*/
function sendEmailNotification($watches, $dummy, $subjectTpl, $subjectParam, $txtTpl, $from = '')
{
global $prefs;
$smarty = TikiLib::lib('smarty');
$tikilib = TikiLib::lib('tiki');
$userlib = TikiLib::lib('user');
include_once 'lib/webmail/tikimaillib.php';
$sent = 0;
$smarty->assign('mail_date', $tikilib->now);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$smarty->assign('mail_machine', $tikilib->httpPrefix(true) . $foo["path"]);
$parts = explode('/', $foo['path']);
if (count($parts) > 1) {
unset($parts[count($parts) - 1]);
}
$smarty->assign('mail_machine_raw', $tikilib->httpPrefix(true) . implode('/', $parts));
// TODO: mail_machine_site may be required for some sef url with rewrite to sub-directory. To refine. (nkoth)
$smarty->assign('mail_machine_site', $tikilib->httpPrefix(true));
if ($dummy == 'group_lead_mail' || $dummy == 'add_rem_mail') {
$api = new TikiAddons_Api_Group();
$subjectParam['gname'] = trim($subjectParam['gname']);
$smarty->assign('mail_appdata', $subjectParam['app_data']);
$smarty->assign('mail_group', $api->getOrganicGroupName($subjectParam['gname']));
$url = '';
if ($dummy == 'group_lead_mail') {
$url = $api->getGroupManagementPage($subjectParam['gname']) . "?itemId=" . $api->getItemIdFromToken($subjectParam['gname']);
$smarty->assign('mail_user', $subjectParam['user']);
$smarty->assign('mail_real', $tikilib->get_user_preference($subjectParam['user'], 'realName', ''));
} elseif ($dummy == 'add_rem_mail') {
$url = $api->getGroupHomePage($subjectParam['gname']) . "?itemId=" . $api->getItemIdFromToken($subjectParam['gname']);
}
foreach ($watches as $key => $value) {
$lang = $tikilib->get_user_preference($key, "language", $prefs['site_language']);
if ($dummy != 'group_lead_mail') {
// group_lead_mail already sets this
$smarty->assign('mail_user', $key);
$smarty->assign('mail_real', $tikilib->get_user_preference($key, 'realName', ''));
}
$smarty->assign('mail_remuser', $tikilib->get_user_preference($value, 'realName', ''));
$userid = "user" . TikiLib::lib('user')->get_user_id($value);
$smarty->assign('mail_userid', $userid);
$smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
$smarty->assign('mail_url', $url);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
if (substr($machine, -1) == '/') {
$machine = substr($machine, 0, -1);
}
$smarty->assign('mail_machine', $machine);
$mail = new TikiMail(null, $from);
if ($key) {
$mail->setUser($key);
}
if ($subjectTpl) {
$mail_data = $smarty->fetchLang($lang, "mail/" . $subjectTpl);
if ($subjectParam) {
$mail_data = sprintf($mail_data, $subjectParam);
}
$mail_data = preg_replace('/%[sd]/', '', $mail_data);
// partial cleaning if param not supply and %s in text
$mail->setSubject($mail_data);
} else {
$mail->setSubject($subjectParam);
}
$mail->setHtml($smarty->fetchLang($lang, "mail/" . $txtTpl));
if ($mail->send(array(TikiLib::lib('user')->get_user_email($key)))) {
$sent++;
}
}
} else {
foreach ($watches as $watch) {
$mail = new TikiMail(null, $from);
$smarty->assign('watchId', $watch['watchId']);
if ($watch['user']) {
$mail->setUser($watch['user']);
}
if ($subjectTpl) {
$mail_data = $smarty->fetchLang($watch['language'], "mail/" . $subjectTpl);
if ($subjectParam) {
$mail_data = sprintf($mail_data, $subjectParam);
}
$mail_data = preg_replace('/%[sd]/', '', $mail_data);
// partial cleaning if param not supply and %s in text
$mail->setSubject($mail_data);
} else {
$mail->setSubject($subjectParam);
}
$mail->setText($smarty->fetchLang($watch['language'], "mail/" . $txtTpl));
if ($mail->send(array($watch['email']))) {
//.........这里部分代码省略.........
示例10: dirname
$foo = parse_url($_SERVER['REQUEST_URI']);
$machine = $tikilib->httpPrefix(true) . dirname($foo['path']);
$machine = preg_replace('!/$!', '', $machine);
// just incase
$smarty->assign_by_ref('mail_machine', $machine);
foreach ($_REQUEST['checked'] as $mail_user) {
$smarty->assign_by_ref('user', $mail_user);
$mail->setUser($mail_user);
$mail->setSubject($info['description']);
$text = $smarty->fetch('wiki:' . $_REQUEST['wikiTpl']);
if (empty($text)) {
$smarty->assign('msg', tra('Error'));
$smarty->display('error.tpl');
die;
}
$mail->setHtml($text);
$mail->send($userlib->get_user_email($mail_user));
}
$smarty->assign_by_ref('user', $user);
}
if (!isset($_REQUEST['sort_mode'])) {
$sort_mode = 'login_asc';
} else {
$sort_mode = $_REQUEST['sort_mode'];
}
$smarty->assign_by_ref('sort_mode', $sort_mode);
if (!isset($_REQUEST['numrows'])) {
$numrows = $maxRecords;
} else {
$numrows = $_REQUEST['numrows'];
}
示例11: send
private function send($email, $title, $html, $args = [])
{
global $prefs;
require_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$mail->setSubject($title);
$mail->setHtml($html);
if (!empty($prefs['monitor_reply_email_pattern']) && isset($args['reply_action'], $args['type'], $args['object'])) {
$data = Tiki_Security::get()->encode(['u' => $GLOBALS['user'], 'a' => $args['reply_action'], 't' => $args['type'], 'o' => $args['object']]);
$reply = str_replace('PLACEHOLDER', $data, $prefs['monitor_reply_email_pattern']);
$name = tr("%0 Reply Handler", $prefs['sitetitle']);
$mail->setReplyTo($reply, $name);
}
$mail->send($email);
}
示例12: TikiMail
/**
* This is a function to invite users to temporarily access the site via a token
* @param array $emails Emails to send the invite to
* @param array $groups Groups that the temporary user should have (Registered is not included unless explicitly added)
* @param int $timeout How long the invitation is valid for, in seconds.
* @param string $prefix Username of the created users will be the token ID prefixed with this
* @param string $path Users will have to autologin using this path on the site using the token
* @throws Exception
*/
function invite_tempuser($emails, $groups, $timeout, $prefix = 'guest', $path = 'index.php')
{
global $smarty, $user, $prefs;
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
foreach ($emails as $email) {
if (!validate_email($email)) {
throw new Exception(tr('Invalid email address "%0"', $email));
}
}
$foo = parse_url($_SERVER['REQUEST_URI']);
$machine = $this->httpPrefix(true) . dirname($foo['path']);
$machine = preg_replace('!/$!', '', $machine);
// just in case
$smarty->assign_by_ref('mail_machine', $machine);
$smarty->assign('mail_sender', $user);
$smarty->assign('expiry', $user);
$mail->setBcc($this->get_user_email($user));
$smarty->assign('token_expiry', $this->get_long_datetime($this->now + $timeout));
require_once 'lib/auth/tokens.php';
foreach ($emails as $email) {
$tokenlib = AuthTokens::build($prefs);
$token_url = $tokenlib->includeToken($machine . "/{$path}", $groups, $email, $timeout, -1, true, $prefix);
include_once 'tiki-sefurl.php';
$token_url = filter_out_sefurl($token_url);
$smarty->assign('token_url', $token_url);
$mail->setUser($user);
$mail->setSubject($smarty->fetch('mail/invite_tempuser_subject.tpl'));
$mail->setHtml($smarty->fetch('mail/invite_tempuser.tpl'));
if (!$mail->send($email)) {
throw new Exception(tr('Unable to send mail to invite "%0"', $email));
}
$smarty->assign_by_ref('user', $user);
}
}
示例13: wikiplugin_tracker
//.........这里部分代码省略.........
$emailOptions[1] = preg_split('/ *, */', $emailOptions[1]);
foreach ($emailOptions[1] as $key=>$email) {
if (is_numeric($email))
$emailOptions[1][$key] = $trklib->get_item_value($trackerId, $rid, $email);
}
}
include_once('lib/webmail/tikimaillib.php');
$mail = new TikiMail();
$mail->setHeader('From', $emailOptions[0]);
if (!empty($emailOptions[2])) { //tpl
$emailOptions[2] = preg_split('/ *, */', $emailOptions[2]);
foreach ($emailOptions[2] as $ieo=>$eo) {
if (!preg_match('/\.tpl$/', $eo))
$emailOptions[2][$ieo] = $eo.'.tpl';
$tplSubject[$ieo] = str_replace('.tpl', '_subject.tpl', $emailOptions[2][$ieo]);
}
} else {
$emailOptions[2] = array('tracker_changed_notification.tpl');
}
if (empty($tplSubject)) {
$tplSubject = array('tracker_changed_notification_subject.tpl');
}
$itpl = 0;
$smarty->assign('mail_date', $tikilib->now);
$smarty->assign('mail_itemId', $rid);
foreach ($emailOptions[1] as $ieo=>$ueo) {
@$mail_data = $smarty->fetch('mail/'.$tplSubject[$itpl]);
if (empty($mail_data))
$mail_data = tra('Tracker was modified at '). $_SERVER["SERVER_NAME"];
$mail->setSubject($mail_data);
$mail_data = $smarty->fetch('mail/'.$emailOptions[2][$itpl]);
if ($emailformat == 'html') {
$mail->setHtml($mail_data);
} else {
$mail->setText($mail_data);
}
$mail->buildMessage(array('text_encoding' => '8bit'));
$mail->send($ueo);
if (isset($tplSubject[$itpl+1]))
++$itpl;
}
}
if (empty($url)) {
if (!empty($_REQUEST['ajax_add'])) { // called by tracker ItemLink fields when adding new list items
global $access;
while ( ob_get_level() ) {
ob_end_clean();
}
if ( $prefs['feature_obzip'] == 'y' ) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
// Need to add newly created itemId for item link selector
$ins_fields['itemId'] = $rid;
$access->output_serialized($ins_fields);
ob_end_flush();
die;
} else if (!empty($page)) {
$url = "tiki-index.php?page=".urlencode($page);
if (!empty($itemId)) {
$url .= "&itemId=".$itemId;
}
$url .= "&ok=y&iTRACKER=$iTRACKER";
示例14: plugin_pending_notification
/**
* Send notification by email that a plugin is waiting to be
* approved to everyone with permission to approve it.
*
* @param string $plugin_name
* @param string $body plugin body
* @param array $arguments plugin arguments
* @param array $context object type and id
* @return void
*/
private function plugin_pending_notification($plugin_name, $body, $arguments, $context)
{
require_once('lib/webmail/tikimaillib.php');
global $prefs, $base_url, $smarty;
$mail = new TikiMail(null, $prefs['sender_email']);
$mail->setSubject(tr("Plugin %0 pending approval", $plugin_name));
$smarty->assign('plugin_name', $plugin_name);
$smarty->assign('type', $context['type']);
$smarty->assign('objectId', $context['object']);
$smarty->assign('arguments', $arguments);
$smarty->assign('body', $body);
$mail->setHtml(nl2br($smarty->fetch('mail/plugin_pending_notification.tpl')));
$recipients = $this->plugin_get_email_users_with_perm();
$mail->setBcc(join(', ', $recipients));
$mail->send(array($prefs['sender_email']));
}
示例15: sendEmailNotification
/**
*\brief Send email notification to a list of emails or a list of (email, user) in a charset+language associated with each email
* \param $watches : bidimensional array of watches. Each watch has user, language, email and watchId keys.
* \param $dummy: unused
* \param $subjectTpl: subject template file or null (ex: "submission_notifcation.tpl")
* \param $subjectParam: le param to be inserted in the subject or null
* \param $txtTpl : texte template file (ex: "submission_notifcation.tpl")
* \param $from email from to not the default one
* \ $smarty is supposed to be already built to fit $txtTpl
* \return the nb of sent emails
*/
function sendEmailNotification($watches, $dummy, $subjectTpl, $subjectParam, $txtTpl, $from = '')
{
global $smarty, $tikilib;
$userlib = TikiLib::lib('user');
include_once 'lib/webmail/tikimaillib.php';
$sent = 0;
$smarty->assign('mail_date', $tikilib->now);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$smarty->assign('mail_machine', $tikilib->httpPrefix(true) . $foo["path"]);
$parts = explode('/', $foo['path']);
if (count($parts) > 1) {
unset($parts[count($parts) - 1]);
}
$smarty->assign('mail_machine_raw', $tikilib->httpPrefix(true) . implode('/', $parts));
// TODO: mail_machine_site may be required for some sef url with rewrite to sub-directory. To refine. (nkoth)
$smarty->assign('mail_machine_site', $tikilib->httpPrefix(true));
if ($dummy == 'group_lead_mail') {
foreach ($watches as $key => $value) {
trim($subjectParam['gname']);
$adurl = "-Admin+-+" . urlencode($subjectParam['gname']) . "-";
$smarty->assign('mail_group', $subjectParam['gname']);
$smarty->assign('mail_user', $subjectParam['user']);
$smarty->assign('mail_real', $tikilib->get_user_preference($subjectParam['user'], 'realName', ''));
$pageLang = isset($subjectParam[$key]['lang']) ? $subjectParam[$key]['lang'] : '';
$userid = "user" . $userlib->get_user_id($value);
$smarty->assign('mail_remuser', $tikilib->get_user_preference($value, 'realName', ''));
$smarty->assign('mail_userid', $userid);
$smarty->assign('mail_site', $_SERVER['SERVER_NAME']);
$smarty->assign('admin_url', $adurl);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
if (substr($machine, -1) == '/') {
$machine = substr($machine, 0, -1);
}
$smarty->assign('mail_machine', $machine);
$mail = new TikiMail(null, $from);
if ($key) {
$mail->setUser($key);
}
if ($subjectTpl) {
$mail_data = $smarty->fetchLang($pageLang, "mail/" . $subjectTpl);
if ($subjectParam) {
$mail_data = sprintf($mail_data, $subjectParam);
}
$mail_data = preg_replace('/%[sd]/', '', $mail_data);
// partial cleaning if param not supply and %s in text
$mail->setSubject($mail_data);
} else {
$mail->setSubject($subjectParam);
}
$mail->setHtml($smarty->fetchLang($pageLang, "mail/" . $txtTpl));
if ($mail->send(array($userlib->get_user_email($key)))) {
$sent++;
}
}
} else {
foreach ($watches as $watch) {
$mail = new TikiMail(null, $from);
$smarty->assign('watchId', $watch['watchId']);
if ($watch['user']) {
$mail->setUser($watch['user']);
}
if ($subjectTpl) {
$mail_data = $smarty->fetchLang($watch['language'], "mail/" . $subjectTpl);
if ($subjectParam) {
$mail_data = sprintf($mail_data, $subjectParam);
}
$mail_data = preg_replace('/%[sd]/', '', $mail_data);
// partial cleaning if param not supply and %s in text
$mail->setSubject($mail_data);
} else {
$mail->setSubject($subjectParam);
}
$mail->setText($smarty->fetchLang($watch['language'], "mail/" . $txtTpl));
if ($mail->send(array($watch['email']))) {
$sent++;
}
}
}
return $sent;
}