diff options
-rw-r--r-- | modules/comment/controllers/admin_comments.php | 8 | ||||
-rw-r--r-- | modules/comment/helpers/comment.php | 1 | ||||
-rw-r--r-- | modules/comment/helpers/comment_installer.php | 1 | ||||
-rw-r--r-- | modules/comment/models/comment.php | 13 | ||||
-rw-r--r-- | modules/comment/views/admin_comments.html.php | 11 |
5 files changed, 31 insertions, 3 deletions
diff --git a/modules/comment/controllers/admin_comments.php b/modules/comment/controllers/admin_comments.php index c5fab259..5460d651 100644 --- a/modules/comment/controllers/admin_comments.php +++ b/modules/comment/controllers/admin_comments.php @@ -55,7 +55,13 @@ class Admin_Comments_Controller extends Admin_Controller { } public function index() { - $this->queue("unpublished"); + // Get rid of old deleted/spam comments + Database::instance()->query( + "DELETE FROM `comments` " . + "WHERE state IN ('deleted', 'spam') " . + "AND unix_timestamp(now()) - updated > 86400 * 7"); + + $this->queue("unpublished"); } public function menu_labels($state) { diff --git a/modules/comment/helpers/comment.php b/modules/comment/helpers/comment.php index 2adbc218..444e7e95 100644 --- a/modules/comment/helpers/comment.php +++ b/modules/comment/helpers/comment.php @@ -38,7 +38,6 @@ class comment_Core { $guest_email=ull, $guest_url=null) { $comment = ORM::factory("comment"); $comment->author_id = $author->id; - $comment->created = time(); $comment->guest_email = $guest_email; $comment->guest_name = $guest_name; $comment->guest_url = $guest_url; diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 30c8874d..7de2c476 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -45,6 +45,7 @@ class comment_installer { `server_remote_port` varchar(16) default NULL, `state` char(15) default 'unpublished', `text` text, + `updated` int(9) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index c83b2721..989597a8 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -52,4 +52,17 @@ class Comment_Model extends ORM { return $author->url; } } + + /** + * @see ORM::save() + */ + public function save() { + if (!empty($this->changed)) { + $this->updated = time(); + if (!$this->loaded) { + $this->created = $this->updated; + } + } + return parent::save(); + } } diff --git a/modules/comment/views/admin_comments.html.php b/modules/comment/views/admin_comments.html.php index 4091270b..b95a02f9 100644 --- a/modules/comment/views/admin_comments.html.php +++ b/modules/comment/views/admin_comments.html.php @@ -60,7 +60,7 @@ function update_menu() { <p> <? if ($spam->count()): ?> <?= t(array("one" => "There is currently one comment in your spam queue. You can delete it with a single click, but there is no undo operation so you may want to check the message first to make sure that it really is spam.", - "other" => "There are currently {{count}} comments in your spam queue. You can delete them all with a single click, but there is no undo operation so you may want to check the messages first to make sure that they really are spam."), + "other" => "There are currently {{count}} comments in your spam queue. You can delete them all with a single click, but there is no undo operation so you may want to check the messages first to make sure that they really are spam. All spam messages will be deleted after 7 days automatically."), array("count" => $spam->count())) ?> </p> <p> @@ -74,6 +74,15 @@ function update_menu() { </div> <? endif ?> + <? if ($queue == "deleted"): ?> + <div> + <p> + <?= t("These are messages that have been recently deleted. They will be permanently erased automatically after 7 days.") ?> + </p> + </div> + <? endif ?> + + <form id="gBulkAction" action="#" method="post"> <label for="bulk_actions"><?= t("Bulk actions")?></label> <select id="bulk_actions"> |