From 41ee837c7e5904007b07ceb369a93a5e0b2e5bad Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 27 Oct 2014 18:31:17 -0700 Subject: [PATCH] Mailout ajax process timing correction and log file added in debug mode. --- e107_admin/mailout.php | 12 +++++-- e107_handlers/form_handler.php | 35 ++++++++++++++----- e107_handlers/mail_manager_class.php | 50 +++++++++++++++++----------- 3 files changed, 67 insertions(+), 30 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 7c6261ee7..9925917e1 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -98,8 +98,10 @@ function sendProgress($id) ob_start(); + $perAjaxHit = e107::getConfig()->get('mail_pause',1); + $mailManager = new e107MailManager(); - $mailManager->doEmailTask(varset($pref['mail_workpertick'],5)); + $mailManager->doEmailTask($perAjaxHit); $sqld = e107::getDb('progress'); @@ -716,6 +718,8 @@ class mailout_main_ui extends e_admin_ui function sendnowPage() { $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_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 { - $text = "

Ready to Process Mail Queue

"; - $text .= e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start #'.$id, 'url'=> e_SELF, 'mode'=>$id)); + $pause = e107::getConfig()->get('mail_pausetime',1); + $interval = ($pause * 1000); + + $text = e107::getForm()->progressBar('mail-progress',1, array('btn-label'=>'Start', 'interval'=>$interval, 'url'=> e_SELF, 'mode'=>$id)); } return $text; diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index d8a7df080..1eb8ec36a 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1116,11 +1116,13 @@ class e_form $buttonId = $target.'-start'; + + if(vartrue($options['btn-label'])) { - $text .= ''.$options['btn-label'].''; + $interval = vartrue($options['interval'],1000); + $text .= ''.$options['btn-label'].''; $text .= ' '.LAN_CANCEL.''; - } @@ -3336,14 +3338,31 @@ class e_form $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); $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']) + { + + case 'checklist': + $xtype = 'checklist'; + break; + + case 'select': + $xtype = 'select'; + break; + + case 'textarea': + $xtype = 'textarea'; + break; + + + default: + $xtype = 'text'; + $methodParms = null; + break; + } } - else - { - $xtype = 'select'; - } + diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index 5095f1d5a..58413588d 100644 --- a/e107_handlers/mail_manager_class.php +++ b/e107_handlers/mail_manager_class.php @@ -696,8 +696,19 @@ class e107MailManager // 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 - $result = $this->mailer->sendEmail($email['mail_recipient_email'], $email['mail_recipient_name'], $mailToSend, TRUE); + // return; // ************************************************** Temporarily stop DB being updated when line active ***************************** @@ -738,20 +749,19 @@ class e107MailManager if (count($targetData)) { //print_a($targetData); - $this->db2->db_Update('mail_recipients', array('data' => $targetData, - '_FIELD_TYPES' => $this->dbTypes['mail_recipients'], - 'WHERE' => '`mail_target_id` = '.intval($email['mail_target_id']))); + $this->db2->update('mail_recipients', array('data' => $targetData, '_FIELD_TYPES' => $this->dbTypes['mail_recipients'], 'WHERE' => '`mail_target_id` = '.intval($email['mail_target_id']))); } + if (count($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'], 'WHERE' => '`mail_source_id` = '.intval($email['mail_source_id']))); } - if (($this->currentBatchInfo['mail_togo_count'] == 0) && ($email['mail_notify_complete'] > 0)) - { // Need to notify completion + if (($this->currentBatchInfo['mail_togo_count'] == 0) && ($email['mail_notify_complete'] > 0)) // Need to notify completion + { $email = array_merge($email, $this->currentBatchInfo); // This should ensure the counters are up to date $mailInfo = LAN_MAILOUT_247.'
'.LAN_MAILOUT_135.': '.$email['mail_title'].'
'.LAN_MAILOUT_248.$this->statusToText($email['mail_content_status']).'
'; $mailInfo .= '
'.LAN_MAILOUT_249.'
'; @@ -765,20 +775,17 @@ class e107MailManager 'mail_body' => $mailInfo.'
' ); - if ($email['mail_notify_complete'] & 1) - { // Notify email initiator + if ($email['mail_notify_complete'] & 1) // Notify email initiator + { if ($this->db2->select('user', 'user_name, user_email', '`user_id`='.intval($email['mail_creator']))) { - $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); + $row = $this->db2->fetch(); + e107::getEmail()->sendEmail($row['user_name'], $row['user_email'], $message,FALSE); } } - if ($email['mail_notify_complete'] & 2) - { // Do e107 notify + if ($email['mail_notify_complete'] & 2) // Do e107 notify + { require_once(e_HANDLER."notify_class.php"); - notify_maildone($message); } e107::getEvent()->trigger('maildone', $email); @@ -874,7 +881,7 @@ class e107MailManager } $title = "

".__METHOD__." Line: ".__LINE__."

"; - e107::getAdminLog()->addDebug($title.print_a($email,true),true); + // e107::getAdminLog()->addDebug($title.print_a($email,true),true); if(!empty($email['mail_media'])) { @@ -882,7 +889,7 @@ class e107MailManager } $title2 = "

".__METHOD__." Line: ".__LINE__."

"; - 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']; @@ -1630,7 +1637,7 @@ class e107MailManager $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); + $log->toFile('mail_manager','Mail Manager Log',true); if (!is_array($emailData)) @@ -1723,6 +1730,11 @@ class e107MailManager // Fill in other bits of email $emailData['mail_target_info'] = $recip; $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)) { $tempResult = FALSE;