".$this->token()."
@@ -3970,12 +4036,21 @@ class e_form
}
}
+ if(!is_array($att['writeParms']))
+ {
+ parse_str(varset($att['writeParms']), $writeParms);
+ }
+ else
+ {
+ $writeParms = $att['writeParms'];
+ }
+
+
+
if('hidden' === $att['type'])
{
- if(!is_array($att['writeParms'])) parse_str(varset($att['writeParms']), $tmp);
- else $tmp = $att['writeParms'];
- if(!vartrue($tmp['show']))
+ if(!vartrue($writeParms['show']))
{
continue;
}
@@ -4025,12 +4100,13 @@ class e_form
$leftCell = $required."
".defset(vartrue($att['title']), vartrue($att['title']))." ".$label;
$rightCell = $this->renderElement($keyName, $model->getIfPosted($valPath), $att, varset($model_required[$key], array()), $model->getId())." {$help}";
- if(vartrue($att['type']) == 'bbarea')
+ if(vartrue($att['type']) == 'bbarea' || $writeParms['nolabel'] == true)
{
$text .= "
-
- ".$leftCell."
".
- $rightCell."
+ ";
+
+ $text .= "".$leftCell."
";
+ $text .= $rightCell."
diff --git a/e107_handlers/login.php b/e107_handlers/login.php
index 5511baf1a..6dc42c81d 100644
--- a/e107_handlers/login.php
+++ b/e107_handlers/login.php
@@ -243,7 +243,7 @@ class userlogin
// Problem is that USERCLASS_LIST just contains 'guest' and 'everyone' at this point
$class_list = $this->userMethods->addCommonClasses($this->userData, TRUE);
- $user_logging_opts = array_flip(explode(',',varset($pref['user_audit_opts'],'')));
+ $user_logging_opts = e107::getConfig()->get('user_audit_opts');
if (isset($user_logging_opts[USER_AUDIT_LOGIN]) && in_array(varset($pref['user_audit_class'],''),$class_list))
{ // Need to note in user audit trail
$this->e107->admin_log->user_audit(USER_AUDIT_LOGIN,'', $user_id,$user_name);
diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php
index 4e76e6900..4ecdc91cf 100644
--- a/e107_handlers/mail.php
+++ b/e107_handlers/mail.php
@@ -138,7 +138,7 @@ define('MAIL_LOG_PATH',e_LOG);
class e107Email extends PHPMailer
{
private $general_opts = array();
- private $logEnable = 0; // 0 = log disabled, 1 = 'dry run' (debug and log, no send). 2 = 'log all' (send, and log result)
+ private $logEnable = 2; // 0 = log disabled, 1 = 'dry run' (debug and log, no send). 2 = 'log all' (send, and log result)
private $logHandle = FALSE; // Save handle of log file if opened
private $localUseVerp = FALSE; // Use our own variable - PHPMailer one doesn't work with all mailers
@@ -156,7 +156,7 @@ class e107Email extends PHPMailer
public $legacyBody = false; // TRUE enables legacy conversion of plain text body to HTML in HTML emails
private $debug = false; // echos various debug info when set to true.
private $pref = array(); // Store code prefs.
-
+ private $previewMode = false;
/**
* Constructor sets up all the global options, and sensible defaults - it should be the only place the prefs are accessed
*
@@ -196,7 +196,12 @@ class e107Email extends PHPMailer
$this->allow_html = varset($pref['mail_sendstyle'],'textonly') == 'texthtml' ? true : 1;
if (varsettrue($pref['mail_options'])) $this->general_opts = explode(',',$pref['mail_options'],'');
- if ($this->debug) echo 'Mail_options: '.$pref['mail_options'].' Count: '.count($this->general_opts).'
';
+
+ if ($this->debug)
+ {
+ echo 'Mail_options: '.$pref['mail_options'].' Count: '.count($this->general_opts).'
';
+ }
+
foreach ($this->general_opts as $k => $v)
{
$v = trim($v);
@@ -520,7 +525,10 @@ class e107Email extends PHPMailer
$message = str_replace("\r","\n",$message); // Handle alternative newline characters
$message = str_replace("\n", "
\n", $message);
}
+
+
$this->MsgHTML($message); // Theoretically this should do everything, including handling of inline images.
+
}
else
{ // generate the plain text as the sole part of the email
@@ -589,6 +597,64 @@ class e107Email extends PHPMailer
}
}
+ /**
+ * Preview the BODY of an email
+ * @param $eml - array.
+ */
+ public function preview($eml)
+ {
+ $this->previewMode = true;
+
+ if (count($eml))
+ {
+ if($error = $this->arraySet($eml)) // Set parameters from list
+ {
+ return $error;
+ }
+
+ }
+
+ return $this->Body;
+
+ }
+
+
+ function processShortcodes($eml)
+ {
+ $tp = e107::getParser();
+
+ $eml['shortcodes']['BODY'] = $tp->toEmail($eml['body']);
+ $eml['shortcodes']['SUBJECT'] = $eml['subject'];
+ $eml['shortcodes']['THEME'] = ($this->previewMode == true) ? e_THEME_ABS.$this->pref['sitetheme'].'/' : e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
+
+
+ if(!empty($eml['media']) && is_array($eml['media']))
+ {
+ foreach($eml['media'] as $k=>$val)
+ {
+ if(vartrue($val['path']))
+ {
+ $id = 'MEDIA'.($k+1);
+
+ if($tp->isVideo($val['path']))
+ {
+ $eml['shortcodes'][$id] = "
".$tp->toVideo($val['path'],array('thumb'=>'email'))."
";
+ }
+ else
+ {
+ $eml['shortcodes'][$id] = "
";
+ }
+
+ }
+ }
+
+
+ }
+
+ return $eml['shortcodes'];
+
+ }
+
/**
* Sets one or more parameters from an array. See @see{sendEmail()} for list of parameters
@@ -601,25 +667,36 @@ class e107Email extends PHPMailer
*/
public function arraySet($eml)
{
-
-
$tp = e107::getParser();
- if(vartrue($eml['template'])) // @see e107_core/templates/email_template.php
+ // Cleanup legacy key names. ie. remove 'email_' prefix.
+ foreach($eml as $k=>$v)
{
-
-
+ if(substr($k,0,6) == 'email_')
+ {
+ $nkey = substr($k,6);
+ $eml[$nkey] = $v;
+ unset($eml[$k]);
+ }
+ }
+
+
+
+ if(vartrue($eml['template'])) // @see e107_core/templates/email_template.php
+ {
+
if($tmpl = e107::getCoreTemplate('email', $eml['template'], 'front', true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry?
{
- $eml['shortcodes']['BODY'] = $eml['email_body'];
- $eml['shortcodes']['SUBJECT'] = $eml['email_subject'];
- $eml['shortcodes']['THEME'] = e_THEME.$this->pref['sitetheme'].'/'; // Always use front-end theme path.
+ $eml['shortcodes'] = $this->processShortcodes($eml);
+
+ // print_a($eml);
+
$emailBody = $tmpl['header']. $tmpl['body'] . $tmpl['footer'];
- $eml['email_body'] = $tp->parseTemplate($emailBody, true, varset($eml['shortcodes'],null));
+ $eml['body'] = $tp->parseTemplate($emailBody, true, $eml['shortcodes']);
- // $eml['email_body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['email_body'], $tmpl['body']). $tp->toEmail($tmpl['footer']));
+ // $eml['body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['body'], $tmpl['body']). $tp->toEmail($tmpl['footer']));
if($this->debug)
{
@@ -637,28 +714,32 @@ class e107Email extends PHPMailer
{
echo "
Couldn't find email template: ".$eml['template']." ";
}
- if (vartrue($eml['email_subject'])) $this->Subject = $tp->parseTemplate($eml['email_subject'], true, varset($eml['shortcodes'],null));
+ // $emailBody = $eml['body'];
+
+ if (vartrue($eml['subject'])) $this->Subject = $tp->parseTemplate($eml['subject'], true, varset($eml['shortcodes'],null));
e107::getMessage()->addDebug("Couldn't find email template: ".$eml['template']);
}
}
else
{
- if (vartrue($eml['email_subject'])) $this->Subject = $tp->parseTemplate($eml['email_subject'], true, varset($eml['shortcodes'],null));
+ if (vartrue($eml['subject'])) $this->Subject = $tp->parseTemplate($eml['subject'], true, varset($eml['shortcodes'],null));
+ // $eml['body'] = ($tp->toEmail($tmpl['header']). str_replace('{BODY}', $eml['body'], $tmpl['body']). $tp->toEmail($tmpl['footer']));
}
-
+
+
if (isset($eml['SMTPDebug'])) $this->SMTPDebug = $eml['SMTPDebug']; // 'FALSE' is a valid value!
- if (vartrue($eml['email_sender_email'])) $this->From = $eml['email_sender_email'];
- if (vartrue($eml['email_sender_name'])) $this->FromName = $eml['email_sender_name'];
- if (vartrue($eml['email_replyto'])) $this->AddAddressList('replyto',$eml['email_replyto'],vartrue($eml['email_replytonames'],''));
+ if (vartrue($eml['sender_email'])) $this->From = $eml['sender_email'];
+ if (vartrue($eml['sender_name'])) $this->FromName = $eml['sender_name'];
+ if (vartrue($eml['replyto'])) $this->AddAddressList('replyto',$eml['replyto'],vartrue($eml['replytonames'],''));
if (isset($eml['send_html'])) $this->allow_html = $eml['send_html']; // 'FALSE' is a valid value!
if (isset($eml['add_html_header'])) $this->add_HTML_header = $eml['add_html_header']; // 'FALSE' is a valid value!
- if (vartrue($eml['email_body'])) $this->makeBody($eml['email_body'], $this->allow_html, $this->add_HTML_header);
- if (vartrue($eml['email_attach'])) $this->attach($eml['email_attach']);
- if (vartrue($eml['email_copy_to'])) $this->AddAddressList('cc',$eml['email_copy_to'],vartrue($eml['email_cc_names'],''));
- if (vartrue($eml['email_bcopy_to'])) $this->AddAddressList('bcc',$eml['email_bcopy_to'],vartrue($eml['email_bcc_names'],''));
+ if (vartrue($eml['body'])) $this->makeBody($eml['body'], $this->allow_html, $this->add_HTML_header);
+ if (vartrue($eml['attach'])) $this->attach($eml['attach']);
+ if (vartrue($eml['copy_to'])) $this->AddAddressList('cc',$eml['copy_to'],vartrue($eml['cc_names'],''));
+ if (vartrue($eml['bcopy_to'])) $this->AddAddressList('bcc',$eml['bcopy_to'],vartrue($eml['bcc_names'],''));
if (vartrue($eml['bouncepath']))
{
@@ -672,11 +753,12 @@ class e107Email extends PHPMailer
print_a($eml);
}
+ $identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id');
if (vartrue($eml['returnreceipt'])) $this->ConfirmReadingTo = $eml['returnreceipt'];
- if (vartrue($eml['email_inline_images'])) $this->addInlineImages($eml['email_inline_images']);
- if (vartrue($eml['email_priority'])) $this->Priority = $eml['email_priority'];
- if (vartrue($eml['e107_header'])) $this->AddCustomHeader("X-e107-id: {$eml['e107_header']}");
+ if (vartrue($eml['inline_images'])) $this->addInlineImages($eml['inline_images']);
+ if (vartrue($eml['priority'])) $this->Priority = $eml['priority'];
+ if (vartrue($eml['e107_header'])) $this->AddCustomHeader($identifier.": {$eml['e107_header']}");
if (vartrue($eml['extra_header']))
{
if (is_array($eml['extra_header']))
@@ -695,6 +777,8 @@ class e107Email extends PHPMailer
if (varset($eml['wordwrap'])) $this->WordWrap = $eml['wordwrap'];
if (vartrue($eml['split'])) $this->SingleTo = ($eml['split'] != FALSE);
+ $this->logLine("ArraySet Data:".print_r($eml,true));
+
return 0; // No error
}
@@ -706,29 +790,31 @@ class e107Email extends PHPMailer
Where parameter not present in the array, doesn't get changed - useful for bulk mailing
If doing bulk mailing with repetitive calls, set $bulkmail parameter true, and must call allSent() when completed
Some of these parameters have been made compatible with the array calculated by render_email() in signup.php
+ *
Possible array parameters:
- $eml['email_subject']
- $eml['email_sender_email'] - 'From' email address
- $eml['email_sender_name'] - 'From' name
- $eml['email_replyto'] - Optional 'reply to' field
- $eml['email_replytonames'] - Name(s) corresponding to 'reply to' field - only used if 'replyto' used
+ $eml['subject']
+ $eml['sender_email'] - 'From' email address
+ $eml['sender_name'] - 'From' name
+ $eml['replyto'] - Optional 'reply to' field
+ $eml['replytonames'] - Name(s) corresponding to 'reply to' field - only used if 'replyto' used
$eml['send_html'] - if TRUE, includes HTML part in messages (only those added after this flag)
$eml['add_html_header'] - if TRUE, adds the 2-line DOCTYPE declaration to the front of the HTML part (but doesn't add ...)
- $eml['email_body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag
- $eml['email_attach'] - string if one file, array of filenames if one or more.
- $eml['email_copy_to'] - comma-separated list of cc addresses.
- $eml['email_cc_names'] - comma-separated list of cc names. Optional, used only if $eml['email_copy_to'] specified
- $eml['email_bcopy_to'] - comma-separated list
- $eml['email_bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['email_copy_to'] specified
+ $eml['body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag
+ $eml['attach'] - string if one file, array of filenames if one or more.
+ $eml['copy_to'] - comma-separated list of cc addresses.
+ $eml['cc_names'] - comma-separated list of cc names. Optional, used only if $eml['copy_to'] specified
+ $eml['bcopy_to'] - comma-separated list
+ $eml['bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['copy_to'] specified
$eml['bouncepath'] - Sender field (used for bounces)
$eml['returnreceipt'] - email address for notification of receipt (reading)
- $eml['email_inline_images'] - array of files for inline images
+ $eml['inline_images'] - array of files for inline images
$eml['priority'] - Email priority (1 = High, 3 = Normal, 5 = low)
$eml['e107_header'] - Adds specific 'X-e107-id:' header
$eml['extra_header'] - additional headers (format is name: value
$eml['wordwrap'] - Set wordwrap value
$eml['split'] - If true, sends an individual email to each recipient
$eml['template'] - template to use. 'default'
+ $eml['shortcodes'] - array of shortcode values. eg. array('MY_SHORTCODE'=>'12345');
* @param string $send_to - recipient email address
* @param string $to_name - recipient name
@@ -740,9 +826,12 @@ class e107Email extends PHPMailer
public function sendEmail($send_to, $to_name, $eml = '', $bulkmail = FALSE)
{
if (count($eml))
- { // Set parameters from list
- $ret = $this->arraySet($eml);
- if ($ret) return $ret;
+ {
+ if($error = $this->arraySet($eml)) // Set parameters from list
+ {
+ return $error;
+ }
+
}
if ($bulkmail && $this->localUseVerp && $this->save_bouncepath && (strpos($this->save_bouncepath,'@') !== FALSE))
@@ -764,8 +853,17 @@ class e107Email extends PHPMailer
if (($this->logEnable == 0) || ($this->logEnable == 2))
{
+ // prevent user/script details being exposed in X-PHP-Script header
+ $oldphpself = $_SERVER['PHP_SELF'];
+ $oldremoteaddr = $_SERVER['REMOTE_ADDR'];
+ $_SERVER['PHP_SELF'] = "/";
+ $_SERVER['REMOTE_ADDR'] = $_SERVER['SERVER_ADDR'];
+
$result = $this->Send(); // Actually send email
-
+
+ $_SERVER['PHP_SELF'] = $oldphpself;
+ $_SERVER['REMOTE_ADDR'] = $oldremoteaddr;
+
if (!$bulkmail && !$this->SMTPKeepAlive && ($this->Mailer == 'smtp')) $this->SmtpClose();
}
else
@@ -776,6 +874,7 @@ class e107Email extends PHPMailer
}
$this->TotalSent++;
+
if (($this->pause_amount > 0) && ($this->SendCount >= $this->pause_amount))
{
if ($this->SMTPKeepAlive && ($this->Mailer == 'smtp')) $this->SmtpClose();
@@ -785,6 +884,12 @@ class e107Email extends PHPMailer
$this->logLine("Send to {$to_name} at {$send_to} Mail-ID={$this->MessageID} - ".($result ? 'Success' : 'Fail'));
+ if(!$result)
+ {
+ $this->logLine(print_r($eml,true));
+ }
+
+
$this->ClearAddresses(); // In case we send another email
$this->ClearCustomHeaders();
@@ -834,10 +939,10 @@ class e107Email extends PHPMailer
*/
public function MsgHTML($message, $basedir = '')
{
-
-
+ $tp = e107::getParser();
+
preg_match_all("/(src|background)=([\"\'])(.*)\\2/Ui", $message, $images); // Modified to accept single quotes as well
- if(isset($images[3]))
+ if(isset($images[3]) && ($this->previewMode === false))
{
if($this->debug)
@@ -846,10 +951,12 @@ class e107Email extends PHPMailer
print_a($images[3]);
}
- $tp = e107::getParser();
-
foreach($images[3] as $i => $url)
{
+
+
+
+
// do not change urls for absolute images (thanks to corvuscorax)
if (!preg_match('#^[A-z]+://#',$url))
{
@@ -902,6 +1009,11 @@ class e107Email extends PHPMailer
}
}
+ if($this->previewMode === true)
+ {
+ $message = $tp->replaceConstants($message, 'abs');
+ }
+
$this->IsHTML(true);
$this->Body = $message;
@@ -1008,8 +1120,10 @@ function sendemail($send_to, $subject, $message, $to_name='', $send_from='', $fr
// Create a mailer object of the correct type (which auto-fills in sending method, server details)
$mail = new e107Email($overrides);
+
+ $identifier = deftrue('MAIL_IDENTIFIER', 'X-e107-id');
- if (varsettrue($mailheader_e107id)) $mail->AddCustomHeader("X-e107-id: {$mailheader_e107id}");
+ if (varsettrue($mailheader_e107id)) $mail->AddCustomHeader($identifier.": {$mailheader_e107id}");
$mail->legacyBody = TRUE; // Need to handle plain text email conversion to HTML
$mail->makeBody($message); // Add body, with conversion if required
diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php
index 55ba7b277..5095f1d5a 100644
--- a/e107_handlers/mail_manager_class.php
+++ b/e107_handlers/mail_manager_class.php
@@ -123,7 +123,7 @@ class e107MailManager
const E107_EMAIL_MAX_TRIES = 3; // Maximum number of tries by us (mail server may do more)
// - max allowable value is MAIL_STATUS_MAX_ACTIVE - MAIL_STATUS_PENDING
- private $debugMode = 0;
+ private $debugMode = 1;
protected $e107;
protected $db = NULL; // Use our own database object - this one for reading data
protected $db2 = NULL; // Use our own database object - this one for updates
@@ -262,8 +262,8 @@ class e107MailManager
$res[$f] = '';
}
}
- $array = new ArrayData;
- $res['mail_other'] = $array->WriteArray($res1, TRUE); // Ready to write to DB
+
+ $res['mail_other'] = e107::serialize($res1,false); // Ready to write to DB
return $res;
}
@@ -296,8 +296,8 @@ class e107MailManager
}
if (isset($data['mail_other']))
{
- $array = new ArrayData;
- $tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data
+
+ $tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data
if (is_array($tmp))
{
$res = array_merge($res,$tmp);
@@ -315,6 +315,12 @@ class e107MailManager
$res[$f] = '';
}
}
+
+ if (isset($data['mail_media']))
+ {
+ $res['mail_media'] = e107::unserialize($data['mail_media']);
+ }
+
return $res;
}
@@ -348,8 +354,7 @@ class e107MailManager
}
if (isset($data['mail_target_info']) && is_array($data['mail_target_info']))
{
- $array = new ArrayData;
- $tmp = $array->WriteArray($data['mail_target_info'], TRUE);
+ $tmp = e107::serialize($data['mail_target_info'], TRUE);
$res['mail_target_info'] = $tmp;
}
return $res;
@@ -423,10 +428,9 @@ class e107MailManager
}
// Now array fields
- $array = new ArrayData;
if (isset($data['mail_other']))
{
- $tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data
+ $tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_other'])); // May have escaped data
if (is_array($tmp))
{
$res = array_merge($res,$tmp);
@@ -442,9 +446,15 @@ class e107MailManager
}
if (isset($data['mail_target_info']))
{
- $tmp = $array->ReadArray(str_replace('\\\'', '\'',$data['mail_target_info'])); // May have escaped data
+ $tmp = e107::unserialize(str_replace('\\\'', '\'',$data['mail_target_info'])); // May have escaped data
$res['mail_target_info'] = $tmp;
}
+
+ if (isset($data['mail_media']))
+ {
+ $res['mail_media'] = e107::unserialize($data['mail_media']);
+ }
+
return $res;
}
@@ -571,7 +581,8 @@ class e107MailManager
AND (ms.`mail_last_date` >= ".time()." OR ms.`mail_last_date`=0)
ORDER BY ms.`mail_e107_priority` DESC {$count}";
// echo $query.'
';
- $result = $this->db->db_Select_gen($query);
+ $result = $this->db->gen($query);
+
if ($result !== FALSE)
{
$this->queryActive = $result; // Note number of emails to go
@@ -756,9 +767,9 @@ class e107MailManager
if ($email['mail_notify_complete'] & 1)
{ // Notify email initiator
- if ($this->db2->db_Select('user', 'user_name, user_email', '`user_id`='.intval($email['mail_creator'])))
+ if ($this->db2->select('user', 'user_name, user_email', '`user_id`='.intval($email['mail_creator'])))
{
- $row = $this->db2->db_Fetch(MYSQL_ASSOC);
+ $row = $this->db2->fetch(MYSQL_ASSOC);
require_once(e_HANDLER.'mail.php');
$mailer = new e107Email();
$mailer->sendEmail($row['user_name'], $row['user_email'], $message,FALSE);
@@ -767,6 +778,7 @@ class e107MailManager
if ($email['mail_notify_complete'] & 2)
{ // Do e107 notify
require_once(e_HANDLER."notify_class.php");
+
notify_maildone($message);
}
e107::getEvent()->trigger('maildone', $email);
@@ -799,8 +811,8 @@ class e107MailManager
//'extra_header' - additional headers (format is name: value
//'wordwrap' - Set wordwrap value
//'split' - If true, sends an individual email to each recipient
- 'template' => 'template', // required
- 'shortcodes' => 'shortcodes' // required
+ 'template' => 'mail_send_style', // required
+ 'shortcodes' => 'mail_target_info' // required
);
$result = array();
if (!isset($email['mail_source_id'])) $email['mail_source_id'] = 0;
@@ -838,22 +850,42 @@ class e107MailManager
$temp = intval($email['mail_recipient_id']).'/'.intval($email['mail_source_id']).'/'.intval($email['mail_target_id']).'/';
$result['e107_header'] = $temp.md5($temp); // Set up an ID
}
+
if (isset($email['mail_attach']) && (trim($email['mail_attach']) || is_array($email['mail_attach'])))
{
- $downDir = realpath(e_ROOT.$this->e107->getFolder('downloads'));
+ $tp = e107::getParser();
+
if (is_array($email['mail_attach']))
{
foreach ($email['mail_attach'] as $k => $v)
{
- $result['email_attach'][$k] = $downDir.$v;
+ $result['email_attach'][$k] = $tp->replaceConstants($v);
}
}
else
{
- $result['email_attach'] = $downDir.trim($email['mail_attach']);
+ $result['email_attach'] = $tp->replaceConstants(trim($email['mail_attach']));
}
}
- if (isset($email['mail_overrides']) && is_array($email['mail_overrides'])) $result = array_merge($result, $email['mail_overrides']);
+
+ if (isset($email['mail_overrides']) && is_array($email['mail_overrides']))
+ {
+ $result = array_merge($result, $email['mail_overrides']);
+ }
+
+ $title = "
".__METHOD__." Line: ".__LINE__." ";
+ e107::getAdminLog()->addDebug($title.print_a($email,true),true);
+
+ if(!empty($email['mail_media']))
+ {
+ $result['media'] = $email['mail_media'];
+ }
+
+ $title2 = "
".__METHOD__." Line: ".__LINE__." ";
+ e107::getAdminLog()->addDebug($title2.print_a($result,true),true);
+
+ $result['shortcodes']['MAILREF'] = $email['mail_source_id'];
+
return $result;
}
@@ -879,6 +911,10 @@ class e107MailManager
$this->mailer->allSent(); // Tidy up on completion
}
}
+ else
+ {
+ e107::getAdminLog()->addDebug("Couldn't select emails", true);
+ }
}
@@ -896,20 +932,20 @@ class e107MailManager
$this->checkDB(2); // Make sure we have a DB object to use
$dbData = $this->mailToDB($emailData, FALSE); // Convert array formats
-// print_a($dbData);
+ // print_a($dbData);
- if ($isNew)
+
+ if ($isNew === true)
{
unset($dbData['mail_source_id']); // Just in case - there are circumstances where might be set
- $result = $this->db2->db_Insert('mail_content', array('data' => $dbData,
- '_FIELD_TYPES' => $this->dbTypes['mail_content'],
- '_NOTNULL' => $this->dbNull['mail_content']));
+ $result = $this->db2->insert('mail_content', array('data' => $dbData,
+ '_FIELD_TYPES' => $this->dbTypes['mail_content'], '_NOTNULL' => $this->dbNull['mail_content']));
}
else
{
if (isset($dbData['mail_source_id']))
{
- $result = $this->db2->db_Update('mail_content', array('data' => $dbData,
+ $result = $this->db2->update('mail_content', array('data' => $dbData,
'_FIELD_TYPES' => $this->dbTypes['mail_content'],
'WHERE' => '`mail_source_id` = '.intval($dbData['mail_source_id'])));
if ($result !== FALSE) { $result = $dbData['mail_source_id']; }
@@ -938,11 +974,11 @@ class e107MailManager
return FALSE;
}
$this->checkDB(2); // Make sure we have a DB object to use
- if ($this->db2->db_Select('mail_content', '*', '`mail_source_id`='.$mailID) === FALSE)
+ if ($this->db2->select('mail_content', '*', '`mail_source_id`='.$mailID) === FALSE)
{
return FALSE;
}
- $mailData = $this->db2->db_Fetch(MYSQL_ASSOC);
+ $mailData = $this->db2->fetch();
return $this->dbToMail($mailData, $addMissing); // Convert to 'flat array' format
}
@@ -959,20 +995,23 @@ class e107MailManager
$result = array();
if ($actions == 'all') $actions = 'content,recipients';
$actArray = explode(',', $actions);
+
if (!is_numeric($mailID) || ($mailID == 0))
{
return FALSE;
}
$this->checkDB(2); // Make sure we have a DB object to use
+
if (isset($actArray['content']))
{
- $result['content'] = $this->db2->db_Delete('mail_content', '`mail_source_id`='.$mailID);
+ $result['content'] = $this->db2->delete('mail_content', '`mail_source_id`='.$mailID);
}
if (isset($actArray['recipients']))
{
- $result['recipients'] = $this->db2->db_Delete('mail_recipients', '`mail_detail_id`='.$mailID);
+ $result['recipients'] = $this->db2->delete('mail_recipients', '`mail_detail_id`='.$mailID);
}
+
return $result;
}
@@ -1041,6 +1080,11 @@ class e107MailManager
if (($handle <= 0) || !is_numeric($handle)) return FALSE;
if (!isset($this->mailCounters[$handle])) return 'nocounter';
$this->checkDB(2); // Make sure DB object created
+
+
+
+
+
$query = '`mail_togo_count`='.intval($this->mailCounters[$handle]['add']).' WHERE `mail_source_id`='.$handle;
if ($this->db2->db_Update('mail_content', $query))
{
@@ -1050,6 +1094,22 @@ class e107MailManager
}
+ public function updateCounter($id, $type, $count)
+ {
+ if(empty($id) || empty($type))
+ {
+ return false;
+ }
+
+ $update = array(
+ 'mail_'.$type.'_count' => intval($count),
+ 'WHERE' => "mail_source_id=".intval($id)
+ );
+
+ return e107::getDb('mail')->update('mail_content', $update) ? $count : false;
+ }
+
+
/**
* Retrieve the counters for a mail record
@@ -1108,15 +1168,17 @@ class e107MailManager
$query .= '`mail_notify_complete`='.intval($notify).', `mail_content_status` = '.($hold ? MAIL_STATUS_HELD : MAIL_STATUS_PENDING).$lt.' WHERE `mail_source_id` = '.intval($handle);
// echo "Update mail body: {$query}
";
// Set status of email body first
- if (!$this->db->db_Update('mail_content',$query))
+
+ if (!$this->db->update('mail_content',$query))
{
$this->e107->admin_log->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_content: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
return FALSE;
}
+
// Now set status of individual emails
$query = '`mail_status` = '.($hold ? MAIL_STATUS_HELD : (MAIL_STATUS_PENDING + e107MailManager::E107_EMAIL_MAX_TRIES)).$ft.' WHERE `mail_detail_id` = '.intval($handle);
// echo "Update individual emails: {$query}
";
- if (FALSE === $this->db->db_Update('mail_recipients',$query))
+ if (FALSE === $this->db->update('mail_recipients',$query))
{
$this->e107->admin_log->e_log_event(10,-1,'MAIL','Activate/hold mail','mail_recipient: '.$query.'[!br!]Fail: '.$this->db->mySQLlastErrText,FALSE,LOG_TO_ROLLING);
return FALSE;
@@ -1135,12 +1197,12 @@ class e107MailManager
if (($handle <= 0) || !is_numeric($handle)) return FALSE;
$this->checkDB(1); // Make sure DB object created
// Set status of individual emails first, so we can get a count
- if (FALSE === ($count = $this->db->db_Update('mail_recipients','`mail_status` = '.MAIL_STATUS_CANCELLED.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
+ if (FALSE === ($count = $this->db->update('mail_recipients','`mail_status` = '.MAIL_STATUS_CANCELLED.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
{
return FALSE;
}
// Now do status of email body - no emails to go, add those not sent to fail count
- if (!$this->db->db_Update('mail_content','`mail_content_status` = '.MAIL_STATUS_PARTIAL.', `mail_togo_count`=0, `mail_fail_count` = `mail_fail_count` + '.intval($count).' WHERE `mail_source_id` = '.intval($handle)))
+ if (!$this->db->update('mail_content','`mail_content_status` = '.MAIL_STATUS_PARTIAL.', `mail_togo_count`=0, `mail_fail_count` = `mail_fail_count` + '.intval($count).' WHERE `mail_source_id` = '.intval($handle)))
{
return FALSE;
}
@@ -1158,13 +1220,13 @@ class e107MailManager
if (($handle <= 0) || !is_numeric($handle)) return FALSE;
$this->checkDB(1); // Make sure DB object created
// Set status of individual emails first, so we can get a count
- if (FALSE === ($count = $this->db->db_Update('mail_recipients','`mail_status` = '.MAIL_STATUS_HELD.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
+ if (FALSE === ($count = $this->db->update('mail_recipients','`mail_status` = '.MAIL_STATUS_HELD.' WHERE `mail_detail_id` = '.intval($handle).' AND `mail_status` >'.MAIL_STATUS_FAILED)))
{
return FALSE;
}
if ($count == 0) return TRUE; // If zero count, must have held email just as queue being emptied, so don't touch main status
- if (!$this->db->db_Update('mail_content','`mail_content_status` = '.MAIL_STATUS_HELD.' WHERE `mail_source_id` = '.intval($handle)))
+ if (!$this->db->update('mail_content','`mail_content_status` = '.MAIL_STATUS_HELD.' WHERE `mail_source_id` = '.intval($handle)))
{
return FALSE;
}
@@ -1180,83 +1242,165 @@ class e107MailManager
*/
public function markBounce($bounceString, $emailAddress = '')
{
- $bounceInfo = array('mail_bounce_string' => $bounceString, 'mail_recipient_email' => $emailAddress); // Ready for event data
- $errors = array(); // Log all errors, at least until proven
- $vals = explode('/',$bounceString); // Should get one or four fields
+
+ $bounceString = trim($bounceString);
+
+ $bounceInfo = array('mail_bounce_string' => $bounceString, 'mail_recipient_email' => $emailAddress); // Ready for event data
+ $errors = array(); // Log all errors, at least until proven
+ $vals = explode('/', $bounceString); // Should get one or four fields
+
+ // echo "
Bounce String ";
+ // print_a($bounceString);
+ // echo "
Vals ";
+ // print_a($vals);
+
if (!is_numeric($vals[0])) // Email recipient user id number (may be zero)
{
$errors[] = 'Bad user ID: '.$vals[0];
}
+
$uid = intval($vals[0]); // User ID (zero is valid)
- if (count($vals) == 4)
+
+ if (count($vals) == 4) // Admin->Mailout format.
{
- if (md5($vals[0].'/'.$vals[1].'/'.$vals[2].'/') != $vals[3])
- { // 'Extended' ID has md5 validation
- $errors[] = 'Bad md5';
- }
+
if (!is_numeric($vals[1])) // Email body record number
{
$errors[] = 'Bad body record: '.$vals[1];
}
+
if (!is_numeric($vals[2])) // Email recipient table record number
{
$errors[] = 'Bad recipient record: '.$vals[2];
}
+
+ $vals[0] = intval($vals[0]);
$vals[1] = intval($vals[1]);
$vals[2] = intval($vals[2]);
- if (count($errors) == 0)
- { // Look up in mailer DB if no errors so far
- $this->checkDB(1);
- if (FALSE === ($this->db->db_Select_gen(
- "SELECT mr.`mail_recipient_id`, mr.`mail_recipient_email`, mr.`mail_recipient_name` FROM `#mail_recipients` AS mr
- LEFT JOIN `#mail_content` as mc ON mr.`mail_detail_id` = mc.`mail_source_id`
+ $vals[3] = trim($vals[3]);
+
+
+ $hash = ($vals[0].'/'.$vals[1].'/'.$vals[2].'/');
+
+ if (md5($hash) != $vals[3]) // 'Extended' ID has md5 validation
+ {
+ $errors[] = 'Bad md5';
+ $errors[] = print_r($vals,true);
+ $errors[] = 'hash:'.md5($hash);
+ }
+
+ if (empty($errors))
+ {
+ $this->checkDB(1); // Look up in mailer DB if no errors so far
+
+ if (false === ($this->db->gen(
+ "SELECT mr.`mail_recipient_id`, mr.`mail_recipient_email`, mr.`mail_recipient_name`, mr.mail_target_info,
+ mc.mail_create_date, mc.mail_start_send, mc.mail_end_send, mc.`mail_title`, mc.`mail_subject`, mc.`mail_creator`, mc.`mail_other` FROM `#mail_recipients` AS mr
+ LEFT JOIN `#mail_content` as mc ON mr.`mail_detail_id` = mc.`mail_source_id`
WHERE mr.`mail_target_id` = {$vals[2]} AND mc.`mail_source_id` = {$vals[1]}")))
{ // Invalid mailer record
$errors[] = 'Not found in DB: '.$vals[1].'/'.$vals[2];
}
- $row = $this->db->db_Fetch(MYSQL_ASSOC);
- if ($emailAddress && ($emailAddress != $row['mail_recipient_email']))
- { // Email address mismatch
+
+ $row = $this->db->fetch(MYSQL_ASSOC);
+
+ $row = $this->dbToBoth($row);
+
+ $bounceInfo = $row;
+
+ if ($emailAddress && ($emailAddress != $row['mail_recipient_email'])) // Email address mismatch
+ {
$errors[] = 'Email address mismatch: '.$emailAddress.'/'.$row['mail_recipient_email'];
}
- if ($uid != $row['mail_recipient_id'])
- { // User ID mismatch
+
+ if ($uid != $row['mail_recipient_id']) // User ID mismatch
+ {
$errors[] = 'User ID mismatch: '.$uid.'/'.$row['mail_recipient_id'];
}
- if (count($errors) == 0)
- { // All passed - can update mailout databases
- $this->db->db_Update('mail_content', '`mail_bounce_count` = `mail_bounce_count` + 1 WHERE `mail_source_id` = '.$vals[1]);
- $this->db->db_Update('mail_recipients', '`mail_status` = '.MAIL_STATUS_BOUNCED.' WHERE `mail_target_id` = '.$vals[2]);
- $bounceInfo['mail_source_id'] = $vals[1];
- $bounceInfo['mail_target_id'] = $vals[2];
- $bounceInfo['mail_recipient_id'] = $uid;
- $bounceInfo['mail_recipient_name'] = $row['mail_recipient_name'];
+
+ if (count($errors) == 0) // All passed - can update mailout databases
+ {
+ $bounceInfo['mail_source_id'] = $vals[1];
+ $bounceInfo['mail_target_id'] = $vals[2];
+ $bounceInfo['mail_recipient_id'] = $uid;
+ $bounceInfo['mail_recipient_name'] = $row['mail_recipient_name'];
+
+
+ if(!$this->db->update('mail_content', '`mail_bounce_count` = `mail_bounce_count` + 1 WHERE `mail_source_id` = '.$vals[1]))
+ {
+ e107::getAdminLog()->add('Unable to increment bounce-count on mail_source_id='.$vals[1],$bounceInfo, E_LOG_FATAL, 'BOUNCE',LOG_TO_ROLLING);
+ }
+
+
+ if(!$this->db->update('mail_recipients', '`mail_status` = '.MAIL_STATUS_BOUNCED.' WHERE `mail_target_id` = '.$vals[2]))
+ {
+ e107::getAdminLog()->add('Unable to update recipient mail_status to bounce on mail_target_id = '.$vals[2],$bounceInfo, E_LOG_FATAL, 'BOUNCE',LOG_TO_ROLLING);
+ }
+
+ $addons = array_keys($row['mail_selectors']); // trigger e_mailout.php addons. 'bounce' method.
+ foreach($addons as $plug)
+ {
+ if($plug == 'core')
+ {
+ require_once(e_HANDLER.'user_handler.php');
+ if($err = userHandler::userStatusUpdate('bounce', $uid, $emailAddress));
+ {
+ $errors[] = $err;
+ }
+
+ }
+ else
+ {
+ if($cls = e107::getAddon($plug,'e_mailout'))
+ {
+ if(e107::callMethod($cls, 'bounce', $bounceInfo)===false)
+ {
+ e107::getAdminLog()->add($plug.' bounce process failed',$bounceInfo, E_LOG_FATAL, 'BOUNCE',LOG_TO_ROLLING);
+ }
+ }
+
+ }
+ }
}
+
+
+ // echo e107::getMessage()->render();
+ // print_a($bounceInfo);
+
+
}
}
-
- if ((count($vals) != 1) && (count($vals) != 4))
+ elseif ((count($vals) != 1) && (count($vals) != 4)) // invalid e107-id header.
{
$errors[] = 'Bad element count: '.count($vals);
}
- elseif ($uid || $emailAddress)
- { // Now log the bounce against the user (user handler will do any required logging)
+ elseif ($uid || $emailAddress) // Not using admin->mailout, so just update the user table for user_id = $uid;
+ {
require_once(e_HANDLER.'user_handler.php');
- $result = userHandler::userStatusUpdate('bounce', $uid, $emailAddress);
- if ($result) // Returns FALSE if update successful
+
+ if($err = userHandler::userStatusUpdate('bounce', $uid, $emailAddress))
{
- $errors[] = $result;
+ $errors[] = $err;
}
}
- if (count($errors))
+
+ if (!empty($errors))
{
- $logString = $bounceString.' ('.$emailAddress.')[!br!]'.implode('[!br!]',$errors);
- $this->e107->admin_log->e_log_event(10,-1,'BOUNCE','Bounce receive error',$logString,FALSE,LOG_TO_ROLLING);
- return FALSE;
+ $logString = $bounceString.' ('.$emailAddress.')[!br!]'.implode('[!br!]',$errors).implode('[!br!]',$bounceInfo);
+ // e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce receive error',$logString, FALSE,LOG_TO_ROLLING);
+ e107::getAdminLog()->add('Bounce receive error',$logString, E_LOG_WARNING, 'BOUNCE', LOG_TO_ROLLING);
+ return $errors;
}
- $this->e107->admin_log->e_log_event(10,-1,'BOUNCE','Bounce received/logged',$bounceString.' ('.$emailAddress.')',FALSE,LOG_TO_ROLLING);
+ else
+ {
+ // e107::getAdminLog()->e_log_event(10,-1,'BOUNCE','Bounce received/logged',$bounceInfo, FALSE,LOG_TO_ROLLING);
+ e107::getAdminLog()->add('Bounce received/logged',$bounceInfo, E_LOG_INFORMATIVE, 'BOUNCE',LOG_TO_ROLLING);
+ }
+
+
e107::getEvent()->trigger('mailbounce', $bounceInfo);
- return TRUE;
+
+ return false;
}
@@ -1483,30 +1627,47 @@ class e107MailManager
public function sendEmails($templateName, $emailData, $recipientData, $extra = FALSE)
{
- if (!is_array($emailData)) return FALSE;
+ $log = e107::getAdminLog();
+ $log->addDebug(print_a($emailData, true),true);
+ $log->addDebug(print_a($recipientData, true),true);
+ $log->toFile('mail_manager','Main Manager Log',true);
+
+
+ if (!is_array($emailData))
+ {
+ return FALSE;
+ }
+
if (!is_array($recipientData))
{
$recipientData = array('mail_recipient_email' => $recipientData, 'mail_recipient_name' => $recipientData);
}
+
$emailData['mail_content_status'] = MAIL_STATUS_TEMP;
if ($templateName == '')
{
- $templateName = varset($email['mail_send_style'], 'textonly'); // Safest default if nothing specified
+ $templateName = varset($emailData['mail_send_style'], 'textonly'); // Safest default if nothing specified
}
+
+
$templateName = trim($templateName);
if ($templateName == '') return FALSE;
-
+
// Get template data, override email settings as appropriate
- require_once(e_HANDLER.'mail_template_class.php');
- $ourTemplate = new e107MailTemplate();
- if (!$ourTemplate->setNewTemplate($templateName) && empty($emailData['template'])) return FALSE; // Probably template not found if error
- if (!$ourTemplate->makeEmailBody($emailData['mail_body'], varset($emailData['mail_include_images'], TRUE))) return FALSE; // Create body text
- $emailData['mail_body_templated'] = $ourTemplate->mainBodyText;
- $this->currentMailBody = $emailData['mail_body_templated']; // In case we send immediately
- $emailData['mail_body_alt'] = $ourTemplate->altBodyText;
- $this->currentTextBody = $emailData['mail_body_alt'];
+ // require_once(e_HANDLER.'mail_template_class.php');
+ // $ourTemplate = new e107MailTemplate();
+ // if (!$ourTemplate->setNewTemplate($templateName) && empty($emailData['template'])) return FALSE; // Probably template not found if error
+ // if (!$ourTemplate->makeEmailBody($emailData['mail_body'], varset($emailData['mail_include_images'], TRUE))) return FALSE; // Create body text
+
+
+
+// $emailData['mail_body_templated'] = $ourTemplate->mainBodyText;
+ $this->currentMailBody = $emailData['mail_body']; // In case we send immediately
+// $emailData['mail_body_alt'] = $ourTemplate->altBodyText;
+ $this->currentTextBody = strip_tags($emailData['mail_body']);
+
if (!isset($emailData['mail_overrides']))
{
$emailData['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides'];
@@ -1522,9 +1683,13 @@ class e107MailManager
echo "
".$emailData['template']." Template detected ";
}
}
+
+
+
-
$forceQueue = FALSE;
+
+
if (is_array($extra) && isset($extra['mail_force_queue']))
{
$forceQueue = $extra['mail_force_queue'];
@@ -1533,6 +1698,8 @@ class e107MailManager
if($this->debugMode)
{
+
+ echo "
".__CLASS__." :: ".__METHOD__." - Line ".__LINE__." ";
print_a($emailData);
print_a($recipientData);
diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php
index 4877f0c6e..32d654c10 100644
--- a/e107_handlers/mailout_admin_class.php
+++ b/e107_handlers/mailout_admin_class.php
@@ -11,31 +11,35 @@
*/
/**
- * Various admin-related mailout functions, mostly to do with creating and handling forms.
- *
+ * Various admin-related mailout functions, mostly to do with creating and
+ * handling forms.
+ *
* @package e107
* @subpackage e107_handlers
-*/
-
+ */
/*
-TODO:
- 1. Use API to downloads plugin to get available files (when available)
- 2. Fuller checking prior to send
- 3. May want more control over date display format
- 4. Use new date picker
-*/
+ TODO:
+ 1. Use API to downloads plugin to get available files (when available)
+ 2. Fuller checking prior to send
+ 3. May want more control over date display format
+ 4. Use new date picker
+ */
-if (!defined('e107_INIT')) { exit; }
+if(!defined('e107_INIT'))
+{
+ exit ;
+}
define('MAIL_ADMIN_DEBUG', TRUE);
-require_once(e_HANDLER.'mail_manager_class.php');
+require_once (e_HANDLER . 'mail_manager_class.php');
class mailoutAdminClass extends e107MailManager
{
- public $_cal = array();
- protected $mode; // So we know what the current task is
+ public $_cal = array();
+ protected $mode;
+ // So we know what the current task is
protected $mailHandlers = array();
protected $showFrom = 0;
protected $showCount = 10;
@@ -43,124 +47,252 @@ class mailoutAdminClass extends e107MailManager
protected $sortOrder = 'asc';
protected $fieldPref = array();
protected $userCache = array();
-
- // Definitions associated with each column which might be displayed. (Compatible with forms-based display)
+ // Definitions associated with each column which might be displayed. (Compatible
+ // with forms-based display)
// Fields are displayed in the order listed.
// Can also have: width
// type
// thclass
protected $fields = array(
- 'mail_recipients' => array
- ( 'mail_target_id' => array('title' => LAN_MAILOUT_143, 'thclass' => 'center', 'forced' => TRUE),
- 'mail_recipient_id' => array('title' => LAN_MAILOUT_142, 'thclass' => 'center'),
- 'mail_recipient_name' => array('title' => LAN_MAILOUT_141, 'forced' => TRUE),
- 'mail_recipient_email' => array('title' => LAN_MAILOUT_140, 'thclass' => 'left', 'forced' => TRUE),
- 'mail_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'center', 'proc' => 'contentstatus'),
- 'mail_detail_id' => array('title' => LAN_MAILOUT_137),
- 'mail_send_date' => array('title' => LAN_MAILOUT_139, 'proc' => 'sdatetime'),
- 'mail_target_info' => array('title' => LAN_MAILOUT_148, 'proc' => 'array'),
- 'options' => array('title' => LAN_OPTIONS, 'forced' => TRUE)
+ 'mail_recipients' => array(
+ 'mail_target_id' => array(
+ 'title' => LAN_MAILOUT_143,
+ 'thclass' => 'center',
+ 'forced' => TRUE
+ ),
+ 'mail_recipient_id' => array(
+ 'title' => LAN_MAILOUT_142,
+ 'thclass' => 'center'
+ ),
+ 'mail_recipient_name' => array(
+ 'title' => LAN_MAILOUT_141,
+ 'forced' => TRUE
+ ),
+ 'mail_recipient_email' => array(
+ 'title' => LAN_MAILOUT_140,
+ 'thclass' => 'left',
+ 'forced' => TRUE
+ ),
+ 'mail_status' => array(
+ 'title' => LAN_MAILOUT_138,
+ 'thclass' => 'center',
+ 'proc' => 'contentstatus'
+ ),
+ 'mail_detail_id' => array('title' => LAN_MAILOUT_137),
+ 'mail_send_date' => array(
+ 'title' => LAN_MAILOUT_139,
+ 'proc' => 'sdatetime'
+ ),
+ 'mail_target_info' => array(
+ 'title' => LAN_MAILOUT_148,
+ 'proc' => 'array'
+ ),
+ 'options' => array(
+ 'title' => LAN_OPTIONS,
+ 'forced' => TRUE
+ )
),
'mail_content' => array(
- 'mail_source_id' => array('title' => LAN_MAILOUT_137, 'thclass' => 'center', 'forced' => TRUE),
- 'mail_title' => array('title' => LAN_MAILOUT_135, 'forced' => TRUE),
- 'mail_subject' => array('title' => LAN_MAILOUT_06, 'forced' => TRUE),
- 'mail_content_status' => array('title' => LAN_MAILOUT_136, 'thclass' => 'center', 'proc' => 'contentstatus'),
- 'mail_togo_count' => array('title' => LAN_MAILOUT_83),
- 'mail_sent_count' => array('title' => LAN_MAILOUT_82),
- 'mail_fail_count' => array('title' => LAN_MAILOUT_128),
+ 'mail_source_id' => array(
+ 'title' => LAN_MAILOUT_137,
+ 'thclass' => 'center',
+ 'forced' => TRUE
+ ),
+ 'mail_title' => array(
+ 'title' => LAN_MAILOUT_135,
+ 'forced' => TRUE
+ ),
+ 'mail_subject' => array(
+ 'title' => LAN_MAILOUT_06,
+ 'forced' => TRUE
+ ),
+ 'mail_content_status' => array(
+ 'title' => LAN_MAILOUT_136,
+ 'thclass' => 'center',
+ 'proc' => 'contentstatus'
+ ),
+ 'mail_togo_count' => array('title' => LAN_MAILOUT_83),
+ 'mail_sent_count' => array('title' => LAN_MAILOUT_82),
+ 'mail_fail_count' => array('title' => LAN_MAILOUT_128),
'mail_bounce_count' => array('title' => LAN_MAILOUT_144),
- 'mail_start_send' => array('title' => LAN_MAILOUT_131, 'proc' => 'sdatetime'),
- 'mail_end_send' => array('title' => LAN_MAILOUT_132, 'proc' => 'sdatetime'),
- 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'proc' => 'sdatetime'),
- 'mail_creator' => array('title' => LAN_MAILOUT_85, 'proc' => 'username'),
- 'mail_create_app' => array('title' => LAN_MAILOUT_133),
+ 'mail_start_send' => array(
+ 'title' => LAN_MAILOUT_131,
+ 'proc' => 'sdatetime'
+ ),
+ 'mail_end_send' => array(
+ 'title' => LAN_MAILOUT_132,
+ 'proc' => 'sdatetime'
+ ),
+ 'mail_create_date' => array(
+ 'title' => LAN_MAILOUT_130,
+ 'proc' => 'sdatetime'
+ ),
+ 'mail_creator' => array(
+ 'title' => LAN_MAILOUT_85,
+ 'proc' => 'username'
+ ),
+ 'mail_create_app' => array('title' => LAN_MAILOUT_133),
'mail_e107_priority' => array('title' => LAN_MAILOUT_134),
- 'mail_notify_complete' => array('title' => LAN_MAILOUT_243, 'nolist' => 'TRUE'),
- 'mail_last_date' => array('title' => LAN_MAILOUT_129, 'proc' => 'sdatetime'),
- 'mail_body' => array('title' => LAN_MAILOUT_100, 'proc' => 'trunc200'),
- 'mail_body_templated' => array('title' => LAN_MAILOUT_257, 'proc' => 'chars'),
- // 'mail_other' = array('title' => LAN_MAILOUT_84),
+ 'mail_notify_complete' => array(
+ 'title' => LAN_MAILOUT_243,
+ 'nolist' => 'TRUE'
+ ),
+ 'mail_last_date' => array(
+ 'title' => LAN_MAILOUT_129,
+ 'proc' => 'sdatetime'
+ ),
+ 'mail_body' => array(
+ 'title' => LAN_MAILOUT_100,
+ 'proc' => 'trunc200'
+ ),
+ 'mail_body_templated' => array(
+ 'title' => LAN_MAILOUT_257,
+ 'proc' => 'chars'
+ ),
+ // 'mail_other' = array('title' => LAN_MAILOUT_84),
'mail_sender_email' => array('title' => LAN_MAILOUT_149),
- 'mail_sender_name' => array('title' => LAN_MAILOUT_150),
- 'mail_copy_to' => array('title' => LAN_MAILOUT_151),
- 'mail_bcopy_to' => array('title' => LAN_MAILOUT_152),
- 'mail_attach' => array('title' => LAN_MAILOUT_153),
- 'mail_send_style' => array('title' => LAN_MAILOUT_154),
- 'mail_selectors' => array('title' => LAN_MAILOUT_155, 'proc' => 'selectors', 'nolist' => 'TRUE'),
- 'mail_include_images' => array('title' => LAN_MAILOUT_224, 'proc' => 'yesno'),
- 'options' => array('title' => LAN_OPTIONS, 'forced' => TRUE)
+ 'mail_sender_name' => array('title' => LAN_MAILOUT_150),
+ 'mail_copy_to' => array('title' => LAN_MAILOUT_151),
+ 'mail_bcopy_to' => array('title' => LAN_MAILOUT_152),
+ 'mail_attach' => array('title' => LAN_MAILOUT_153),
+ 'mail_send_style' => array('title' => LAN_MAILOUT_154),
+ 'mail_selectors' => array(
+ 'title' => LAN_MAILOUT_155,
+ 'proc' => 'selectors',
+ 'nolist' => 'TRUE'
+ ),
+ 'mail_include_images' => array(
+ 'title' => LAN_MAILOUT_224,
+ 'proc' => 'yesno'
+ ),
+ 'options' => array(
+ 'title' => LAN_OPTIONS,
+ 'forced' => TRUE
+ )
)
);
// List of fields to be hidden for each action ('nolist' attribute true)
protected $hideFields = array(
'orphans' => array(),
- 'saved' => 'mail_content_status,mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors',
- 'sent' => 'mail_togo_count,mail_last_date,mail_selectors,mail_notify_complete',
-// 'pending' => 'mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_last_date,mail_selectors',
- 'pending' => 'mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors',
- 'held' => 'mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors',
- 'resend' => 'mail_Selectors,mail_notify_complete',
+ 'saved' => 'mail_content_status,mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors',
+ 'sent' => 'mail_togo_count,mail_last_date,mail_selectors,mail_notify_complete',
+ // 'pending' =>
+ // 'mail_togo_count,mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_last_date,mail_selectors',
+ 'pending' => 'mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors',
+ 'held' => 'mail_sent_count,mail_fail_count,mail_bounce_count,mail_start_send,mail_end_send,mail_e107_priority,mail_notify_complete,mail_last_date,mail_selectors',
+ 'resend' => 'mail_Selectors,mail_notify_complete',
'recipients' => 'mail_detail_id'
- );
+ );
// Array of info associated with each task we might do
protected $tasks = array(
- 'makemail' => array('title' => LAN_MAILOUT_190, 'defaultSort' => '', 'defaultTable' => ''),
- 'saved' => array('title' => LAN_MAILOUT_191, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'),
- 'marksend' => array('title' => 'Internal: marksend', 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'),
- 'sent' => array('title' => LAN_MAILOUT_192, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'),
- 'pending' => array('title' => LAN_MAILOUT_193, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'),
- 'held' => array('title' => LAN_MAILOUT_194, 'defaultSort' => 'mail_source_id', 'defaultTable' => 'mail_content'),
- 'recipients' => array('title' => LAN_MAILOUT_173, 'defaultSort' => 'mail_recipient_email', 'defaultTable' => 'mail_recipients'),
- 'mailtargets' => array('title' => LAN_MAILOUT_173, 'defaultSort' => 'mail_recipient_email', 'defaultTable' => 'mail_recipients'),
- 'prefs' => array('title' => ADLAN_40, 'defaultSort' => '', 'defaultTable' => ''),
- 'maint' => array('title' => ADLAN_40, 'defaultSort' => '', 'defaultTable' => '')
- );
-
+ 'makemail' => array(
+ 'title' => LAN_MAILOUT_190,
+ 'defaultSort' => '',
+ 'defaultTable' => ''
+ ),
+ 'saved' => array(
+ 'title' => LAN_MAILOUT_191,
+ 'defaultSort' => 'mail_source_id',
+ 'defaultTable' => 'mail_content'
+ ),
+ 'marksend' => array(
+ 'title' => 'Internal: marksend',
+ 'defaultSort' => 'mail_source_id',
+ 'defaultTable' => 'mail_content'
+ ),
+ 'sent' => array(
+ 'title' => LAN_MAILOUT_192,
+ 'defaultSort' => 'mail_source_id',
+ 'defaultTable' => 'mail_content'
+ ),
+ 'pending' => array(
+ 'title' => LAN_MAILOUT_193,
+ 'defaultSort' => 'mail_source_id',
+ 'defaultTable' => 'mail_content'
+ ),
+ 'held' => array(
+ 'title' => LAN_MAILOUT_194,
+ 'defaultSort' => 'mail_source_id',
+ 'defaultTable' => 'mail_content'
+ ),
+ 'recipients' => array(
+ 'title' => LAN_MAILOUT_173,
+ 'defaultSort' => 'mail_recipient_email',
+ 'defaultTable' => 'mail_recipients'
+ ),
+ 'mailtargets' => array(
+ 'title' => LAN_MAILOUT_173,
+ 'defaultSort' => 'mail_recipient_email',
+ 'defaultTable' => 'mail_recipients'
+ ),
+ 'prefs' => array(
+ 'title' => ADLAN_40,
+ 'defaultSort' => '',
+ 'defaultTable' => ''
+ ),
+ 'maint' => array(
+ 'title' => ADLAN_40,
+ 'defaultSort' => '',
+ 'defaultTable' => ''
+ )
+ );
// Options for mail listing dropdown - actions apertaining to a stored email
protected $modeOptions = array(
'saved' => array(
- 'mailedit' => LAN_MAILOUT_163,
- 'maildelete' => LAN_DELETE,
+ 'mailedit' => LAN_MAILOUT_163,
+ 'maildelete' => LAN_DELETE,
'mailshowtemplate' => LAN_MAILOUT_254
- ),
+ ),
'pending' => array(
'mailsendimmediately' => "Send Immediately",
- 'mailhold' => LAN_MAILOUT_159,
- 'mailcancel' => LAN_MAILOUT_160,
- 'mailtargets' => LAN_MAILOUT_181
- ),
+ 'mailhold' => LAN_MAILOUT_159,
+ 'mailcancel' => LAN_MAILOUT_160,
+ 'mailtargets' => LAN_MAILOUT_181
+ ),
'held' => array(
- 'mailsendnow' => LAN_MAILOUT_158,
- 'mailcancel' => LAN_MAILOUT_160,
- 'mailtargets' => LAN_MAILOUT_181
- ),
+ 'mailsendnow' => LAN_MAILOUT_158,
+ 'mailcancel' => LAN_MAILOUT_160,
+ 'mailtargets' => LAN_MAILOUT_181
+ ),
'sent' => array(
- 'mailcopy' => LAN_MAILOUT_251,
- 'maildelete' => LAN_DELETE,
- 'mailtargets' => LAN_MAILOUT_181
- ),
- 'recipients' => array(
- 'mailonedelete' => LAN_DELETE
- )
+ 'mailcopy' => LAN_MAILOUT_251,
+ 'maildelete' => LAN_DELETE,
+ 'mailtargets' => LAN_MAILOUT_181
+ ),
+ 'recipients' => array('mailonedelete' => LAN_DELETE)
);
-
// List of fields to be included in email display for various options
protected $mailDetailDisplay = array(
- 'basic' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 200),
- 'send' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 500, 'mail_send_style' => 1),
- 'template' => array('mail_source_id' => 1, 'mail_title' => 1, 'mail_subject' => 1, 'mail_body' => 200, 'mail_body_templated' => 'chars'),
+ 'basic' => array(
+ 'mail_source_id' => 1,
+ 'mail_title' => 1,
+ 'mail_subject' => 1,
+ 'mail_body' => 200
+ ),
+ 'send' => array(
+ 'mail_source_id' => 1,
+ 'mail_title' => 1,
+ 'mail_subject' => 1,
+ 'mail_body' => 500,
+ 'mail_send_style' => 1
+ ),
+ 'template' => array(
+ 'mail_source_id' => 1,
+ 'mail_title' => 1,
+ 'mail_subject' => 1,
+ 'mail_body' => 200,
+ 'mail_body_templated' => 'chars'
+ ),
);
-
/**
* Constructor
- *
+ *
*
* @return void
*/
@@ -169,34 +301,37 @@ class mailoutAdminClass extends e107MailManager
parent::__construct();
$dbTable = '';
- if (isset($this->tasks[$mode]))
+ if(isset($this->tasks[$mode]))
{
$dbTable = $this->tasks[$mode]['defaultTable'];
}
if(isset($_GET['frm']))
{
$temp = intval($_GET['frm']);
- if ($temp < 0) $temp = 0;
+ if($temp < 0)
+ $temp = 0;
$this->showFrom = $temp;
}
if(isset($_GET['count']))
{
- $temp = min(intval($_GET['count']), 50); // Limit to 50 per page
- $temp = max($temp, 5); // ...and minimum 5 per page
+ $temp = min(intval($_GET['count']), 50);
+ // Limit to 50 per page
+ $temp = max($temp, 5);
+ // ...and minimum 5 per page
$this->showCount = $temp;
}
- if (isset($_GET['fld']))
+ if(isset($_GET['fld']))
{
$temp = e107::getParser()->toDB($_GET['fld']);
- if (is_array($this->fields[$dbTable][$temp]))
+ if(is_array($this->fields[$dbTable][$temp]))
{
$this->sortField = $temp;
}
}
- if (isset($_GET['asc']))
+ if(isset($_GET['asc']))
{
$temp = strtolower(e107::getParser()->toDB($_GET['asc']));
- if (($temp == 'asc') || ($temp == 'desc'))
+ if(($temp == 'asc') || ($temp == 'desc'))
{
$this->sortOrder = $temp;
}
@@ -204,7 +339,6 @@ class mailoutAdminClass extends e107MailManager
$this->newMode($mode);
}
-
/**
* Set up new mode
*
@@ -216,18 +350,20 @@ class mailoutAdminClass extends e107MailManager
global $user_pref;
$this->mode = $mode;
$curTable = $this->tasks[$this->mode]['defaultTable'];
- if ($curTable)
+ if($curTable)
{
- if (isset($user_pref['admin_mailout_columns'][$mode]) && is_array($user_pref['admin_mailout_columns'][$mode]))
- { // Use saved list of fields to view if it exists
+ if(isset($user_pref['admin_mailout_columns'][$mode]) && is_array($user_pref['admin_mailout_columns'][$mode]))
+ {
+ // Use saved list of fields to view if it exists
$this->fieldPref = $user_pref['admin_mailout_columns'][$mode];
}
else
- { // Default list is minimal fields only
+ {
+ // Default list is minimal fields only
$this->fieldPref = array();
- foreach ($this->fields[$curTable] as $f => $v)
+ foreach($this->fields[$curTable] as $f => $v)
{
- if (vartrue($v['forced']))
+ if(vartrue($v['forced']))
{
$this->fieldPref[] = $f;
}
@@ -236,22 +372,23 @@ class mailoutAdminClass extends e107MailManager
}
// Possibly the sort field needs changing
- if (!isset($this->fields[$curTable][$this->sortField]))
+ if(!isset($this->fields[$curTable][$this->sortField]))
{
$this->sortField = $this->tasks[$mode]['defaultSort'];
}
-
+
// Now hide any fields that need to be for this mode
- if (isset($this->hideFields[$mode]))
+ if(isset($this->hideFields[$mode]))
{
- $hideList = array_flip(explode(',',$this->hideFields[$mode]));
- foreach ($this->fields[$curTable] as $f => $v)
+ $hideList = array_flip(explode(',', $this->hideFields[$mode]));
+ foreach($this->fields[$curTable] as $f => $v)
{
$this->fields[$curTable][$f]['nolist'] = isset($hideList[$f]);
}
- foreach ($this->fieldPref as $k => $v) // Remove from list of active fields (shouldn't often do anything)
+ foreach($this->fieldPref as $k => $v)// Remove from list of active fields
+ // (shouldn't often do anything)
{
- if (isset($hideList[$v]))
+ if(isset($hideList[$v]))
{
unset($this->fieldPref[$k]);
}
@@ -259,29 +396,28 @@ class mailoutAdminClass extends e107MailManager
}
}
-
-
/**
* Calculate the list of fields (columns) to be displayed for a given mode
*
* @param string $mode - display mode
- * @param boolean $noOptions - set TRUE to suppress inclusion of any 'options' column. FALSE to include 'options' (default)
+ * @param boolean $noOptions - set TRUE to suppress inclusion of any 'options'
+ * column. FALSE to include 'options' (default)
* @return array of field definitions
*/
protected function calcFieldSpec($mode, $noOptions = FALSE)
{
- if (!isset($this->tasks[$mode]))
+ if(!isset($this->tasks[$mode]))
{
echo "CalcfieldSpec({$mode}) - programming bungle
";
return FALSE;
}
$ret = array();
$curTable = $this->tasks[$this->mode]['defaultTable'];
- foreach ($this->fields[$curTable] as $f => $v)
+ foreach($this->fields[$curTable] as $f => $v)
{
- if ((vartrue($v['forced']) && !vartrue($v['nolist'])) || in_array($f, $this->fieldPref))
+ if((vartrue($v['forced']) && !vartrue($v['nolist'])) || in_array($f, $this->fieldPref))
{
- if (($f != 'options') || ($noOptions === FALSE))
+ if(($f != 'options') || ($noOptions === FALSE))
{
$ret[] = $f;
}
@@ -290,30 +426,30 @@ class mailoutAdminClass extends e107MailManager
return $ret;
}
-
/**
* Save the column visibility prefs for this mode
*
* @param $target - display mode
* @return none
*/
- public function mailbodySaveColumnPref($target)
- {
- global $user_pref;
- if (!$target) return;
- if (!isset($this->tasks[$target]))
- {
- echo "Invalid prefs target: {$target}
";
- return;
- }
- if (isset ($_POST['etrigger_ecolumns']))
- {
- $user_pref['admin_mailout_columns'][$target] = $_POST['e-columns'];
- save_prefs('user');
- $this->fieldPref = $user_pref['admin_mailout_columns'][$target];
- }
- }
-
+ /*
+ public function mailbodySaveColumnPref($target)
+ {
+ global $user_pref;
+ if (!$target) return;
+ if (!isset($this->tasks[$target]))
+ {
+ echo "Invalid prefs target: {$target}
";
+ return;
+ }
+ if (isset ($_POST['etrigger_ecolumns']))
+ {
+ $user_pref['admin_mailout_columns'][$target] = $_POST['e-columns'];
+ save_prefs('user');
+ $this->fieldPref = $user_pref['admin_mailout_columns'][$target];
+ }
+ }
+ */
/**
* Get the user name associated with a user ID.
* The result is cached in case required again
@@ -324,35 +460,36 @@ class mailoutAdminClass extends e107MailManager
*/
protected function getUserName($uid)
{
- if (!isset($this->userCache[$uid]))
+ if(!isset($this->userCache[$uid]))
{
// Look up user
- $this->checkDB(2); // Make sure DB object created
- if ($this->db2->select('user','user_name, user_loginname', 'user_id='.intval($uid)))
+ $this->checkDB(2);
+ // Make sure DB object created
+ if($this->db2->select('user', 'user_name, user_loginname', 'user_id=' . intval($uid)))
{
$row = $this->db2->fetch(MYSQL_ASSOC);
- $this->userCache[$uid] = $row['user_name'].' ('.$row['user_loginname'].')';
+ $this->userCache[$uid] = $row['user_name'] . ' (' . $row['user_loginname'] . ')';
}
else
{
- $this->userCache[$uid] = 'UID: '.$uid;
+ $this->userCache[$uid] = 'UID: ' . $uid;
}
}
return $this->userCache[$uid];
}
-
/**
* Generate the HTML for displaying actions box for emails
- *
- * Options given depend on $mode (saved|sent|pending|held), and also values in the email data.
+ *
+ * Options given depend on $mode (saved|sent|pending|held), and also values in
+ * the email data.
*
* @param array $mailData - array of email-related info
* @return string HTML for display
*/
- public function makeMailOptions($mode,$mailData)
+ public function makeMailOptions($mode, $mailData)
{
- if (!is_numeric($mailData['mail_source_id']) || ($mailData['mail_source_id'] == 0))
+ if(!is_numeric($mailData['mail_source_id']) || ($mailData['mail_source_id'] == 0))
{
echo "makeMailOptions ({$mode}): Programming bungle!";
print_a($mailData);
@@ -360,7 +497,7 @@ class mailoutAdminClass extends e107MailManager
}
$text = "
\n
\n";
- foreach ($this->modeOptions[$mode] as $key => $val)
+ foreach($this->modeOptions[$mode] as $key => $val)
{
$text .= "{$val} \n";
}
@@ -368,18 +505,17 @@ class mailoutAdminClass extends e107MailManager
return $text;
}
-
/**
* Generate the HTML for displaying actions box for emails
- *
+ *
* Options given depend on $mode, and also values in the email data.
*
* @param $mailData - array of email-related info
* @return HTML for display
*/
- public function makeTargetOptions($mode,$targetData)
+ public function makeTargetOptions($mode, $targetData)
{
- if (!is_numeric($targetData['mail_target_id']) || ($targetData['mail_target_id'] == 0))
+ if(!is_numeric($targetData['mail_target_id']) || ($targetData['mail_target_id'] == 0))
{
echo "makeTargetOptions ({$mode}): Programming bungle!";
print_a($targetData);
@@ -387,7 +523,7 @@ class mailoutAdminClass extends e107MailManager
}
$text = "\n
\n";
- foreach ($this->modeOptions[$mode] as $key => $val)
+ foreach($this->modeOptions[$mode] as $key => $val)
{
$text .= "{$val} \n";
}
@@ -395,10 +531,9 @@ class mailoutAdminClass extends e107MailManager
return $text;
}
-
/**
* Generate the HTML for displaying email selection fields
- *
+ *
* @param $options - comma-separate string of handlers to load
* 'core' - core handler
* plugin name - obvious!
@@ -411,37 +546,42 @@ class mailoutAdminClass extends e107MailManager
$ret = 0;
$toLoad = explode(',', $options);
- if (in_array('core', $toLoad) || ($options == 'all'))
+
+ $active_mailers = explode(',', varset($pref['mailout_enabled'], 'core'));
+
+ if((in_array('core', $toLoad) || ($options == 'all')) && in_array('core', $active_mailers))
{
- require_once(e_HANDLER.'mailout_class.php');
- $this->mailHandlers['core'] = new core_mailout; // Start by loading the core mailout class
+ require_once (e_HANDLER . 'mailout_class.php');
+ $this->mailHandlers['core'] = new core_mailout; // Start by loading the core mailout class
$ret++;
}
- $active_mailers = explode(',',varset($pref['mailout_enabled'],''));
-
- // Load additional configured handlers
- foreach ($pref['e_mailout_list'] as $mailer => $v)
+ // Load additional configured handlers e_mailout.php from plugins.
+ foreach($pref['e_mailout_list'] as $mailer => $v)
{
- if (isset($pref['plug_installed'][$mailer]) && in_array($mailer,$active_mailers) && (($options == 'all') || in_array($mailer, $toLoad)))
- { // Could potentially use this handler - its installed and enabled
- if (!is_readable(e_PLUGIN.$mailer.'/e_mailout.php'))
+
+ if(isset($pref['plug_installed'][$mailer]) && in_array($mailer, $active_mailers) && (($options == 'all') || in_array($mailer, $toLoad)))
+ {
+ // Could potentially use this handler - its installed and enabled
+ if(!is_readable(e_PLUGIN . $mailer . '/e_mailout.php'))
{
- echo 'Invalid mailer selected: '.$mailer.' ';
- exit;
+ echo 'Invalid mailer selected: ' . $mailer . ' ';
+ exit ;
}
- require_once(e_PLUGIN.$mailer.'/e_mailout.php');
- if (varset($mailerIncludeWithDefault,TRUE))
- { // Definitely need this plugin
- $mailClass = $mailer.'_mailout';
+ require_once (e_PLUGIN . $mailer . '/e_mailout.php');
+ if(varset($mailerIncludeWithDefault, TRUE))
+ {
+ // Definitely need this plugin
+ $mailClass = $mailer . '_mailout';
$temp = new $mailClass;
- if ($temp->mailerEnabled)
+ if($temp->mailerEnabled)
{
$this->mailHandlers[$mailer] = $temp;
$ret++;
- if (varset($mailerExcludeDefault,FALSE) && isset($this->mailHandlers['core']))
+ if(varset($mailerExcludeDefault, FALSE) && isset($this->mailHandlers['core']))
{
- $this->mailHandlers['core']->mailerEnabled = FALSE; // Don't need default (core) handler
+ $this->mailHandlers['core']->mailerEnabled = FALSE;
+ // Don't need default (core) handler
$ret--;
}
}
@@ -456,10 +596,9 @@ class mailoutAdminClass extends e107MailManager
return $ret;
}
-
/**
* Generate the HTML for displaying email selection fields
- *
+ *
* @param $options - comma-separated string of areas to display:
* plugins - selectors from any available plugins
* cc - field for 'cc' options
@@ -470,69 +609,70 @@ class mailoutAdminClass extends e107MailManager
*/
public function emailSelector($options = 'all', $selectorInfo = FALSE)
{
- $ret = '';
- $tab = '';
- $tabc = '';
+ $tabs = array();
-
- foreach ($this->mailHandlers as $key => $m)
+ foreach($this->mailHandlers as $key => $m)
{
- if ($m->mailerEnabled)
+
+ if($m->mailerEnabled)
{
- $lactive = ($key == 'core') ? " class='active'" : '';
- $tab .= "".$m->mailerName." ";
-
- $pactive = ($key == 'core') ? 'active' : '';
- $tabc .= "";
$content = $m->showSelect(TRUE, varset($selectorInfo[$key], FALSE));
-
+
if(is_array($content))
{
- $tabc .= "
";
+
}
else
{
- $tabc .= $content; //BC (0.8 only) but should be deprecated
+ $text = $content; //BC (0.8 only) but should be deprecated
}
-
- $tabc .= "
";
+
+ $tabs[$key] = array('caption'=>$m->mailerName, 'text'=>$text);
+
}
}
-
-// $ret .= ""; // This hides tabs!
- $ret .= "";
- $ret .= "\n";
- $ret .= $tabc;
- $ret .= "
";
- return $ret;
-
+ if(count($tabs) < 2) // no tabs if there's only 1 category.
+ {
+ return $text;
+ }
+
+
+ return e107::getForm()->tabs($tabs);
}
+
/**
* Get the selector details from each mail plugin (to add to mail data)
- *
- * @return array of selectors - key is the plugin name, value is the selector data (often itself an array)
+ *
+ * @return array of selectors - key is the plugin name, value is the selector
+ * data (often itself an array)
*/
public function getAllSelectors()
{
$ret = array();
- foreach ($this->mailHandlers as $key => $m)
+ foreach($this->mailHandlers as $key => $m)
{
- if ($m->mailerEnabled)
+ if($m->mailerEnabled)
{
$ret[$key] = $m->returnSelectors();
}
@@ -540,110 +680,118 @@ class mailoutAdminClass extends e107MailManager
return $ret;
}
-
/**
- * Creates a 'select' dropdown of userclasses, including the number of members in each class.
- *
+ * Creates a 'select' dropdown of userclasses, including the number of members in
+ * each class.
+ *
* @param string $name - name for
* @param string $curSel - current select value
* @return text for display
*
* @TODO: Doesn't give correct count for core classes where no data initialised
*/
- public function userClassesTotals($name, $curSel)
+ public function userClassesTotals($name, $curSel)
{
- $fixedClasses = array('all' => LAN_MAILOUT_12,'unverified' => LAN_MAILOUT_13, 'admin' => LAN_MAILOUT_53, 'self' => LAN_MAILOUT_54);
+ $fixedClasses = array(
+ 'self' => LAN_MAILOUT_54,
+ 'all' => LAN_MAILOUT_12,
+ 'unverified' => LAN_MAILOUT_13,
+ 'admin' => LAN_MAILOUT_53
+ );
$ret = '';
- $this->checkDB(2); // Make sure DB object created
+ $this->checkDB(2);
+ // Make sure DB object created
$ret .= "
\n";
-
- foreach ($fixedClasses as $k => $v)
+
+ foreach($fixedClasses as $k => $v)
{
- $sel = ($k == $curSel) ? " selected='selected'" : '';
+ $sel = ($k == $curSel)? " selected='selected'": '';
$ret .= "{$v} \n";
}
$query = "SELECT uc.*, count(u.user_id) AS members
FROM #userclass_classes AS uc
LEFT JOIN #user AS u ON u.user_class REGEXP concat('(^|,)',uc.userclass_id,'(,|$)')
- WHERE NOT uc.userclass_id IN (".e_UC_PUBLIC.','.e_UC_NOBODY.','.e_UC_READONLY.','.e_UC_BOTS.")
+ WHERE NOT uc.userclass_id IN (" . e_UC_PUBLIC . ',' . e_UC_NOBODY . ',' . e_UC_READONLY . ',' . e_UC_BOTS . ")
GROUP BY uc.userclass_id
";
$this->db2->gen($query);
- while ($row = $this->db2->fetch())
+ while($row = $this->db2->fetch())
{
- $public = ($row['userclass_editclass'] == e_UC_PUBLIC)? "(".LAN_MAILOUT_10.")" : "";
- $selected = ($row['userclass_id'] == $curSel) ? " selected='selected'" : '';
- $ret .= "".LAN_MAILOUT_55." - {$row['userclass_name']} {$public} [{$row['members']}] \n";
+ $public = ($row['userclass_editclass'] == e_UC_PUBLIC)? "(" . LAN_MAILOUT_10 . ")": "";
+ $selected = ($row['userclass_id'] == $curSel)? " selected='selected'": '';
+ $ret .= "" . LAN_MAILOUT_55 . " - {$row['userclass_name']} {$public} [{$row['members']}] \n";
}
$ret .= " \n";
return $ret;
}
-
-
/**
* Creates a 'select' dropdown of non-system user fields
- *
+ *
* @param string $list_name - name for
* @param string $curval - current select value
* @param boolean $add_blank - add a blank line before the options if TRUE
- * @return text for display if any extended fields defined; FALSE if none available
+ * @return text for display if any extended fields defined; FALSE if none
+ * available
*/
public function ret_extended_field_list($list_name, $curval = '', $add_blank = FALSE)
{
- $ue = e107::getUserExt(); // Get the extended field handler
- if (count($ue->fieldDefinitions) == 0) return FALSE;
+ $ue = e107::getUserExt();
+ // Get the extended field handler
+ if(count($ue->fieldDefinitions) == 0)
+ return FALSE;
$ret = "\n";
- if ($add_blank) $ret .= " \n";
+ if($add_blank)
+ $ret .= " \n";
- foreach ($ue->fieldDefinitions as $fd)
+ foreach($ue->fieldDefinitions as $fd)
{
- if ($fd['user_extended_struct_text'] != '_system_')
+ if($fd['user_extended_struct_text'] != '_system_')
{
- $value = 'ue.user_'.$fd['user_extended_struct_name'];
- $selected = ($value == $curval) ? " selected='selected'" : '';
- $ret .= "".ucfirst($fd['user_extended_struct_name'])." \n";
+ $value = 'ue.user_' . $fd['user_extended_struct_name'];
+ $selected = ($value == $curval)? " selected='selected'": '';
+ $ret .= "" . ucfirst($fd['user_extended_struct_name']) . " \n";
}
}
$ret .= " \n";
return $ret;
}
-
-
/**
* Creates an array of data from standard $_POST fields
- *
+ *
* @param $newMail - set TRUE for initial creation, FALSE when updating
* @return array of data
*/
public function parseEmailPost($newMail = TRUE)
{
$tp = e107::getParser();
-
- $ret = array( 'mail_title' => $_POST['email_title'],
- 'mail_subject' => $_POST['email_subject'],
- 'mail_body' => $_POST['email_body'],
- 'mail_sender_email' => $_POST['email_from_email'],
- 'mail_sender_name' => $_POST['email_from_name'],
- 'mail_copy_to' => $_POST['email_cc'],
- 'mail_bcopy_to' => $_POST['email_bcc'],
- 'mail_attach' => trim($_POST['email_attachment']),
- 'mail_send_style' => varset($_POST['email_send_style'],'textonly'),
- 'mail_include_images' => (isset($_POST['email_include_images']) ? 1 : 0)
- );
-
- $ret = $tp->toDB($ret); // recursive
-
- if (isset($_POST['mail_source_id']))
+
+ $ret = array(
+ 'mail_title' => $_POST['email_title'],
+ 'mail_subject' => $_POST['email_subject'],
+ 'mail_body' => $_POST['email_body'],
+ 'mail_sender_email' => $_POST['email_from_email'],
+ 'mail_sender_name' => $_POST['email_from_name'],
+ 'mail_copy_to' => $_POST['email_cc'],
+ 'mail_bcopy_to' => $_POST['email_bcc'],
+ 'mail_attach' => trim($_POST['email_attachment']),
+ 'mail_send_style' => varset($_POST['email_send_style'], 'textonly'),
+ 'mail_include_images' => (isset($_POST['email_include_images'])? 1: 0)
+ );
+
+ $ret = $tp->toDB($ret);
+ // recursive
+
+ if(isset($_POST['mail_source_id']))
{
$ret['mail_source_id'] = intval($_POST['mail_source_id']);
}
- if ($newMail)
+ if($newMail)
{
$ret['mail_creator'] = USERID;
$ret['mail_create_date'] = time();
@@ -651,139 +799,151 @@ class mailoutAdminClass extends e107MailManager
return $ret;
}
-
-
/**
* Does some basic checking on email data.
- *
+ *
* @param $email - array of data in parseEmailPost() format
- * @param $fullCheck - TRUE to check all fields that are required (immediately prior to sending); FALSE to just check a few basics (prior to save)
+ * @param $fullCheck - TRUE to check all fields that are required (immediately
+ * prior to sending); FALSE to just check a few basics (prior to save)
* @return TRUE if OK. Array of error messages if any errors found
*/
public function checkEmailPost(&$email, $fullCheck = FALSE)
{
$errList = array();
- if (count($email) < 3)
+ if(count($email) < 3)
{
$errList[] = LAN_MAILOUT_201;
return $errList;
}
- if (!trim($email['mail_subject'])) $errList[] = LAN_MAILOUT_200;
- if (!trim($email['mail_body'])) $errList[] = LAN_MAILOUT_202;
- if (!trim($email['mail_sender_name'])) $errList[] = LAN_MAILOUT_203;
- if (!trim($email['mail_sender_email'])) $errList[] = LAN_MAILOUT_204;
- if (strlen($email['mail_send_style']) == 0)
- { // Can be a template name now
+ if(!trim($email['mail_subject']))
+ $errList[] = LAN_MAILOUT_200;
+ if(!trim($email['mail_body']))
+ $errList[] = LAN_MAILOUT_202;
+ if(!trim($email['mail_sender_name']))
+ $errList[] = LAN_MAILOUT_203;
+ if(!trim($email['mail_sender_email']))
+ $errList[] = LAN_MAILOUT_204;
+ if(strlen($email['mail_send_style']) == 0)
+ {
+ // Can be a template name now
$errList[] = LAN_MAILOUT_205;
break;
}
else
{
// Get template data, override email settings as appropriate
- require_once(e_HANDLER.'mail_template_class.php');
+ require_once (e_HANDLER . 'mail_template_class.php');
$ourTemplate = new e107MailTemplate();
$templateName = $email['mail_send_style'];
- if (!$ourTemplate->setNewTemplate($templateName))
+ if(!$ourTemplate->setNewTemplate($templateName))
{
- $errList[] = LAN_MAILOUT_207.':'.$templateName;
- print_a($ourTemplate); // Probably template not found if error
+ $errList[] = LAN_MAILOUT_207 . ':' . $templateName;
+ print_a($ourTemplate);
+ // Probably template not found if error
}
- if (!$ourTemplate->makeEmailBody($email['mail_body'], $email['mail_include_images']))
+ if(!$ourTemplate->makeEmailBody($email['mail_body'], $email['mail_include_images']))
{
- $errList[] = LAN_MAILOUT_205.':'.$templateName;
+ $errList[] = LAN_MAILOUT_205 . ':' . $templateName;
print_a($ourTemplate);
}
else
{
$email['mail_body_templated'] = $ourTemplate->mainBodyText;
$email['mail_body_alt'] = $ourTemplate->altBodyText;
- if (count($ourTemplate->lastTemplateData['email_overrides']))
+ if(count($ourTemplate->lastTemplateData['email_overrides']))
{
$email['mail_overrides'] = $ourTemplate->lastTemplateData['email_overrides'];
}
}
}
- if (count($errList) == 0)
+ if(count($errList) == 0)
{
return TRUE;
}
return $errList;
}
-
/**
* Generate a table which shows some information about an email.
- * Intended to be part of a 2-column table - includes the row detail, but not the surrounding table definitions
- *
+ * Intended to be part of a 2-column table - includes the row detail, but not the
+ * surrounding table definitions
+ *
* @param $mailSource - array of mail information
* @param $options - controls how much information is displayed
* @return text for display
*/
- public function showMailDetail(&$mailSource, $options='basic')
+ public function showMailDetail(&$mailSource, $options = 'basic')
{
$tp = e107::getParser();
-
-
- if (!isset($this->mailDetailDisplay[$options]))
+
+ if(!isset($this->mailDetailDisplay[$options]))
{
return "Programming bungle - invalid option value: {$options} ";
}
$text = '';
- foreach ($this->mailDetailDisplay[$options] as $k => $v)
+ foreach($this->mailDetailDisplay[$options] as $k => $v)
{
- $text .= ''.$this->fields['mail_content'][$k]['title'].' ';
+ $text .= ' ' . $this->fields['mail_content'][$k]['title'] . ' ';
$val = $mailSource[$k];
- if (is_numeric($v))
+
+ if($k == 'mail_body')
{
- $text .= ($v > 1) ? $tp->text_truncate($val, $v, '...') : $val;
+ // $text .= print_a($mailSource,true);
+ // $text .= $tp->toHtml($val,true);
+ $text .= "";
+ continue;
+ }
+
+ if(is_numeric($v))
+ {
+ $text .= ($v > 1)? $tp->text_truncate($val, $v, '...'): $val;
}
else
{
switch ($v)
{
- case 'username' :
+ case 'username':
$text .= $this->getUserName($val);
- break;
- case 'sdatetime' :
+ break;
+ case 'sdatetime':
$text .= $gen->convert_date($val, 'short');
- break;
- case 'trunc200' :
+ break;
+ case 'trunc200':
+
$text .= e107::getParser()->text_truncate($val, 200, '...');
- break;
- case 'chars' : // Show generated html as is
+ break;
+ case 'chars':
+ // Show generated html as is
$text .= htmlspecialchars($val, ENT_COMPAT, 'UTF-8');
- break;
- case 'contentstatus' :
+ break;
+ case 'contentstatus':
$text .= $this->statusToText($val);
- break;
- case 'selectors' :
+ break;
+ case 'selectors':
$text .= 'cannot display';
- break;
- case 'yesno' :
- $text .= $val ? LAN_YES : LAN_NO;
- break;
- case 'default' :
- default :
+ break;
+ case 'yesno':
+ $text .= $val? LAN_YES: LAN_NO;
+ break;
+ case 'default':
+ default:
$text .= $val;
}
}
- $text .= ' '."\n";
+ $text .= '' . "\n";
}
return $text;
}
-
-
/**
* Generate the HTML for dropdown to select mail sending style (text/HTML/styled
- *
+ *
* @param $curval - current value
* @param $name name of item
* @return text for display
*/
- //FIXME use $frm->select() instead.
public function sendStyleSelect($curval = '', $name = 'email_send_style', $incTemplates = TRUE)
{
@@ -793,222 +953,230 @@ class mailoutAdminClass extends e107MailManager
'texttheme' => LAN_MAILOUT_127
);
- $text = "\n";
-
- foreach ($emFormat as $key=>$val)
- {
- $selected = ($key == $curval) ? " selected='selected'" : '';
- $text .= "".$val." \n";
- }
- if ($incTemplates)
+ if($incTemplates)
{
$tList = self::getEmailTemplateNames('user');
- foreach ($tList as $key=>$val)
+ foreach($tList as $key => $val)
{
- $selected = ($key == $curval) ? " selected='selected'" : '';
- $text .= "".LAN_MAILOUT_258.$val." \n";
- }
+ $emFormat[$key] = LAN_MAILOUT_258 . $val;
+ }
+ }
+
+ if(empty($curval))
+ {
+ $curval = e107::getConfig()->get('mail_sendstyle');
+
}
- $text .=" \n";
- return $text;
- }
+
+ return e107::getForm()->select($name,$emFormat, $curval, 'required=1&size=xxlarge');
+
+ }
/**
* Generate the HTML to show the mailout form. Used for both sending and editing
- *
+ *
* @param $mailSource - array of mail information
* @return text for display
*/
- function show_mailform(&$mailSource)
- {
- global $HANDLERS_DIRECTORY;
- global $mailAdmin;
-
- $sql = e107::getDb();
- $ns = e107::getRender();
- $tp = e107::getParser();
- $frm = e107::getForm();
- $mes = e107::getMessage();
- $pref = e107::getPref();
-
- if (!is_array($mailSource))
- {
- $mes->addError('Coding error - mail not array (521)');
- //$ns->tablerender('ERROR!!', );
- //exit;
- }
+ /*
+ function show_mailform(&$mailSource)
+ {
+ global $HANDLERS_DIRECTORY;
+ global $mailAdmin;
- $email_subject = varset($mailSource['mail_subject'], '');
- $email_body = $tp->toForm(varset($mailSource['mail_body'],''));
- $email_id = varset($mailSource['mail_source_id'],'');
-
- $text = '';
+ $sql = e107::getDb();
+ $ns = e107::getRender();
+ $tp = e107::getParser();
+ $frm = e107::getForm();
+ $mes = e107::getMessage();
+ $pref = e107::getPref();
- if(strpos($_SERVER['SERVER_SOFTWARE'],'mod_gzip') && !is_readable(e_HANDLER.'phpmailer/.htaccess'))
- {
- $warning = LAN_MAILOUT_40.' '.$HANDLERS_DIRECTORY.'phpmailer/ '.LAN_MAILOUT_41;
- $ns->tablerender(LAN_MAILOUT_42, $mes->render().$warning);
- }
+ if (!is_array($mailSource))
+ {
+ $mes->addError('Coding error - mail not array (521)');
+ //$ns->tablerender('ERROR!!', );
+ //exit;
+ }
- $debug = (e_MENU == "debug") ? "?[debug]" : "";
-
-
-
- $text .= "";
+
+ return $text;
+
+ // $ns->tablerender(ADLAN_136.SEP.LAN_MAILOUT_15, $mes->render(). $text); //
+ // Render the complete form
+ }
+ */
/**
* Helper function manages the shortcodes which can be inserted
*/
- function sc_Select($container='sc_selector')
+ function sc_Select($container = 'sc_selector')
{
- $text ="
+ $text = "
\n
@@ -1017,19 +1185,19 @@ class mailoutAdminClass extends e107MailManager
-- \n";
- $sc = array(
- '|DISPLAYNAME|' => LAN_MAILOUT_14,
- '|USERNAME|' => LAN_MAILOUT_16,
- '|SIGNUP_LINK|' => LAN_MAILOUT_17,
- '|USERID|' => LAN_MAILOUT_18,
- '|USERLASTVISIT|' => LAN_MAILOUT_178
- );
+ $sc = array(
+ '|DISPLAYNAME|' => LAN_MAILOUT_14,
+ '|USERNAME|' => LAN_MAILOUT_16,
+ '|SIGNUP_LINK|' => LAN_MAILOUT_17,
+ '|USERID|' => LAN_MAILOUT_18,
+ '|USERLASTVISIT|' => LAN_MAILOUT_178
+ );
- foreach($sc as $key=>$val)
- {
- $text .= "".$val." \n";
- }
- $text .="
+ foreach($sc as $key => $val)
+ {
+ $text .= "" . $val . " \n";
+ }
+ $text .= "
\n