Movable Type: Easier edit/removal of new comments

Journal entry
September 9, 2003

Apparently some people are receiving a good deal of spam comments on their blogs. In an effort to do something about this Kalsey brings up the idea of making it easier to delete comments:

When someone posts a comment, MT automatically sends me an email. That email should include a link to delete the comment and rebuild the entry. Then when a comment does slip through, its a simple matter to remove it.

This small hack doesn’t quite do this (no automatic rebuilding), but it certainly makes it easier to edit or remove new comments.

In order for this to work, you need to get down and dirty in the Movable Type perl files. This is naturally at your own risk, I have no responsibility even if cheese falls from the sky and reality shows are taken off the air because of any changes you make to your MT source files yadda yadda. Hint: Backup.

Follow these steps:

  1. In your MT cgi directory, open the file /lib/MT/app/Comments.pm - for example /home/example/cgi-bin/mt/lib/MT/app/Comments.pm .
  2. Go to line 152. Near that you should find a line looking like:

    UPDATE: With version 2.661 of Movable Type, the line you’re looking for is 236. It still looks the same, and the rest of the instructions still work.

    MT::Mail->send(\%head, $body);
  3. Above that line add the following 2 lines
    my $cfg = MT::ConfigMgr->instance;
    $body .= $app->translate('Edit this comment:') . " " . $cfg->CGIPath . 
    "mt.cgi?__mode=view&_type=comment&id=" . $comment->id. 
    "&blog_id=" . $blog->id . "\n" ;

    so the entire section looks like

    $body = Text::Wrap::wrap('', '', $body) . "\n$link_url\n\n" .
      $app->translate('IP Address:') . ' ' . $comment->ip . "\n" .
      $app->translate('Name:') . ' ' . $comment->author . "\n" .
      $app->translate('Email Address:') . ' ' . $comment->email . "\n" .
      $app->translate('URL:') . ' ' . $comment->url . "\n\n" .
      $app->translate('Comments:') . "\n\n" . $comment->text . "\n\n";             
    my $cfg = MT::ConfigMgr->instance;
    $body .= $app->translate('Edit this comment:') . " " . $cfg->CGIPath . 
    "mt.cgi?__mode=view&_type=comment&id=" . $comment->id. 
    "&blog_id=" . $blog->id . "\n" ;
    MT::Mail->send(\%head, $body);
  4. Voila, you should now get a link in the email taking you to the edit comments page, where you can edit (duh) or delete the comment.
Categories
Selling out

Comments and Trackbacks

Shirley Kaiser September 13, 2003

Jakob, thanks for the MT hack. Your directions were easy to follow and it works beautifully.

Just wanted to thank you for sharing that. :-)

Jakob S September 13, 2003

Cool, it’s great hearing that some people actually got value from this :)

Links September 13, 2003

Movable Type: Easier edit/removal of new comments | mentalized.net...

Read the rest on Links

Scott Manning September 13, 2003

Jacob,

I’ve been looking for this one for a while and have implemented your code. Thanks a lot.

Scott

lovelinks September 14, 2003

mentalized.net: Easier edit/removal of new comments - add the edit link to your comment notification email to make editing (or...

Read the rest on lovelinks

sarah September 23, 2003

I finally implemented this hack, and it isperfect, thanks! I was playing with the files after someone requested it on the MT forum, but couldn’t wrap my head around the variables. You rock! ;)

The Midnight Blog October 1, 2003

http://www.mentalized.net/journal/archives/2003/09/09/movable_type_easier_editremoval_of_new_comments/index.asp

Read the rest on The Midnight Blog

KevinDonahue.com October 3, 2003

The BurningBird has a quick and easy fix for MovableType users to try to help stem the tide of comment spam. According to Mark, it's just a "club" and not a "lojack", but I'll take what I can get until...

Read the rest on KevinDonahue.com

kristine October 5, 2003

Thanks a lot for writing this out — I finally got a chance to set it up on my site, and its gonna really make things easier.

It seems like this might be a related hack — maybe a link below that one that says “ban this IP address” and adds the IP address of the commenter to the ban list? I could see that being pretty helpful too, with the comment spam that’s been going around lately. I wish I knew more perl!!! But, I don’t know how to pass the IP address into the form and make it save it. Maybe I’ll snoop around the code some more.

Kris October 6, 2003

Thanks Jakob.

This (via Shirley) is much appreciated.

JayAllen - The Daily Journey October 11, 2003

Well, I let my perfectionist tendancies get a hold of me (as well as the undeniable lure of feature creep)

Read the rest on JayAllen - The Daily Journey

izzy|wizzy October 13, 2003

Intrigued by a comment Kristine made on this post over at mentalized, regarding adding a delete comment link to the emails that MT automatically sends when a comment is added, I dug into MT a little to discover how to...

Read the rest on izzy|wizzy

Emmanuel's Link Flow October 13, 2003

Movable Type: Easier edit/removal of new comments...

Read the rest on Emmanuel's Link Flow

*** Dave October 13, 2003

Nicely done.

POs Blog October 13, 2003

Having hurt email, it would appear the spammers are moving on to blogs. Movable Type's popularity seems to have made it a target for the spam bots. The coding arms race has started......

Read the rest on POs Blog

Design-A-Blog October 14, 2003

Comment spam is suddenly the topic du jour in the blogosphere. I admit that even when suffering from writer's block, a single spam comment can inspire much ranting. While there's plenty of suggestions out there for how to stop comment spam, a lo...

Read the rest on Design-A-Blog

.:| bamsplat |:. October 26, 2003

The really great thing about open source, such as MovableType and Invision Board, is how strong the internal support and drive to improve can be. The software offers the flexibility, and the users reveal this flexibility through plugins and mods....

Read the rest on .:| bamsplat |:.

Sproet December 28, 2003

Hi, this is a very useful hack! Thanks to your instructions it’s easy to implement. I think it should become standard in the MT templates. Good work, thanks!

David H. Sundwall January 25, 2004

Does this work with the updated comments file with 2.661? I found the line where the code insertion is supposed to go around line 236 instead. And yet it would not work. Comments worked fine, just no line to edit or remove the comment. Thanks for any help and thanks for the hack.

Jakob S January 26, 2004

Hm, it might. Let’s see.

Edit: Yup, seems to work still

Ron March 7, 2004

Thanks. It works great and sends you right to the fancy editing screen.

Kasey May 20, 2004

This is a great idea. I just implemented it on my own blog and it works very well! Very slick. :)

I’d like to add that if you’re running MT-Blacklist, you’ll also need to edit the /extlib/jayallen/MTBlPost.pm file. For bloggers using MT 2.65, you need to edit at or near line #195. For those of us using MT 2.66 or 2.661, you need to edit at or near line #405.

Neto Cury Blog June 1, 2004

Enfim achei o plugin que tanto estava procurando... Funciona da seguinte maneira: Quando alguém faz um comentário no meu blog, eu recebo e-mail com uma notificação sobre o comentário feito, o plugin nada mais faz do q...

Read the rest on Neto Cury Blog

Blog@MNMNN August 31, 2004

我就算天天更新mt-blacklist,這兩天spam又變多了,已經到了無可救藥的地步了嗎? 一個方法是,揚棄MT,換另一個blog系統?可能很麻煩,我麻煩大家也麻煩,好不好用還不知道。 網路上找資料...

Read the rest on Blog@MNMNN

vita mea November 23, 2004

Almost immediately after I got rid of the security code, I got six spam comments advertising some online poker website. So I did a little research and found some great solutions here and here. Thank you, online blogging community!...

Read the rest on vita mea

Commenting on this entry has been closed.

... but if you're a dirty spambot, feel free to post a comment here anyways.