[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_0-137-g21f8f5d
Michal Čihař
nijel at users.sourceforge.net
Wed May 11 13:53:43 CEST 2011
The branch, master has been updated
via 21f8f5d072fb7bdc30751ab904c7e8d29cdc9a78 (commit)
from 9210f44a612511a92790c92ed4204e7098fc3488 (commit)
- Log -----------------------------------------------------------------
commit 21f8f5d072fb7bdc30751ab904c7e8d29cdc9a78
Author: bumbu <bumbu at mail.ru>
Date: Fri Apr 22 03:31:17 2011 +0300
+ delete button into tracking table + function change tracking data in Tracker.class.php
-----------------------------------------------------------------------
Summary of changes:
libraries/Tracker.class.php | 45 ++++++++++++++++++++++++++++++
tbl_tracking.php | 63 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 105 insertions(+), 3 deletions(-)
diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php
index 4f5c52f..7592c2c 100644
--- a/libraries/Tracker.class.php
+++ b/libraries/Tracker.class.php
@@ -465,6 +465,51 @@ class PMA_Tracker
}
/**
+ * Changes tracking data of a table.
+ *
+ * @static
+ *
+ * @param string $dbname name of database
+ * @param string $tablename name of table
+ * @param string $version version
+ * @param string $type type of data(DDL || DML)
+ * @param string || array $new_data the new tracking data
+ *
+ * @return bool result of change
+ */
+ static public function changeTrackingData($dbname, $tablename, $version, $type, $new_data)
+ {
+ if ($type == 'DDL')
+ $save_to = 'schema_sql';
+ elseif ($type == 'DML')
+ $save_to = 'data_sql';
+ else
+ return false;
+
+ $date = date('Y-m-d H:i:s');
+
+ $new_data_processed = '';
+ if (is_array($new_data)) {
+ foreach ($new_data as $data) {
+ $new_data_processed .= '# log ' . $date . ' ' . $data['username'] . PMA_sqlAddslashes($data['statement']) . "\n";
+ }
+ } else {
+ $new_data_processed = $new_data;
+ }
+
+ $sql_query =
+ " UPDATE " . self::$pma_table .
+ " SET `" . $save_to . "` = '" . $new_data_processed . "' " .
+ " WHERE `db_name` = '" . PMA_sqlAddslashes($dbname) . "' " .
+ " AND `table_name` = '" . PMA_sqlAddslashes($tablename) . "' " .
+ " AND `version` = '" . PMA_sqlAddslashes($version) . "' ";
+
+ $result = PMA_query_as_controluser($sql_query);
+
+ return $result;
+ }
+
+ /**
* Activates tracking of a table.
*
* @static
diff --git a/tbl_tracking.php b/tbl_tracking.php
index 757456b..9c3aae1 100644
--- a/tbl_tracking.php
+++ b/tbl_tracking.php
@@ -210,8 +210,7 @@ if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'execution'
}
// Export as SQL dump
-if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump')
-{
+if (isset($_REQUEST['report_export']) && $_REQUEST['export_type'] == 'sqldump') {
$new_query = "# " . __('You can execute the dump by creating and using a temporary database. Please ensure that you have the privileges to do so.') . "\n" .
"# " . __('Comment out these two lines if you do not need them.') . "\n" .
"\n" .
@@ -368,6 +367,43 @@ if (isset($_REQUEST['snapshot'])) {
/*
* Tracking report
*/
+if (isset($_REQUEST['report']) && (isset($_REQUEST['delete_ddlog']) || isset($_REQUEST['delete_dmlog']))) {
+
+ if(isset($_REQUEST['delete_ddlog'])){
+
+ // Delete ddlog row data
+ $delete_id = $_REQUEST['delete_ddlog'];
+
+ // Only in case of valable id
+ if($delete_id == (int)$delete_id){
+ unset($data['ddlog'][$delete_id]);
+
+ if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DDL', $data['ddlog']))
+ $msg = PMA_Message::success(__('Tracking data definition succesfully deleted'));
+ else
+ $msg = PMA_Message::rawError(__('Query error'));
+ $msg->display();
+ }
+ }
+
+ if(isset($_REQUEST['delete_dmlog'])){
+
+ // Delete dmlog row data
+ $delete_id = $_REQUEST['delete_dmlog'];
+
+ // Only in case of valable id
+ if($delete_id == (int)$delete_id){
+ unset($data['dmlog'][$delete_id]);
+
+ if (PMA_Tracker::changeTrackingData($_REQUEST['db'], $_REQUEST['table'], $_REQUEST['version'], 'DML', $data['dmlog']))
+ $msg = PMA_Message::success(__('Tracking data manipulation succesfully deleted'));
+ else
+ $msg = PMA_Message::rawError(__('Query error'));
+ $msg->display();
+ }
+ }
+}
+
if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
?>
<h3><?php echo __('Tracking report');?> [<a href="tbl_tracking.php?<?php echo $url_query;?>"><?php echo __('Close');?></a>]</h3>
@@ -390,12 +426,25 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
printf(__('Show %s with dates from %s to %s by user %s %s'), $str1, $str2, $str3, $str4, $str5);
+ // Prepare delete link content here
+ $drop_image_or_text = '';
+ if (true == $GLOBALS['cfg']['PropertiesIconic']) {
+ $drop_image_or_text .= '<img class="icon" width="16" height="16" src="' . $pmaThemeImage . 'b_drop.png" alt="' . __('Delete tracking data row from report') . '" title="' . __('Delete tracking data row from report') . '" />';
+ }
+ if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) {
+ $drop_image_or_text .= __('Delete');
+ }
/*
* First, list tracked data definition statements
*/
$i = 1;
- if ($selection_schema || $selection_both ) {
+ if (count($data['ddlog']) == 0 && count($data['dmlog']) == 0) {
+ $msg = PMA_Message::notice(__('No data'));
+ $msg->display();
+ }
+
+ if ($selection_schema || $selection_both && count($data['ddlog']) > 0) {
?>
<table id="ddl_versions" class="data" width="100%">
<thead>
@@ -404,10 +453,12 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
<th width="100"><?php echo __('Date');?></th>
<th width="60"><?php echo __('Username');?></th>
<th><?php echo __('Data definition statement');?></th>
+ <th><?php echo __('Delete');?></th>
</tr>
</thead>
<tbody>
<?php
+
$style = 'odd';
foreach ($data['ddlog'] as $entry) {
if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
@@ -425,6 +476,7 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
<td><small><?php echo $entry['date'];?></small></td>
<td><small><?php echo $entry['username']; ?></small></td>
<td><?php echo $statement; ?></td>
+ <td nowrap="nowrap"><a href="tbl_tracking.php?<?php echo $url_query;?>&report=true&version=<?php echo $version['version'];?>&delete_ddlog=<?php echo $i-1; ?>"><?php echo $drop_image_or_text; ?></a></td>
</tr>
<?php
if ($style == 'even') {
@@ -442,6 +494,9 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
} //endif
+ // Memorize data definition amount
+ $ddlog_count = $i;
+
/*
* Secondly, list tracked data manipulation statements
*/
@@ -455,6 +510,7 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
<th width="100"><?php echo __('Date');?></th>
<th width="60"><?php echo __('Username');?></th>
<th><?php echo __('Data manipulation statement');?></th>
+ <th><?php echo __('Delete');?></th>
</tr>
</thead>
<tbody>
@@ -476,6 +532,7 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
<td><small><?php echo $entry['date']; ?></small></td>
<td><small><?php echo $entry['username']; ?></small></td>
<td><?php echo $statement; ?></td>
+ <td nowrap="nowrap"><a href="tbl_tracking.php?<?php echo $url_query;?>&report=true&version=<?php echo $version['version'];?>&delete_dmlog=<?php echo $i-$ddlog_count; ?>"><?php echo $drop_image_or_text; ?></a></td>
</tr>
<?php
if ($style == 'even') {
hooks/post-receive
--
phpMyAdmin
More information about the Git
mailing list