2 /* vim: set expandtab sw=4 ts=4 sts=4: */
5 * @author Alexander Rutkowski
10 require_once './libraries/common.inc.php';
11 require_once './libraries/Table.class.php';
13 require './libraries/db_common.inc.php';
14 $url_query .= '&goto=tbl_tracking.php&back=db_tracking.php';
16 // Get the database structure
17 $sub_part = '_structure';
18 require './libraries/db_info.inc.php';
20 // Get relation settings
21 require_once './libraries/relation.lib.php';
23 // Get tracked data about the database
24 $data = PMA_Tracker
::getTrackedData($_REQUEST['db'], '', '1');
26 // No tables present and no log exist
27 if ($num_tables == 0 && count($data['ddlog']) == 0) {
28 echo '<p>' . $strNoTablesFound . '</p>' . "\n";
30 if (empty($db_is_information_schema)) {
31 require './libraries/display_create_table.lib.php';
35 require_once './libraries/footer.inc.php';
39 // ---------------------------------------------------------------------------
42 * Display top menu links
44 require_once './libraries/db_links.inc.php';
51 * List versions of current table
54 // Prepare statement to get HEAD version
55 $sql_query = ' SELECT *, MAX(version) as version FROM ' .
56 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
57 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
58 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
59 ' AND ' . PMA_backquote('table_name') . ' <> \'' . PMA_sqlAddslashes('') . '\' ' .
60 ' GROUP BY '. PMA_backquote('table_name') .
61 ' ORDER BY '. PMA_backquote('table_name') .'ASC , '. PMA_backquote('version') .' ASC ';
63 $sql_result = PMA_query_as_controluser($sql_query);
69 $maxversion = PMA_DBI_fetch_array($sql_result);
70 $last_version = $maxversion['version'];
72 // If a HEAD version exists
73 if ($last_version > 0) {
75 <h3
><?php
echo $strTrackingTrackedTables;?
></h3
>
77 <table id
="versions" class="data">
80 <th
><?php
echo $strDatabase;?
></th
>
81 <th
><?php
echo $strTable;?
></th
>
82 <th
><?php
echo $strTrackingThLastVersion;?
></th
>
83 <th
><?php
echo $strTrackingThCreated;?
></th
>
84 <th
><?php
echo $strTrackingThUpdated;?
></th
>
85 <th
><?php
echo $strStatus;?
></th
>
86 <th
><?php
echo $strShow;?
></th
>
92 // Print out information about versions
95 PMA_DBI_data_seek($sql_result, 0);
96 while ($version = PMA_DBI_fetch_array($sql_result)) {
97 if ($version['tracking_active'] == 1) {
98 $version_status = $strTrackingStatusActive;
100 $version_status = $strTrackingStatusNotActive;
103 if (($version['version'] == $last_version) && ($version_status == $strTrackingStatusNotActive)) {
104 $tracking_active = false;
106 if (($version['version'] == $last_version) && ($version_status == $strTrackingStatusActive)) {
107 $tracking_active = true;
110 <tr
class="<?php echo $style;?>">
111 <td
><?php
echo $version['db_name'];?
></td
>
112 <td
><?php
echo $version['table_name'];?
></td
>
113 <td
><?php
echo $version['version'];?
></td
>
114 <td
><?php
echo $version['date_created'];?
></td
>
115 <td
><?php
echo $version['date_updated'];?
></td
>
116 <td
><?php
echo $version_status;?
></td
>
117 <td
> <a href
="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>"><?php
echo $strTrackingVersions;?
></a
>
118 |
<a href
="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>&report=true&version=<?php echo $version['version'];?>"><?php
echo $strTrackingReport;?
></a
>
119 |
<a href
="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>&snapshot=true&version=<?php echo $version['version'];?>"><?php
echo $strTrackingStructureSnapshot;?
></a
></td
>
122 if ($style == 'even') {
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 $strTrackingUntrackedTables;?
></h3
>
149 <table id
="noversions" class="data">
152 <th width
="300"><?php
echo $strTable;?
></th
>
158 // Print out list of untracked tables
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 . '&table=' . $tablename .'">';
166 if ($cfg['PropertiesIconic']) {
167 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
169 $my_link .= $strTrackingTrackTable . '</a>';
171 <tr
class="<?php echo $style;?>">
172 <td
><?php
echo $tablename;?
></td
>
173 <td
><?php
echo $my_link;?
></td
>
176 if ($style == 'even') {
193 // If available print out database log
194 if (count($data['ddlog']) > 0) {
196 foreach ($data['ddlog'] as $entry) {
197 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
199 PMA_showMessage($strTrackingDatabaseLog, $log);
205 require_once './libraries/footer.inc.php';