removed unused function
[openemr.git] / phpmyadmin / db_tracking.php
blobe451ccd57489dd1e060c4cad341e04b7e887604e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Tracking configuration for database
6 * @package PhpMyAdmin
7 */
9 /**
10 * Run common work
12 require_once 'libraries/common.inc.php';
14 require_once './libraries/tracking.lib.php';
15 require_once 'libraries/display_create_table.lib.php';
17 //Get some js files needed for Ajax requests
18 $response = PMA_Response::getInstance();
19 $header = $response->getHeader();
20 $scripts = $header->getScripts();
21 $scripts->addFile('jquery/jquery.tablesorter.js');
22 $scripts->addFile('db_tracking.js');
24 /**
25 * If we are not in an Ajax request, then do the common work and show the links etc.
27 require 'libraries/db_common.inc.php';
28 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
30 // Get the database structure
31 $sub_part = '_structure';
33 list(
34 $tables,
35 $num_tables,
36 $total_num_tables,
37 $sub_part,
38 $is_show_stats,
39 $db_is_system_schema,
40 $tooltip_truename,
41 $tooltip_aliasname,
42 $pos
43 ) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
45 // Work to do?
46 // (here, do not use $_REQUEST['db] as it can be crafted)
47 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
49 PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
50 PMA_Message::success(
51 __('Tracking data deleted successfully.')
52 )->display();
54 } elseif (isset($_REQUEST['submit_create_version'])) {
56 PMA_createTrackingForMultipleTables($_REQUEST['selected']);
57 PMA_Message::success(
58 sprintf(
59 __(
60 'Version %1$s was created for selected tables,'
61 . ' tracking is active for them.'
63 htmlspecialchars($_REQUEST['version'])
65 )->display();
67 } elseif (isset($_REQUEST['submit_mult'])) {
69 if (! empty($_REQUEST['selected_tbl'])) {
70 if ($_REQUEST['submit_mult'] == 'delete_tracking') {
72 foreach ($_REQUEST['selected_tbl'] as $table) {
73 PMA_Tracker::deleteTracking($GLOBALS['db'], $table);
75 PMA_Message::success(
76 __('Tracking data deleted successfully.')
77 )->display();
79 } elseif ($_REQUEST['submit_mult'] == 'track') {
81 echo PMA_getHtmlForDataDefinitionAndManipulationStatements(
82 'db_tracking.php' . $url_query,
84 $GLOBALS['db'],
85 $_REQUEST['selected_tbl']
87 exit;
89 } else {
90 PMA_Message::notice(
91 __('No tables selected.')
92 )->display();
96 // Get tracked data about the database
97 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
99 // No tables present and no log exist
100 if ($num_tables == 0 && count($data['ddlog']) == 0) {
101 echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
103 if (empty($db_is_system_schema)) {
104 echo PMA_getHtmlForCreateTable($db);
106 exit;
109 // ---------------------------------------------------------------------------
110 $cfgRelation = PMA_getRelationsParam();
112 // Prepare statement to get HEAD version
113 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
114 PMA_Util::backquote($cfgRelation['db']) . '.' .
115 PMA_Util::backquote($cfgRelation['tracking']) .
116 ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($_REQUEST['db']) . '\' ' .
117 ' GROUP BY table_name' .
118 ' ORDER BY table_name ASC';
120 $all_tables_result = PMA_queryAsControlUser($all_tables_query);
122 // If a HEAD version exists
123 if (is_object($all_tables_result) && $GLOBALS['dbi']->numRows($all_tables_result) > 0) {
124 PMA_displayTrackedTables(
125 $GLOBALS['db'], $all_tables_result, $url_query, $pmaThemeImage,
126 $text_dir, $cfgRelation
130 $untracked_tables = PMA_getUntrackedTables($GLOBALS['db']);
132 // If untracked tables exist
133 if (count($untracked_tables) > 0) {
134 PMA_displayUntrackedTables(
135 $GLOBALS['db'], $untracked_tables, $url_query, $pmaThemeImage, $text_dir
138 // If available print out database log
139 if (count($data['ddlog']) > 0) {
140 $log = '';
141 foreach ($data['ddlog'] as $entry) {
142 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
143 . $entry['statement'] . "\n";
145 echo PMA_Util::getMessage(__('Database Log'), $log);