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 and count($data['ddlog']) == 0)
29 echo '<p>' . $strNoTablesFound . '</p>' . "\n";
31 if (empty($db_is_information_schema))
33 require './libraries/display_create_table.lib.php';
37 require_once './libraries/footer.inc.php';
41 // ---------------------------------------------------------------------------
44 * Display top menu links
46 require_once './libraries/db_links.inc.php';
53 * List versions of current table
56 // Prepare statement to get HEAD version
57 $sql_query = ' SELECT *, MAX(version) as version FROM ' .
58 PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
59 PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
60 ' WHERE ' . PMA_backquote('db_name') . ' = \'' . PMA_sqlAddslashes($_REQUEST['db']) . '\' ' .
61 ' AND ' . PMA_backquote('table_name') . ' <> \'' . PMA_sqlAddslashes('') . '\' ' .
62 ' GROUP BY '. PMA_backquote('table_name') .
63 ' ORDER BY '. PMA_backquote('table_name') .'ASC , '. PMA_backquote('version') .' ASC ';
65 $sql_result = PMA_query_as_controluser($sql_query);
71 $maxversion = PMA_DBI_fetch_array($sql_result);
72 $last_version = $maxversion['version'];
74 // If a HEAD version exists
78 <h3
><?php
echo $strTrackingTrackedTables;?
></h3
>
80 <table id
="versions" class="data">
83 <th
><?php
echo $strTrackingThDatabase;?
></th
>
84 <th
><?php
echo $strTrackingThTable;?
></th
>
85 <th
><?php
echo $strTrackingThLastVersion;?
></th
>
86 <th
><?php
echo $strTrackingThCreated;?
></th
>
87 <th
><?php
echo $strTrackingThUpdated;?
></th
>
88 <th
><?php
echo $strTrackingThStatus;?
></th
>
89 <th
><?php
echo $strTrackingThShow;?
></th
>
95 // Print out information about versions
98 PMA_DBI_data_seek($sql_result, 0);
99 while($version = PMA_DBI_fetch_array($sql_result))
101 if($version['tracking_active'] == 1)
102 $version_status = $strTrackingStatusActive;
104 $version_status = $strTrackingStatusDeactive;
106 if(($version['version'] == $last_version) and ($version_status == $strTrackingStatusDeactive))
107 $tracking_active = false;
108 if(($version['version'] == $last_version) and ($version_status == $strTrackingStatusActive))
109 $tracking_active = true;
111 <tr
class="<?php echo $style;?>">
112 <td
><?php
echo $version['db_name'];?
></td
>
113 <td
><?php
echo $version['table_name'];?
></td
>
114 <td
><?php
echo $version['version'];?
></td
>
115 <td
><?php
echo $version['date_created'];?
></td
>
116 <td
><?php
echo $version['date_updated'];?
></td
>
117 <td
><?php
echo $version_status;?
></td
>
118 <td
> <a href
="tbl_tracking.php?<?php echo $url_query;?>&table=<?php echo $version['table_name'];?>"><?php
echo $strTrackingVersions;?
></a
>
119 |
<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
>
120 |
<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
>
123 if($style == 'even') $style = 'odd'; else $style = 'even';
131 // Get list of tables
132 $table_list = PMA_getTableList($GLOBALS['db']);
134 // For each table try to get the tracking version
135 foreach($table_list as $key => $value)
137 if(PMA_Tracker
::getVersion($GLOBALS['db'], $value['Name']) == -1)
138 $my_tables[] = $value['Name'];
141 // If untracked tables exist
142 if(isset($my_tables))
145 <h3
><?php
echo $strTrackingUntrackedTables;?
></h3
>
147 <table id
="noversions" class="data">
150 <th width
="300"><?php
echo $strTrackingThTable;?
></th
>
156 // Print out list of untracked tables
160 foreach($my_tables as $key => $tablename)
162 if(PMA_Tracker
::getVersion($GLOBALS['db'], $tablename) == -1)
164 $my_link = '<a href="tbl_tracking.php?' . $url_query . '&table=' . $tablename .'">';
166 if ($cfg['PropertiesIconic'])
168 $my_link .= '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
170 $my_link .= $strTrackingTrackTable . '</a>';
172 <tr
class="<?php echo $style;?>">
173 <td
><?php
echo $tablename;?
></td
>
174 <td
><?php
echo $my_link;?
></td
>
177 if($style == 'even') $style = 'odd'; else $style = 'even';
190 // If available print out database log
191 if(count($data['ddlog']) > 0)
194 foreach ($data['ddlog'] as $entry)
196 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
198 PMA_showMessage($strTrackingDatabaseLog, $log);
205 require_once './libraries/footer.inc.php';