Permalink
Browse files

add post deleting feature

  • Loading branch information...
1 parent 13b7d44 commit d7583b18944aa3de51b37266526e8b634da38d7e @szabgab committed Sep 7, 2010
Showing with 38 additions and 1 deletion.
  1. +2 −0 lib/CPAN/Forum.pm
  2. +19 −0 lib/CPAN/Forum/DB/Posts.pm
  3. +16 −0 lib/CPAN/Forum/RM/Admin.pm
  4. +1 −1 tt/pages/posts.tt
View
@@ -475,6 +475,7 @@ my @restricted_modes = qw(
module_search
selfconfig change_password change_info update_subscription
update
+ admin_del_posts
);
my @urls = qw(
@@ -499,6 +500,7 @@ my @urls = qw(
reset_password_request
reset_password_request_process
module_search
+ admin_del_posts
);
@@ -255,6 +255,25 @@ sub set_notified {
return;
}
+sub delete_posts_of_users {
+ my ($self) = @_;
+
+ # temporarily hard-coded list of spammers:
+ my @users = qw(nationshoes njgoogle wowpowerlvl gdoit shoesgreat jordan2008 pickcounty cnbearing);
+ #push @users, qw(rainyjin angelae8654 nisha jojokinkaid billy001 papu);
+ #push @users, qw(bettytalk mcgaha digitss adam01 mili sales3 sindabearing dpibearing yangmayer);
+ #push @users, qw(salesplaza releasesoft overnightmoney);
+ push @users, qw(markettips1 jerseykl);
+
+ my $sql = "DELETE FROM posts WHERE id in (SELECT posts.id FROM posts, users WHERE username ";
+ $sql .= "IN(" . join ", ", map {"'$_'"} @users;
+ $sql .= ") and posts.uid=users.id)";
+
+ my $dbh = CPAN::Forum::DBI::db_Main();
+ $dbh->do($sql);
+ return;
+}
+
1;
@@ -6,6 +6,7 @@ our $VERSION = '0.20';
use CPAN::Forum::DB::Users ();
use CPAN::Forum::DB::Configure ();
+use CPAN::Forum::DB::Posts ();
sub admin_edit_user_process {
my ($self) = @_;
@@ -97,5 +98,20 @@ sub admin {
return $self->tt_process('pages/admin.tt', \%params);
}
+# Temporary run-mode to delete posts of specific users
+sub admin_del_posts {
+ my ($self) = @_;
+ if ( not $self->session->param("admin") ) {
+ return $self->internal_error( "", "restricted_area" );
+ }
+ my $q = $self->query;
+
+ CPAN::Forum::DB::Posts::delete_posts_of_users();
+
+ my %params = ();
+ return $self->tt_process('pages/admin.tt', \%params);
+}
+
+
1;
View
@@ -10,7 +10,7 @@
[% IF admin %]
<div class="admin_links">
- <a href="/?rm=hide&amp;post=[% id %]">hide this post</a>
+ <a href="/admin_hide_post&amp;post=[% post.id %]">hide this post</a>
</div>
[% END %]

0 comments on commit d7583b1

Please sign in to comment.