1
0
mirror of https://github.com/e107inc/e107.git synced 2025-09-02 19:02:39 +02:00

Bugtracker #4302 and general reorganisation of comment table for 0.8

This commit is contained in:
e107steved
2008-05-24 12:45:34 +00:00
parent 8ac2be2e12
commit e01a9ce04e
5 changed files with 268 additions and 157 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/admin_log.php,v $
| $Revision: 1.13 $
| $Date: 2008-05-17 15:00:32 $
| $Revision: 1.14 $
| $Date: 2008-05-24 12:45:26 $
| $Author: e107steved $
|
| Preferences:
@@ -527,7 +527,7 @@ $col_fields = array('adminlog' => array('cf_datestring','dblog_type','dblog_ip',
'rolllog' => array('cf_datestring','dblog_type','dblog_ip','dblog_user_id','dblog_user_name','dblog_eventcode','dblog_caller','dblog_title','dblog_remarks'),
'downlog' => array('cf_datestring','dblog_ip','dblog_user_id','user_name','download_request_download_id','download_name'),
'detailed' => array('cf_microtime','cf_microtimediff','source','dblog_type','dblog_ip','dblog_user_id','user_name','dblog_eventcode','dblog_title','dblog_remarks'),
'comments' => array('cf_datestring', 'comment_id', 'comment_pid', 'comment_item_id', 'comment_subject', 'author_id', 'comment_author', 'comment_ip', 'comment_type', 'comment_comment', 'comment_blocked', 'comment_lock', 'del_check')
'comments' => array('cf_datestring', 'comment_id', 'comment_pid', 'comment_item_id', 'comment_subject', 'comment_author_id', 'comment_author_name', 'comment_ip', 'comment_type', 'comment_comment', 'comment_blocked', 'comment_lock', 'del_check')
);
$col_widths = array('adminlog' => array(18,4,14,7,15,8,14,20), // Date - Pri - IP - UID - User - Code - Event - Info
'auditlog' => array(18,14,7,15,8,14,24),
@@ -570,9 +570,7 @@ $base_query = array(
UNION
SELECT dblog_datestamp + (dblog_microtime/1000000) AS dblog_time, dblog_user_id, dblog_eventcode, dblog_title, dblog_remarks, dblog_type, dblog_ip, 'admin' AS source FROM `#admin_log`) AS cl
LEFT JOIN `#user` AS u ON cl.dblog_user_id=u.user_id ",
'comments' => "SELECT SQL_CALC_FOUND_ROWS *, comment_datestamp AS dblog_datestamp, SUBSTRING_INDEX(c.comment_author,'.',1) as author_id
FROM `#comments` AS c"
// LEFT JOIN `#user` AS u ON SUBSTRING_INDEX(c.comment_author,'.',1) = u.user_id"
'comments' => "SELECT SQL_CALC_FOUND_ROWS *, comment_datestamp AS dblog_datestamp FROM `#comments` AS c"
);
// The filters have to use the 'actual' db field names. So the following table sets the defaults and the exceptions which vary across the range of tables supported
@@ -580,7 +578,7 @@ $map_filters = array(
'default' => array('datetimes' => '`dblog_datestamp`', 'ipfilter' => '`dblog_ip`', 'userfilter' => '`dblog_user_id`', 'eventfilter' => '`dblog_eventcode`'),
'downlog' => array('datetimes' => '`download_request_datestamp`', 'ipfilter' => '`download_request_ip`', 'userfilter' => '`download_request_userid`'),
'detailed' => array('datestart' => '`dblog_time`'),
'comments' => array('datetimes' => '`comment_datestamp`', 'ipfilter' => '`comment_ip`', 'eventfilter' => 'comment_type', 'userfilter' => "SUBSTRING_INDEX(c.`comment_author`,'.',1)")
'comments' => array('datetimes' => '`comment_datestamp`', 'ipfilter' => '`comment_ip`', 'eventfilter' => 'comment_type', 'userfilter' => '`comment_author_id`')
);
@@ -905,9 +903,6 @@ function log_process($matches)
// Look for pseudo-code for newlines, link insertion
$val = preg_replace_callback("#\[!(\w+?)(=.+?){0,1}!]#",'log_process',$row['dblog_remarks']);
break;
case 'comment_author' :
list(,$val) = explode('.',$row['comment_author'],2);
break;
case 'comment_ip' :
$val = $row['comment_ip'];
if (strlen($val) == 8)

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
| $Revision: 1.9 $
| $Date: 2008-01-20 22:21:14 $
| $Author: secretr $
| $Revision: 1.10 $
| $Date: 2008-05-24 12:45:27 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
header("location:../index.php");
@@ -121,7 +121,8 @@ CREATE TABLE comments (
comment_pid int(10) unsigned NOT NULL default '0',
comment_item_id int(10) unsigned NOT NULL default '0',
comment_subject varchar(100) NOT NULL default '',
comment_author varchar(100) NOT NULL default '',
comment_author_id int(10) unsigned NOT NULL default '0',
comment_author_name varchar(100) NOT NULL default '',
comment_author_email varchar(200) NOT NULL default '',
comment_datestamp int(10) unsigned NOT NULL default '0',
comment_comment text NOT NULL,

View File

@@ -11,12 +11,13 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $
| $Revision: 1.20 $
| $Date: 2008-04-29 19:44:17 $
| $Revision: 1.21 $
| $Date: 2008-05-24 12:45:26 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
require_once(e_HANDLER.'db_table_admin_class.php');
@@ -28,6 +29,8 @@ require_once(e_HANDLER.'db_table_admin_class.php');
// To do - how do we handle multi-language tables?
// If following line uncommented, enables a test routine
//define('TEST_UPDATE',TRUE);
$update_debug = FALSE; // TRUE gives extra messages in places
//$update_debug = TRUE; // TRUE gives extra messages in places
@@ -89,6 +92,10 @@ foreach ($dbupdateplugs as $path => $ver)
// 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";
@@ -175,6 +182,24 @@ function update_core_prefs($type='')
}
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
//--------------**************---------------
return $just_check;
}
} // End of test routine
//--------------------------------------------
// Upgrade later versions of 0.7.x to 0.8
//--------------------------------------------
@@ -211,7 +236,7 @@ function update_706_to_800($type='')
$db_parser = new db_table_admin; // Class to read table defs and process them
$do_save = FALSE; // Set TRUE to update prefs when update complete
$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 whether an update is needed
if (isset($pref['forum_user_customtitle']) && !isset($pref['signup_option_customtitle']))
@@ -307,6 +332,42 @@ function update_706_to_800($type='')
}
//---------------------------------------------------------
// Comments - split user field
//---------------------------------------------------------
if($sql->db_Field("comments","comment_author"))
{
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
echo "Error<br />";
}
else
{
if (!$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
echo "Error<br />";
}
else
{ // Delete superceded field - comment_author
if (!$sql->db_Select_gen("ALTER TABLE `#comments` DROP COLUMN `comment_author`"))
{
// Flag error
echo "Error<br />";
}
}
}
}
//---------------------------------------------------------
// Add index to download history
//---------------------------------------------------------
if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX."download_requests"))
{
$found = FALSE;
@@ -380,9 +441,9 @@ function update_706_to_800($type='')
}
}
// Tables defined in core_sql.php
//---------------------------------
if (mysql_table_exists('dblog') && !mysql_table_exists('admin_log'))
{
if ($just_check) return update_needed('Rename dblog to admin_log');
@@ -472,8 +533,8 @@ function update_706_to_800($type='')
{
if (strtolower($field_info['Type']) != 'varchar(45)')
{
if ($just_check) return update_needed('Update field '.$f.' in table '.$t);
mysql_query("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR( 45 ) NOT NULL DEFAULT '';");
if ($just_check) return update_needed('Update IP address field '.$f.' in table '.$t);
mysql_query("ALTER TABLE `".MPREFIX.$t."` MODIFY `{$f}` VARCHAR(45) NOT NULL DEFAULT '';");
catch_error();
}
}