New Email » '; } printHeader("Email", 1); require_once 'email.inc'; clearstatcache(); $commentSeparator = "\n***************************************************************\n"; // author comments separator $specialIndexAR = array(); // tracks which DB col to use for special var handling function showAddresses($recipient, $sql) { $r = ocsql_query($sql) or err("Unable to retrieve emails " . ocsql_errno()); if (ocsql_num_rows($r) == 0) { print '
No email addresses available for ' . safeHTMLstr($recipient) . '
'; } else { print 'Email addresses for ' . safeHTMLstr($recipient) . ':
'; while ($l = ocsql_fetch_array($r)){ print safeHTMLstr($l['email']) . "Messages are being queued for delivery. Once queued, this page will refresh and the message sent out. If the page does not refresh, you must click the link that will appear at the bottom of the page, and is also available on the ' . OCC_WORD_CHAIR . ' home page.
'; } else { $queueMessages = false; } ob_end_flush(); flush(); ob_start(); while ($l = ocsql_fetch_array($r)) { if (empty($l['email'])) { continue; } $tmpsubject = oc_replaceVariables($subject, $l); $tmpmessage = oc_replaceVariables($message, $l); // Replace special vars (\w-\w) if (isset($recipientAR[$_POST['recipient']]['special'])) { $tmpmessage = preg_replace_callback( "/\[:(\w+)-(\w+):\]/", function ($matches) { return specialValue($matches[1], $matches[2]); }, $tmpmessage ); } // YMMV wrt below $tmpmessage = preg_replace("/\r/","",$tmpmessage); $to = $l['email']; // req'd for OC_mailCopyLast code block below print 'emailing ' . safeHTMLstr($l['email'] . ' (' . $l[0] . ') ... '); ob_flush(); flush(); if ($queueMessages) { $queueAR[] = "('" . $date . "', '" . safeSQLstr($l['email']) . "', '" . safeSQLstr($tmpsubject) . "', '" . safeSQLstr($tmpmessage) . "')"; print "queuedA copy of the last message ' . ($queueMessages ? 'queued' : 'sent') . ' has been forwarded to ' . $OC_configAR['OC_confirmmail'] . '.
'; } else { print 'The system was unable to forward a copy of the last message ' . ($queueMessages ? 'queued' : 'sent') . ' to ' . $OC_configAR['OC_confirmmail'] . '.
'; } } // attempt javascript redirect if ($queueMessages) { print 'Your messages have been queued. If this page does not refresh automatically and your browser does not look like it is doing something, please follow this link to send them out now, or visit the ' . OCC_WORD_CHAIR . ' home page to send them out later.
'; } } // Preview Email elseif ($_POST['submit'] == "Preview Message") { $q = $recipientAR[$_POST['recipient']]['sql'] . " LIMIT 1"; if (isset($_POST['selected_recipients']) && !empty($_POST['selected_recipients'])) { $q = preg_replace("/ WHERE /", " WHERE " . $recipientAR[$_POST['recipient']]['id'] . "='" . safeSQLstr(substr($_POST['selected_recipients'][0], 0, strpos($_POST['selected_recipients'][0], '/'))) . "' AND ", $q); } $r = ocsql_query($q) or err("Unable to retrieve information to preview"); if (ocsql_num_rows($r) == 0) { err("No email addresses found (preview)"); } $l = ocsql_fetch_array($r); // Special var handling if (isset($recipientAR[$_POST['recipient']]['special']) && is_file($recipientAR[$_POST['recipient']]['special'])) { require_once $recipientAR[$_POST['recipient']]['special']; } print ''; $tmpsubject = oc_replaceVariables($subject, $l); $tmpmessage = oc_replaceVariables($message, $l); // Replace special vars (\w-\w) if (isset($recipientAR[$_POST['recipient']]['special'])) { $tmpmessage = preg_replace_callback( "/\[:(\w+)-(\w+):\]/", function ($matches) { return specialValue($matches[1], $matches[2]); }, $tmpmessage ); } // strip extra returns from headers $headers = safeHTMLstr(preg_replace("/[\r\n]+/","\n", $OC_configAR['OC_mailHeaders'])); // Show headers & msg print preg_replace("/([\w-]+\:)/","$1",$headers) . "\n"; print 'To: '; if (isset($_POST['select_recipients']) && ($_POST['select_recipients'] == 1)) { if (! isset($_POST['selected_recipients']) || empty($_POST['selected_recipients'])) { warn('No recipients selected'); } elseif (count($_POST['selected_recipients']) == 1) { list($id, $email) = explode("/", $_POST['selected_recipients'][0]); print safeHTMLstr($email . ' (ID: ' . $id . ')'); } else { foreach ($_POST['selected_recipients'] as $recip) { list($id, $email) = explode("/", $recip); print "\n " . safeHTMLstr($email . ' (ID: ' . $id . ')'); } } } else { print safeHTMLstr($l['email']); } print "\n"; print 'Subject: ' . safeHTMLstr($tmpsubject) . "\n\n"; print safeHTMLstr(wordwrap($tmpmessage, $OC_configAR['OC_emailWrap'])) . "\n\n"; } // Write Email elseif (($_POST['submit'] == "Write Email Online") || ($_POST['submit'] == "Edit Message")) { // Valid recipient? if (!isset($_POST['recipient']) || !isset($recipients[$_POST['recipient']])) { err("Unknown recipient group selected"); } // Any addresses $r = ocsql_query($recipientAR[$_POST['recipient']]['sql']) or err("Unable to retrieve email addresses " . ocsql_errno()); if (ocsql_num_rows($r) == 0) { print '
No email addresses available for ' . safeHTMLstr($recipientAR[$_POST['recipient']]['text']) . '
'; } else { print 'The variables appearing next to the message field may be used in your email by enclosing each instance in [:variable:] . These will be substituted for their value prior to the email being sent. For example, to include the conference (short) name in your message use [:OC_confName:] . Some variables are only available for certain recipient groups. The [:review-fields:] variable, available when emailing author acceptance notices, includes the review form fields designated to "show author" in the Custom Forms module; the default is to only show the reviewer Comments to Author.
'; } // if Any emails } // end submit write } // end submit // Not a submit - select recipient/template else { print ' '; } // else not a submit printFooter(); ?>