Make default functions configurable (RFE #821271).
This commit is contained in:
@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
|
||||
$Id$
|
||||
$Source$
|
||||
|
||||
2003-10-20 Michal Cihar <nijel@users.sourceforge.net>
|
||||
* Documentation, config.inc.php3, tbl_change.php3,
|
||||
libraries/common.lib.php3, libraries/config_import.lib.php3: Make
|
||||
default functions configurable (RFE #821271).
|
||||
|
||||
2003-10-18 Marc Delisle <lem9@users.sourceforge.net>
|
||||
* libraries/common.lib.php3: bug 821512, Safari 1.0 v85.5 and fonts
|
||||
* libraries/functions.js: bug 825665, scratchboard and paper size
|
||||
|
@@ -1912,6 +1912,31 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
|
||||
<br /><br />
|
||||
</dd>
|
||||
|
||||
<dt><b>$cfg['RestrictColumnTypes'] </b>array</dt>
|
||||
<dd>
|
||||
Mapping of column types to meta types used for prefering displayed
|
||||
functions. In most cases you don't need to edit this.
|
||||
<br /><br />
|
||||
</dd>
|
||||
|
||||
<dt><b>$cfg['RestrictFunctions'] </b>array</dt>
|
||||
<dd>
|
||||
Functions prefered for column meta types as defined in
|
||||
<code>$cfg['RestrictColumnTypes']</code>. In most cases you don't need
|
||||
to edit this.
|
||||
<br /><br />
|
||||
</dd>
|
||||
|
||||
<dt><b>$cfg['DefaultFunctions'] </b>array</dt>
|
||||
<dd>
|
||||
Functions selected by default when insering/changing row, Functions
|
||||
are defined for meta types from
|
||||
<code>$cfg['RestrictColumnTypes']</code> and for
|
||||
<code>first_timestamp</code>, which is used for first timestamp column
|
||||
in table.
|
||||
<br /><br />
|
||||
</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<!-- TRANSFORMATIONS -->
|
||||
|
@@ -14,8 +14,8 @@
|
||||
+ Version history: ChangeLog
|
||||
+ General notes: README
|
||||
+ License: LICENSE
|
||||
* Documentation version: $Id: Documentation.html,v 1.509 2003/10/13
|
||||
00:53:11 lem9 Exp $
|
||||
* Documentation version: $Id: Documentation.html,v 1.510 2003/10/16
|
||||
15:22:11 nijel Exp $
|
||||
|
||||
Requirements
|
||||
|
||||
@@ -1300,6 +1300,21 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
|
||||
A list of functions MySQL supports. In most cases you don't
|
||||
need to edit this.
|
||||
|
||||
$cfg['RestrictColumnTypes'] array
|
||||
Mapping of column types to meta types used for prefering
|
||||
displayed functions. In most cases you don't need to edit this.
|
||||
|
||||
$cfg['RestrictFunctions'] array
|
||||
Functions prefered for column meta types as defined in
|
||||
$cfg['RestrictColumnTypes']. In most cases you don't need to
|
||||
edit this.
|
||||
|
||||
$cfg['DefaultFunctions'] array
|
||||
Functions selected by default when insering/changing row,
|
||||
Functions are defined for meta types from
|
||||
$cfg['RestrictColumnTypes'] and for first_timestamp, which is
|
||||
used for first timestamp column in table.
|
||||
|
||||
Transformations
|
||||
|
||||
Introduction - Usage - File structure -
|
||||
|
@@ -724,6 +724,15 @@ if ($cfg['ShowFunctionFields']) {
|
||||
)
|
||||
);
|
||||
|
||||
// Default functions for above defined groups
|
||||
$cfg['DefaultFunctions'] = array(
|
||||
'FUNC_CHAR' => '',
|
||||
'FUNC_DATE' => '',
|
||||
'FUNC_NUMBER' => '',
|
||||
'first_timestamp' => 'NOW'
|
||||
);
|
||||
|
||||
|
||||
} // end if
|
||||
|
||||
|
||||
|
@@ -135,7 +135,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
||||
* Includes compatibility code for older config.inc.php3 revisions
|
||||
* if necessary
|
||||
*/
|
||||
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 203) {
|
||||
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 206) {
|
||||
include('./libraries/config_import.lib.php3');
|
||||
}
|
||||
|
||||
|
@@ -1012,109 +1012,120 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cfg['Functions']) && $cfg['ShowFunctionFields']) {
|
||||
if (isset($cfgFunctions)) {
|
||||
$cfg['Functions'] = $cfgFunctions;
|
||||
} else {
|
||||
$cfg['Functions'] = array(
|
||||
'ASCII',
|
||||
'CHAR',
|
||||
'SOUNDEX',
|
||||
'LCASE',
|
||||
'UCASE',
|
||||
'NOW',
|
||||
'PASSWORD',
|
||||
'MD5',
|
||||
'ENCRYPT',
|
||||
'RAND',
|
||||
'LAST_INSERT_ID',
|
||||
'COUNT',
|
||||
'AVG',
|
||||
'SUM',
|
||||
'CURDATE',
|
||||
'CURTIME',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'PERIOD_ADD',
|
||||
'PERIOD_DIFF',
|
||||
'TO_DAYS',
|
||||
'UNIX_TIMESTAMP',
|
||||
'USER',
|
||||
'WEEKDAY',
|
||||
'CONCAT'
|
||||
if ($cfg['ShowFunctionFields']) {
|
||||
if (!isset($cfg['Functions'])) {
|
||||
if (isset($cfgFunctions)) {
|
||||
$cfg['Functions'] = $cfgFunctions;
|
||||
} else {
|
||||
$cfg['Functions'] = array(
|
||||
'ASCII',
|
||||
'CHAR',
|
||||
'SOUNDEX',
|
||||
'LCASE',
|
||||
'UCASE',
|
||||
'NOW',
|
||||
'PASSWORD',
|
||||
'MD5',
|
||||
'ENCRYPT',
|
||||
'RAND',
|
||||
'LAST_INSERT_ID',
|
||||
'COUNT',
|
||||
'AVG',
|
||||
'SUM',
|
||||
'CURDATE',
|
||||
'CURTIME',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'PERIOD_ADD',
|
||||
'PERIOD_DIFF',
|
||||
'TO_DAYS',
|
||||
'UNIX_TIMESTAMP',
|
||||
'USER',
|
||||
'WEEKDAY',
|
||||
'CONCAT'
|
||||
);
|
||||
}
|
||||
|
||||
// Which column types will be mapped to which Group?
|
||||
$cfg['RestrictColumnTypes'] = array(
|
||||
'VARCHAR' => 'FUNC_CHAR',
|
||||
'TINYINT' => 'FUNC_NUMBER',
|
||||
'TEXT' => 'FUNC_CHAR',
|
||||
'DATE' => 'FUNC_DATE',
|
||||
'SMALLINT' => 'FUNC_NUMBER',
|
||||
'MEDIUMINT' => 'FUNC_NUMBER',
|
||||
'INT' => 'FUNC_NUMBER',
|
||||
'BIGINT' => 'FUNC_NUMBER',
|
||||
'FLOAT' => 'FUNC_NUMBER',
|
||||
'DOUBLE' => 'FUNC_NUMBER',
|
||||
'DECIMAL' => 'FUNC_NUMBER',
|
||||
'DATETIME' => 'FUNC_DATE',
|
||||
'TIMESTAMP' => 'FUNC_DATE',
|
||||
'TIME' => 'FUNC_DATE',
|
||||
'YEAR' => 'FUNC_DATE',
|
||||
'CHAR' => 'FUNC_CHAR',
|
||||
'TINYBLOB' => 'FUNC_CHAR',
|
||||
'TINYTEXT' => 'FUNC_CHAR',
|
||||
'BLOB' => 'FUNC_CHAR',
|
||||
'MEDIUMBLOB' => 'FUNC_CHAR',
|
||||
'MEDIUMTEXT' => 'FUNC_CHAR',
|
||||
'LONGBLOB' => 'FUNC_CHAR',
|
||||
'LONGTEXT' => 'FUNC_CHAR',
|
||||
'ENUM' => '',
|
||||
'SET' => ''
|
||||
);
|
||||
|
||||
// Map above defined groups to any function
|
||||
$cfg['RestrictFunctions'] = array(
|
||||
'FUNC_CHAR' => array(
|
||||
'ASCII',
|
||||
'CHAR',
|
||||
'SOUNDEX',
|
||||
'LCASE',
|
||||
'UCASE',
|
||||
'PASSWORD',
|
||||
'MD5',
|
||||
'ENCRYPT',
|
||||
'LAST_INSERT_ID',
|
||||
'USER',
|
||||
'CONCAT'
|
||||
),
|
||||
|
||||
'FUNC_DATE' => array(
|
||||
'NOW',
|
||||
'CURDATE',
|
||||
'CURTIME',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'PERIOD_ADD',
|
||||
'PERIOD_DIFF',
|
||||
'TO_DAYS',
|
||||
'UNIX_TIMESTAMP',
|
||||
'WEEKDAY'
|
||||
),
|
||||
|
||||
'FUNC_NUMBER' => array(
|
||||
'ASCII',
|
||||
'CHAR',
|
||||
'MD5',
|
||||
'ENCRYPT',
|
||||
'RAND',
|
||||
'LAST_INSERT_ID',
|
||||
'COUNT',
|
||||
'AVG',
|
||||
'SUM'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Which column types will be mapped to which Group?
|
||||
$cfg['RestrictColumnTypes'] = array(
|
||||
'VARCHAR' => 'FUNC_CHAR',
|
||||
'TINYINT' => 'FUNC_NUMBER',
|
||||
'TEXT' => 'FUNC_CHAR',
|
||||
'DATE' => 'FUNC_DATE',
|
||||
'SMALLINT' => 'FUNC_NUMBER',
|
||||
'MEDIUMINT' => 'FUNC_NUMBER',
|
||||
'INT' => 'FUNC_NUMBER',
|
||||
'BIGINT' => 'FUNC_NUMBER',
|
||||
'FLOAT' => 'FUNC_NUMBER',
|
||||
'DOUBLE' => 'FUNC_NUMBER',
|
||||
'DECIMAL' => 'FUNC_NUMBER',
|
||||
'DATETIME' => 'FUNC_DATE',
|
||||
'TIMESTAMP' => 'FUNC_DATE',
|
||||
'TIME' => 'FUNC_DATE',
|
||||
'YEAR' => 'FUNC_DATE',
|
||||
'CHAR' => 'FUNC_CHAR',
|
||||
'TINYBLOB' => 'FUNC_CHAR',
|
||||
'TINYTEXT' => 'FUNC_CHAR',
|
||||
'BLOB' => 'FUNC_CHAR',
|
||||
'MEDIUMBLOB' => 'FUNC_CHAR',
|
||||
'MEDIUMTEXT' => 'FUNC_CHAR',
|
||||
'LONGBLOB' => 'FUNC_CHAR',
|
||||
'LONGTEXT' => 'FUNC_CHAR',
|
||||
'ENUM' => '',
|
||||
'SET' => ''
|
||||
);
|
||||
|
||||
// Map above defined groups to any function
|
||||
$cfg['RestrictFunctions'] = array(
|
||||
'FUNC_CHAR' => array(
|
||||
'ASCII',
|
||||
'CHAR',
|
||||
'SOUNDEX',
|
||||
'LCASE',
|
||||
'UCASE',
|
||||
'PASSWORD',
|
||||
'MD5',
|
||||
'ENCRYPT',
|
||||
'LAST_INSERT_ID',
|
||||
'USER',
|
||||
'CONCAT'
|
||||
),
|
||||
|
||||
'FUNC_DATE' => array(
|
||||
'NOW',
|
||||
'CURDATE',
|
||||
'CURTIME',
|
||||
'FROM_DAYS',
|
||||
'FROM_UNIXTIME',
|
||||
'PERIOD_ADD',
|
||||
'PERIOD_DIFF',
|
||||
'TO_DAYS',
|
||||
'UNIX_TIMESTAMP',
|
||||
'WEEKDAY'
|
||||
),
|
||||
|
||||
'FUNC_NUMBER' => array(
|
||||
'ASCII',
|
||||
'CHAR',
|
||||
'MD5',
|
||||
'ENCRYPT',
|
||||
'RAND',
|
||||
'LAST_INSERT_ID',
|
||||
'COUNT',
|
||||
'AVG',
|
||||
'SUM'
|
||||
)
|
||||
);
|
||||
if (!isset($cfg['DefaultFunctions'])) {
|
||||
$cfg['DefaultFunctions'] = array(
|
||||
'FUNC_CHAR' => '',
|
||||
'FUNC_DATE' => '',
|
||||
'FUNC_NUMBER' => '',
|
||||
'first_timestamp' => 'NOW'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cfg['GD2Available'])) {
|
||||
|
@@ -360,7 +360,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
// or something similar. Then directly look up the entry in the RestrictFunctions array,
|
||||
// which will then reveal the available dropdown options
|
||||
if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
|
||||
$dropdown = $cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]];
|
||||
$current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
|
||||
$dropdown = $cfg['RestrictFunctions'][$current_func_type];
|
||||
$default_function = $cfg['DefaultFunctions'][$current_func_type];
|
||||
} else {
|
||||
$dropdown = array();
|
||||
}
|
||||
@@ -370,9 +372,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
|
||||
// garvin: loop on the dropdown array and print all available options for that field.
|
||||
for ($j = 0; $j < count($dropdown); $j++) {
|
||||
// for default function = NOW() on first timestamp field
|
||||
// -- swix/18jul01
|
||||
$selected = ($first_timestamp && $dropdown[$j] == 'NOW')
|
||||
// Is current function defined as default?
|
||||
$selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
|
||||
|| (!$first_timestamp && $dropdown[$j] == $default_function)
|
||||
? ' selected="selected"'
|
||||
: '';
|
||||
echo ' ';
|
||||
@@ -386,9 +388,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
// yet.
|
||||
for ($j = 0; $j < count($cfg['Functions']); $j++) {
|
||||
if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
|
||||
// for default function = NOW() on first timestamp field
|
||||
// -- swix/18jul01
|
||||
$selected = ($first_timestamp && $cfg['Functions'][$j] == 'NOW')
|
||||
// Is current function defined as default?
|
||||
$selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
|
||||
|| (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
|
||||
? ' selected="selected"'
|
||||
: '';
|
||||
if ($op_spacing_needed == TRUE) {
|
||||
|
Reference in New Issue
Block a user