From e641e5ceba7b5c78807293038f58ff74222a5c6e Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 24 May 2011 17:16:13 +0200 Subject: [PATCH] Limit commands and import in customization (bug #3194432) --- adminer/include/adminer.inc.php | 16 ++++++++++++++++ adminer/select.inc.php | 16 +++++++++------- editor/include/adminer.inc.php | 8 ++++++++ plugins/plugin.php | 10 ++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 19a6238b..c29546ff 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -1,4 +1,6 @@ \n"; } + /** Print command box in select + * @return bool whether to print default commands + */ + function selectCommandPrint() { + return !information_schema(DB); + } + + /** Print import box in select + * @return bool whether to print default import + */ + function selectImportPrint() { + return true; + } + /** Print extra text in the end of a select form * @param array fields holding e-mails * @param array selectable columns diff --git a/adminer/select.inc.php b/adminer/select.inc.php index f9f3f0ec..bcde4e77 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -395,7 +395,7 @@ if (!$columns) { } echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n"; - if (!information_schema(DB)) { + if ($adminer->selectCommandPrint()) { ?>
@@ -412,12 +412,14 @@ if (!$columns) { echo " \n"; echo "
\n"; } - print_fieldset("import", lang('Import'), !$rows); - echo " "; - echo html_select("separator", array("csv" => "CSV,", "csv;" => "CSV;", "tsv" => "TSV"), $adminer_export["format"], 1); // 1 - select - echo " "; - echo "\n"; - echo "\n"; + if ($adminer->selectImportPrint()) { + print_fieldset("import", lang('Import'), !$rows); + echo " "; + echo html_select("separator", array("csv" => "CSV,", "csv;" => "CSV;", "tsv" => "TSV"), $adminer_export["format"], 1); // 1 - select + echo " "; + echo "\n"; + echo "\n"; + } $adminer->selectEmailPrint(array_filter($email_fields, 'strlen'), $columns); diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index 4714b0a9..2692c892 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -275,6 +275,14 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 echo "\n"; } + function selectCommandPrint() { + return true; + } + + function selectImportPrint() { + return true; + } + function selectEmailPrint($emailFields, $columns) { if ($emailFields) { print_fieldset("email", lang('E-mail'), $_POST["email_append"]); diff --git a/plugins/plugin.php b/plugins/plugin.php index 35798c98..344f0310 100644 --- a/plugins/plugin.php +++ b/plugins/plugin.php @@ -215,6 +215,16 @@ class AdminerPlugin extends Adminer { return $this->_applyPlugin(__FUNCTION__, $args); } + function selectCommandPrint() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectImportPrint() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + function selectEmailPrint() { $args = func_get_args(); return $this->_applyPlugin(__FUNCTION__, $args);