Translation update done using Pootle.
[phpmyadmin/lorilee.git] / db_tracking.php
blob1c8c5cece919d721facdb8e7d7321f429f7df651
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package phpMyAdmin
5 */
7 /**
8 * Run common work
9 */
10 require_once './libraries/common.inc.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 // Work to do?
20 // (here, do not use $_REQUEST['db] as it can be crafted)
21 if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
22 PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
25 // Get tracked data about the database
26 $data = PMA_Tracker::getTrackedData($_REQUEST['db'], '', '1');
28 // No tables present and no log exist
29 if ($num_tables == 0 && count($data['ddlog']) == 0) {
30 echo '<p>' . __('No tables found in database.') . '</p>' . "\n";
32 if (empty($db_is_information_schema)) {
33 require './libraries/display_create_table.lib.php';
36 // Display the footer
37 require './libraries/footer.inc.php';
38 exit;
41 // ---------------------------------------------------------------------------
44 * Display top menu links
46 require_once './libraries/db_links.inc.php';
48 // Prepare statement to get HEAD version
49 $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
50 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
51 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
52 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
53 ' GROUP BY '. PMA_backquote('table_name') .
54 ' ORDER BY '. PMA_backquote('table_name') .' ASC';
56 $all_tables_result = PMA_query_as_controluser($all_tables_query);
58 // If a HEAD version exists
59 if (PMA_DBI_num_rows($all_tables_result) > 0) {
61 <h3><?php echo __('Tracked tables');?></h3>
63 <table id="versions" class="data">
64 <thead>
65 <tr>
66 <th><?php echo __('Database');?></th>
67 <th><?php echo __('Table');?></th>
68 <th><?php echo __('Last version');?></th>
69 <th><?php echo __('Created');?></th>
70 <th><?php echo __('Updated');?></th>
71 <th><?php echo __('Status');?></th>
72 <th><?php echo __('Action');?></th>
73 <th><?php echo __('Show');?></th>
74 </tr>
75 </thead>
76 <tbody>
77 <?php
79 // Print out information about versions
81 $drop_image_or_text = '';
82 if (true == $GLOBALS['cfg']['PropertiesIconic']) {
83 $drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . __('Delete tracking data for this table') . '" title="' . __('Delete tracking data for this table') . '" />';
85 if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
86 $drop_image_or_text .= __('Drop');
89 $style = 'odd';
90 while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
91 list($table_name, $version_number) = $one_result;
92 $table_query = ' SELECT * FROM ' .
93 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
94 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
95 ' WHERE `db_name` = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA_sqlAddslashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
97 $table_result = PMA_query_as_controluser($table_query);
98 $version_data = PMA_DBI_fetch_array($table_result);
100 if ($version_data['tracking_active'] == 1) {
101 $version_status = __('active');
102 } else {
103 $version_status = __('not active');
105 $tmp_link = 'tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
106 $delete_link = 'db_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
108 <tr class="<?php echo $style;?>">
109 <td><?php echo htmlspecialchars($version_data['db_name']);?></td>
110 <td><?php echo htmlspecialchars($version_data['table_name']);?></td>
111 <td><?php echo $version_data['version'];?></td>
112 <td><?php echo $version_data['date_created'];?></td>
113 <td><?php echo $version_data['date_updated'];?></td>
114 <td><?php echo $version_status;?></td>
115 <td><a href="<?php echo $delete_link;?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat(__('Delete tracking data for this table'), false); ?>')"><?php echo $drop_image_or_text; ?></a></td>
116 <td> <a href="<?php echo $tmp_link; ?>"><?php echo __('Versions');?></a>
117 | <a href="<?php echo $tmp_link; ?>&amp;report=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Tracking report');?></a>
118 | <a href="<?php echo $tmp_link; ?>&amp;snapshot=true&amp;version=<?php echo $version_data['version'];?>"><?php echo __('Structure snapshot');?></a></td>
119 </tr>
120 <?php
121 if ($style == 'even') {
122 $style = 'odd';
123 } else {
124 $style = 'even';
127 unset($tmp_link);
129 </tbody>
130 </table>
131 <?php
134 // Get list of tables
135 $table_list = PMA_getTableList($GLOBALS['db']);
137 // For each table try to get the tracking version
138 foreach ($table_list as $key => $value) {
139 if (PMA_Tracker::getVersion($GLOBALS['db'], $value['Name']) == -1) {
140 $my_tables[] = $value['Name'];
144 // If untracked tables exist
145 if (isset($my_tables)) {
147 <h3><?php echo __('Untracked tables');?></h3>
149 <table id="noversions" class="data">
150 <thead>
151 <tr>
152 <th width="300"><?php echo __('Table');?></th>
153 <th></th>
154 </tr>
155 </thead>
156 <tbody>
157 <?php
158 // Print out list of untracked tables
160 $style = 'odd';
162 foreach ($my_tables as $key => $tablename) {
163 if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
164 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&amp;table=' . htmlspecialchars($tablename) .'">';
166 if ($cfg['PropertiesIconic']) {
167 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
169 $my_link .= __('Track table') . '</a>';
171 <tr class="<?php echo $style;?>">
172 <td><?php echo htmlspecialchars($tablename);?></td>
173 <td><?php echo $my_link;?></td>
174 </tr>
175 <?php
176 if ($style == 'even') {
177 $style = 'odd';
178 } else {
179 $style = 'even';
184 </tbody>
185 </table>
187 <?php
189 // If available print out database log
190 if (count($data['ddlog']) > 0) {
191 $log = '';
192 foreach ($data['ddlog'] as $entry) {
193 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
195 PMA_showMessage(__('Database Log'), $log);
199 * Display the footer
201 require './libraries/footer.inc.php';