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:
authorMadhura Jayaratne <madhura.cj@gmail.com>2015-06-30 23:27:38 +0300
committerMadhura Jayaratne <madhura.cj@gmail.com>2015-07-02 18:33:57 +0300
commit545db4a44353e0ee70a1a93ea01dce4d5c4cad70 (patch)
tree8cc592657975caecc316941fac2442f732d03224 /tbl_export.php
parent89b75b3a4e94fb33e427281dce12fe474c248291 (diff)
rfe #812 store export definitions for reuse
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
Diffstat (limited to 'tbl_export.php')
-rw-r--r--tbl_export.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/tbl_export.php b/tbl_export.php
index 82a61253d1..d9eeb701b3 100644
--- a/tbl_export.php
+++ b/tbl_export.php
@@ -11,6 +11,7 @@
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/config/page_settings.class.php';
+require_once 'libraries/display_export.lib.php';
PMA_PageSettings::showGroup('Export');
@@ -19,6 +20,79 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('export.js');
+// Get the relation settings
+$cfgRelation = PMA_getRelationsParam();
+
+// handling export template actions
+if (isset($_REQUEST['templateAction']) && $cfgRelation['exporttemplateswork']) {
+
+ if (isset($_REQUEST['templateId'])) {
+ $templateId = $_REQUEST['templateId'];
+ $id = PMA_Util::sqlAddSlashes($templateId);
+ }
+
+ $templateTable = PMA_Util::backquote($cfgRelation['db']) . '.'
+ . PMA_Util::backquote($cfgRelation['exporttemplates']);
+ $user = PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']);
+
+ if ('create' == $_REQUEST['templateAction']) {
+ $query = "INSERT INTO " . $templateTable . "("
+ . " `username`, `db_name`, `table_name`,"
+ . " `template_name`, `template_data`"
+ . ") VALUES ("
+ . "'" . $user . "', "
+ . (! empty($GLOBALS['db'])
+ ? "'" . PMA_Util::sqlAddSlashes($GLOBALS['db']) . "'"
+ : 'NULL'
+ ) . ","
+ . (! empty($GLOBALS['table'])
+ ? "'" . PMA_Util::sqlAddSlashes($GLOBALS['table']) . "'"
+ : 'NULL'
+ ) . ","
+ . "'" . PMA_Util::sqlAddSlashes($_REQUEST['templateName']) . "', "
+ . "'" . PMA_Util::sqlAddSlashes($_REQUEST['templateData']) . "');";
+
+ } elseif ('load' == $_REQUEST['templateAction']) {
+ $query = "SELECT `template_data` FROM " . $templateTable
+ . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
+
+ } elseif ('update' == $_REQUEST['templateAction']) {
+ $query = "UPDATE " . $templateTable . " SET `template_data` = "
+ . "'" . PMA_Util::sqlAddSlashes($_REQUEST['templateData']) . "'"
+ . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
+
+ } elseif ('delete' == $_REQUEST['templateAction']) {
+ $query = "DELETE FROM " . $templateTable
+ . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
+ }
+
+ $result = PMA_queryAsControlUser($query, false);
+
+ $response = PMA_Response::getInstance();
+ if (! $result) {
+ $error = $GLOBALS['dbi']->getError($GLOBALS['controllink']);
+ $response->isSuccess(false);
+ $response->addJSON('message', $error);
+ exit;
+ }
+
+ $response->isSuccess(true);
+ if ('create' == $_REQUEST['templateAction']) {
+ $response->addJSON(
+ 'data',
+ PMA_getOptionsForExportTemplates($GLOBALS['db'], $GLOBALS['table'])
+ );
+ } 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);
+ exit;
+}
+
/**
* Gets tables information and displays top links
*/