From a21f57d361bd34f78e986db34ec7f378ba040f3a Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sun, 10 Jan 2010 03:56:28 +0000 Subject: [PATCH] Mailout bug fixes and ui cleanup --- e107_admin/mailout.php | 14 +- e107_handlers/form_handler.php | 16 +- e107_handlers/mailout_admin_class.php | 234 ++++++++++-------- e107_handlers/mailout_class.php | 152 ++++-------- e107_languages/English/admin/lan_mailout.php | 8 +- e107_plugins/calendar_menu/e_mailout.php | 57 +++-- .../languages/English_mailer.php | 8 +- e107_plugins/newsletter/e_mailout.php | 51 ++-- .../languages/English_admin_newsletter.php | 8 +- 9 files changed, 274 insertions(+), 274 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 425249bf3..0f28b4c24 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -9,9 +9,9 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_admin/mailout.php,v $ - * $Revision: 1.32 $ - * $Date: 2009-12-01 20:05:51 $ - * $Author: e107steved $ + * $Revision: 1.33 $ + * $Date: 2010-01-10 03:56:26 $ + * $Author: e107coders $ * */ @@ -468,7 +468,7 @@ if (is_array($errors) && (count($errors) > 0)) } if ($emessage->hasMessage()) { - $e107->ns->tablerender(LAN_MAILOUT_97, $emessage->render()); + $ns->tablerender(LAN_MAILOUT_97, $emessage->render()); } @@ -887,7 +887,9 @@ function show_prefs($mailAdmin) //----------------------------------------------------------- function show_maint($debug = FALSE) { - $e107 = e107::getInstance(); + $mes = e107::getMessage(); + $ns = e107::getRender(); + $text = "
"; $text .= " @@ -904,7 +906,7 @@ function show_maint($debug = FALSE) $text .= "".LAN_MAILOUT_182."
".LAN_MAILOUT_252.""; $text .= "\n
"; - $e107->ns->tablerender("
".ADLAN_136." :: ".ADLAN_40."
", $text); + $ns->tablerender("
".ADLAN_136." :: ".ADLAN_40."
", $mes->render().$text); // $text .= ""; } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index b710c8a1d..5f52d9498 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -9,8 +9,8 @@ * Form Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ - * $Revision: 1.111 $ - * $Date: 2010-01-07 23:44:33 $ + * $Revision: 1.112 $ + * $Date: 2010-01-10 03:56:27 $ * $Author: e107coders $ * */ @@ -439,12 +439,13 @@ class e_form /** * * @param object $name - * @param object $option_array + * @param array $option_array * @param object $selected [optional] * @param object $options [optional] + * @param boolean $defaultBlank [optional] set to TRUE if the first entry should be blank * @return string HTML text for display */ - function selectbox($name, $option_array, $selected = false, $options = array()) + function selectbox($name, $option_array, $selected = false, $options = array(),$defaultBlank= false) { if(!is_array($options)) parse_str($options, $options); @@ -455,9 +456,14 @@ class e_form $text = $this->select_open($name, $options)."\n"; if(vartrue($options['default'])) - { + { $text .= $this->option($options['default'],''); } + + if(vartrue($defaultBlank)) + { + $text .= $this->option(' ',''); + } $text .= $this->option_multi($option_array, $selected)."\n".$this->select_close(); return $text; diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 30b6fcc2a..c83e01b7c 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -9,9 +9,9 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_handlers/mailout_admin_class.php,v $ - * $Revision: 1.10 $ - * $Date: 2010-01-04 21:35:38 $ - * $Author: e107steved $ + * $Revision: 1.11 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ @@ -19,8 +19,8 @@ * * @package e107 * @subpackage e107_handlers - * @version $Revision: 1.10 $ - * @author $Author: e107steved $ + * @version $Revision: 1.11 $ + * @author $Author: e107coders $ * Various admin-related mailout functions, mostly to do with creating and handling forms. */ @@ -409,17 +409,15 @@ class mailoutAdminClass extends e107MailManager { global $pref; - - $ret = 0; $toLoad = explode(',', $options); if (in_array('core', $toLoad) || ($options == 'all')) { require_once(e_HANDLER.'mailout_class.php'); - $this->mailHandlers[] = new core_mailout($this); // Start by loading the core mailout class + $this->mailHandlers[] = new core_mailout; // Start by loading the core mailout class $ret++; } - + $active_mailers = explode(',',varset($pref['mailout_enabled'],'')); // Load additional configured handlers @@ -439,7 +437,7 @@ class mailoutAdminClass extends e107MailManager $temp = new $mailClass; if ($temp->mailerEnabled) { - $this->mailHandlers[] = &$temp; + $this->mailHandlers[] = $temp; $ret++; if (varset($mailerExcludeDefault,FALSE) && isset($this->mailHandlers[0]) && ($this->mailHandlers[0]->mailerSource == 'core')) { @@ -473,14 +471,49 @@ class mailoutAdminClass extends e107MailManager public function emailSelector($options = 'all', $selectorInfo = FALSE) { $ret = ''; - foreach ($this->mailHandlers as $m) + $tab = ''; + $tabc = ''; + + $ret .= "
\n"; + + foreach ($this->mailHandlers as $key=>$m) { if ($m->mailerEnabled) { - $ret .= "".$m->mailerName."".$m->showSelect(TRUE, varset($selectorInfo[$m->mailerSource], FALSE)).""; + $tab .= "
  • ".$m->mailerName."
  • "; + $tabc .= "
    "; + + $content = $m->showSelect(TRUE, varset($selectorInfo[$m->mailerSource], FALSE)); + + if(is_array($content)) + { + $tabc .= " + + + + + "; + + foreach($content as $var) + { + $tabc .= ""; + } + $tabc .= "
    ".$var['caption']."".$var['html']."
    "; + } + else + { + $tabc .= $content; //BC (0.8 only) but should be deprecated + } + + $tabc .= "
    "; } } + $ret .= ""; + $ret .= $tabc; + $ret .= "
    "; + return $ret; + } @@ -706,117 +739,111 @@ class mailoutAdminClass extends e107MailManager { global $pref,$HANDLERS_DIRECTORY; global $mailAdmin; - + + $sql = e107::getDb(); + $ns = e107::getRender(); + $tp = e107::getParser(); + $frm = e107::getForm(); + $mes = e107::getMessage(); + if (!is_array($mailSource)) { - $this->e107->ns->tablerender('ERROR!!', 'Coding error - mail not array (521)'); - exit; + $mes = e107::getMessage(); + $mes->add('Coding error - mail not array (521)', E_MESSAGE_ERROR); + //$ns->tablerender('ERROR!!', ); + //exit; } $email_subject = varset($mailSource['mail_subject'], ''); - $email_body = $this->e107->tp->toForm(varset($mailSource['mail_body'],'')); + $email_body = $tp->toForm(varset($mailSource['mail_body'],'')); $email_id = varset($mailSource['mail_source_id'],''); + $text = ''; if(strpos($_SERVER['SERVER_SOFTWARE'],'mod_gzip') && !is_readable(e_HANDLER.'phpmailer/.htaccess')) { $warning = LAN_MAILOUT_40.' '.$HANDLERS_DIRECTORY.'phpmailer/ '.LAN_MAILOUT_41; - $this->e107->ns->tablerender(LAN_MAILOUT_42, $warning); + $ns->tablerender(LAN_MAILOUT_42, $warning); } $debug = (e_MENU == "debug") ? "?[debug]" : ""; + $text .= "
    + ".$this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE))." - - + + - - - "; - - - $text .=" - - - - "; - - - // Add in the core and any plugin selectors here - $text .= $this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE)); - - - - // CC, BCC - $text .= " - - - + + - - + + "; - - // Close one table, open another - to give a boundary between addressees and content - $text .= "
    ".LAN_MAILOUT_111.": - - ".LAN_MAILOUT_111.": ".$frm->text('email_title',varset($mailSource['mail_title'],''))."
    ".LAN_MAILOUT_01.": - -
    ".LAN_MAILOUT_02.": - -
    ".LAN_MAILOUT_04.": - - ".LAN_MAILOUT_01.": ".$frm->text('email_from_name',varset($mailSource['mail_from_name'],USERNAME))."
    ".LAN_MAILOUT_05.": - - ".LAN_MAILOUT_02.": ".$frm->text('email_from_email',varset($mailSource['mail_from_email'],USEREMAIL))."
    - - - - - "; - - // Subject + // Add in the core and any plugin selectors here + + /*$text .= " + + + + + ";*/ + $text .= " - - + + + + + + + + + + + + "; // Attachment. - if ($this->e107->isInstalled('download')) + if (e107::isInstalled('download')) { // TODO - use download plugin API - $text .= " + + if($sql->db_Select("download", "download_url,download_name", "download_id !='' ORDER BY download_name")) + { + $text .= " + "; } - $text .= " "; - $text .= " - "; + } @@ -825,22 +852,6 @@ class mailoutAdminClass extends e107MailManager \n - - - "; - - $text .=" - - \n + + + + "; + + $text .=" + +
    ".LAN_MAILOUT_03.": ".$this->emailSelector('all', varset($mailSource['mail_selectors'], FALSE))."
    ".LAN_MAILOUT_51.": - - ".LAN_MAILOUT_04.": ".$frm->text('email_cc',varset($mailSource['mail_cc'],''))."
    ".LAN_MAILOUT_05.": ".$frm->text('email_bcc',varset($mailSource['mail_bcc'],''))."
    ".LAN_MAILOUT_51.": ".$frm->text('email_subject',varset($email_subject,''))."
    ".LAN_MAILOUT_07.": "; - $text .= " \n"; - $this->e107->sql->db_Select("download", "download_url,download_name", "download_id !='' ORDER BY download_name"); - while ($row = $this->e107->sql->db_Fetch()) - { - $selected = ($mailSource['mail_attach'] == $row['download_url']) ? "selected='selected'" : ''; -// $text .= "\n"; - $text .= "\n"; + + while ($row = $this->e107->sql->db_Fetch()) + { + $selected = ($mailSource['mail_attach'] == $row['download_url']) ? "selected='selected'" : ''; + // $text .= "\n"; + $text .= "\n"; + } + $text .= " "; + + $text .= "
    ".LAN_MAILOUT_09.": \n"; - $text .= $this->sendStyleSelect($mailSource['mail_send_style']); - $checked = (isset($mailSource['mail_include_images']) && $mailSource['mail_include_images']) ? " checked='checked'" : ''; - $text .= "  ".LAN_MAILOUT_225; - $text .=" -
    - -
    -
    "; - global $eplug_bb; $eplug_bb[] = array( @@ -853,7 +864,23 @@ class mailoutAdminClass extends e107MailManager 'function_var' => 'sc_selector' ); - $text .= display_help('helpb','mailout'); + + $text .= $this->sendStyleSelect($mailSource['mail_send_style']); + $checked = (isset($mailSource['mail_include_images']) && $mailSource['mail_include_images']) ? " checked='checked'" : ''; + $text .= "  ".LAN_MAILOUT_225; + $text .=" +
     ".$frm->bbarea('email_body',$email_body,'mailout','helpb')."
    +
    "; + + // $text .= display_help('helpb','mailout'); if(e_WYSIWYG) { @@ -870,24 +897,27 @@ class mailoutAdminClass extends e107MailManager $text .= "
    "; + if($email_id) { - $text .= ""; - $text .= ""; + $text .= $frm->hidden('mail_source_id',$email_id); + $text .= $frm->admin_button('update_email',LAN_UPDATE); + //$text .= ""; + //$text .= ""; } else { - $text .= ""; + $text .= $frm->admin_button('save_email',LAN_SAVE); } - $text .="  + $text .= $frm->admin_button('send_email',LAN_MAILOUT_08); -
    + $text .= "
    "; - $this->e107->ns->tablerender(LAN_MAILOUT_15, $text); // Render the complete form + $ns->tablerender(LAN_MAILOUT_15,$mes->render(). $text); // Render the complete form } diff --git a/e107_handlers/mailout_class.php b/e107_handlers/mailout_class.php index 245a52707..e7c7f5d7e 100644 --- a/e107_handlers/mailout_class.php +++ b/e107_handlers/mailout_class.php @@ -9,9 +9,9 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_handlers/mailout_class.php,v $ - * $Revision: 1.6 $ - * $Date: 2009-12-01 20:05:53 $ - * $Author: e107steved $ + * $Revision: 1.7 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ @@ -47,11 +47,11 @@ class core_mailout { protected $mailCount = 0; protected $mailRead = 0; - protected $e107; + // protected $e107; public $mailerSource = 'core'; // Plugin name (core mailer is special case) Must be directory for this file public $mailerName = LAN_MAILOUT_68; // Text to identify the source of selector (displayed on left of admin page) public $mailerEnabled = TRUE; // Mandatory - set to FALSE to disable this plugin (e.g. due to permissions restrictions) - protected $adminHandler = NULL; // Filled in with the name of the admin handler on creation + // protected $adminHandler = NULL; // Filled in with the name of the admin handler on creation // List of fields used by selectors private $selectFields = array('email_to', @@ -64,8 +64,9 @@ class core_mailout // Constructor public function __construct() { - $this->e107 = e107::getInstance(); - $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions + //FIXME Bad for Performance and causes data conflicts. + // $this->e107 = e107::getInstance(); + // $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions } @@ -250,125 +251,58 @@ class core_mailout */ public function showSelect($allow_edit = FALSE, $selectVals = FALSE) { - $ret = ""; - - $ret = "
    -
    - - - - - "; - + $frm = e107::getForm(); + $sql = e107::getDb(); + $admin = e107::getRegistry('_mailout_admin'); + + $var = array(); + + $var[0]['caption'] = LAN_MAILOUT_03; // User class select + $var[1]['caption'] = LAN_MAILOUT_46; // User Search Field. + $var[2]['caption'] = LAN_MAILOUT_56; // User last visit + $var[3]['caption'] = LAN_MAILOUT_46; // Extended user field + $var[4]['caption'] = LAN_MAILOUT_46; // Extended user field + if ($allow_edit) { - // User class select - $ret .= " - - - "; - - // User Search Field. $u_array = array('user_name'=>LAN_MAILOUT_43,'user_login'=>LAN_MAILOUT_44,'user_email'=>LAN_MAILOUT_45); - $ret .= " - - - - "; - - // User last visit - $ret .= " - - "; - - - // Extended user fields - $ret .= " - - - - - "; + + $var[0]['html'] = $admin->userClassesTotals('email_to', varset($selectVals['email_to'], '')); + $var[1]['html'] = $frm->selectbox('user_search_name', $u_array, $selectVals['user_search_name'],'',TRUE)." ".LAN_MAILOUT_47." ".$frm->text('user_search_value', $selectVals['user_search_value']); + $var[2]['html'] = $admin->comparisonSelect('last_visit_match', $selectVals['last_visit_match'])." ".$frm->text('last_visit_date', $selectVals['last_visit_date']); + $var[3]['html'] = $admin->ret_extended_field_list('extended_1_name', varset($selectVals['extended_1_name'], ''), TRUE).LAN_MAILOUT_48." ".$frm->text('extended_1_value',$selectVals['extended_1_value']); + $var[4]['html'] = $admin->ret_extended_field_list('extended_2_name', varset($selectVals['extended_2_name'], ''), TRUE).LAN_MAILOUT_48." ".$frm->text('extended_2_value',$selectVals['extended_2_value']); + } - else - { // Display existing values + else // Display existing values + { if(is_numeric($selectVals['email_to'])) { - $this->e107->sql->db_Select('userclass_classes', 'userclass_name', "userclass_id = ".intval($selectVals['email_to'])); - $row = $this->e107->sql->db_Fetch(); + $sql->db_Select('userclass_classes', 'userclass_name', "userclass_id = ".intval($selectVals['email_to'])); + $row = $sql->db_Fetch(); $_to = LAN_MAILOUT_23.$row['userclass_name']; } else { $_to = $selectVals['email_to']; } - $ret .= " - - "; - - - if (vartrue($selectVals['user_search_name']) && vartrue($selectVals['user_search_value'])) - { - $ret .= " - - - - "; - } - - if (vartrue($selectVals['last_visit_match']) && vartrue($selectVals['last_visit_date'])) - { - $ret .= " - - - - "; - } - - if (vartrue($selectVals['extended_1_name']) && vartrue($selectVals['extended_1_value'])) - { - $ret .= " - - - - "; - } - if (vartrue($selectVals['extended_2_name']) && vartrue($selectVals['extended_2_value'])) - { - $ret .= " - - - - "; + $var_0 .= "<".USEREMAIL.">"; } + + $var[0]['html'] = $var_0; + $var[1]['html'] = vartrue($selectVals['user_search_name'])." ". vartrue($selectVals['user_search_value']); + $var[2]['html'] = vartrue($selectVals['last_visit_match']).' '.gmstrftime("%D-%M-%Y",vartrue($selectVals['last_visit_date'])); //FIXME use e107 date function. + $var[3]['html'] = vartrue($selectVals['extended_1_name']).' '.vartrue($selectVals['extended_1_value']); + $var[4]['html'] = vartrue($selectVals['extended_2_name']).' '.vartrue($selectVals['extended_2_value']); + } - return $ret.'
    ".LAN_MAILOUT_03.": - ".$this->adminHandler->userClassesTotals('email_to', varset($selectVals['email_to'], ''))."
    ".LAN_MAILOUT_46." - ".LAN_MAILOUT_47." - -
    ".LAN_MAILOUT_56.' '.$this->adminHandler->comparisonSelect('last_visit_match', $selectVals['last_visit_match'])." - -
    ".LAN_MAILOUT_46.$this->adminHandler->ret_extended_field_list('extended_1_name', varset($selectVals['extended_1_name'], ''), TRUE).LAN_MAILOUT_48." - -
    ".LAN_MAILOUT_46.$this->adminHandler->ret_extended_field_list('extended_2_name', varset($selectVals['extended_2_name'], ''), TRUE).LAN_MAILOUT_48." - -
    ".LAN_MAILOUT_03."".$_to." "; + + $var_0 = $_to." "; if($selectVals['email_to'] == "self") { - $text .= "<".USEREMAIL.">"; - } - $ret .= "
    ".$selectVals['user_search_name']."".varset($selectVals['user_search_value'])." 
    ".LAN_MAILOUT_56."".$selectVals['last_visit_match'].' '.gmstrtotime("%D-%M-%Y",$selectVals['last_visit_date'])." 
    ".$selectVals['extended_1_name']."".$selectVals['extended_1_value']." 
    ".$selectVals['extended_2_name']."".$selectVals['extended_2_value']." 
    '; + return $var; + } } diff --git a/e107_languages/English/admin/lan_mailout.php b/e107_languages/English/admin/lan_mailout.php index 50e089332..7eb001416 100644 --- a/e107_languages/English/admin/lan_mailout.php +++ b/e107_languages/English/admin/lan_mailout.php @@ -9,9 +9,9 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_mailout.php,v $ - * $Revision: 1.15 $ - * $Date: 2009-12-01 20:05:54 $ - * $Author: e107steved $ + * $Revision: 1.16 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ @@ -85,7 +85,7 @@ define('LAN_MAILOUT_57', 'Send bulk SMTP emails in blocks'); // SMTP KeepAlive //define('LAN_MAILOUT_65', 'seconds'); //define('LAN_MAILOUT_66', 'Cancelled Successfully'); define('LAN_MAILOUT_67', 'The email could not be sent. Please review your SMTP settings, or select another mailing method and try again.'); -define('LAN_MAILOUT_68','Include from registered users'); +define('LAN_MAILOUT_68','Registered Users'); define('LAN_MAILOUT_69','matches, after '); define('LAN_MAILOUT_70',' duplicates stripped.'); define('LAN_MAILOUT_71','Total emails to send'); diff --git a/e107_plugins/calendar_menu/e_mailout.php b/e107_plugins/calendar_menu/e_mailout.php index 42b4128f2..ad5ec09d8 100644 --- a/e107_plugins/calendar_menu/e_mailout.php +++ b/e107_plugins/calendar_menu/e_mailout.php @@ -9,9 +9,9 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/e_mailout.php,v $ - * $Revision: 1.8 $ - * $Date: 2009-12-20 22:47:28 $ - * $Author: e107steved $ + * $Revision: 1.9 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ @@ -20,7 +20,7 @@ * * @package e107_plugins * @subpackage event_calendar - * @version $Id: e_mailout.php,v 1.8 2009-12-20 22:47:28 e107steved Exp $; + * @version $Id: e_mailout.php,v 1.9 2010-01-10 03:56:28 e107coders Exp $; */ if (!defined('e107_INIT')) { exit(); } @@ -41,19 +41,15 @@ class calendar_menu_mailout { protected $mailCount = 0; protected $mailRead = 0; - protected $e107; - public $mailerSource = 'calendar_menu'; // Plugin name (core mailer is special case) Must be directory for this file + public $mailerSource = 'calendar_menu'; //FIXME should be auto-detected // Plugin name (core mailer is special case) Must be directory for this file public $mailerName = LAN_EC_MAIL_01; // Text to identify the source of selector (displayed on left of admin page) public $mailerEnabled = TRUE; // Mandatory - set to FALSE to disable this plugin (e.g. due to permissions restrictions) - protected $adminHandler = NULL; // Filled in with the name of the admin handler on creation private $selectorActive = FALSE; // Set TRUE if we've got a valid selector to start returning entries // Constructor public function __construct() { - $this->e107 = e107::getInstance(); - $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions } @@ -90,6 +86,9 @@ class calendar_menu_mailout */ public function selectInit($selectVals = FALSE) { + + $sql = e107::getDb(); + if (($selectVals === FALSE) || ($selectVals == '')) { return 0; // No valid selector - so no valid records @@ -100,7 +99,7 @@ class calendar_menu_mailout $qry .= ' LEFT JOIN `#user` AS u ON es.`event_subid` = u.`user_id` WHERE es.`event_cat` IN (\''.$selectVals.'\') AND u.`user_id` IS NOT NULL'; $qry .= ' GROUP BY u.`user_id`'; // echo "Selector query: ".$qry.'
    '; - if (!( $this->mail_count = $this->e107->sql->db_Select_gen($qry))) return FALSE; + if (!( $this->mail_count = $sql->db_Select_gen($qry))) return FALSE; $this->selectorActive = TRUE; $this->mail_read = 0; return $this->mail_count; @@ -120,8 +119,10 @@ class calendar_menu_mailout */ public function selectAdd() { + $sql = e107::getDb(); + if (!$this->selectorActive) return FALSE; - if (!($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC))) return FALSE; + if (!($row = $sql->db_Fetch(MYSQL_ASSOC))) return FALSE; $ret = array('mail_recipient_id' => $row['user_id'], 'mail_recipient_name' => $row['user_name'], // Should this use realname? 'mail_recipient_email' => $row['user_email'], @@ -154,35 +155,49 @@ class calendar_menu_mailout * @param boolean $allow_edit is TRUE to allow user to change the selection; FALSE to just display current settings * @param string $selectVals is the current selection information - in the same format as returned by returnSelectors() * - * @return string Returns HTML which is displayed in a table cell. Typically we return a complete table + * @return array Returns array which is displayed in a table cell. */ public function showSelect($allow_edit = FALSE, $selectVals = FALSE) { - $ret = ""; + $sql = e107::getDb(); + $frm = e107::getForm(); + + // $ret = "
    "; $selects = array_flip(explode(',', $selectVals)); - if ($this->e107->sql->db_Select('event_cat', 'event_cat_id, event_cat_name', "event_cat_name != 'Default'")) + if ($sql->db_Select('event_cat', 'event_cat_id, event_cat_name', "event_cat_name != 'Default'")) { - while ($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC)) + $c=0; + while ($row = $sql->db_Fetch(MYSQL_ASSOC)) { $checked = (isset($selects[$row['event_cat_id']])) ? " checked='checked'" : ''; if ($allow_edit) { - $ret .= ""; + $var[$c]['caption'] = $row['event_cat_name']; + $var[$c]['html'] = $frm->checkbox('ec_category_sel[]',$row['event_cat_id'],$checked); + + /*$ret .= "";*/ } elseif($checked) { - $ret .= ""; + $var[$c]['caption'] = $row['event_cat_name']; + $var[$c]['html'] = LAN_EC_MAIL_03; + + /*$ret .= "";*/ } + $c++; } } else { - $ret .= "'; + $var[0]['caption'] = LAN_EC_MAIL_02; + $var[0]['html'] = ''; } - return $ret.'
    - ".$row['event_cat_name']."
    + ".$row['event_cat_name']."
    ".LAN_EC_MAIL_03." - ".$row['event_cat_name']."
    ".LAN_EC_MAIL_03." + ".$row['event_cat_name']."
    ".LAN_EC_MAIL_02.'
    '; + + return $var; + // return $ret.'
    '; } } diff --git a/e107_plugins/calendar_menu/languages/English_mailer.php b/e107_plugins/calendar_menu/languages/English_mailer.php index a729592b4..3c315570a 100644 --- a/e107_plugins/calendar_menu/languages/English_mailer.php +++ b/e107_plugins/calendar_menu/languages/English_mailer.php @@ -9,13 +9,13 @@ * Event calendar - language file for mailout related routines * * $Source: /cvs_backup/e107_0.8/e107_plugins/calendar_menu/languages/English_mailer.php,v $ - * $Revision: 1.4 $ - * $Date: 2009-11-22 10:11:32 $ - * $Author: e107steved $ + * $Revision: 1.5 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ -define('LAN_EC_MAIL_01', 'Event calendar subscribers list'); +define('LAN_EC_MAIL_01', 'Event Calendar Subscribers'); define('LAN_EC_MAIL_02', 'No categories defined, or database error'); define('LAN_EC_MAIL_03', 'Category: '); define('LAN_EC_MAIL_04', 'Calendar Subscriptions'); diff --git a/e107_plugins/newsletter/e_mailout.php b/e107_plugins/newsletter/e_mailout.php index 1e1e4bb38..cfb7ce2e9 100644 --- a/e107_plugins/newsletter/e_mailout.php +++ b/e107_plugins/newsletter/e_mailout.php @@ -9,9 +9,9 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_plugins/newsletter/e_mailout.php,v $ - * $Revision: 1.2 $ - * $Date: 2009-12-01 20:05:54 $ - * $Author: e107steved $ + * $Revision: 1.3 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ @@ -34,11 +34,9 @@ class newsletter_mailout { protected $mailCount = 0; protected $mailRead = 0; - protected $e107; public $mailerSource = 'newsletter'; // Plugin name (core mailer is special case) Must be directory for this file public $mailerName = NLLAN_48; // Text to identify the source of selector (displayed on left of admin page) public $mailerEnabled = TRUE; // Mandatory - set to FALSE to disable this plugin (e.g. due to permissions restrictions) - protected $adminHandler = NULL; // Filled in with the name of the admin handler on creation private $selectorActive = FALSE; // Set TRUE if we've got a valid selector to start returning entries private $targets = array(); // Used to store potential recipients private $ourDB; @@ -47,8 +45,9 @@ class newsletter_mailout // Constructor public function __construct() { - $this->e107 = e107::getInstance(); - $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions + // BAD FOR PERFORMANCE + //$this->e107 = e107::getInstance(); + //$this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions } @@ -85,6 +84,9 @@ class newsletter_mailout */ public function selectInit($selectVals = FALSE) { + $sql = e107::getDb(); + + if (($selectVals === FALSE) || ($selectVals == '')) { return 0; // No valid selector - so no valid records @@ -92,7 +94,7 @@ class newsletter_mailout $qry = "SELECT newsletter_id,newsletter_subscribers FROM `#newsletter` WHERE (`newsletter_parent`=0) AND (`newsletter_id` IN ({$selectVals}))"; // echo "Selector {$selectVals} query: ".$qry.'
    '; - if (!($this->e107->sql->db_Select_gen($qry))) return FALSE; + if (!($sql->db_Select_gen($qry))) return FALSE; $this->selectorActive = TRUE; $this->mail_count = 1; // We have no idea of how many subscribers without reading all relevant DB records $this->mail_read = 0; @@ -114,13 +116,17 @@ class newsletter_mailout */ public function selectAdd() { + + $sql = e107::getDb(); + + if (!$this->selectorActive) return FALSE; while ($this->selectorActive) { if (count($this->targets) == 0) { // Read in and process another newletter mailing list - if (!($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC))) + if (!($row = $sql->db_Fetch(MYSQL_ASSOC))) { $this->selectorActive = FALSE; return FALSE; // Run out of DB records @@ -173,35 +179,42 @@ class newsletter_mailout * @param boolean $allow_edit is TRUE to allow user to change the selection; FALSE to just display current settings * @param string $selectVals is the current selection information - in the same format as returned by returnSelectors() * - * @return string Returns HTML which is displayed in a table cell. Typically we return a complete table + * @return array Returns array which is displayed in a table cell */ public function showSelect($allow_edit = FALSE, $selectVals = FALSE) { - $ret = ""; + $sql = e107::getDb(); + $frm = e107::getForm(); + $selects = array_flip(explode(',', $selectVals)); - if ($this->e107->sql->db_Select('newsletter', 'newsletter_id, newsletter_title', '`newsletter_parent`=0')) + if ($sql->db_Select('newsletter', 'newsletter_id, newsletter_title', '`newsletter_parent`=0')) { - while ($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC)) + $c=0; + while ($row = $sql->db_Fetch(MYSQL_ASSOC)) { $checked = (isset($selects[$row['newsletter_id']])) ? " checked='checked'" : ''; + if ($allow_edit) { - $ret .= ""; + $var[$c]['caption'] = $row['newsletter_title']; + $var[$c]['html'] = $frm->checkbox('nl_category_sel[]',$row['newsletter_id'] ,$checked); } elseif($checked) { - $ret .= ""; + $var[$c]['caption'] = $row['newsletter_title']; + $var[$c]['html'] = NLLAN_49; } + $c++; } } else { - $ret .= "'; + $var[$c]['caption'] = NLLAN_50; + $var[$c]['html'] = ''; } - return $ret.'
    - ".$row['newsletter_title']."
    ".NLLAN_49." - ".$row['newsletter_title']."
    ".NLLAN_50.'
    '; + + return $var; } } diff --git a/e107_plugins/newsletter/languages/English_admin_newsletter.php b/e107_plugins/newsletter/languages/English_admin_newsletter.php index 70124a0de..b0799d209 100644 --- a/e107_plugins/newsletter/languages/English_admin_newsletter.php +++ b/e107_plugins/newsletter/languages/English_admin_newsletter.php @@ -9,9 +9,9 @@ * Plugin - newsfeeds * * $Source: /cvs_backup/e107_0.8/e107_plugins/newsletter/languages/English_admin_newsletter.php,v $ - * $Revision: 1.1 $ - * $Date: 2009-11-19 20:24:21 $ - * $Author: e107steved $ + * $Revision: 1.2 $ + * $Date: 2010-01-10 03:56:28 $ + * $Author: e107coders $ * */ @@ -65,7 +65,7 @@ define('NLLAN_44', 'Newsletter Front Page'); define('NLLAN_45', 'Create Newsletter'); define('NLLAN_46', 'Create mailing'); define('NLLAN_47', 'Newsletter Options'); -define('NLLAN_48', 'Subscribers to each newsletter'); +define('NLLAN_48', 'Newsletter Subscribers'); define('NLLAN_49', 'Newsletter: '); define('NLLAN_54', 'Sending');