fix okapi_syncbase for deleted logs

This commit is contained in:
following
2013-04-22 13:26:37 +02:00
parent 7fbdc2e3ed
commit da12a3e4a7
2 changed files with 9 additions and 2 deletions

View File

@ -166,7 +166,7 @@
sql_free_result($rs);
// move to archive, even if own log (uuids are used for OKAPI replication)
sql("INSERT IGNORE INTO `cache_logs_archived` SELECT *, NOW() AS `deletion_date`, '&2' AS `deleted_by`, 0 AS `restored_by` FROM `cache_logs` WHERE `cache_logs`.`id`='&1' LIMIT 1", $log_id, $usr['userid']);
sql("INSERT IGNORE INTO `cache_logs_archived` SELECT *, '0' AS `deletion_date`, '&2' AS `deleted_by`, 0 AS `restored_by` FROM `cache_logs` WHERE `cache_logs`.`id`='&1' LIMIT 1", $log_id, $usr['userid']);
// remove log entry
sql("DELETE FROM `cache_logs` WHERE `cache_logs`.`id`='&1' LIMIT 1", $log_id);
@ -177,6 +177,10 @@
0 = (SELECT COUNT(*) FROM `cache_logs` WHERE `user_id` = '&1' AND `cache_id` = '&2' AND `type` IN (1,7))",
$log_record['log_user_id'], $log_record['cache_id']);
// now tell OKAPI about the deletion;
// this will trigger an okapi_syncbase update, if OKAPI is installed:
sql("UPDATE `cache_logs_archived` SET `deletion_date`=NOW() WHERE `id`='&1'", $log_id);
// do not use slave server for the next time ...
db_slave_exclude();

View File

@ -731,11 +731,14 @@ function restore_listings($cacheids, $rdate, $roptions, $simulate)
if (!$simulate)
{
sql("INSERT INTO `cache_logs_archived`
SELECT *, NOW(), '&2', '&3' FROM `cache_logs` WHERE `id`='&1'",
SELECT *, '0', '&2', '&3' FROM `cache_logs` WHERE `id`='&1'",
$revert_logid,
$user_id, // original deletor's ID and not restoring admin's ID!
$login->userid);
sql("DELETE FROM `cache_logs` WHERE `id`='&1'", $revert_logid);
// This triggers an okapi_syncbase update, if OKAPI is installed:
sql("UPDATE `cache_logs_archived` SET `deletion_date`=NOW() WHERE `id`='&1'",
$revert_logid);
}
$logs_restored = true;
}