1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

Mailout ajax process timing correction and log file added in debug mode.

This commit is contained in:
Cameron
2014-10-27 18:31:17 -07:00
parent 14a403d0de
commit 41ee837c7e
3 changed files with 67 additions and 30 deletions

View File

@@ -98,8 +98,10 @@ function sendProgress($id)
ob_start(); ob_start();
$perAjaxHit = e107::getConfig()->get('mail_pause',1);
$mailManager = new e107MailManager(); $mailManager = new e107MailManager();
$mailManager->doEmailTask(varset($pref['mail_workpertick'],5)); $mailManager->doEmailTask($perAjaxHit);
$sqld = e107::getDb('progress'); $sqld = e107::getDb('progress');
@@ -717,6 +719,8 @@ class mailout_main_ui extends e_admin_ui
{ {
$id = $this->getId(); $id = $this->getId();
$this->getResponse()->setTitle(LAN_MAILOUT_15.SEP.'Process Mail Queue #'.$id);
e107::getDb()->update('mail_content', 'mail_content_status='.MAIL_STATUS_PENDING.' WHERE mail_source_id = '.intval($id)); e107::getDb()->update('mail_content', 'mail_content_status='.MAIL_STATUS_PENDING.' WHERE mail_source_id = '.intval($id));
e107::getDb()->update('mail_recipients', 'mail_status='.MAIL_STATUS_PENDING.' WHERE mail_detail_id = '.intval($id)); e107::getDb()->update('mail_recipients', 'mail_status='.MAIL_STATUS_PENDING.' WHERE mail_detail_id = '.intval($id));
@@ -727,8 +731,10 @@ class mailout_main_ui extends e_admin_ui
} }
else else
{ {
$text = "<h4>Ready to Process Mail Queue</h4>"; $pause = e107::getConfig()->get('mail_pausetime',1);
$text .= e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start #'.$id, 'url'=> e_SELF, 'mode'=>$id)); $interval = ($pause * 1000);
$text = e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start', 'interval'=>$interval, 'url'=> e_SELF, 'mode'=>$id));
} }
return $text; return $text;

View File

@@ -1116,11 +1116,13 @@ class e_form
$buttonId = $target.'-start'; $buttonId = $target.'-start';
if(vartrue($options['btn-label'])) if(vartrue($options['btn-label']))
{ {
$text .= '<a id="'.$buttonId.'" data-loading-text="'.$loading.'" data-progress-target="'.$target.'" data-progress="' . $options['url'] . '" data-progress-mode="'.varset($options['mode'],0).'" data-progress-show="'.$nextStep.'" data-progress-hide="'.$buttonId.'" class="btn btn-primary e-progress" >'.$options['btn-label'].'</a>'; $interval = vartrue($options['interval'],1000);
$text .= '<a id="'.$buttonId.'" data-loading-text="'.$loading.'" data-progress-interval="'.$interval.'" data-progress-target="'.$target.'" data-progress="' . $options['url'] . '" data-progress-mode="'.varset($options['mode'],0).'" data-progress-show="'.$nextStep.'" data-progress-hide="'.$buttonId.'" class="btn btn-primary e-progress" >'.$options['btn-label'].'</a>';
$text .= ' <a data-progress-target="'.$target.'" class="btn btn-danger e-progress-cancel" >'.LAN_CANCEL.'</a>'; $text .= ' <a data-progress-target="'.$target.'" class="btn btn-danger e-progress-cancel" >'.LAN_CANCEL.'</a>';
} }
@@ -3336,17 +3338,34 @@ class e_form
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
$methodParms = call_user_func_array(array($this, $method), array($value, 'inline', $parms)); $methodParms = call_user_func_array(array($this, $method), array($value, 'inline', $parms));
if($attributes['inline'] === 'checklist') if(is_string($attributes['inline'])) // text, textarea, select, checklist.
{ {
$xtype = 'checklist'; switch ($attributes['inline'])
} {
else
{ case 'checklist':
$xtype = 'select'; $xtype = 'checklist';
break;
case 'select':
$xtype = 'select';
break;
case 'textarea':
$xtype = 'textarea';
break;
default:
$xtype = 'text';
$methodParms = null;
break;
}
} }
$value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $methodParms); $value = $this->renderInline($field, $id, $attributes['title'], $_value, $value, $xtype, $methodParms);
// $source = str_replace('"',"'",json_encode($methodParms, JSON_FORCE_OBJECT)); // $source = str_replace('"',"'",json_encode($methodParms, JSON_FORCE_OBJECT));

View File

@@ -696,8 +696,19 @@ class e107MailManager
// print_a($email); // print_a($email);
if($this->debugMode)
{
$logName = "mailout_simulation_".$email['mail_source_id'];
e107::getLog()->addDebug("Sending Email to <".$email['mail_recipient_name']."> ".$email['mail_recipient_email'])->toFile($logName,'Mailout Simulation Log',true);
$result = true;
}
else
{
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE);
}
// Try and send // Try and send
$result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE);
// return; // ************************************************** Temporarily stop DB being updated when line active ***************************** // return; // ************************************************** Temporarily stop DB being updated when line active *****************************
@@ -738,20 +749,19 @@ class e107MailManager
if (count($targetData)) if (count($targetData))
{ {
//print_a($targetData); //print_a($targetData);
$this->db2->db_Update('mail_recipients', array('data' => $targetData, $this->db2->update('mail_recipients', array('data' => $targetData, '_FIELD_TYPES' => $this->dbTypes['mail_recipients'], 'WHERE' => '`mail_target_id` = '.intval($email['mail_target_id'])));
'_FIELD_TYPES' => $this->dbTypes['mail_recipients'],
'WHERE' => '`mail_target_id` = '.intval($email['mail_target_id'])));
} }
if (count($this->currentBatchInfo)) if (count($this->currentBatchInfo))
{ {
//print_a($this->currentBatchInfo); //print_a($this->currentBatchInfo);
$this->db2->db_Update('mail_content', array('data' => $this->currentBatchInfo, $this->db2->update('mail_content', array('data' => $this->currentBatchInfo,
'_FIELD_TYPES' => $this->dbTypes['mail_content'], '_FIELD_TYPES' => $this->dbTypes['mail_content'],
'WHERE' => '`mail_source_id` = '.intval($email['mail_source_id']))); 'WHERE' => '`mail_source_id` = '.intval($email['mail_source_id'])));
} }
if (($this->currentBatchInfo['mail_togo_count'] == 0) && ($email['mail_notify_complete'] > 0)) if (($this->currentBatchInfo['mail_togo_count'] == 0) && ($email['mail_notify_complete'] > 0)) // Need to notify completion
{ // Need to notify completion {
$email = array_merge($email, $this->currentBatchInfo); // This should ensure the counters are up to date $email = array_merge($email, $this->currentBatchInfo); // This should ensure the counters are up to date
$mailInfo = LAN_MAILOUT_247.'<br />'.LAN_MAILOUT_135.': '.$email['mail_title'].'<br />'.LAN_MAILOUT_248.$this->statusToText($email['mail_content_status']).'<br />'; $mailInfo = LAN_MAILOUT_247.'<br />'.LAN_MAILOUT_135.': '.$email['mail_title'].'<br />'.LAN_MAILOUT_248.$this->statusToText($email['mail_content_status']).'<br />';
$mailInfo .= '<br />'.LAN_MAILOUT_249.'<br />'; $mailInfo .= '<br />'.LAN_MAILOUT_249.'<br />';
@@ -765,20 +775,17 @@ class e107MailManager
'mail_body' => $mailInfo.'<br />' 'mail_body' => $mailInfo.'<br />'
); );
if ($email['mail_notify_complete'] & 1) if ($email['mail_notify_complete'] & 1) // Notify email initiator
{ // Notify email initiator {
if ($this->db2->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->fetch(MYSQL_ASSOC); $row = $this->db2->fetch();
require_once(e_HANDLER.'mail.php'); e107::getEmail()->sendEmail($row['user_name'], $row['user_email'], $message,FALSE);
$mailer = new e107Email();
$mailer->sendEmail($row['user_name'], $row['user_email'], $message,FALSE);
} }
} }
if ($email['mail_notify_complete'] & 2) if ($email['mail_notify_complete'] & 2) // Do e107 notify
{ // Do e107 notify {
require_once(e_HANDLER."notify_class.php"); require_once(e_HANDLER."notify_class.php");
notify_maildone($message); notify_maildone($message);
} }
e107::getEvent()->trigger('maildone', $email); e107::getEvent()->trigger('maildone', $email);
@@ -874,7 +881,7 @@ class e107MailManager
} }
$title = "<h4>".__METHOD__." Line: ".__LINE__."</h4>"; $title = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
e107::getAdminLog()->addDebug($title.print_a($email,true),true); // e107::getAdminLog()->addDebug($title.print_a($email,true),true);
if(!empty($email['mail_media'])) if(!empty($email['mail_media']))
{ {
@@ -882,7 +889,7 @@ class e107MailManager
} }
$title2 = "<h4>".__METHOD__." Line: ".__LINE__."</h4>"; $title2 = "<h4>".__METHOD__." Line: ".__LINE__."</h4>";
e107::getAdminLog()->addDebug($title2.print_a($result,true),true); // e107::getAdminLog()->addDebug($title2.print_a($result,true),true);
$result['shortcodes']['MAILREF'] = $email['mail_source_id']; $result['shortcodes']['MAILREF'] = $email['mail_source_id'];
@@ -1630,7 +1637,7 @@ class e107MailManager
$log = e107::getAdminLog(); $log = e107::getAdminLog();
$log->addDebug(print_a($emailData, true),true); $log->addDebug(print_a($emailData, true),true);
$log->addDebug(print_a($recipientData, true),true); $log->addDebug(print_a($recipientData, true),true);
$log->toFile('mail_manager','Main Manager Log',true); $log->toFile('mail_manager','Mail Manager Log',true);
if (!is_array($emailData)) if (!is_array($emailData))
@@ -1723,6 +1730,11 @@ class e107MailManager
// Fill in other bits of email // Fill in other bits of email
$emailData['mail_target_info'] = $recip; $emailData['mail_target_info'] = $recip;
$mailToSend = $this->makeEmailBlock($emailData); // Substitute mail-specific variables, attachments etc $mailToSend = $this->makeEmailBlock($emailData); // Substitute mail-specific variables, attachments etc
if (FALSE == $this->mailer->sendEmail($recip['mail_recipient_email'], $recip['mail_recipient_name'], $mailToSend, TRUE)) if (FALSE == $this->mailer->sendEmail($recip['mail_recipient_email'], $recip['mail_recipient_name'], $mailToSend, TRUE))
{ {
$tempResult = FALSE; $tempResult = FALSE;