New Email » '; } printHeader("Email",1); clearstatcache(); // Additional vars (of interest) available for use in emails $varAR = array( 'OC_pcemail' => OCC_WORD_CHAIR . ' Email', 'OC_confirmmail' => 'Notification Email', 'OC_confName' => 'Event Short Name', 'OC_confNameFull' => 'Event Full Name', 'OC_confURL' => 'Event Web Address' ); $authorVarAR = array( 'paperid' => 'Submission ID', 'title' => 'Submission Title', 'name_last' => 'Recipient Last Name', 'name_first' => 'Recipient First Name', 'email' => 'Recipient Email' ); $authorVarAR2 = array_merge( $authorVarAR, array( 'author-comments' => 'Reviewer Comments', 'advocate-comments' => 'Committee (Adv.) Comments', 'chair-notes' => OCC_WORD_CHAIR . ' Notes' ) ); if (preg_match("/professional/i", OCC_LICENSE_TYPE)) { $authorVarAR2['review-fields'] = 'Review Fields (set to Show Author)'; } $reviewerVarAR = array( 'name_last' => 'Reviewer Last Name', 'name_first' => 'Reviewer First Name', 'username' => 'Reviewer Username', 'email' => 'Reviewer Email' ); // Author comments separator $commentSeparator = "\n***************************************************************\n"; // Retrieve templates $templateAR = array(); $q = "SELECT `templateid`, `name`, `module` FROM `" . OCC_TABLE_TEMPLATE . "` ORDER BY `name` ASC"; $r = ocsql_query($q) or err('Unable to retrieve templates'); while ($l = ocsql_fetch_assoc($r)) { // Skip templates for modules not active if (isset($l['module']) && !empty($l['module']) && ($l['module'] != 'OC') && !in_array($l['module'], $OC_activeModulesAR)) { continue; } // Skip PC templates if advocates not used if ($OC_configAR['OC_paperAdvocates'] || !preg_match("/^pc_/", $l['templateid'])) { $templateAR[$l['templateid']] = $l['name']; } } // Set up recipients $recipientAR = array(); $specialIndexAR = array(); // tracks which DB col to use for special var handling $recipientAR['authors_all']['text'] = OCC_WORD_AUTHOR . 's - All'; $recipientAR['authors_all']['sql'] = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `name_last`, `name_first`, `title`, `email` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_AUTHOR . "` WHERE `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` AND `" . OCC_TABLE_AUTHOR . "`.`position`=`" . OCC_TABLE_PAPER . "`.`contactid` ORDER BY `paperid`"; $recipientAR['authors_all']['vars'] = $authorVarAR; $recipientAR['authors_all']['id'] = "`" . OCC_TABLE_PAPER . "`.`paperid`"; $sr = ocsql_query("SELECT COUNT(*) AS `count` FROM `" . OCC_TABLE_PAPER . "` WHERE `student`='T'") or err('Unable to check student field'); if (($sl = ocsql_fetch_assoc($sr)) && ($sl['count'] > 0)) { $recipientAR['authors_students']['text'] = 'Authors - Student submissions'; $recipientAR['authors_students']['sql'] = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `name_last`, `name_first`, `title`, `email` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_AUTHOR . "` WHERE `" . OCC_TABLE_PAPER . "`.`student`='T' AND `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` AND `" . OCC_TABLE_AUTHOR . "`.`position`=`" . OCC_TABLE_PAPER . "`.`contactid` ORDER BY `paperid`"; $recipientAR['authors_students']['vars'] = $authorVarAR; $recipientAR['authors_students']['id'] = "`" . OCC_TABLE_PAPER . "`.`paperid`"; } $recipientAR['authors_nofile']['text'] = OCC_WORD_AUTHOR . 's - Missing file'; $recipientAR['authors_nofile']['sql'] = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `name_last`, `name_first`, `title`, `email` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_AUTHOR . "` WHERE `format` is NULL AND `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` AND `" . OCC_TABLE_AUTHOR . "`.`position`=`" . OCC_TABLE_PAPER . "`.`contactid` ORDER BY `paperid`"; $recipientAR['authors_nofile']['vars'] = $authorVarAR; $recipientAR['authors_nofile']['id'] = "`" . OCC_TABLE_PAPER . "`.`paperid`"; // acceptance break down foreach ($OC_acceptanceValuesAR as $idx => $acc) { $recipientAR['authors_' . $idx]['text'] = OCC_WORD_AUTHOR . 's - Submission ' . $acc['value']; $recipientAR['authors_' . $idx]['sql'] = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `name_last`, `name_first`, `title`, `email` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_AUTHOR . "` WHERE `" . OCC_TABLE_PAPER . "`.`accepted`='" . safeSQLstr($acc['value']) . "' AND `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` AND `" . OCC_TABLE_AUTHOR . "`.`position`=`" . OCC_TABLE_PAPER . "`.`contactid` ORDER BY `paperid`"; $recipientAR['authors_' . $idx]['vars'] = $authorVarAR2; $recipientAR['authors_' . $idx]['special'] = 'email-authors.inc'; $recipientAR['authors_' . $idx]['id'] = "`" . OCC_TABLE_PAPER . "`.`paperid`"; } if (isset($OC_submissionFieldAR['presenter']) && in_array('presenter', $OC_submissionFieldSetAR['fs_authors']['fields'])) { $recipientAR['presenters']['text'] = 'Presenting ' . OCC_WORD_AUTHOR . 's - All'; $recipientAR['presenters']['sql'] = "SELECT `" . OCC_TABLE_PAPER . "`.`paperid`, `name_last`, `name_first`, `title`, `email` FROM `" . OCC_TABLE_PAPER . "`, `" . OCC_TABLE_AUTHOR . "` WHERE `" . OCC_TABLE_AUTHOR . "`.`presenter`='T' AND `" . OCC_TABLE_PAPER . "`.`paperid`=`" . OCC_TABLE_AUTHOR . "`.`paperid` ORDER BY `paperid`"; $recipientAR['presenters']['vars'] = $authorVarAR; $recipientAR['presenters']['id'] = "`" . OCC_TABLE_PAPER . "`.`paperid`"; } if ($OC_configAR['OC_paperAdvocates']) { $recipientAR['reviewer_pc_all']['text'] = 'Review and Program Committee Members - All'; $recipientAR['reviewer_pc_all']['text'] = 'Review and Program Committee Members - All'; $recipientAR['reviewer_pc_all']['sql'] = "SELECT `reviewerid`, `name_last`, `name_first`, `username`, `email` FROM `" . OCC_TABLE_REVIEWER . "` WHERE 1=1 ORDER BY `reviewerid`"; $recipientAR['reviewer_pc_all']['vars'] = $reviewerVarAR; $recipientAR['reviewer_pc_all']['id'] = '`reviewerid`'; $recipientAR['reviewers_all']['text'] = 'Reviewers - All (except Program Committee members)'; } else { $recipientAR['reviewers_all']['text'] = 'Reviewers - All'; } $recipientAR['reviewers_all']['sql'] = "SELECT `reviewerid`, `name_last`, `name_first`, `username`, `email` FROM `" . OCC_TABLE_REVIEWER . "` WHERE `onprogramcommittee`='F' ORDER BY `reviewerid`"; $recipientAR['reviewers_all']['vars'] = $reviewerVarAR; $recipientAR['reviewers_all']['id'] = '`reviewerid`'; $recipientAR['reviewers_noreview']['text'] = 'Reviewers - Reviews not yet completed or no score'; $recipientAR['reviewers_noreview']['sql'] = "SELECT `" . OCC_TABLE_REVIEWER . "`.`reviewerid`, `name_last`, `name_first`, `username`, `email` FROM `" . OCC_TABLE_REVIEWER . "`, `" . OCC_TABLE_PAPERREVIEWER . "` WHERE (`" . OCC_TABLE_PAPERREVIEWER . "`.`completed` != 'T' OR `" . OCC_TABLE_PAPERREVIEWER . "`.`score` IS NULL) AND `" . OCC_TABLE_PAPERREVIEWER . "`.`reviewerid`=`" . OCC_TABLE_REVIEWER . "`.`reviewerid` GROUP BY `reviewerid` ORDER BY `reviewerid`"; $recipientAR['reviewers_noreview']['vars'] = $reviewerVarAR; $recipientAR['reviewers_noreview']['id'] = "`" . OCC_TABLE_REVIEWER . "`.`reviewerid`"; $recipientAR['reviewers_reviewscomplete']['text'] = 'Reviewers - Reviews all completed'; $recipientAR['reviewers_reviewscomplete']['sql'] = "SELECT `" . OCC_TABLE_REVIEWER . "`.`reviewerid`, `name_last`, `name_first`, `username`, `email`, MIN(`completed`) AS `minc` FROM `" . OCC_TABLE_REVIEWER . "`, `" . OCC_TABLE_PAPERREVIEWER . "` WHERE `" . OCC_TABLE_PAPERREVIEWER . "`.`reviewerid`=`" . OCC_TABLE_REVIEWER . "`.`reviewerid` GROUP BY `reviewerid` HAVING `minc` NOT LIKE 'F' ORDER BY `reviewerid`"; $recipientAR['reviewers_reviewscomplete']['vars'] = $reviewerVarAR; $recipientAR['reviewers_reviewscomplete']['id'] = "`" . OCC_TABLE_REVIEWER . "`.`reviewerid`"; $recipientAR['reviewers_nocomment']['text'] = 'Reviewers - Missing author comments'; $recipientAR['reviewers_nocomment']['sql'] = "SELECT `" . OCC_TABLE_REVIEWER . "`.`reviewerid`, `name_last`, `name_first`, `username`, `email` FROM `" . OCC_TABLE_REVIEWER . "`, `" . OCC_TABLE_PAPERREVIEWER . "` WHERE `" . OCC_TABLE_PAPERREVIEWER . "`.`authorcomments` IS NULL AND `" . OCC_TABLE_PAPERREVIEWER . "`.`reviewerid`=`" . OCC_TABLE_REVIEWER . "`.`reviewerid` GROUP BY `reviewerid` ORDER BY `reviewerid`"; $recipientAR['reviewers_nocomment']['vars'] = $reviewerVarAR; $recipientAR['reviewers_nocomment']['id'] = "`" . OCC_TABLE_REVIEWER . "`.`reviewerid`"; if ($OC_configAR['OC_paperAdvocates']) { $recipientAR['pc_all']['text'] = 'Program Committee - All'; $recipientAR['pc_all']['sql'] = "SELECT `reviewerid`, `name_last`, `name_first`, `username`, `email` FROM `" . OCC_TABLE_REVIEWER . "` WHERE `onprogramcommittee`='T' ORDER BY `reviewerid`"; $recipientAR['pc_all']['vars'] = $reviewerVarAR; $recipientAR['pc_all']['id'] = '`reviewerid`'; $recipientAR['pc_norecommendation']['text'] = 'Program Committee - Missing advocate recommendation'; $recipientAR['pc_norecommendation']['sql'] = "SELECT `" . OCC_TABLE_REVIEWER . "`.`reviewerid`, `name_last`, `name_first`, `username`, `email` FROM `" . OCC_TABLE_REVIEWER . "`, `" . OCC_TABLE_PAPERADVOCATE . "` WHERE `" . OCC_TABLE_PAPERADVOCATE . "`.`adv_recommendation` is NULL and `" . OCC_TABLE_PAPERADVOCATE . "`.`advocateid`=`" . OCC_TABLE_REVIEWER . "`.`reviewerid` GROUP BY `reviewerid` ORDER BY `reviewerid`"; $recipientAR['pc_norecommendation']['vars'] = $reviewerVarAR; $recipientAR['pc_norecommendation']['id'] = "`" . OCC_TABLE_REVIEWER . "`.`reviewerid`"; } // Check for addt'l (hook) recipients if (oc_hookSet('chair-email-recipient')) { foreach ($OC_hooksAR['chair-email-recipient'] as $f) { require_once $f; } } // Get sorted list of recipients $recipients = array(); foreach ($recipientAR as $k => $v) { $recipients[$v['text']] = $k; } ksort($recipients); function saveTemplate($subject, $body, $templateid) { $q = "UPDATE `" . OCC_TABLE_TEMPLATE . "` SET `subject`='" . safeSQLstr($subject) . "', `body`='" . safeSQLstr($body) . "' WHERE `templateid`='" . safeSQLstr($templateid) . "'"; ocsql_query($q) or err('Unable to save template'); } 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 $l['email'] . "
\n"; } } } function specialValue($a1, $a2) { global $specialIndexAR, $l; $varName = $a1 . $a2; if (!empty($varName) && isset($specialIndexAR[$varName]) && isset($l[$specialIndexAR[$varName]]) && isset($GLOBALS[$varName][$l[$specialIndexAR[$varName]]])) { return($GLOBALS[$varName][$l[$specialIndexAR[$varName]]]); } else { return(''); } } function queueMessage(&$queueAR, $date) { $q = "INSERT INTO `" . OCC_TABLE_EMAIL_QUEUE . "` (`queued`, `to`, `subject`, `body`) VALUES " . implode(', ', $queueAR); if ( ! ocsql_query($q)) { $err = 'Unable to queue messages (' . ocsql_errno() . '). You may want to try again or have the administrator check the error logs. '; if (ocsql_query("DELETE FROM `" . OCC_TABLE_EMAIL_QUEUE . "` WHERE `datetime`='" . $date . "'")) { $err .= 'Messages just queued for delivered have been deleted'; } else { $err .= 'We were unable to remove messages queued for delivery; for reference ,their time stamp is ' . $date . '.'; } err($err); } } if (isset($_POST['submit'])) { // Check for valid submission if (!validToken('chair')) { warn('Invalid submission'); } // Verify recipient if (!in_array($_POST['recipient'], $recipients)) { err("Recipient unknown"); } // Verify template if (!empty($_POST['template']) && !in_array($_POST['template'], array_keys($templateAR))) { err("Invalid template"); } // Which message should we use? if (isset($_POST['message'])) { $subject = stripslashes($_POST['subject']); $message = stripslashes($_POST['message']); // YMMV wrt below $message = preg_replace("/\r/","",$message); // Save template? if (!empty($_POST['template']) && isset($_POST['save']) && ($_POST['save'] == "yes")) { saveTemplate($subject, $message, $_POST['template']); } } elseif (!empty($_POST['template'])) { // retrieve template $q = "SELECT `subject`, `body` FROM `" . OCC_TABLE_TEMPLATE . "` WHERE `templateid`='" . safeSQLstr($_POST['template']) . "'"; $r = ocsql_query($q) or err('Unable to retrieve template'); if (ocsql_num_rows($r) != 1) { warn('Template not found'); } $l = ocsql_fetch_assoc($r); $subject = $l['subject']; $message = $l['body']; } else { $message = ""; $subject = ""; } // Which submit? // List Email addresses if ($_POST['submit'] == "List Email Addresses") { showAddresses($recipientAR[$_POST['recipient']]['text'], $recipientAR[$_POST['recipient']]['sql']); } // Send Email elseif ($_POST['submit'] == "Send Message") { $q = $recipientAR[$_POST['recipient']]['sql']; // Individual recipients? $recipientList = array(); if (isset($_POST['select_recipients']) && ($_POST['select_recipients'] == 1)) { if (! isset($_POST['selected_recipients']) || empty($_POST['selected_recipients'])) { warn('No recipients selected'); } $selectRecipients = true; foreach ($_POST['selected_recipients'] as $recip) { list($id, $email) = explode('/', $recip); if (!preg_match("/^\d+$/", $id)) { continue; } $recipientList[$id] = $email; } $q = preg_replace("/ WHERE /", " WHERE " . $recipientAR[$_POST['recipient']]['id'] . " IN (" . safeSQLstr(implode(',', array_keys($recipientList))) . ") AND ", $q); } else { $selectRecipients = false; } $r = ocsql_query($q) or err("Unable to retrieve information to email"); $recipientTotal = ocsql_num_rows($r); if ($recipientTotal == 0) { err("No email addresses found (send)"); } elseif ($selectRecipients && ($recipientTotal != count($_POST['selected_recipients']))) { // This may mean that the recipientAR SELECT statement does not contain a WHERE clause, resulting the preg_replace above failing warn("Recipient mismatch - contact your OpenConf administrator"); } // Special var handling if (isset($recipientAR[$_POST['recipient']]['special']) && is_file($recipientAR[$_POST['recipient']]['special'])) { require_once $recipientAR[$_POST['recipient']]['special']; } // Log it $date = safeSQLstr(gmdate('Y-m-d H:i:s')); // set fixed time for log & so messages in queue are grouped together $logq = "INSERT INTO `" . OCC_TABLE_LOG . "` SET `datetime`='" . $date . "', `type`='email', `entry`='Email sent to "; if ($selectRecipients) { $logq .= safeSQLstr($extra = implode(", ", $recipientList)); } else { $logq .= safeSQLstr($extra = $recipientAR[$_POST['recipient']]['text']); } $extra .= "\nSubject: " . $subject . "\n\n" . $message; $logq .= "', `extra`='To: " . safeSQLstr($extra) . "'"; ocsql_query($logq); // Send out emails $to = $tmpmessage = $tmpsubject = ''; $queueAR = array(); $queue_date = gmdate('Y-m-d H:i:s'); if ($OC_configAR['OC_queueEmails']) { // queue messages? $queueMessages = true; print '

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 = $subject; $tmpmessage = $message; // Replace config vars $tmpsubject = preg_replace_callback( "/\[:([A-Z]\w+):\]/", function ($matches) { return $GLOBALS['OC_configAR'][$matches[1]]; }, $tmpsubject ); $tmpmessage = preg_replace_callback( "/\[:([A-Z]\w+):\]/", function ($matches) { return $GLOBALS['OC_configAR'][$matches[1]]; }, $tmpmessage ); // Replace other vars $tmpsubject = preg_replace_callback( "/\[:(\w+):\]/", function ($matches) { return $GLOBALS['l'][$matches[1]]; }, $tmpsubject ); $tmpmessage = preg_replace_callback( "/\[:(\w+):\]/", function ($matches) { return $GLOBALS['l'][$matches[1]]; }, $tmpmessage ); // 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 ' . $l['email'] . ' (' . $l[0] . ') ... '; ob_flush(); flush(); if ($queueMessages) { $queueAR[] = "('" . $date . "', '" . safeSQLstr($l['email']) . "', '" . safeSQLstr($tmpsubject) . "', '" . safeSQLstr($tmpmessage) . "')"; print "queued
\n"; if (count($queueAR) >= 10) { // store messages as a group to save on DB calls queueMessage($queueAR, $date); $queueAR = array(); // reset queue array } } elseif (oc_mail($l['email'], $tmpsubject, $tmpmessage)) { // deliver instantly print "sent
\n"; } else { print "FAILED!!!
\n"; } } ob_end_flush(); flush(); // Any remaining messages for queue storage? if ($queueMessages && (count($queueAR) > 0)) { queueMessage($queueAR, $date); } // Email chair a copy of last email sent if ($OC_configAR['OC_mailCopyLast']) { $msg = "To: " . $to . "\nSubject: " . $tmpsubject . "\n\n" . $tmpmessage . "\n"; if (sendEmail($OC_configAR['OC_confirmmail'], 'Copy of last email sent', $msg)) { print '

A 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 '
'; if (isset($_POST['select_recipients']) && ($_POST['select_recipients'] == 1)) { print ''; if (isset($_POST['selected_recipients'])) { foreach ($_POST['selected_recipients'] as $selected_recipient) { print ''; } } } print '      
';		

		$tmpsubject = $subject;
		$tmpmessage = $message;
		// Replace config vars
		$tmpsubject = preg_replace_callback( 
			"/\[:([A-Z]\w+):\]/",
			function ($matches) {
				return $GLOBALS['OC_configAR'][$matches[1]];
			},
			$tmpsubject
		);
		$tmpmessage = preg_replace_callback( 
			"/\[:([A-Z]\w+):\]/",
			function ($matches) {
				return $GLOBALS['OC_configAR'][$matches[1]];
			},
			$tmpmessage
		);
		// Replace other vars
		$tmpsubject = preg_replace_callback( 
			"/\[:(\w+):\]/",
			function ($matches) {
				return $GLOBALS['l'][$matches[1]];
			},
			$tmpsubject
		);
		$tmpmessage = preg_replace_callback( 
			"/\[:(\w+):\]/",
			function ($matches) {
				return $GLOBALS['l'][$matches[1]];
			},
			$tmpmessage
		);
		// 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 (!in_array($_POST['recipient'],$recipients)) { 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 ' . $recipientAR[$_POST['recipient']]['text'] . '

'; } else { print '
'; // Save template? if (!empty($_POST['template'])) { print ''; } print '
From:' . safeHTMLstr($OC_configAR['OC_pcemail']) . ' 
To:'; if (isset($_POST['select_recipients']) && ($_POST['select_recipients'] == 1)) { print ''; } else { print safeHTMLstr($recipientAR[$_POST['recipient']]['text']); } print ' 
 
[:variables:]

'; foreach ($varAR as $vkey => $vval) { print ''; } foreach ($recipientAR[$_POST['recipient']]['vars'] as $vkey => $vval) { print ''; } print '
[:' . safeHTMLstr($vkey) . ':]' . safeHTMLstr($vval) . '
[:' . safeHTMLstr($vkey) . ':]' . safeHTMLstr($vval) . '


     

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 '

Select the recipient group you would like to email:

For ' . oc_strtolower(OCC_WORD_AUTHOR) . 's, only the contact ' . oc_strtolower(OCC_WORD_AUTHOR) . ' of a submission will be emailed

Select an email template to use:


     
'; } // else not a submit printFooter(); ?>