Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Delisle <marc@infomarc.info>2015-11-21 14:50:41 +0300
committerMarc Delisle <marc@infomarc.info>2015-11-21 14:50:41 +0300
commite02542d0ba955200b70baa9cca94e4eb472f8f30 (patch)
treeaa364edae9eade7b26eb59ebb7c513bf9904c89e /tbl_export.php
parent0dae3b2874cbbc8fbaa289b3d3069c92517e2267 (diff)
Refactor handling of export template actions
Signed-off-by: Marc Delisle <marc@infomarc.info>
Diffstat (limited to 'tbl_export.php')
-rw-r--r--tbl_export.php66
1 files changed, 1 insertions, 65 deletions
diff --git a/tbl_export.php b/tbl_export.php
index 5831971a5c..deac625dc9 100644
--- a/tbl_export.php
+++ b/tbl_export.php
@@ -28,71 +28,7 @@ $cfgRelation = PMA_getRelationsParam();
// handling export template actions
if (isset($_REQUEST['templateAction']) && $cfgRelation['exporttemplateswork']) {
-
- if (isset($_REQUEST['templateId'])) {
- $templateId = $_REQUEST['templateId'];
- $id = PMA\libraries\Util::sqlAddSlashes($templateId);
- }
-
- $templateTable = PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
- . PMA\libraries\Util::backquote($cfgRelation['export_templates']);
- $user = PMA\libraries\Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']);
-
- switch ($_REQUEST['templateAction']) {
- case 'create':
- $query = "INSERT INTO " . $templateTable . "("
- . " `username`, `export_type`,"
- . " `template_name`, `template_data`"
- . ") VALUES ("
- . "'" . $user . "', "
- . "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['exportType'])
- . "', '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateName'])
- . "', '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateData'])
- . "');";
- break;
- case 'load':
- $query = "SELECT `template_data` FROM " . $templateTable
- . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
- break;
- case 'update':
- $query = "UPDATE " . $templateTable . " SET `template_data` = "
- . "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateData']) . "'"
- . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
- break;
- case 'delete':
- $query = "DELETE FROM " . $templateTable
- . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
- break;
- default:
- break;
- }
-
- $result = PMA_queryAsControlUser($query, false);
-
- $response = PMA\libraries\Response::getInstance();
- if (! $result) {
- $error = $GLOBALS['dbi']->getError($GLOBALS['controllink']);
- $response->setRequestStatus(false);
- $response->addJSON('message', $error);
- exit;
- }
-
- $response->setRequestStatus(true);
- if ('create' == $_REQUEST['templateAction']) {
- $response->addJSON(
- 'data',
- PMA_getOptionsForExportTemplates($_REQUEST['exportType'])
- );
- } elseif ('load' == $_REQUEST['templateAction']) {
- $data = null;
- while ($row = $GLOBALS['dbi']->fetchAssoc(
- $result, $GLOBALS['controllink']
- )) {
- $data = $row['template_data'];
- }
- $response->addJSON('data', $data);
- }
- $GLOBALS['dbi']->freeResult($result);
+ PMA_handleExportTemplateActions($cfgRelation);
exit;
}