diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index 9c05431bb..425249bf3 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -9,17 +9,12 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_admin/mailout.php,v $ - * $Revision: 1.31 $ - * $Date: 2009-11-30 20:40:02 $ + * $Revision: 1.32 $ + * $Date: 2009-12-01 20:05:51 $ * $Author: e107steved $ * */ -/* -TODO: - 1. Improve maintenance page -*/ - /* Features: 1. Additional sources of email addresses for mailouts can be provided via plugins, and can be enabled via the mailout preferences page @@ -98,22 +93,22 @@ require_once(e_HANDLER.'mail_manager_class.php'); // Mail DB API require_once (e_HANDLER.'message_handler.php'); $emessage = &eMessage :: getInstance(); +$action = $e107->tp->toDB(varset($_GET['mode'],'makemail')); +$pageMode = varset($_GET['savepage'], $action); // Sometimes we need to know what brought us here - $action gets changed +$mailId = intval(varset($_GET['m'],0)); +$targetId = intval(varset($_GET['t'],0)); + // Create mail admin object, load all mail handlers $mailAdmin = new mailoutAdminClass($action); // This decodes parts of the query using $_GET syntax +e107::setRegistry('_mailout_admin', $mailAdmin); if ($mailAdmin->loadMailHandlers() == 0) { // No mail handlers loaded echo 'No mail handlers loaded!!'; exit; } -e107::setRegistry('_mailout_admin', $mailAdmin); require_once(e_ADMIN.'auth.php'); -$action = $e107->tp->toDB(varset($_GET['mode'],'makemail')); -$pageMode = varset($_GET['savepage'], $action); // Sometimes we need to know what brought us here - $action gets changed -$mailId = intval(varset($_GET['m'],0)); -$targetId = intval(varset($_GET['t'],0)); - @@ -442,11 +437,11 @@ switch ($midAction) // TODO: Save these fields if (isset($_POST['mail_earliest_time'])) { - $first = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', 'dmy', FALSE); + $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', 'dmy', TRUE); + $last = e107::getDateConvert()->decodeDateTime($_POST['mail_earliest_time'], 'datetime', CORE_DATE_ORDER, TRUE); } if ($mailAdmin->activateEmail($mailId, FALSE, $notify, $first, $last)) { @@ -906,8 +901,8 @@ function show_maint($debug = FALSE) "; - $text .= "".LAN_MAILOUT_182." "; - $text .= "\n"; + $text .= "".LAN_MAILOUT_182."
".LAN_MAILOUT_252.""; + $text .= "\n"; $e107->ns->tablerender("
".ADLAN_136." :: ".ADLAN_40."
", $text); diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index e509aa1a7..f6ecef7f9 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -11,25 +11,23 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ -| $Revision: 1.64 $ -| $Date: 2009-11-20 22:23:02 $ +| $Revision: 1.65 $ +| $Date: 2009-12-01 20:05:52 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ // [debug=8] shows the operations on major table update -require_once("../class2.php"); +require_once('../class2.php'); require_once(e_HANDLER.'db_table_admin_class.php'); -include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_e107_update.php"); -//include_lan(e_LANGUAGE.'admin/lan_e107_update.php'); - +include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_e107_update.php'); // Modified update routine - combines checking and update code into one block per function // - reduces code size typically 30%. // - keeping check and update code together should improve clarity/reduce mis-types etc -// To do - how do we handle multi-language tables? +// TODO: how do we handle update of multi-language tables? // If following line uncommented, enables a test routine // define('TEST_UPDATE',TRUE); @@ -38,20 +36,20 @@ $update_debug = FALSE; // TRUE gives extra messages in places if (defined('TEST_UPDATE')) $update_debug = TRUE; -if (!defined("LAN_UPDATE_8")) { define("LAN_UPDATE_8", ""); } -if (!defined("LAN_UPDATE_9")) { define("LAN_UPDATE_9", ""); } +if (!defined('LAN_UPDATE_8')) { define('LAN_UPDATE_8', ''); } +if (!defined('LAN_UPDATE_9')) { define('LAN_UPDATE_9', ''); } // Determine which installed plugins have an update file - save the path and the installed version in an array $dbupdateplugs = array(); // Array of paths to installed plugins which have a checking routine -$dbupdatep = array(); // Array of plugin upgrade actions (similar to $dbupdate) -$dbupdate = array(); +$dbupdatep = array(); // Array of plugin upgrade actions (similar to $dbupdate) +$dbupdate = array(); // Array of core upgrade actions global $e107cache; -if (is_readable(e_ADMIN."ver.php")) +if (is_readable(e_ADMIN.'ver.php')) { - include(e_ADMIN."ver.php"); + include(e_ADMIN.'ver.php'); } @@ -61,123 +59,124 @@ $dont_check_update = varset($dont_check_update, FALSE); if ($dont_check_update === TRUE) { - $dont_check_update = FALSE; - if ($tempData = $e107cache->retrieve_sys("nq_admin_updatecheck",3600, TRUE)) - { // See when we last checked for an admin update - list($last_time, $dont_check_update,$last_ver) = explode(',',$tempData); - if ($last_ver != $e107info['e107_version']) - { - $dont_check_update = FALSE; // Do proper check on version change + $dont_check_update = FALSE; + if ($tempData = $e107cache->retrieve_sys('nq_admin_updatecheck',3600, TRUE)) + { // See when we last checked for an admin update + list($last_time, $dont_check_update, $last_ver) = explode(',',$tempData); + if ($last_ver != $e107info['e107_version']) + { + $dont_check_update = FALSE; // Do proper check on version change + } } - } } if (!$dont_check_update) { -if ($sql->db_Select("plugin", "plugin_version, plugin_path", "plugin_installflag='1' ")) -{ - while ($row = $sql->db_Fetch()) - { // Mark plugins for update which have a specific update file, or a plugin.php file to check - if(is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_update_check.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/plugin.php')) + if ($sql->db_Select('plugin', 'plugin_version, plugin_path', 'plugin_installflag=1')) { - $dbupdateplugs[$row['plugin_path']] = $row['plugin_version']; + while ($row = $sql->db_Fetch()) + { // Mark plugins for update which have a specific update file, or a plugin.php file to check + if(is_readable(e_PLUGIN.$row['plugin_path'].'/'.$row['plugin_path'].'_update_check.php') || is_readable(e_PLUGIN.$row['plugin_path'].'/plugin.php')) + { + $dbupdateplugs[$row['plugin_path']] = $row['plugin_version']; + } + } } - } -} -// Read in each update file - this will add an entry to the $dbupdatep array if a potential update exists -foreach ($dbupdateplugs as $path => $ver) -{ - $fname = e_PLUGIN.$path.'/'.$path.'_update_check.php'; - if (is_readable($fname)) include_once($fname); -} + // Read in each update file - this will add an entry to the $dbupdatep array if a potential update exists + foreach ($dbupdateplugs as $path => $ver) + { + $fname = e_PLUGIN.$path.'/'.$path.'_update_check.php'; + if (is_readable($fname)) include_once($fname); + } -// List of potential updates -if (defined('TEST_UPDATE')) -{ - $dbupdate["test_code"] = "Test update routine"; -} -$dbupdate["core_prefs"] = LAN_UPDATE_13; // Prefs check -$dbupdate["706_to_800"] = LAN_UPDATE_8." .706 ".LAN_UPDATE_9." .8"; -$dbupdate["70x_to_706"] = LAN_UPDATE_8." .70x ".LAN_UPDATE_9." .706"; + // List of potential updates + if (defined('TEST_UPDATE')) + { + $dbupdate['test_code'] = 'Test update routine'; + } + $dbupdate['core_prefs'] = LAN_UPDATE_13; // Prefs check + $dbupdate['706_to_800'] = LAN_UPDATE_8.' .706 '.LAN_UPDATE_9.' .8'; + $dbupdate['70x_to_706'] = LAN_UPDATE_8.' .70x '.LAN_UPDATE_9.' .706'; } // End if (!$dont_check_update) + + +/** + * Master routine to call to check for updates + */ function update_check() { global $ns, $dont_check_update, $e107info; + $update_needed = FALSE; - $update_needed = FALSE; - - if ($dont_check_update === FALSE) - { - global $dbupdate, $dbupdatep, $e107cache; - - // See which core functions need update - foreach($dbupdate as $func => $rmks) + if ($dont_check_update === FALSE) { -// echo "Core Check {$func}=>{$rmks}
"; - if (function_exists("update_".$func)) - { - if (!call_user_func("update_".$func, FALSE)) + global $dbupdate, $dbupdatep, $e107cache; + + // See which core functions need update + foreach($dbupdate as $func => $rmks) { - $update_needed = TRUE; - continue; + if (function_exists('update_'.$func)) + { + if (!call_user_func('update_'.$func, FALSE)) + { + $update_needed = TRUE; + continue; + } + } } - } + + + + + // Now check plugins + foreach($dbupdatep as $func => $rmks) + { + if (function_exists('update_'.$func)) + { + if (!call_user_func('update_'.$func, FALSE)) + { + $update_needed = TRUE; + continue; + } + } + } + + $e107cache->set_sys('nq_admin_updatecheck', time().','.($update_needed ? '2,' : '1,').$e107info['e107_version'], TRUE); + } + else + { + $update_needed = ($dont_check_update == '2'); } - - - - // Now check plugins - foreach($dbupdatep as $func => $rmks) + if ($update_needed === TRUE) { -// echo "Plugin Check {$func}=>{$rmks}
"; - if (function_exists("update_".$func)) - { - if (!call_user_func("update_".$func, FALSE)) - { - $update_needed = TRUE; - continue; - } - } + require_once (e_HANDLER.'form_handler.php'); + $frm = new e_form(); + $txt = " +
+
+ ".ADLAN_120." + ".$frm->admin_button('e107_system_update', LAN_UPDATE, 'update')." +
+
+ "; + + require_once (e_HANDLER.'message_handler.php'); + $emessage = &eMessage::getInstance(); + $emessage->add($txt); } - $e107cache->set_sys("nq_admin_updatecheck", time().','.($update_needed ? '2,' : '1,').$e107info['e107_version'], TRUE); - } - else - { - $update_needed = ($dont_check_update == '2'); - } - - if ($update_needed === TRUE) - { - require_once (e_HANDLER."form_handler.php"); - $frm = new e_form(); - $txt = " - -
-
- ".ADLAN_120." - ".$frm->admin_button('e107_system_update', LAN_UPDATE, 'update')." -
-
- "; - - require_once (e_HANDLER."message_handler.php"); - $emessage = &eMessage::getInstance(); - $emessage->add($txt); - - } } - require_once(e_HANDLER."e_upgrade_class.php"); +require_once(e_HANDLER.'e_upgrade_class.php'); // $upg = new e_upgrade; //TODO Enable this before release!! // $upg->checkSiteTheme(); @@ -189,52 +188,56 @@ function update_check() //-------------------------------------------- function update_core_prefs($type='') { - global $pref, $admin_log, $e107info; - $do_save = FALSE; - $should = get_default_prefs(); - $accum = array(); + global $pref, $admin_log, $e107info; + $do_save = FALSE; + $should = get_default_prefs(); + $accum = array(); - $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed + $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing if an update is needed - foreach ($should as $k => $v) - { - if ($k && !array_key_exists($k,$pref)) + foreach ($should as $k => $v) { - if ($just_check) return update_needed('Missing pref: '.$k); - $pref[$k] = $v; - $accum[] = $k; - $do_save = TRUE; + if ($k && !array_key_exists($k,$pref)) + { + if ($just_check) return update_needed('Missing pref: '.$k); + $pref[$k] = $v; + $accum[] = $k; + $do_save = TRUE; + } } - } - if ($do_save) - { - save_prefs(); - $admin_log->log_event('UPDATE_03',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode(', ',$accum),E_LOG_INFORMATIVE,''); // Log result of actual update - } - return $just_check; + if ($do_save) + { + save_prefs(); + $admin_log->log_event('UPDATE_03',LAN_UPDATE_14.$e107info['e107_version'].'[!br!]'.implode(', ',$accum),E_LOG_INFORMATIVE,''); // Log result of actual update + } + return $just_check; } + if (defined('TEST_UPDATE')) { //-------------------------------------------- // Test routine - to activate, define TEST_UPDATE //-------------------------------------------- - function update_test_code($type='') - { - global $sql,$ns, $pref; - $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed - //--------------**************--------------- - // Add your test code in here - //--------------**************--------------- + function update_test_code($type='') + { + global $sql,$ns, $pref; + $just_check = $type == 'do' ? FALSE : TRUE; // TRUE if we're just seeing whether an update is needed + //--------------**************--------------- + // Add your test code in here + //--------------**************--------------- - //--------------**************--------------- - // End of test code - //--------------**************--------------- - return $just_check; - } + //--------------**************--------------- + // End of test code + //--------------**************--------------- + return $just_check; + } } // End of test routine + + + //-------------------------------------------- // Upgrade later versions of 0.7.x to 0.8 //-------------------------------------------- @@ -415,48 +418,49 @@ function update_706_to_800($type='') { foreach($changeMenuPaths as $val) { - $qry = "SELECT menu_path FROM #menus WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) LIMIT 1"; + $qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) LIMIT 1"; if($sql->db_Select_gen($qry)) { if ($just_check) return update_needed('Menu path changed required: '.$val['menu'].' '); $updqry = "menu_path='".$val['newpath']."/' WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) "; - $status = $sql->db_Update("menus", $updqry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $status = $sql->db_Update('menus', $updqry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $mes->add(LAN_UPDATE_23.''.$val['menu'].' : '.$val['oldpath'].' => '.$val['newpath'], $status); // LAN_UPDATE_25; - // catch_error(); + // catch_error($sql); } } } // Leave this one here.. just in case.. //delete record for online_extended_menu (now only using one online menu) - if($sql->db_Select("menus", "*", "menu_path='online_extended_menu' || menu_path='online_extended_menu/'")) + if($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'")) { - if ($just_check) return update_needed(); + if ($just_check) return update_needed(); - $row=$sql->db_Fetch(); + $row=$sql->db_Fetch(); - //if online_extended is activated, we need to activate the new 'online' menu, and delete this record - if($row['menu_location']!=0) - { - $status = $sql->db_Update("menus", "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; - $mes->add(LAN_UPDATE_23."online_menu : online/", $status); - } - else - { //else if the menu is not active - //we need to delete the online_extended menu row, and change the online_menu to online - $sql->db_Delete("menus", " menu_path='online_extended_menu' || menu_path='online_extended_menu/' "); - // $updateMessages[] = LAN_UPXXDATE_31; - } - catch_error(); + //if online_extended is activated, we need to activate the new 'online' menu, and delete this record + if($row['menu_location']!=0) + { + $status = $sql->db_Update("menus", "menu_name='online_menu', menu_path='online/' WHERE menu_path='online_extended_menu' || menu_path='online_extended_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $mes->add(LAN_UPDATE_23."online_menu : online/", $status); + } + else + { //else if the menu is not active + //we need to delete the online_extended menu row, and change the online_menu to online + $sql->db_Delete('menus', " menu_path='online_extended_menu' || menu_path='online_extended_menu/' "); + // $updateMessages[] = LAN_UPXXDATE_31; + } + catch_error($sql); } //change menu_path for online_menu (if it still exists) - if($sql->db_Select("menus", "menu_path", "menu_path='online_menu' || menu_path='online_menu/'")) + if($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'")) { - if ($just_check) return update_needed(); + if ($just_check) return update_needed(); + $status = $sql->db_Update("menus", "menu_path='online/' WHERE menu_path='online_menu' || menu_path='online_menu/' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $mes->add(LAN_UPDATE_23."online_menu : online/", $status); - catch_error(); + catch_error($sql); } @@ -465,36 +469,35 @@ function update_706_to_800($type='') //--------------------------------------------------------- if($sql->db_Field('comments','comment_author')) { - if ($just_check) return update_needed('Comment table author field update'); + if ($just_check) return update_needed('Comment table author field update'); - if ((!$sql->db_Field("comments","comment_author_id")) // Check to see whether new fields already added - maybe data copy failed part way through - && (!$sql->db_Select_gen("ALTER TABLE `#comments` - ADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`, - ADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`"))) - { - // Flag error - // $commentMessage = LAN_UPDAXXTE_34; - $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_ERROR); - } - else - { - if (FALSE ===$sql->db_Update('comments',"comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1), comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)")) + if ((!$sql->db_Field('comments','comment_author_id')) // Check to see whether new fields already added - maybe data copy failed part way through + && (!$sql->db_Select_gen("ALTER TABLE `#comments` + ADD COLUMN comment_author_id int(10) unsigned NOT NULL default '0' AFTER `comment_author`, + ADD COLUMN comment_author_name varchar(100) NOT NULL default '' AFTER `comment_author_id`"))) { // Flag error - $mes->add(LAN_UPDATE_21.'comments', E_MESSAGE_ERROR); + // $commentMessage = LAN_UPDAXXTE_34; + $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_ERROR); } else - { // Delete superceded field - comment_author - if (!$sql->db_Select_gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`")) - { - // Flag error - $mes->add(LAN_UPDATE_24."comments - comment_author", E_MESSAGE_ERROR); - } + { + if (FALSE ===$sql->db_Update('comments',"comment_author_id=SUBSTRING_INDEX(`comment_author`,'.',1), comment_author_name=SUBSTRING(`comment_author` FROM POSITION('.' IN `comment_author`)+1)")) + { + // Flag error + $mes->add(LAN_UPDATE_21.'comments', E_MESSAGE_ERROR); + } + else + { // Delete superceded field - comment_author + if (!$sql->db_Select_gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`")) + { + // Flag error + $mes->add(LAN_UPDATE_24.'comments - comment_author', E_MESSAGE_ERROR); + } + } } - } - - $mes->add(LAN_UPDATE_21."comments", E_MESSAGE_SUCCESS); + $mes->add(LAN_UPDATE_21.'comments', E_MESSAGE_SUCCESS); } @@ -529,77 +532,78 @@ function update_706_to_800($type='') // Front page prefs (logic has changed) if (!isset($pref['frontpage_force'])) { // Just set basic options; no real method of converting the existing - if ($just_check) return update_needed('Change front page prefs'); - $pref['frontpage_force'] = array(e_UC_PUBLIC => ''); - $pref['frontpage'] = array(e_UC_PUBLIC => 'news.php'); + if ($just_check) return update_needed('Change front page prefs'); + $pref['frontpage_force'] = array(e_UC_PUBLIC => ''); + $pref['frontpage'] = array(e_UC_PUBLIC => 'news.php'); // $_pdateMessages[] = LAN_UPDATE_38; //FIXME $mes->add(LAN_UPDATE_20."frontpage",E_MESSAGE_SUCCESS); - $do_save = TRUE; + $do_save = TRUE; } if ($sql->db_Table_exists('newsfeed')) { // Need to extend field newsfeed_url varchar(250) NOT NULL default '' - if ($sql -> db_Query("SHOW FIELDS FROM ".MPREFIX."newsfeed LIKE 'newsfeed_url'")) - { - $row = $sql -> db_Fetch(); - if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(250)') + if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."newsfeed LIKE 'newsfeed_url'")) { - if ($just_check) return update_needed('Update newsfeed field definition'); - $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; - $updateMessages[] = LAN_UPDATE_40; //FIXME - $mes->add(LAN_UPDATE_21."newsfeed",$status); - // catch_error(); + $row = $sql -> db_Fetch(); + if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(250)') + { + if ($just_check) return update_needed('Update newsfeed field definition'); + $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX."newsfeed` MODIFY `newsfeed_url` VARCHAR(250) NOT NULL DEFAULT '' ") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $updateMessages[] = LAN_UPDATE_40; //FIXME + $mes->add(LAN_UPDATE_21."newsfeed",$status); + // catch_error($sql); + } } - } } + //TODO use generic function for this update. if ($sql->db_Table_exists('download')) { // Need to extend field download_url varchar(255) NOT NULL default '' - if ($sql -> db_Query("SHOW FIELDS FROM ".MPREFIX."download LIKE 'download_url'")) - { - $row = $sql -> db_Fetch(); - if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)') + if ($sql->db_Query("SHOW FIELDS FROM ".MPREFIX."download LIKE 'download_url'")) { - if ($just_check) return update_needed('Update download table field definition'); - $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download` MODIFY `download_url` VARCHAR(255) NOT NULL DEFAULT '' "); - $updateMessages[] = LAN_UPDATE_52; //FIXME - catch_error(); + $row = $sql -> db_Fetch(); + if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)') + { + if ($just_check) return update_needed('Update download table field definition'); + $sql->db_Select_gen("ALTER TABLE `#download` MODIFY `download_url` VARCHAR(255) NOT NULL DEFAULT '' "); + $updateMessages[] = LAN_UPDATE_52; //FIXME + catch_error($sql); + } } - } } //TODO use generic function for this update. if ($sql->db_Table_exists('download_mirror')) { // Need to extend field download_url varchar(255) NOT NULL default '' - if ($sql->db_Select_gen("SHOW FIELDS FROM ".MPREFIX."download_mirror LIKE 'mirror_url'")) - { - $row = $sql -> db_Fetch(); - if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)') + if ($sql->db_Select_gen("SHOW FIELDS FROM ".MPREFIX."download_mirror LIKE 'mirror_url'")) { - if ($just_check) return update_needed('Update download mirror table field definition'); - $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download_mirror` MODIFY `mirror_url` VARCHAR(255) NOT NULL DEFAULT '' "); - $updateMessages[] = LAN_UPDATE_53; //FIXME - catch_error(); + $row = $sql -> db_Fetch(); + if (str_replace('varchar', 'char', strtolower($row['Type'])) != 'char(255)') + { + if ($just_check) return update_needed('Update download mirror table field definition'); + $sql->db_Select_gen("ALTER TABLE `".MPREFIX."download_mirror` MODIFY `mirror_url` VARCHAR(255) NOT NULL DEFAULT '' "); + $updateMessages[] = LAN_UPDATE_53; //FIXME + catch_error($sql); + } } - } } // Check need for user timezone before we delete the field if (varsettrue($pref['signup_option_timezone'])) { - if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended','user_timezone','',TRUE)) - { - if ($just_check) return update_needed('Move user timezone info'); - if (!copy_user_timezone()) - { // Error doing the transfer - $updateMessages[] = LAN_UPDATE_42; //FIXME - return FALSE; + if ($sql->db_Field('user', 'user_timezone', '', TRUE) && !$sql->db_Field('user_extended','user_timezone','',TRUE)) + { + if ($just_check) return update_needed('Move user timezone info'); + if (!copy_user_timezone()) + { // Error doing the transfer + $updateMessages[] = LAN_UPDATE_42; //FIXME + return FALSE; + } + $updateMessages[] = LAN_UPDATE_41; } - $updateMessages[] = LAN_UPDATE_41; - } } @@ -609,7 +613,7 @@ function update_706_to_800($type='') { if ($just_check) return update_needed('Rename dblog to admin_log'); $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'dblog` RENAME `'.MPREFIX.'admin_log`'); - catch_error(); + catch_error($sql); $updateMessages[] = LAN_UPDATE_43; //FIXME } @@ -620,30 +624,30 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Rename rl_history to dblog'); $sql->db_Select_gen('ALTER TABLE `'.MPREFIX.'rl_history` RENAME `'.MPREFIX.'dblog`'); $updateMessages[] = LAN_UPDATE_44; //FIXME - catch_error(); + catch_error($sql); } // New tables required (list at top. Definitions in core_sql.php) foreach ($new_tables as $nt) { - if (!$sql->db_Table_exists($nt)) - { - if ($just_check) return update_needed("Add table: ".$nt); - // Get the definition - $defs = $db_parser->get_table_def($nt,e_ADMIN."sql/core_sql.php"); - if (count($defs)) // **** Add in table here - { - $status = $sql->db_Select_gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; - // $updateMessages[] = LAN_UPDATE_45.$defs[0][1]; - $mes->add(LAN_UPDATE_27.$defs[0][1], $status); //TODO - all update messages should work like this. - // catch_error(); + if (!$sql->db_Table_exists($nt)) + { + if ($just_check) return update_needed('Add table: '.$nt); + // Get the definition + $defs = $db_parser->get_table_def($nt,e_ADMIN.'sql/core_sql.php'); + if (count($defs)) // **** Add in table here + { + $status = $sql->db_Select_gen('CREATE TABLE `'.MPREFIX.$defs[0][1].'` ('.$defs[0][2].') TYPE='.$defs[0][3]) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + // $updateMessages[] = LAN_UPDATE_45.$defs[0][1]; + $mes->add(LAN_UPDATE_27.$defs[0][1], $status); //TODO - all update messages should work like this. But also need $updateMessages[] for admin log + // catch_error($sql); + } + else + { // error parsing defs file + $mes->add(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR); + } + unset($defs); } - else - { // error parsing defs file - $mes->add(LAN_UPDATE_46.$defs[0][1], E_MESSAGE_ERROR); - } - unset($defs); - } } @@ -692,7 +696,7 @@ function update_706_to_800($type='') $status = $sql->db_Select_gen($qry) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $mes->add(LAN_UPDATE_21.$ct, $status); - catch_error(); + catch_error($sql); } } } @@ -756,7 +760,7 @@ function update_706_to_800($type='') } $sql->db_Select_gen($qry); $updateMessages[] = LAN_UPDATE_51.$ct; //FIXME - catch_error(); + catch_error($sql); } } } @@ -771,7 +775,7 @@ function update_706_to_800($type='') $ep = new e107plugin; $ep -> update_plugins_table(); // $_pdateMessages[] = LAN_UPDATE_XX24; - // catch_error(); + // catch_error($sql); } @@ -800,7 +804,7 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Update IP address field '.$f.' in table '.$t); $status = $sql->db_Select_gen("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';") ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $mes->add(LAN_UPDATE_26.$t.' - '.$f, $status); - // catch_error(); + // catch_error($sql); } } else @@ -850,7 +854,7 @@ function update_70x_to_706($type='') { if ($just_check) return update_needed(); $sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` ADD `plugin_addons` TEXT NOT NULL ;"); - catch_error(); + catch_error($sql); } //rename plugin_rss field @@ -858,7 +862,7 @@ function update_70x_to_706($type='') { if ($just_check) return update_needed(); $sql->db_Select_gen("ALTER TABLE `".MPREFIX."plugin` CHANGE `plugin_rss` `plugin_addons` TEXT NOT NULL;"); - catch_error(); + catch_error($sql); } @@ -879,7 +883,7 @@ function update_70x_to_706($type='') $mes = LAN_UPDATE_12." : ".ADLAN_145."."; //$ns -> tablerender(LAN_ERROR,$mes); $emessage->add($mes, E_MESSAGE_ERROR); - catch_error(); + catch_error($sql); } } @@ -887,7 +891,7 @@ function update_70x_to_706($type='') { if ($just_check) return update_needed(); $sql->db_Select_gen("ALTER TABLE ".MPREFIX."online ADD online_active INT(10) UNSIGNED NOT NULL DEFAULT '0'"); - catch_error(); + catch_error($sql); } if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX."tmp")) @@ -1015,6 +1019,10 @@ function addIndexToTable($target, $indexSpec, $just_check, &$updateMessages, $op } +/** Check for database access errors + * @param reference $target - pointer to db object + * @return none + */ function catch_error(&$target) { if (vartrue($target->mySQLlastErrText) && E107_DEBUG_LEVEL != 0) diff --git a/e107_files/shortcode/batch/admin_shortcodes_class.php b/e107_files/shortcode/batch/admin_shortcodes_class.php index 60d4b7469..70b50220b 100644 --- a/e107_files/shortcode/batch/admin_shortcodes_class.php +++ b/e107_files/shortcode/batch/admin_shortcodes_class.php @@ -1,7 +1,7 @@ '; diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php index 5489feeeb..5088dfb2e 100644 --- a/e107_handlers/date_handler.php +++ b/e107_handlers/date_handler.php @@ -7,8 +7,8 @@ * GNU General Public License (http://gnu.org). * * $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $ - * $Revision: 1.13 $ - * $Date: 2009-11-27 21:42:46 $ + * $Revision: 1.14 $ + * $Date: 2009-12-01 20:05:53 $ * $Author: e107steved $ * */ @@ -126,7 +126,7 @@ class convert * @param string $input - usually date/time string with numeric values for relevant fields, and almost any separator. e.g. dd-mm-yy hh:mm * Date and time must be separated by one or more spaces. In times, minutes and seconds are optional, and default to zero * One special value is allowed - 'now' - * @param string $decode - one of 'date', 'time', 'datetime' + * @param string $decode - one of 'date', 'time', 'datetime', 'timedate' * @param string $format - sets field order for dates. Valid strings are dmy, mdy, ymd. Add suffix 'z' to return UTC/GMT * @param boolean $endDay - if TRUE, and no time entered, includes a time of 23:59:59 in the entered date * @@ -134,7 +134,7 @@ class convert */ public function decodeDateTime($input, $decode = 'date', $format = 'dmy', $endDay = FALSE) { - if ($input == 'now') return time(); + if ($input == 'now') return time(); // Current time TODO: option to return UTC or local time here $useLocale = TRUE; if (substr($format,-1,1) == 'z') { @@ -145,21 +145,25 @@ class convert { case 'date' : $timeString = ''; - $dateString = trim($input); + $dateString = $input; break; case 'time' : - $timeString = trim($input); + $timeString = $input; $dateString = ''; break; - case 'datetime' : + case 'datetime' : // Date then time, separated by space $input = str_replace(' ',' ', $input); list($dateString, $timeString) = explode(' ',$input,2); - $timeString = trim($timeString); - $dateString = trim($dateString); + break; + case 'timedate' : // Time then date, separated by space + $input = str_replace(' ',' ', $input); + list($timeString, $dateString) = explode(' ',$input,2); break; default : return 0; } + $timeString = trim($timeString); + $dateString = trim($dateString); $dateVals = array (1 => 0, 2 => 0, 3 => 0); // Preset date in case $timeVals = array (1 => 0, 2 => 0, 3 => 0); // Preset time in case if ($dateString) @@ -214,7 +218,6 @@ class convert { preg_match('#(\d{1,2})(?:\D(\d{1,2})){0,1}(?:\D(\d{1,2})){0,1}#', $timeString, $timeVals); } - //print_a($timeVals); } elseif ($endDay) { diff --git a/e107_handlers/db_table_admin_class.php b/e107_handlers/db_table_admin_class.php index 506da4dfb..2cb5768f2 100644 --- a/e107_handlers/db_table_admin_class.php +++ b/e107_handlers/db_table_admin_class.php @@ -9,8 +9,8 @@ * Database utilities * * $Source: /cvs_backup/e107_0.8/e107_handlers/db_table_admin_class.php,v $ - * $Revision: 1.13 $ - * $Date: 2009-11-20 22:23:02 $ + * $Revision: 1.14 $ + * $Date: 2009-12-01 20:05:53 $ * $Author: e107steved $ */ @@ -125,6 +125,7 @@ class db_table_admin { unset($defs); $fv = trim(str_replace(' ', ' ', $fv)); + $fv = str_replace('`', '', $fv); if (substr($fv, -1) == ',') { $fv = trim(substr($fv, 0, -1)); diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 7475cbf9b..68e09bcb8 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -9,8 +9,8 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_handlers/mailout_admin_class.php,v $ - * $Revision: 1.8 $ - * $Date: 2009-11-30 20:40:03 $ + * $Revision: 1.9 $ + * $Date: 2009-12-01 20:05:53 $ * $Author: e107steved $ * */ @@ -216,18 +216,21 @@ class mailoutAdminClass extends e107MailManager global $user_pref; $this->mode = $mode; $curTable = $this->tasks[$this->mode]['defaultTable']; - if (is_array($user_pref['admin_mailout_columns'][$mode])) - { // Use saved list of fields to view if it exists - $this->fieldPref = $user_pref['admin_mailout_columns'][$mode]; - } - else - { // Default list is minimal fields only - $this->fieldPref = array(); - foreach ($this->fields[$curTable] as $f => $v) - { - if (vartrue($v['forced'])) + if ($curTable) + { + if (is_array($user_pref['admin_mailout_columns'][$mode])) + { // Use saved list of fields to view if it exists + $this->fieldPref = $user_pref['admin_mailout_columns'][$mode]; + } + else + { // Default list is minimal fields only + $this->fieldPref = array(); + foreach ($this->fields[$curTable] as $f => $v) { - $this->fieldPref[] = $f; + if (vartrue($v['forced'])) + { + $this->fieldPref[] = $f; + } } } } @@ -468,7 +471,7 @@ class mailoutAdminClass extends e107MailManager { if ($m->mailerEnabled) { - $ret .= "".$m->mailerName."".$m->showSelect(TRUE, varset($selectorInfo[$m->mailerSource], FALSE)).""; + $ret .= "".$m->mailerName."".$m->showSelect(TRUE, varset($selectorInfo[$m->mailerSource], FALSE)).""; } } return $ret; @@ -1187,7 +1190,7 @@ class mailoutAdminClass extends e107MailManager // Add in core and any plugin selectors here - foreach ($mail_handlers as $m) + foreach ($this->mailHandlers as $m) { if ($m->mailer_enabled) { @@ -1232,11 +1235,11 @@ class mailoutAdminClass extends e107MailManager "; - $text .= "".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time').""; - $text .= "".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time').""; + $text .= "".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time', '', CORE_DATE_ORDER).""; + $text .= "".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time', '', CORE_DATE_ORDER).""; // Can comment the two lines above, uncomment two lines below, and default time/date is shown. May or may not be preferable -// $text .= "".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time', time()).""; -// $text .= "".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time', time()+86400).""; +// $text .= "".LAN_MAILOUT_238."".$this->makeCalendar('mail_earliest_time', time(), CORE_DATE_ORDER).""; +// $text .= "".LAN_MAILOUT_239."".$this->makeCalendar('mail_latest_time', time()+86400, CORE_DATE_ORDER).""; $text .= "".LAN_MAILOUT_240."".LAN_MAILOUT_241.""; $text .= "\n"; return $text; @@ -1244,19 +1247,35 @@ class mailoutAdminClass extends e107MailManager - public function makeCalendar($calName, $calVal = '') + public function makeCalendar($calName, $calVal = '', $dateOrder = 'dmy') { + // Determine formatting strings this way, to give sensible default + switch ($dateOrder) + { + case 'mdy' : + $dateString = '%m/%d/%Y %H:%I'; + $dispString = 'm/d/Y H:I'; + break; + case 'ymd' : + $dateString = '%Y/%m/%d %H:%I'; + $dispString = 'Y/m/d H:I'; + break; + case 'dmy' : + default : + $dateString = '%d/%m/%Y %H:%I'; + $dispString = 'd/m/Y H:I'; + } $calOptions = array( 'showsTime' => TRUE, 'showOthers' => false, 'weekNumbers' => false, - 'ifFormat' => '%d/%m/%Y %H:%I' + 'ifFormat' => $dateString ); $calAttrib = array( 'class' => 'tbox', 'size' => 15, // Number of characters 'name' => $calName, - 'value' => (($calVal == '') ? '' : date('d/m/Y H:I',$calVal)) + 'value' => (($calVal == '') ? '' : date($dispString,$calVal)) ); return $this->_cal->make_input_field($calOptions, $calAttrib); } @@ -1311,84 +1330,91 @@ class mailoutAdminClass extends e107MailManager $count = $this->selectTargetStatus($mailID, $this->showFrom, $this->showCount, '*', FALSE, $this->sortField, $this->sortOrder); $totalCount = $this->getTargetCount(); - $text .= " -
-
- "; - - - $fieldPrefs = $this->calcFieldSpec('recipients', TRUE); // Get columns to display - - // Must use '&' rather than '&' in query pattern - $text .= $frm->colGroup($this->fields['mail_recipients'],$this->fieldPref).$frm->thead($this->fields['mail_recipients'],$this->fieldPref,'mode='.'recipients&m='.$mailID."&fld=[FIELD]&asc=[ASC]&frm=[FROM]").""; - - while ($row = $this->getNextTargetStatus(FALSE)) + if ($count == 0) { - // print_a($row); - $text .= ''; - foreach ($fieldPrefs as $fieldName) - { // Output column data value - $text .= '
'; - if (isset($row[$fieldName])) - { - $proctype = varset($this->fields['mail_recipients'][$fieldName]['proc'], 'default'); - switch ($proctype) + $text .= "".LAN_MAILOUT_253.''; + } + else + { + $text .= " + +
+ "; + + + $fieldPrefs = $this->calcFieldSpec('recipients', TRUE); // Get columns to display + + // Must use '&' rather than '&' in query pattern + $text .= $frm->colGroup($this->fields['mail_recipients'],$this->fieldPref).$frm->thead($this->fields['mail_recipients'],$this->fieldPref,'mode='.'recipients&m='.$mailID."&fld=[FIELD]&asc=[ASC]&frm=[FROM]").""; + + while ($row = $this->getNextTargetStatus(FALSE)) + { + // print_a($row); + $text .= ''; + foreach ($fieldPrefs as $fieldName) + { // Output column data value + $text .= ''; } - else - { // Special stuff - $text .= 'special'; - } - $text .= ''; + // Add in options here + $text .= ''; + $text .= ''; } - // Add in options here - $text .= ''; - $text .= ''; - } - $text .= "
'; + if (isset($row[$fieldName])) { - case 'username' : - $text .= $this->getUserName($row[$fieldName]); - break; - case 'sdatetime' : - $text .= $gen->convert_date($row[$fieldName], 'short'); - break; - case 'trunc200' : - $text .= $this->e107->tp->text_truncate($row[$fieldName], 200, '...'); - break; - case 'contentstatus' : - $text .= $this->statusToText($row[$fieldName]); - break; - case 'selectors' : - $text .= 'cannot display'; - break; - case 'array' : - if (is_array($row[$fieldName])) - { - $nl = ''; - foreach ($row[$fieldName] as $k => $v) + $proctype = varset($this->fields['mail_recipients'][$fieldName]['proc'], 'default'); + switch ($proctype) + { + case 'username' : + $text .= $this->getUserName($row[$fieldName]); + break; + case 'sdatetime' : + $text .= $gen->convert_date($row[$fieldName], 'short'); + break; + case 'trunc200' : + $text .= $this->e107->tp->text_truncate($row[$fieldName], 200, '...'); + break; + case 'contentstatus' : + $text .= $this->statusToText($row[$fieldName]); + break; + case 'selectors' : + $text .= 'cannot display'; + break; + case 'array' : + if (is_array($row[$fieldName])) { - if ($v) + $nl = ''; + foreach ($row[$fieldName] as $k => $v) { - $text .= $nl.$k.' => '.$v; - $nl = '
'; + if ($v) + { + $text .= $nl.$k.' => '.$v; + $nl = '
'; + } } } - } - else - { - $text .= 'bad data: '; - } - break; - case 'default' : - default : - $text .= $row[$fieldName]; + else + { + $text .= 'bad data: '; + } + break; + case 'default' : + default : + $text .= $row[$fieldName]; + } } + else + { // Special stuff + $text .= 'special'; + } + $text .= '
'.$this->makeTargetOptions('recipients',$row).'
'.$this->makeTargetOptions('recipients',$row).'
\n


"; + $text .= "
\n


"; - if ($totalCount > $count) - { - $parms = "{$totalCount},{$this->showCount},{$this->showFrom},".e_SELF."?mode=recipients&m={$mailID}&count={$this->showCount}&frm=[FROM]&fld={$this->sortField}&asc={$this->sortOrder}&savepage={$nextPage}"; - $text .= $this->e107->tp->parseTemplate("{NEXTPREV={$parms}}"); + if ($totalCount > $count) + { + $parms = "{$totalCount},{$this->showCount},{$this->showFrom},".e_SELF."?mode=recipients&m={$mailID}&count={$this->showCount}&frm=[FROM]&fld={$this->sortField}&asc={$this->sortOrder}&savepage={$nextPage}"; + $text .= $this->e107->tp->parseTemplate("{NEXTPREV={$parms}}"); + } } $text .= ""; diff --git a/e107_handlers/mailout_class.php b/e107_handlers/mailout_class.php index 83e647769..245a52707 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.5 $ - * $Date: 2009-11-18 01:04:43 $ - * $Author: e107coders $ + * $Revision: 1.6 $ + * $Date: 2009-12-01 20:05:53 $ + * $Author: e107steved $ * */ @@ -62,15 +62,10 @@ class core_mailout ); // Constructor - public function __construct(&$mailerAdminHandler = NULL) + public function __construct() { $this->e107 = e107::getInstance(); - if ($mailerAdminHandler == NULL) - { - global $mailAdmin; - $mailerAdminHandler = $mailAdmin; - } - $this->adminHandler = $mailerAdminHandler; + $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions } @@ -257,12 +252,20 @@ class core_mailout { $ret = ""; + $ret = "
+
+ + + + + "; + if ($allow_edit) { // User class select $ret .= " - - + "; @@ -270,7 +273,7 @@ class core_mailout $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 .= " - - + - - + "; @@ -320,8 +323,8 @@ class core_mailout $_to = $selectVals['email_to']; } $ret .= " - - + - - + + "; } @@ -342,8 +345,8 @@ class core_mailout { $ret .= " - - + + "; } @@ -351,21 +354,21 @@ class core_mailout { $ret .= " - - + + "; } if (vartrue($selectVals['extended_2_name']) && vartrue($selectVals['extended_2_value'])) { $ret .= " - - + + "; } } - return $ret.'
".LAN_MAILOUT_03.": + ".LAN_MAILOUT_03.": ".$this->adminHandler->userClassesTotals('email_to', varset($selectVals['email_to'], ''))."
".LAN_MAILOUT_46." + ".LAN_MAILOUT_46." ".LAN_MAILOUT_47." +
".LAN_MAILOUT_56.' '.$this->adminHandler->comparisonSelect('last_visit_match', $selectVals['last_visit_match'])." +
".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_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_46.$this->adminHandler->ret_extended_field_list('extended_2_name', varset($selectVals['extended_2_name'], ''), TRUE).LAN_MAILOUT_48."
".LAN_MAILOUT_03."".$_to." "; + ".LAN_MAILOUT_03."".$_to." "; if($selectVals['email_to'] == "self") { $text .= "<".USEREMAIL.">"; @@ -333,8 +336,8 @@ class core_mailout { $ret .= "
".$selectVals['user_search_name']."".varset($selectVals['user_search_value'])." ".$selectVals['user_search_name']."".varset($selectVals['user_search_value'])." 
".LAN_MAILOUT_56."".$selectVals['last_visit_match'].' '.gmstrtotime("%D-%M-%Y",$selectVals['last_visit_date'])." ".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_1_name']."".$selectVals['extended_1_value']." 
".$selectVals['extended_2_name']."".$selectVals['extended_2_value']." ".$selectVals['extended_2_name']."".$selectVals['extended_2_value']." 
'; + return $ret.''; } } diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index b4cccfbd9..b8ebd2803 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -9,9 +9,9 @@ * mySQL Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $ - * $Revision: 1.66 $ - * $Date: 2009-11-26 17:14:07 $ - * $Author: secretr $ + * $Revision: 1.67 $ + * $Date: 2009-12-01 20:05:54 $ + * $Author: e107steved $ */ if(defined('MYSQL_LIGHT')) @@ -49,8 +49,8 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s * * @package e107 * @category e107_handlers - * @version $Revision: 1.66 $ - * @author $Author: secretr $ + * @version $Revision: 1.67 $ + * @author $Author: e107steved $ * */ class e_db_mysql { @@ -219,12 +219,15 @@ class e_db_mysql { /** - * @desc Enter description here... * This is the 'core' routine which handles much of the interface between other functions and the DB * - * @param unknown $query + * If a SELECT query includes SQL_CALC_FOUND_ROWS, the value of FOUND_ROWS() is retrieved and stored in $this->total_results + * @param string $query * @param unknown $rli - * @return unknown + * @return boolean | resource - as mysql_query() function. + * FALSE indicates an error + * For SELECT, SHOW, DESCRIBE, EXPLAIN and others returning a result set, returns a resource + * TRUE indicates success in other cases */ public function db_Query($query, $rli = NULL, $qry_from = '', $debug = FALSE, $log_type = '', $log_remark = '') { @@ -262,7 +265,7 @@ class e_db_mysql { if ((strpos($query,'SQL_CALC_FOUND_ROWS') !== FALSE) && (strpos($query,'SELECT') !== FALSE)) { // Need to get the total record count as well. Return code is a resource identifier // Have to do this before any debug action, otherwise this bit gets messed up - $fr = mysql_query("SELECT FOUND_ROWS()", $this->mySQLaccess); + $fr = mysql_query('SELECT FOUND_ROWS()', $this->mySQLaccess); $rc = mysql_fetch_array($fr); $this->total_results = $rc['FOUND_ROWS()']; } @@ -843,12 +846,15 @@ class e_db_mysql { /** - * @return unknown - * @param unknown $arg - * @desc Enter description here... - * @access private + * Function to handle any MySQL query + * @param string $query - the MySQL query string, where '#' represents the database prefix in front of table names. + * Recommended to enclose all table names in backticks, to minimise the possibility of erroneous substitutions + * @return boolean | integer + * Returns FALSE if there is an error in the query + * Returns TRUE if the query is successful, and it does not return a row count + * Returns the number of rows added/updated/deleted for DELETE, INSERT, REPLACE, or UPDATE */ - function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '') + public function db_Select_gen($query, $debug = FALSE, $log_type = '', $log_remark = '') { $this->tabset = FALSE; @@ -869,16 +875,22 @@ class e_db_mysql { //FIXME - this is a quick Fix for REGEXP queries, as used in admin_ui. $query = str_replace("`#","`".$this->mySQLPrefix,$query); - if (($this->mySQLresult = $this->db_Query($query, NULL, 'db_Select_gen', $debug, $log_type, $log_remark)) === TRUE) - { // Successful query which doesn't return a row count - $this->dbError('db_Select_gen'); - return TRUE; - } - elseif ($this->mySQLresult === FALSE) + if ($this->mySQLresult === FALSE) { // Failed query $this->dbError('db_Select_gen('.$query.')'); return FALSE; } + elseif (($this->mySQLresult = $this->db_Query($query, NULL, 'db_Select_gen', $debug, $log_type, $log_remark)) === TRUE) + { // Successful query which may return a row count (because it operated on a number of rows without returning a result set) + if(preg_match('#^(DELETE|INSERT|REPLACE|UPDATE)#',$query, $matches)) + { // Need to check mysql_affected_rows() - to return number of rows actually updated + $tmp = mysql_affected_rows($this->mySQLaccess); + $this->dbError('db_Select_gen'); + return $tmp; + } + $this->dbError('db_Select_gen'); // No row count here + return TRUE; + } else { // Successful query which does return a row count - get the count and return it $this->dbError('db_Select_gen'); diff --git a/e107_languages/English/admin/lan_mailout.php b/e107_languages/English/admin/lan_mailout.php index 4afec8ba1..50e089332 100644 --- a/e107_languages/English/admin/lan_mailout.php +++ b/e107_languages/English/admin/lan_mailout.php @@ -9,11 +9,15 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_mailout.php,v $ - * $Revision: 1.14 $ - * $Date: 2009-11-30 20:40:03 $ + * $Revision: 1.15 $ + * $Date: 2009-12-01 20:05:54 $ * $Author: e107steved $ * */ + +define('CORE_DATE_ORDER', 'dmy'); // Temporary until we find somewhere better to put it. + // Defines order of field entry/display in date boxes + // Acceptable values: dmy, mdy, ymd define('LAN_MAILOUT_01','From Name'); define('LAN_MAILOUT_02','From Email'); define('LAN_MAILOUT_03','To'); @@ -270,8 +274,8 @@ define('LAN_MAILOUT_248', 'Completion status: '); define('LAN_MAILOUT_249', 'Send results:'); define('LAN_MAILOUT_250', '--- End of notification ---'); define('LAN_MAILOUT_251', 'Copy and edit'); -define('LAN_MAILOUT_252', ''); -define('LAN_MAILOUT_253', ''); +define('LAN_MAILOUT_252', 'Does various consistency checks on the data, corrects counts, deletes temporary data'); +define('LAN_MAILOUT_253', 'No recipients found - check for database corruption'); define('LAN_MAILOUT_254', ''); diff --git a/e107_plugins/calendar_menu/e_mailout.php b/e107_plugins/calendar_menu/e_mailout.php index b1ca6a2ce..b58638687 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.6 $ - * $Date: 2009-11-19 10:09:12 $ - * $Author: marj_nl_fr $ + * $Revision: 1.7 $ + * $Date: 2009-12-01 20:05:54 $ + * $Author: e107steved $ * */ @@ -43,15 +43,10 @@ class calendar_menu_mailout // Constructor - public function __construct(&$mailerAdminHandler = NULL) + public function __construct() { $this->e107 = e107::getInstance(); - if ($mailerAdminHandler == NULL) - { - global $mailAdmin; - $mailerAdminHandler = $mailAdmin; - } - $this->adminHandler = $mailerAdminHandler; + $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions } @@ -66,9 +61,12 @@ class calendar_menu_mailout public function returnSelectors() { $res = array(); - foreach ($_POST['ec_category_sel'] as $k => $v) + if (is_array($_POST['ec_category_sel'])) { - $res[] = intval($v); + foreach ($_POST['ec_category_sel'] as $k => $v) + { + $res[] = intval($v); + } } return implode(',',$res); } diff --git a/e107_plugins/newsletter/e_mailout.php b/e107_plugins/newsletter/e_mailout.php index 676db0579..1e1e4bb38 100644 --- a/e107_plugins/newsletter/e_mailout.php +++ b/e107_plugins/newsletter/e_mailout.php @@ -9,8 +9,8 @@ * Administration - Site Maintenance * * $Source: /cvs_backup/e107_0.8/e107_plugins/newsletter/e_mailout.php,v $ - * $Revision: 1.1 $ - * $Date: 2009-11-19 20:24:21 $ + * $Revision: 1.2 $ + * $Date: 2009-12-01 20:05:54 $ * $Author: e107steved $ * */ @@ -45,15 +45,10 @@ class newsletter_mailout // Constructor - public function __construct(&$mailerAdminHandler = NULL) + public function __construct() { $this->e107 = e107::getInstance(); - if ($mailerAdminHandler == NULL) - { - global $mailAdmin; - $mailerAdminHandler = $mailAdmin; - } - $this->adminHandler = $mailerAdminHandler; + $this->adminHandler = e107::getRegistry('_mailout_admin'); // Get the mailer admin object - we want to use some of its functions } @@ -68,9 +63,12 @@ class newsletter_mailout public function returnSelectors() { $res = array(); - foreach ($_POST['nl_category_sel'] as $k => $v) + if (is_array($_POST['nl_category_sel'])) { - $res[] = intval($v); + foreach ($_POST['nl_category_sel'] as $k => $v) + { + $res[] = intval($v); + } } return implode(',',$res); }