Approve/Moderate All
In the early days of MT 3, when I had unreg'd comments set to moderate, I really wanted to have an approval all button as I would read the comment in the email notification I received. Since then that feature request has not progressed so I decided to take matters into my own hands. As the screenshot shows, at the end of this hack you will end up with two buttons on the comments listing screen. This buttons will allow you to mass approve/moderate comments by checking the boxes of the corresponding entries.
First of all open lib/MT/App/CMS.pm and find on approximately line 32 the following
'approve_comment' => \&approve_comment,
and right after it
'approve_confirm' => \&approve_confirm,
'approve_all' => \&approve_all,
Next find on approximately line 2115
sub list_commenters {
and add right above it the following
sub approve_confirm {
my $app = shift;
my %param = ( type => scalar $app->{query}->param('_type') );
my @data;
for my $id ($app->{query}->param('id')) {
push @data, { id => $id };
}
$param{id_loop} = \@data;
$param{num} = scalar @data;
$param{'type_' . $param{type}} = 1;
$param{is_zero} = @data == 0;
$param{is_one} = @data == 1;
$param{is_many} = !$param{is_zero} && !$param{is_one};
$param{thisthese} = $param{is_one} ? 'this' : 'these';
$param{is_power_edit} = $app->{query}->param('is_power_edit') ? 1 : 0;
$param{_return} = $app->{query}->param('_return');
my $dowhat;
if($app->{query}->param('do') eq 'approve') {
$dowhat = "Approve";
} elsif($app->{query}->param('do') eq 'unapprove') {
$dowhat = "Unapprove";
}
$param{dowhat} = $dowhat;
$app->build_page('approve_confirm.tmpl', \%param);
}
sub approve_all {
my $app = shift;
my $perms = $app->{perms}
or return $app->error($app->translate("No permissions"));
my $q = $app->{query};
my $blog_id = $q->param('blog_id');
my $type = $q->param('_type');
my $class = $app->_load_driver_for($type) or return;
for my $id ($q->param('id')) {
my $obj = $class->load($id);
next unless $obj;
my $entry = MT::Entry->load($obj->entry_id)
|| return $app->error("Comment on missing entry!");
if (!$perms->can_edit_all_posts()
&& $entry->author_id != $app->{author}->id) {
return $app->error($app->translate(
"You don't have permission to approve this comment."));
}
if($q->param('do') eq 'approve') {
$obj->visible(1);
} elsif($q->param('do') eq 'unapprove') {
$obj->visible(0);
}
$obj->save();
$app->rebuild_entry(Entry => $obj->entry_id, BuildDependencies => 1);
}
my $url = $app->uri . '?__mode=list_comments&blog_id='.$blog_id.'&'.$q->param('do').'=1';
$app->build_page('reload_opener.tmpl', { url => $url });
}
Add this to mt.js
function doApproveItems (f, type, plural, nameRestrict) {
var base = ScriptURI + '?__mode=approve_confirm&_type=' + type;
var url = '';
var e = f.id;
if (!e) return;
if (e.value && e.checked)
url += '&id=' + e.value;
else
if (nameRestrict) {
for (i=0; i<e.length; i++)
if (e[i].checked && (e[i].name == nameRestrict))
url += '&id=' + e[i].value;
} else {
for (i=0; i<e.length; i++)
if (e[i].checked)
url += '&id=' + e[i].value;
}
if (!url) {
alert('You did not select any ' + plural + ' to approve/unapprove.');
return false;
}
url = base + url;
window.open(url, 'confirm_delete',
'width=370,height=250,scrollbars=yes');
}
Next in list_comment.tmpl, find
<input type="button" onclick="doRemoveItems(this.form, 'comment&blog_id=<TMPL_VAR NAME=BLOG_ID>&_return=list_comments', 'comments')" name="delete_comments" value="<MT_TRANS phrase="Delete">" />
and add right above it
<input type="button" onclick="doApproveItems(this.form, 'comment&do=approve&blog_id=<TMPL_VAR NAME=BLOG_ID>&_return=list_comments', 'comments')" name="approve_comments" value="<MT_TRANS phrase="Approve">" />
<input type="button" onclick="doApproveItems(this.form, 'comment&do=unapprove&blog_id=<TMPL_VAR NAME=BLOG_ID>&_return=list_comments', 'comments')" name="approve_comments" value="<MT_TRANS phrase="Unapprove">" />
Finally, download approve_confirm.tmpl
Upload all files to their necessary locations and you should be good to go.

mac said:
on Jan 14, 2005 11:08 AM | Reply
movable type does rock. they have to be working on an all in one install that doesn't require the same chmod and install prep that it does. something more simple would increase its use 10 times easy.