Translation update done using Pootle.
[phpmyadmin-themes.git] / db_tracking.php
blobc2dde64eb9959208d6b110819f8022318060a936
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @version $Id$
5 * @package phpMyAdmin
6 */
8 // Run common work
9 require_once './libraries/common.inc.php';
10 require_once './libraries/Table.class.php';
12 require './libraries/db_common.inc.php';
13 $url_query .= '&amp;goto=tbl_tracking.php&amp;back=db_tracking.php';
15 // Get the database structure
16 $sub_part = '_structure';
17 require './libraries/db_info.inc.php';
19 // Get relation settings
20 require_once './libraries/relation.lib.php';
22 // Work to do?
23 // (here, do not use $_REQUEST['db] as it can be crafted)
24 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
25 PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
28 // Get tracked data about the database
29 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
31 // No tables present and no log exist
32 if ($num_tables == 0 && count($data['ddlog']) == 0) {
33 echo '<p>' . $strNoTablesFound . '</p>' . "\n";
35 if (empty($db_is_information_schema)) {
36 require './libraries/display_create_table.lib.php';
39 // Display the footer
40 require_once './libraries/footer.inc.php';
41 exit;
44 // ---------------------------------------------------------------------------
47 * Display top menu links
49 require_once './libraries/db_links.inc.php';
51 // Prepare statement to get HEAD version
52 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
53 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
54 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
55 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
56 ' GROUP BY '. PMA_backquote('table_name') .
57 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
59 $all_tables_result = PMA_query_as_controluser($all_tables_query);
61 // If a HEAD version exists
62 if (PMA_DBI_num_rows($all_tables_result) > 0) {
64 <h3><?php echo $strTrackingTrackedTables;?></h3>
66 <table id="versions" class="data">
67 <thead>
68 <tr>
69 <th><?php echo $strDatabase;?></th>
70 <th><?php echo $strTable;?></th>
71 <th><?php echo $strTrackingThLastVersion;?></th>
72 <th><?php echo $strTrackingThCreated;?></th>
73 <th><?php echo $strTrackingThUpdated;?></th>
74 <th><?php echo $strStatus;?></th>
75 <th><?php echo $strAction;?></th>
76 <th><?php echo $strShow;?></th>
77 </tr>
78 </thead>
79 <tbody>
80 <?php
82 // Print out information about versions
84 $drop_image_or_text = '';
85 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
86 $drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . $strDeleteTrackingData . '" title="' . $strDeleteTrackingData . '" />';
88 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
89 $drop_image_or_text .= $strDrop;
92 $style = 'odd';
93 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
94 list($table_name, $version_number) = $one_result;
95 $table_query = ' SELECT * FROM ' .
96 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
97 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
98 ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
100 $table_result = PMA_query_as_controluser($table_query);
101 $version_data = PMA_DBI_fetch_array($table_result);
103 if ($version_data['tracking_active'] == 1) {
104 $version_status = $strTrackingStatusActive;
105 } else {
106 $version_status = $strTrackingStatusNotActive;
108 $tmp_link = 'tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
109 $delete_link = 'db_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
111 <tr class="<?php echo $style;?>">
112 <td><?php echo htmlspecialchars($version_data['db_name']);?></td>
113 <td><?php echo htmlspecialchars($version_data['table_name']);?></td>
114 <td><?php echo $version_data['version'];?></td>
115 <td><?php echo $version_data['date_created'];?></td>
116 <td><?php echo $version_data['date_updated'];?></td>
117 <td><?php echo $version_status;?></td>
118 <td><a href="<?php echo $delete_link;?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($strDeleteTrackingData, false); ?>')"><?php echo $drop_image_or_text; ?></a></td>
119 <td> <a href="<?php echo $tmp_link; ?>"><?php echo $strTrackingVersions;?></a>
120 | <a href="<?php echo $tmp_link; ?>&amp;report=true&amp;version=<?php echo $version_data['version'];?>"><?php echo $strTrackingReport;?></a>
121 | <a href="<?php echo $tmp_link; ?>&amp;snapshot=true&amp;version=<?php echo $version_data['version'];?>"><?php echo $strTrackingStructureSnapshot;?></a></td>
122 </tr>
123 <?php
124 if ($style == 'even') {
125 $style = 'odd';
126 } else {
127 $style = 'even';
130 unset($tmp_link);
132 </tbody>
133 </table>
134 <?php
137 // Get list of tables
138 $table_list = PMA_getTableList($GLOBALS['db']);
140 // For each table try to get the tracking version
141 foreach ($table_list as $key => $value) {
142 if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) {
143 $my_tables[] = $value['Name'];
147 // If untracked tables exist
148 if (isset($my_tables)) {
150 <h3><?php echo $strTrackingUntrackedTables;?></h3>
152 <table id="noversions" class="data">
153 <thead>
154 <tr>
155 <th width="300"><?php echo $strTable;?></th>
156 <th></th>
157 </tr>
158 </thead>
159 <tbody>
160 <?php
161 // Print out list of untracked tables
163 $style = 'odd';
165 foreach ($my_tables as $key => $tablename) {
166 if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
167 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($tablename) .'">';
169 if ($cfg['PropertiesIconic']) {
170 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
172 $my_link .= $strTrackingTrackTable . '</a>';
174 <tr class="<?php echo $style;?>">
175 <td><?php echo htmlspecialchars($tablename);?></td>
176 <td><?php echo $my_link;?></td>
177 </tr>
178 <?php
179 if ($style == 'even') {
180 $style = 'odd';
181 } else {
182 $style = 'even';
187 </tbody>
188 </table>
190 <?php
192 // If available print out database log
193 if (count($data['ddlog']) > 0) {
194 $log = '';
195 foreach ($data['ddlog'] as $entry) {
196 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
198 PMA_showMessage($strTrackingDatabaseLog, $log);
202 * Display the footer
204 require_once './libraries/footer.inc.php';