Skip to content

Commit

Permalink
Refactor tracking functions to static methods
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Aug 21, 2017
1 parent f5c2c54 commit bb0555b
Show file tree
Hide file tree
Showing 5 changed files with 1,821 additions and 1,816 deletions.
31 changes: 16 additions & 15 deletions db_tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
*
* @package PhpMyAdmin
*/
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Tracker;
use PhpMyAdmin\Tracking;
use PhpMyAdmin\Util;

/**
* Run common work
*/
require_once 'libraries/common.inc.php';

require_once './libraries/tracking.lib.php';
require_once 'libraries/display_create_table.lib.php';

//Get some js files needed for Ajax requests
Expand Down Expand Up @@ -42,21 +43,21 @@
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PhpMyAdmin\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');

// Work to do?
// (here, do not use $_REQUEST['db] as it can be crafted)
if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {

Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
PhpMyAdmin\Message::success(
Message::success(
__('Tracking data deleted successfully.')
)->display();

} elseif (isset($_REQUEST['submit_create_version'])) {

PMA_createTrackingForMultipleTables($_REQUEST['selected']);
PhpMyAdmin\Message::success(
Tracking::createTrackingForMultipleTables($_REQUEST['selected']);
Message::success(
sprintf(
__(
'Version %1$s was created for selected tables,'
Expand All @@ -74,13 +75,13 @@
foreach ($_REQUEST['selected_tbl'] as $table) {
Tracker::deleteTracking($GLOBALS['db'], $table);
}
PhpMyAdmin\Message::success(
Message::success(
__('Tracking data deleted successfully.')
)->display();

} elseif ($_REQUEST['submit_mult'] == 'track') {

echo PMA_getHtmlForDataDefinitionAndManipulationStatements(
echo Tracking::getHtmlForDataDefinitionAndManipulationStatements(
'db_tracking.php' . $url_query,
0,
$GLOBALS['db'],
Expand All @@ -89,7 +90,7 @@
exit;
}
} else {
PhpMyAdmin\Message::notice(
Message::notice(
__('No tables selected.')
)->display();
}
Expand All @@ -113,8 +114,8 @@

// Prepare statement to get HEAD version
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
PhpMyAdmin\Util::backquote($cfgRelation['db']) . '.' .
PhpMyAdmin\Util::backquote($cfgRelation['tracking']) .
Util::backquote($cfgRelation['db']) . '.' .
Util::backquote($cfgRelation['tracking']) .
' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['db']) .
'\' ' .
' GROUP BY table_name' .
Expand All @@ -126,17 +127,17 @@
if (is_object($all_tables_result)
&& $GLOBALS['dbi']->numRows($all_tables_result) > 0
) {
PMA_displayTrackedTables(
Tracking::displayTrackedTables(
$GLOBALS['db'], $all_tables_result, $url_query, $pmaThemeImage,
$text_dir, $cfgRelation
);
}

$untracked_tables = PMA_getUntrackedTables($GLOBALS['db']);
$untracked_tables = Tracking::getUntrackedTables($GLOBALS['db']);

// If untracked tables exist
if (count($untracked_tables) > 0) {
PMA_displayUntrackedTables(
Tracking::displayUntrackedTables(
$GLOBALS['db'], $untracked_tables, $url_query, $pmaThemeImage, $text_dir
);
}
Expand All @@ -147,5 +148,5 @@
$log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
. $entry['statement'] . "\n";
}
echo PhpMyAdmin\Util::getMessage(__('Database Log'), $log);
echo Util::getMessage(__('Database Log'), $log);
}
Loading

0 comments on commit bb0555b

Please sign in to comment.