diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 8590cfdfb..5386f85b3 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -146,7 +146,9 @@ class mailout_admin extends e_admin_dispatcher // 'makemail/makemail' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W', 'url'=>e_SELF), 'main/list' => array('caption'=> LAN_MANAGE, 'perm'=> 'W'), 'main/create' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W'), + 'recipients/list' => array('caption'=> "Recipients", 'perm' => 'W'), + // 'main/send' => array('caption'=> "Send", 'perm' => 'W'), 'other' => array('divider'=> true), 'saved/list' => array('caption'=> LAN_MAILOUT_191, 'perm' => 'W'), 'pending/list' => array('caption'=> LAN_MAILOUT_193, 'perm' => 'W'), @@ -161,7 +163,7 @@ class mailout_admin extends e_admin_dispatcher protected $adminMenuAliases = array( - // 'main/edit' => 'main/list', + 'main/send' => 'main/create', ); protected $menuTitle = LAN_MAILOUT_15; @@ -207,9 +209,9 @@ class mailout_main_ui extends e_admin_ui 'mail_bounce_count' => array('title' => LAN_MAILOUT_144, 'noedit'=>true, 'type'=>'number'), 'mail_start_send' => array('title' => LAN_MAILOUT_131,'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), 'mail_end_send' => array('title' => LAN_MAILOUT_132, 'noedit'=>true, 'type'=>'number', 'proc' => 'sdatetime'), - 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'noedit'=>true, 'type'=>'datestamp', 'proc' => 'sdatetime'), - 'mail_creator' => array('title' => LAN_MAILOUT_85, 'noedit'=>true, 'type'=>'user', 'proc' => 'username'), - 'mail_create_app' => array('title' => LAN_MAILOUT_133, 'noedit'=>true), + 'mail_create_date' => array('title' => LAN_MAILOUT_130, 'type'=>null, 'noedit'=>true, 'data'=>'int', 'type'=>'number'), + 'mail_creator' => array('title' => LAN_MAILOUT_85, 'type'=>null, 'noedit'=>true, 'data'=>'int'), + 'mail_create_app' => array('title' => LAN_MAILOUT_133, 'type'=>null, 'noedit'=>true,'data'=>'str'), 'mail_e107_priority' => array('title' => LAN_MAILOUT_134, 'noedit'=>true), 'mail_notify_complete' => array('title' => LAN_MAILOUT_243, 'noedit'=>true, 'nolist' => true), 'mail_last_date' => array('title' => LAN_MAILOUT_129, 'noedit'=>true, 'type'=>'int', 'proc' => 'sdatetime'), @@ -302,11 +304,14 @@ class mailout_main_ui extends e_admin_ui } else { - $this->fields['options']['type'] = ''; + // $this->fields['options']['type'] = ''; } $this->fields['mail_content_status']['writeParms'] = $types; + $this->processSendActions(); + + if (getperms('0')) { @@ -351,6 +356,7 @@ class mailout_main_ui extends e_admin_ui $ret['mail_create_date'] = time(); $ret['mail_creator'] = USERID; + $ret['mail_create_app'] = 'core'; $ret['mail_content_status'] = 20; // Default status is 'Saved'; return $ret; @@ -360,10 +366,122 @@ class mailout_main_ui extends e_admin_ui public function beforeUpdate($new_data, $old_data, $id) { - return $this->processData($new_data); + $ret = $this->processData($new_data); + + return $ret; } + + + + private function processSendActions() + { + + if((vartrue($_POST['email_sendnow']) || vartrue($_POST['email_send']) || vartrue($_POST['email_hold']) || vartrue($_POST['email_cancel'])) && !vartrue($_POST['email_id'])) + { + e107::getMessage()->addError("No Message ID submitted"); + return; + } + + $id = intval($_POST['email_id']); + + if(vartrue($_POST['email_sendnow'])) + { + $this->emailSendNow($id); + } + + if(vartrue($_POST['email_send'])) + { + $this->emailSend($id); + } + + if(vartrue($_POST['email_hold'])) + { + $this->emailHold($id); + } + + if(vartrue($_POST['email_cancel'])) + { + $this->emailCancel($id); + } + + } + + private function checkForId() + { + + + } + + private function emailSendNow($mailId) + { + e107::getMessage()->addInfo("'Send Now' is Under Construction"); + } + + + + private function emailSend($mailId) + { + $log = e107::getAdminLog(); + + $notify = isset($_POST['mail_notify_complete']) ? 3 : 2; + $first = 0; + $last = 0; // Set defaults for earliest and latest send times. + // TODO: Save these fields + if (isset($_POST['mail_earliest_time'])) + { + $first = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, FALSE); + } + if (isset($_POST['mail_latest_time'])) + { + $last = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, TRUE); + } + if ($this->mailAdmin->activateEmail($mailId, FALSE, $notify, $first, $last)) + { + e107::getMessage()->addSuccess(LAN_MAILOUT_185); + $log->log_event('MAIL_06','ID: '.$mailId,E_LOG_INFORMATIVE,''); + } + else + { + $errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_188); + } + } + + + + private function emailHold($mailId) + { + if ($this->mailAdmin->activateEmail($mailId, TRUE)) + { + e107::getMessage()->addSuccess(str_replace('--ID--', $mailId, LAN_MAILOUT_187)); + } + else + { + $errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_166); + } + } + + + + private function emailCancel($mailId) + { + if ($this->mailAdmin->cancelEmail($mailId)) + { + e107::getMessage()->addSuccess(str_replace('--ID--', $mailId, LAN_MAILOUT_220)); + } + else + { + $errors[] = str_replace('--ID--', $mailId, LAN_MAILOUT_221); + } + } + + + + + + + /** * Process Posted Data */ @@ -413,7 +531,23 @@ class mailout_main_ui extends e_admin_ui } */ + function sendPage() + { + + $id = $this->getId(); + + $mailData = e107::getDb()->retrieve('mail_content','*','mail_source_id='.intval($id)); + + if(empty($mailData)) + { + e107::getMessage()->addError("Couldn't retrieve mail data for id: ".$id); + return ''; + } + return $this->mailAdmin->sendEmailCircular($mailData, $fromHold); + + + } function maintPage() { @@ -978,10 +1112,26 @@ class mailout_admin_form_ui extends e_admin_form_ui } - function options() + function options($parms, $value, $id, $attributes) { $controller = $this->getController(); + + + $mode = $this->getController()->getMode(); + + if($mode == 'main') + { + $text = ""; + + + $link = e_SELF."?mode=main&action=send&id=".$id; + $text .= "".E_32_MAIL.""; + $text .= $this->renderValue('options',$value,$att,$id); + + return $text; + } + $mode = $controller->getMode(); $mailData = $controller->getListModel()->getData(); @@ -1022,7 +1172,7 @@ class mailout_recipients_ui extends e_admin_ui '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_status' => array('title' => LAN_MAILOUT_138, 'thclass' => 'left', 'class'=>'left', 'proc' => 'contentstatus'), 'mail_detail_id' => array('title' => LAN_MAILOUT_137, 'type'=>'dropdown', 'filter'=>true), 'mail_send_date' => array('title' => LAN_MAILOUT_139, 'proc' => 'sdatetime'), 'mail_target_info' => array('title' => LAN_MAILOUT_148, 'proc' => 'array'), @@ -1240,6 +1390,7 @@ switch ($action) } break; */ + /* case 'mailedit' : // Edit existing mail if (isset($_POST['mailaction'])) { @@ -1252,7 +1403,8 @@ switch ($action) } } break; - + */ + case 'makemail' : $newMail = TRUE; diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 7120b2e36..68d076420 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1944,6 +1944,7 @@ class e_form case 'create': case 'import': case 'submit': + case 'success': $options['class'] .= 'btn-success'; break; @@ -1956,6 +1957,7 @@ class e_form break; case 'delete': + case 'danger': $options['class'] .= 'btn-danger'; $options['other'] = 'data-confirm="'.LAN_JSCONFIRM.'"'; break; @@ -1966,6 +1968,7 @@ class e_form case 'other': case 'login': + case 'primary': $options['class'] .= 'btn-primary'; break; diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php index a7650e810..fc51bc3e4 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 diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 448c2f67e..23fe3c022 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -297,6 +297,7 @@ class mailoutAdminClass extends e107MailManager * @param $target - display mode * @return none */ + /* public function mailbodySaveColumnPref($target) { global $user_pref; @@ -313,7 +314,7 @@ class mailoutAdminClass extends e107MailManager $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 @@ -819,6 +820,7 @@ class mailoutAdminClass extends e107MailManager * @param $mailSource - array of mail information * @return text for display */ + /* function show_mailform(&$mailSource) { global $HANDLERS_DIRECTORY; @@ -882,14 +884,14 @@ class mailoutAdminClass extends e107MailManager // Add in the core and any plugin selectors here - + */ /*$text .= "