Add some missing defatults for tracker.
[phpmyadmin/madhuracj.git] / db_tracking.php
blob8e30946a884433b97e75fd4c76916c5761b3ba66
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @version $Id$
5 * @author Alexander Rutkowski
6 * @package phpMyAdmin
7 */
9 // Run common work
10 require_once './libraries/common.inc.php';
11 require_once './libraries/Table.class.php';
13 require './libraries/db_common.inc.php';
14 $url_query .= '&amp;goto=tbl_tracking.php&amp;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';
36 // Display the footer
37 require_once './libraries/footer.inc.php';
38 exit;
41 // ---------------------------------------------------------------------------
44 * Display top menu links
46 require_once './libraries/db_links.inc.php';
48 <p/>
49 <p/>
50 <?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);
67 // Init HEAD version
68 $last_version = 0;
70 // Get HEAD version
71 $maxversion = PMA_DBI_fetch_array($sql_result);
72 $last_version = $maxversion['version'];
74 // If a HEAD version exists
75 if($last_version > 0)
78 <h3><?php echo $strTrackingTrackedTables;?></h3>
80 <table id="versions" class="data">
81 <thead>
82 <tr>
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>
90 </tr>
91 </thead>
92 <tbody>
93 <?php
95 // Print out information about versions
97 $style = 'odd';
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;
103 else
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>
121 </tr>
122 <?php
123 if($style == 'even') $style = 'odd'; else $style = 'even';
126 </tbody>
127 </table>
128 <?php
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">
148 <thead>
149 <tr>
150 <th width="300"><?php echo $strTrackingThTable;?></th>
151 <th></th>
152 </tr>
153 </thead>
154 <tbody>
155 <?php
156 // Print out list of untracked tables
158 $style = 'odd';
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>
175 </tr>
176 <?php
177 if($style == 'even') $style = 'odd'; else $style = 'even';
181 </tbody>
182 </table>
187 <p/>
188 <?php
190 // If available print out database log
191 if(count($data['ddlog']) > 0)
193 $log = '';
194 foreach ($data['ddlog'] as $entry)
196 $log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
198 PMA_showMessage($strTrackingDatabaseLog, $log);
203 * Display the footer
205 require_once './libraries/footer.inc.php';