From 567fb01e122cb7b0695cd1f20be1e535bcf357cb Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 16 Oct 2014 19:04:24 -0700 Subject: [PATCH] Allow email to users to also be disabled via the mailout preferences. --- e107_admin/mailout.php | 10 +++-- e107_handlers/mailout_admin_class.php | 65 ++++++++++++++------------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 3b30859d6..a60e13766 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -854,11 +854,15 @@ class mailout_main_ui extends e_admin_ui "; $mail_enable = explode(',',$pref['mailout_enabled']); + + $coreCheck = (in_array('core',$mail_enable)) ? "checked='checked'" : ""; + $text .= $frm->checkbox('mail_mailer_enabled[]','core', $coreCheck, 'users'); foreach ($pref['e_mailout_list'] as $mailer => $v) { $check = (in_array($mailer,$mail_enable)) ? "checked='checked'" : ""; - $text .= "  {$mailer}
"; + $text .= $frm->checkbox('mail_mailer_enabled[]',$mailer,$check,$mailer); + // $text .= "  {$mailer}
"; } $text .= "\n"; @@ -1062,7 +1066,7 @@ class mailout_main_ui extends e_admin_ui $temp['mail_bounce_type'] = $tp->toDB($_POST['mail_bounce_type']); $temp['mail_bounce_delete'] = intval(varset($_POST['mail_bounce_delete'], 0)); - $temp['mailout_enabled'] = implode(',',varset($_POST['mail_mailer_enabled'], '')); + $temp['mailout_enabled'] = implode(',', varset($_POST['mail_mailer_enabled'], '')); $temp['mail_log_options'] = intval($_POST['mail_log_option']).','.intval($_POST['mail_log_email']); foreach ($temp as &$t) @@ -1096,7 +1100,7 @@ class mailout_admin_form_ui extends e_admin_form_ui switch($mode) { case 'read': - return varset($data['mail_send_style'], ''); + return varset($data['mail_selectors'], ''); break; case 'write': diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 6ae199246..a14c3b37d 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -546,19 +546,20 @@ 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 + $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 + + // 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 @@ -608,25 +609,19 @@ class mailoutAdminClass extends e107MailManager */ public function emailSelector($options = 'all', $selectorInfo = FALSE) { - $ret = ''; - $tab = ''; - $tabc = ''; + $tabs = array(); foreach($this->mailHandlers as $key => $m) { + 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 .= " + $text = "
@@ -635,31 +630,37 @@ class mailoutAdminClass extends e107MailManager foreach($content as $var) { - $tabc .= ""; + $text .= " + + + + "; } - $tabc .= "
" . $var['caption'] . "" . $var['html'] . "
" . $var['caption'] . "" . $var['html'] . "
"; + + $text .= ""; + } 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) *