moved adoption history from logentries to new table; added adoption history to admin cache history
This commit is contained in:
@@ -187,4 +187,40 @@
|
|||||||
sql("ALTER TABLE `user` ADD COLUMN `first_email_problem` date default NULL AFTER `email_problems`");
|
sql("ALTER TABLE `user` ADD COLUMN `first_email_problem` date default NULL AFTER `email_problems`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dbv_110() // move adoption history to separate table
|
||||||
|
{
|
||||||
|
if (!sql_table_exists('cache_adoptions'))
|
||||||
|
{
|
||||||
|
sql(
|
||||||
|
"CREATE TABLE `cache_adoptions` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`cache_id` int(10) unsigned NOT NULL,
|
||||||
|
`date` datetime NOT NULL,
|
||||||
|
`from_user_id` int(10) unsigned NOT NULL,
|
||||||
|
`to_user_id` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `cache_id` (`cache_id`,`date`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
|
||||||
|
|
||||||
|
$rs = sql("SELECT `id`, `date_created`, `objectid1`, `logtext`
|
||||||
|
FROM `logentries`
|
||||||
|
WHERE `eventid`=5
|
||||||
|
ORDER BY `date_created`, `id`");
|
||||||
|
while ($rLog = sql_fetch_assoc($rs))
|
||||||
|
{
|
||||||
|
preg_match('/Cache (\d+) has changed the owner from userid (\d+) to (\d+) by (\d+)/',
|
||||||
|
$rLog['logtext'], $matches);
|
||||||
|
if (count($matches) != 5)
|
||||||
|
die("unknown adoption log entry format for ID " . $rLog['id'] . "\n");
|
||||||
|
sql("INSERT INTO `cache_adoptions`
|
||||||
|
(`cache_id`,`date`,`from_user_id`,`to_user_id`)
|
||||||
|
VALUES ('&1','&2','&3','&4')",
|
||||||
|
$rLog['objectid1'], $rLog['date_created'], $matches[2], $matches[3]);
|
||||||
|
}
|
||||||
|
sql_free_result($rs);
|
||||||
|
|
||||||
|
// We keep the old entries in 'logentries' for the case something went wrong here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -2492,6 +2492,10 @@ INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2070', 'One ore
|
|||||||
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2071', 'This cache has been \"temporarily unavailable\" for more than one year now; therefore it is being archived automatically. The owner may decide to maintain the cache and re-enable the listing.', '2013-05-28 16:51:40');
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2071', 'This cache has been \"temporarily unavailable\" for more than one year now; therefore it is being archived automatically. The owner may decide to maintain the cache and re-enable the listing.', '2013-05-28 16:51:40');
|
||||||
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2072', 'This event took place more than five weeks ago; therefore it is being archived automatically. The owner may re-enable the listing if it should stay active for some exceptional reason.', '2013-05-28 16:51:40');
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2072', 'This event took place more than five weeks ago; therefore it is being archived automatically. The owner may re-enable the listing if it should stay active for some exceptional reason.', '2013-05-28 16:51:40');
|
||||||
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2073', 'This user account is disabled.', '2013-05-28 16:51:40');
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2073', 'This user account is disabled.', '2013-05-28 16:51:40');
|
||||||
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2074', 'Adoptions_', '2013-05-28 16:51:40');
|
||||||
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2075', 'since September 2012', '2013-05-28 16:51:40');
|
||||||
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2076', 'From Owner', '2013-05-28 16:51:40');
|
||||||
|
INSERT INTO `sys_trans` (`id`, `text`, `last_modified`) VALUES ('2077', 'To Owner', '2013-05-28 16:51:40');
|
||||||
|
|
||||||
-- Table sys_trans_ref
|
-- Table sys_trans_ref
|
||||||
SET NAMES 'utf8';
|
SET NAMES 'utf8';
|
||||||
@@ -6436,6 +6440,10 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
|
|||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2071', 'DE', 'Dieser Cache ist seit mehr als einem Jahr „momentan nicht verfügbar“; daher wird er automatisch archiviert. Er kann vom Besitzer jederzeit instand gesetzt und reaktiviert werden.', '2013-04-25 23:00:00');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2071', 'DE', 'Dieser Cache ist seit mehr als einem Jahr „momentan nicht verfügbar“; daher wird er automatisch archiviert. Er kann vom Besitzer jederzeit instand gesetzt und reaktiviert werden.', '2013-04-25 23:00:00');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2072', 'DE', 'Dieses Event fand vor über fünf Wochen statt; daher wird es automatisch archiviert. Das Listing kann vom Owner selbst reaktiviert werden, falls es aus besonderen Gründen weiter aktiv bleiben soll.', '2013-04-25 23:00:00');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2072', 'DE', 'Dieses Event fand vor über fünf Wochen statt; daher wird es automatisch archiviert. Das Listing kann vom Owner selbst reaktiviert werden, falls es aus besonderen Gründen weiter aktiv bleiben soll.', '2013-04-25 23:00:00');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2073', 'DE', 'Dieser Benutzer ist deaktiviert.', '2013-04-25 23:00:00');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2073', 'DE', 'Dieser Benutzer ist deaktiviert.', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2074', 'DE', 'Adoptionen', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2075', 'DE', 'seit September 2012', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2076', 'DE', 'Alter Besitzer', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2077', 'DE', 'Neuer Besitzer', '2013-04-25 23:00:00');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'EN', 'Reorder IDs \r', '2010-09-02 00:15:30');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'EN', 'The database could not be reconnected.', '2010-08-28 11:48:07');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'EN', 'Testing – please do not login', '2010-08-28 11:48:07');
|
||||||
@@ -8000,6 +8008,10 @@ INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUE
|
|||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2071', 'EN', 'This cache has been \"temporarily unavailable\" for more than one year now; therefore it is being archived automatically. The owner may decide to maintain the cache and re-enable the listing.', '2013-04-25 23:00:00');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2071', 'EN', 'This cache has been \"temporarily unavailable\" for more than one year now; therefore it is being archived automatically. The owner may decide to maintain the cache and re-enable the listing.', '2013-04-25 23:00:00');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2072', 'EN', 'This event took place more than five weeks ago; therefore it is being archived automatically. The owner may re-enable the listing if it should stay active for some exceptional reason.', '2013-04-25 23:00:00');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2072', 'EN', 'This event took place more than five weeks ago; therefore it is being archived automatically. The owner may re-enable the listing if it should stay active for some exceptional reason.', '2013-04-25 23:00:00');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2073', 'EN', 'This user account is disabled.', '2013-04-25 23:00:00');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2073', 'EN', 'This user account is disabled.', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2074', 'EN', 'Adoptions', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2075', 'EN', 'since September 2012', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2076', 'EN', 'From Owner', '2013-04-25 23:00:00');
|
||||||
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2077', 'EN', 'To Owner', '2013-04-25 23:00:00');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'ES', 'Reordenar ID', '2010-12-09 00:17:55');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('1', 'ES', 'Reordenar ID', '2010-12-09 00:17:55');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'ES', 'La base de datos no se pudo conectar.', '2010-12-09 00:17:55');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('2', 'ES', 'La base de datos no se pudo conectar.', '2010-12-09 00:17:55');
|
||||||
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'ES', 'En pruebas - por favor, no entre.', '2010-12-09 00:17:55');
|
INSERT INTO `sys_trans_text` (`trans_id`, `lang`, `text`, `last_modified`) VALUES ('3', 'ES', 'En pruebas - por favor, no entre.', '2010-12-09 00:17:55');
|
||||||
|
|||||||
@@ -710,6 +710,10 @@
|
|||||||
/* logpw needs not to be saved */
|
/* logpw needs not to be saved */
|
||||||
/* for further explanation see restorecaches.php */
|
/* for further explanation see restorecaches.php */
|
||||||
END IF;
|
END IF;
|
||||||
|
IF NEW.`user_id`!=OLD.`user_id` THEN
|
||||||
|
INSERT INTO `cache_adoptions` (`cache_id`,`date`,`from_user_id`,`to_user_id`)
|
||||||
|
VALUES (NEW.`cache_id`, NEW.`last_modified`, OLD.`user_id`, NEW.`user_id`);
|
||||||
|
END IF;
|
||||||
IF NEW.`user_id`!=OLD.`user_id` OR NEW.`status`!=OLD.`status` THEN
|
IF NEW.`user_id`!=OLD.`user_id` OR NEW.`status`!=OLD.`status` THEN
|
||||||
CALL sp_update_hiddenstat(OLD.`user_id`, OLD.`status`, TRUE);
|
CALL sp_update_hiddenstat(OLD.`user_id`, OLD.`status`, TRUE);
|
||||||
CALL sp_update_hiddenstat(NEW.`user_id`, NEW.`status`, FALSE);
|
CALL sp_update_hiddenstat(NEW.`user_id`, NEW.`status`, FALSE);
|
||||||
|
|||||||
11
htdocs/doc/sql/tables/cache_adoptions.sql
Normal file
11
htdocs/doc/sql/tables/cache_adoptions.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
SET NAMES 'utf8';
|
||||||
|
DROP TABLE IF EXISTS `cache_adoptions`;
|
||||||
|
CREATE TABLE IF NOT EXISTS `cache_adoptions` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`cache_id` int(10) unsigned NOT NULL,
|
||||||
|
`date` datetime NOT NULL,
|
||||||
|
`from_user_id` int(10) unsigned NOT NULL,
|
||||||
|
`to_user_id` int(10) unsigned NOT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `cache_id` (`cache_id`,`date`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
@@ -413,6 +413,9 @@ class cache
|
|||||||
VALUES ('cache', 5, '&1', '&2', '&3', '&4')",
|
VALUES ('cache', 5, '&1', '&2', '&3', '&4')",
|
||||||
$login->userid, $this->nCacheId, 0,
|
$login->userid, $this->nCacheId, 0,
|
||||||
'Cache ' . sql_escape($this->nCacheId) . ' has changed the owner from userid ' . sql_escape($this->getUserId()) . ' to ' . sql_escape($userid) . ' by ' . sql_escape($login->userid));
|
'Cache ' . sql_escape($this->nCacheId) . ' has changed the owner from userid ' . sql_escape($this->getUserId()) . ' to ' . sql_escape($userid) . ' by ' . sql_escape($login->userid));
|
||||||
|
// Adoptions now are recorded by trigger in cache_adoptions table.
|
||||||
|
// Recording adoptions in 'logentries' may be discarded after ensuring that the
|
||||||
|
// log entries are not used anywhere.
|
||||||
sql("UPDATE `caches` SET `user_id`='&1' WHERE `cache_id`='&2'", $userid, $this->nCacheId);
|
sql("UPDATE `caches` SET `user_id`='&1' WHERE `cache_id`='&2'", $userid, $this->nCacheId);
|
||||||
sql("DELETE FROM `cache_adoption` WHERE `cache_id`='&1'", $this->nCacheId);
|
sql("DELETE FROM `cache_adoption` WHERE `cache_id`='&1'", $this->nCacheId);
|
||||||
|
|
||||||
@@ -529,6 +532,21 @@ class cache
|
|||||||
ORDER BY `date_modified` DESC", $this->getCacheId(), $opt['template']['locale']);
|
ORDER BY `date_modified` DESC", $this->getCacheId(), $opt['template']['locale']);
|
||||||
$tpl->assign_rs('status_changes',$rs);
|
$tpl->assign_rs('status_changes',$rs);
|
||||||
sql_free_result($rs);
|
sql_free_result($rs);
|
||||||
|
|
||||||
|
// Adoptions
|
||||||
|
$rs = sql("SELECT `cache_adoptions`.`date`,
|
||||||
|
`cache_adoptions`.`from_user_id`,
|
||||||
|
`cache_adoptions`.`to_user_id`,
|
||||||
|
`from_user`.`username` AS `from_username`,
|
||||||
|
`to_user`.`username` AS `to_username`
|
||||||
|
FROM `cache_adoptions`
|
||||||
|
LEFT JOIN `user` `from_user` ON `from_user`.`user_id`=`from_user_id`
|
||||||
|
LEFT JOIN `user` `to_user` ON `to_user`.`user_id`=`to_user_id`
|
||||||
|
WHERE `cache_id`='&1'
|
||||||
|
ORDER BY `cache_adoptions`.`date`, `cache_adoptions`.`id`",
|
||||||
|
$this->getCacheId());
|
||||||
|
$tpl->assign_rs('adoptions',$rs);
|
||||||
|
sql_free_result($rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="table" width="80%">
|
<table class="table" width="90%">
|
||||||
{if $status_changes|@count}
|
{if $status_changes|@count}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{t}Date{/t}</th>
|
<th>{t}Date{/t}</th>
|
||||||
@@ -106,6 +106,37 @@
|
|||||||
<tr><td></td></tr>
|
<tr><td></td></tr>
|
||||||
{/if}
|
{/if}
|
||||||
</table>
|
</table>
|
||||||
|
<p> </p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{if !$reportdisplay || $adoptions|@count}
|
||||||
|
<div class="content2-container bg-blue02">
|
||||||
|
<p class="content-title-noshade-size2">
|
||||||
|
<img src="resource2/{$opt.template.style}/images/description/22x22-logs.png" style="align: left; margin-right: 10px;" width="22" height="22" alt="" />
|
||||||
|
{t}Adoptions_{/t} <small>{t}since September 2012{/t}</small>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class="table" width="90%">
|
||||||
|
{if $adoptions|@count}
|
||||||
|
<tr>
|
||||||
|
<th>{t}Date{/t}</th>
|
||||||
|
<th>{t}From Owner{/t}</th>
|
||||||
|
<th></th>
|
||||||
|
<th>{t}To Owner{/t}</th>
|
||||||
|
</tr>
|
||||||
|
{foreach from=$adoptions item=adoption}
|
||||||
|
<tr>
|
||||||
|
<td>{$adoption.date|date_format:$opt.format.date}</td>
|
||||||
|
<td><a href="viewprofile.php?userid={$adoption.from_user_id}">{$adoption.from_username}</a></th>
|
||||||
|
<td>→</td>
|
||||||
|
<td><a href="viewprofile.php?userid={$adoption.to_user_id}">{$adoption.to_username}</a></th>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
{else}
|
||||||
|
<tr><td></td></tr>
|
||||||
|
{/if}
|
||||||
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{else}
|
{else}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ class purge_logs
|
|||||||
if ($opt['logic']['logs']['purge_userdata'] > 0)
|
if ($opt['logic']['logs']['purge_userdata'] > 0)
|
||||||
sql("DELETE FROM `logentries` WHERE date_created < NOW() - INTERVAL &1 DAY AND eventid IN (6,7)",
|
sql("DELETE FROM `logentries` WHERE date_created < NOW() - INTERVAL &1 DAY AND eventid IN (6,7)",
|
||||||
$opt['logic']['logs']['purge_userdata']);
|
$opt['logic']['logs']['purge_userdata']);
|
||||||
|
|
||||||
|
// Type 5 events = adoptions are still recorded here and preliminary archived,
|
||||||
|
// but may be discarded after verifying that they are not used anywhere.
|
||||||
|
// Adoptions are now in cache_adoptions table.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user