diff --git a/ChangeLog b/ChangeLog index dde630345..00568667d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,16 @@ $Source$ * libraries/display_tbl.lib.php3: Fixed transformation-link variable usage for special queries like 'SHOW FIELDS', where certain variables are not set. + * config.inc.php3, tbl_addfield.php3, tbl_alter.php3, tbl_create.php3, + tbl_move_copy.php3, tbl_properties.inc.php3, tbl_properties_structure.php3, + transformation_wrapper.php3, libraries/config_import.lib.php3, + libraries/display_tbl.lib.php3, libraries/relation.lib.php3, + scripts/create_tables.sql: + Test if MIME-feature are really available. Preparation for PMA_db-based + SQL-History. + Removed a dupe for inserting comments, fixed integrity check when + moving/renaming tables and keeping comments. + 2003-02-25 Marc Delisle * db_details_structure.php3: undefined variable $comment diff --git a/config.inc.php3 b/config.inc.php3 index 5fc6d7473..a3de2e5d0 100755 --- a/config.inc.php3 +++ b/config.inc.php3 @@ -94,6 +94,11 @@ $cfg['Servers'][$i]['pdf_pages'] = ''; // table to describe pages o // - leave blank if you don't want to use this $cfg['Servers'][$i]['column_info'] = ''; // table to store column information // - leave blank if you don't want to use this +$cfg['Servers'][$i]['history'] = ''; // table to store SQL history + // - leave blank if you don't want to use this +$cfg['Servers'][$i]['verbose_check'] = TRUE; // set to FALSE if you know that your PMA_* tables + // are up to date. This prevents compatibility + // checks and thereby increases performance. $cfg['Servers'][$i]['AllowDeny']['order'] // Host authentication order, leave blank to not use = ''; $cfg['Servers'][$i]['AllowDeny']['rules'] // Host authentication rules, leave blank for defaults diff --git a/libraries/config_import.lib.php3 b/libraries/config_import.lib.php3 index 71dbe35dd..07b949d23 100644 --- a/libraries/config_import.lib.php3 +++ b/libraries/config_import.lib.php3 @@ -120,6 +120,14 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) { $cfg['Servers'][$i]['pdf_pages'] = ''; } + if (!isset($cfg['Servers'][$i]['history'])) { + $cfg['Servers'][$i]['history'] = ''; + } + + if (!isset($cfg['Servers'][$i]['verbose_check'])) { + $cfg['Servers'][$i]['verbose_check'] = TRUE; + } + if (!isset($cfg['Servers'][$i]['AllowDeny'])) { $cfg['Servers'][$i]['AllowDeny'] = array ('order' => '', 'rules' => array()); diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 2deb8a0f3..544137492 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -527,7 +527,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { $comments_map = array(); } - if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfg']['BrowseMIME']) { + if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { require('./libraries/transformations.lib.php3'); $GLOBALS['mime_map'] = PMA_getMIME($db, $table); } @@ -1001,7 +1001,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { $transform_function = $default_function; $transform_options = array(); - if ($GLOBALS['cfg']['BrowseMIME']) { + if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation'])) { // garvin: for security, never allow to break out from transformations directory diff --git a/libraries/relation.lib.php3 b/libraries/relation.lib.php3 index 088a09d4e..414e81864 100644 --- a/libraries/relation.lib.php3 +++ b/libraries/relation.lib.php3 @@ -84,6 +84,8 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ $cfgRelation['displaywork'] = FALSE; $cfgRelation['pdfwork'] = FALSE; $cfgRelation['commwork'] = FALSE; + $cfgRelation['mimework'] = FALSE; + $cfgRelation['historywork'] = FALSE; $cfgRelation['allworks'] = FALSE; // No server selected -> no bookmark table @@ -127,6 +129,8 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ $cfgRelation['column_info'] = $curr_table[0]; } else if ($curr_table[0] == $cfg['Server']['pdf_pages']) { $cfgRelation['pdf_pages'] = $curr_table[0]; + } else if ($curr_table[0] == $cfg['Server']['history']) { + $cfgRelation['history'] = $curr_table[0]; } } // end while if (isset($cfgRelation['relation'])) { @@ -139,11 +143,42 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ } if (isset($cfgRelation['column_info'])) { $cfgRelation['commwork'] = TRUE; + + if ($cfg['Server']['verbose_check']) { + $mime_query = 'SHOW FIELDS FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']); + $mime_rs = PMA_query_as_cu($mime_query, FALSE); + + $mime_field_mimetype = FALSE; + $mime_field_transformation = FALSE; + $mime_field_transformation_options = FALSE; + while ($curr_mime_field = @PMA_mysql_fetch_array($mime_rs)) { + if ($curr_mime_field[0] == 'mimetype') { + $mime_field_mimetype = TRUE; + } else if ($curr_mime_field[0] == 'transformation') { + $mime_field_transformation = TRUE; + } else if ($curr_mime_field[0] == 'transformation_options') { + $mime_field_transformation_options = TRUE; + } + } + + if ($mime_field_mimetype == TRUE + && $mime_field_transformation == TRUE + && $mime_field_transformation_options == TRUE) { + $cfgRelation['mimework'] = TRUE; + } + } else { + $cfgRelation['mimework'] = TRUE; + } } } // end if + + if (isset($cfgRelation['history'])) { + $cfgRelation['historywork'] = TRUE; + } if ($cfgRelation['relwork'] == TRUE && $cfgRelation['displaywork'] == TRUE - && $cfgRelation['pdfwork'] == TRUE && $cfgRelation['commwork'] == TRUE) { + && $cfgRelation['pdfwork'] == TRUE && $cfgRelation['commwork'] == TRUE + && $cfgRelation['mimework'] && $cfgRelation['historywork']) { $cfgRelation['allworks'] = TRUE; } if ($tab_rs) { @@ -197,6 +232,19 @@ if (!defined('PMA_RELATION_LIB_INCLUDED')){ echo ' ' . $GLOBALS['strColComFeat'] . ': ' . (($cfgRelation['commwork'] == TRUE) ? $enabled : $disabled) . '' . "\n"; + echo ' MIME: ' + . (($cfgRelation['mimework'] == TRUE) ? $enabled : $disabled) + . '' . "\n"; + +// . '
(MIME: ' . (($cfgRelation['mimework'] == TRUE) ? $enabled : $disabled) . ')' + + echo ' $cfg[\'Servers\'][$i][\'history\'] ... ' + . ((isset($cfgRelation['history'])) ? $hit : sprintf($shit, 'history')) + . '' . "\n"; + echo ' ' . $GLOBALS['strQuerySQLHistory'] . ': ' + . (($cfgRelation['historywork'] == TRUE) ? $enabled : $disabled) + . '' . "\n"; + echo '' . "\n"; } // end if ($verbose == TRUE) { diff --git a/scripts/create_tables.sql b/scripts/create_tables.sql index ebd38ea6c..9e88077b1 100644 --- a/scripts/create_tables.sql +++ b/scripts/create_tables.sql @@ -77,3 +77,14 @@ CREATE TABLE `PMA_column_comments` ( PRIMARY KEY (id), UNIQUE KEY db_name (db_name, table_name, column_name) ) TYPE=MyISAM COMMENT='Comments for Columns'; + +CREATE TABLE `PMA_history` ( + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `username` VARCHAR( 64 ) NOT NULL , + `db` VARCHAR( 64 ) NOT NULL , + `table` VARCHAR( 64 ) NOT NULL , + `timevalue` TIMESTAMP NOT NULL , + `sqlquery` TEXT NOT NULL , + PRIMARY KEY ( `id` ) , + INDEX ( `username` , `db` , `table` , `timevalue` ) + ) TYPE=MyISAM COMMENT='SQL history'; diff --git a/tbl_addfield.php3 b/tbl_addfield.php3 index 6adbeab32..aceb211c3 100755 --- a/tbl_addfield.php3 +++ b/tbl_addfield.php3 @@ -207,28 +207,13 @@ if (isset($submit)) { } // garvin: Update comment table for mime types [MIME] - if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { @reset($field_mimetype); while(list($fieldindex, $mimetype) = each($field_mimetype)) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); } } - // garvin: If comments were sent, enable relation stuff - require('./libraries/relation.lib.php3'); - require('./libraries/transformations.lib.php3'); - - $cfgRelation = PMA_getRelationsParam(); - - // garvin: Update comment table for mime types [MIME] - if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { - PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); - } - } - - // Go back to the structure sub-page $sql_query = $sql_query_cpy; unset($sql_query_cpy); diff --git a/tbl_alter.php3 b/tbl_alter.php3 index f6fa63f18..8574ee917 100755 --- a/tbl_alter.php3 +++ b/tbl_alter.php3 @@ -103,7 +103,7 @@ if (isset($submit)) { } // garvin: Update comment table for mime types [MIME] - if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { @reset($field_mimetype); while(list($fieldindex, $mimetype) = each($field_mimetype)) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); diff --git a/tbl_create.php3 b/tbl_create.php3 index 762c1962e..f6a1fc558 100755 --- a/tbl_create.php3 +++ b/tbl_create.php3 @@ -208,7 +208,7 @@ if (isset($submit)) { } // garvin: Update comment table for mime types [MIME] - if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfg['BrowseMIME']) { + if (is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { @reset($field_mimetype); while(list($fieldindex, $mimetype) = each($field_mimetype)) { PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); diff --git a/tbl_move_copy.php3 b/tbl_move_copy.php3 index 7ec353798..598c51f46 100644 --- a/tbl_move_copy.php3 +++ b/tbl_move_copy.php3 @@ -142,9 +142,24 @@ if (isset($new_name) && trim($new_name) != '') { } else { // garvin: Create new entries as duplicates from old comments if ($cfgRelation['commwork']) { + // Write every comment as new copied entry. [MIME] + while ($comments_copy_row = @PMA_mysql_fetch_array($comments_copy_rs)) { + $new_comment_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_comments']) + . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ', mimetype, transformation, transformation_options) ' + . ' VALUES(' + . '\'' . PMA_sqlAddslashes($target_db) . '\',' + . '\'' . PMA_sqlAddslashes($new_name) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['column_name']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['comment']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['mimetype']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['transformation']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['transformation_options']) . '\')'; + $new_comment_rs = PMA_query_as_cu($new_comment_query); + } // end while + // Get all comments and MIME-Types for current table $comments_copy_query = 'SELECT - column_name, ' . PMA_backquote('comment') . ' + column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ' FROM ' . PMA_backquote($cfgRelation['column_info']) . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\' AND @@ -154,11 +169,16 @@ if (isset($new_name) && trim($new_name) != '') { // Write every comment as new copied entry. [MIME] while ($comments_copy_row = @PMA_mysql_fetch_array($comments_copy_rs)) { $new_comment_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_info']) - . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ') ' - . ' VALUES(' - . '\'' . PMA_sqlAddslashes($target_db) . '\',' - . '\'' . PMA_sqlAddslashes($new_name) . '\',' - . '\'' . PMA_handleSlashes($comments_copy_row['comment']) . '\')'; + . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ($cfgRelation['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') ' + . ' VALUES(' + . '\'' . PMA_sqlAddslashes($target_db) . '\',' + . '\'' . PMA_sqlAddslashes($new_name) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['column_name']) . '\'' + . ($cfgRelation['mimework'] ? ',\'' . PMA_handleSlashes($comments_copy_row['comment']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['mimetype']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['transformation']) . '\',' + . '\'' . PMA_handleSlashes($comments_copy_row['transformation_options']) . '\'' : '') + . ')'; $new_comment_rs = PMA_query_as_cu($new_comment_query); } // end while } diff --git a/tbl_properties.inc.php3 b/tbl_properties.inc.php3 index ee4f54019..6c67442ff 100755 --- a/tbl_properties.inc.php3 +++ b/tbl_properties.inc.php3 @@ -51,7 +51,7 @@ if ($cfgRelation['commwork']) { $comments_map = PMA_getComments($db, $table); echo '' . $strComments . ''; - if ($cfg['BrowseMIME']) { + if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) { $mime_map = PMA_getMIME($db, $table); $available_mime = PMA_getAvailableMIMEtypes(); @@ -255,7 +255,7 @@ for ($i = 0 ; $i < $num_fields; $i++) { } // garvin: MIME-types - if ($cfg['BrowseMIME'] && $cfgRelation['commwork']) { + if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) { ?>