Skip to content

Commit

Permalink
refs #1633 : implement - added customizable trash keeping period
Browse files Browse the repository at this point in the history
 - $service['trashtimelimit'] determines keeping period of trash
 comments / trackbacks
 - Default value is 3.5 days. (originally it was 15 days without any
	 option)
 - Checking interval is changed from 86400sec. to 43200sec.
 - Codebase of function trashVan() is changed from 1.7/8 to 2.0 codebase.
  • Loading branch information
inureyes committed Feb 9, 2014
1 parent e0e17af commit 7fe6b94
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions library/model/blog.trash.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,20 @@ function restoreTrackbackTrash($blogid, $id) {
}

function trashVan() {
global $database;
requireModel('common.setting');
if(Timestamp::getUNIXtime() - Setting::getServiceSetting('lastTrashSweep',0, true) > 86400) {
// var_dump(Timestamp::getUNIXtime());
// var_dump(Setting::getServiceSetting('lastTrashSweep',0, true));
POD::execute("DELETE FROM {$database['prefix']}Comments where isfiltered < ".Timestamp::getUNIXtime()." - 1296000 AND isfiltered > 0");
POD::execute("DELETE FROM {$database['prefix']}RemoteResponses where isfiltered < ".Timestamp::getUNIXtime()." - 1296000 AND isfiltered > 0");
POD::execute("DELETE FROM {$database['prefix']}RefererLogs WHERE referred < ".Timestamp::getUNIXtime()." - 604800");
$context = Model_Context::getInstance();
if(Timestamp::getUNIXtime() - Setting::getServiceSetting('lastTrashSweep',0, true) > 43200) {
$pool = DBModel::getInstance();
$pool->reset('Comments');
$pool->setQualifier('isfiltered','s',Timestamp::getUNIXtime()-$context->getProperty('service.trashtimelimit',302400));
$pool->setQualifier('isfiltered','b',0);
$pool->delete();
$pool->reset('RemoteResponses');
$pool->setQualifier('isfiltered','s',Timestamp::getUNIXtime()-$context->getProperty('service.trashtimelimit',302400));
$pool->setQualifier('isfiltered','b',0);
$pool->delete();
$pool->reset('RefererLogs');
$pool->setQualifier('referred','s',Timestamp::getUNIXtime()-604800);
$pool->delete();
Setting::setServiceSetting('lastTrashSweep',Timestamp::getUNIXtime(),true);
}
if(Timestamp::getUNIXtime() - Setting::getServiceSetting('lastNoticeRead',0, true) > 43200) {
Expand Down

0 comments on commit 7fe6b94

Please sign in to comment.