Plugin: Admin Comments
Posted: 25 July 2008 01:30 AM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  03-21-2006

This solves a few different problems I had, so I figured I’d push it out for you guys too. Just getting some feedback and bug testing, and if I have time I’ll develop it some more.

Admin Comments is a plugin that lets the superuser delete or close any comment. Additionally, users who are logged in members can delete their own comments. That’s it!

Wrap it up in some ajax and you can have some pretty fancy stuff going on here. I didn’t put the ajax in this as that seemed to really make the plugin more heavy than it needs to be. I recommend reading up on jquery and doing that yourself. I found it pretty doable.

Here’s how you use it:

THE LINKS
The first thing you want to do is create the links. Make sure these are inside the {exp:comment:entries} tags. I usually put them near the comment meta information (date, time, author link, etc).

Delete Link Parameters

  commentid (Required) - The comment_id of the comment you wish to display a delete link for. (E.g. 47) Usually you can grab this via the {comment_id} tag
  template (Required) - The name of the template containing the {exp:admin_comment:delete} plugin code. (E.g. site/delete)
  authorid (Required) - The author_id of the comment in question. Usually you can grab this via the {author_id} tag. It’s always a number.
  showconfirm (Optional) - If this is set to “true” then the javascript “are you sure?” confirmation box will appear. Defaults to false. Danger!

Example usage inside a comment entries tag:

{exp:admin_comment:delete_link 
  commentid
="{comment_id}" 
  
showconfirm="false" 
  
authorid="{author_id}" 
  
template="embeds/delete-comment"}
    Delete
{
/exp:admin_comment:delete_link} 


Close Link

The exact same parameters and behavior applies to the close link as did with the delete link tags.

{exp:admin_comment:close_link 
  commentid
="{comment_id}" 
  
authorid="{author_id}" 
  
template="embeds/close-comment"}
    Close
{
/exp:admin_comment:close_link} 


THE ACT OF CLOSING/DELETING
The next thing you need to do is create templates that house the actual act of deleting and closing the comments. This is quite simple.

1. Create a template for deleting comments. This is the same template to which you’re referring in the template parameter in the exp:admin_comment:delete_link tag.
2. Inside this template put the following tag:

{exp:admin_comment:delete returnlink="true"}

Note: The parameter “returnlink” is optional and defaults to false. If this is set to “true” then a link to the previous page will appear following a successful comment deletion. The text of this link can be adjusted by changing the value of $returntext in pi.admin_comment.php. You can wrap as little or as much HTML around the tag as you like to ensure that the page is styled to suit your site. The user message (e.g. comment successfully deleted) will appear wherever the tag itself is placed. Currently the plugin is only designed to delete one comment at a time, so you should never embed more than one copy of the tag in a page. All of the standard user EE access checks are completed before a user is allowed to delete the comment, so ensure that your member group permissions are set very carefully.

The exact same parameter and behavior applies to the close tag

{exp:admin_comment:close returnlink="true"


Whew, that’s it. Remember this is a work in progress, and I take no responsibility if you nuke your site. smile

By the way, thanks to Dom Stubbs of Vaya Design for writing the Delete Entry plugin upon which a bit of this code is based.

[edit: grammar]

File Attachments
pi.admin_comment.php.zip  (File Size: 5KB - Downloads: 392)
 Signature 

Brian Warren // Be Good Not Bad // BeGoodNotBad.com

Profile
 
 
Posted: 25 July 2008 02:42 AM   [ Ignore ]   [ # 1 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13725
Joined  04-15-2006

Hi Brian,

Well done. Sounds like a neat little addition this one. I just did something similar with a plugin that I have made. Admittedly not for comments but works in kind of the same way. Might be nice if on the close and delete templates you could instead of having the returnlink=“true” parameter perhaps (also / instead) have a template=”“ parameter and if this is used then the person is re-directed straight back to that template. This could then probably even work for multiple pages using an embedded variable sent through to that template.

Just an idea though. The plugin sounds really good and I’m sure a lot of people will find use for this so well done on this one.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 02 December 2008 10:32 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  489
Joined  07-04-2007

Does this allow the author (not a super admin) of the entry to delete any comments posted to it?

Profile
 
 
Posted: 22 January 2009 12:18 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  519
Joined  10-09-2007

Hi, Looks like a very nice add and well on it’s way.  I did come across one issue, the previous link gave me grief and came back with this error notice causing the link not to populate correctly.  Anything I can do to correct it?

NoticeUndefined index1 in /var/www/vhosts/dvancouver/httpdocs/system/plugins/pi.admin_comment.php on line 165 
 Signature 

Vancouver Travel & Tourism http://www.discovervancouver.com/

Profile
 
 
Posted: 27 January 2009 02:49 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  191
Joined  01-20-2006

Hi Brian, is there a way to skip the delete template and go straight back to the comment template? And maybe display an inline succes message?

 Signature 

buro taggetig: freelance web design from Belgium.  |  Follow me on Twitter

Profile
 
 
Posted: 27 January 2009 06:43 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  03-21-2006

Hi Brian, is there a way to skip the delete template and go straight back to the comment template? And maybe display an inline succes message?

There is, if you use a bit of ajax. That’s how I’ve done it in the past.

 Signature 

Brian Warren // Be Good Not Bad // BeGoodNotBad.com

Profile
 
 
Posted: 27 January 2009 06:44 PM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  03-21-2006
Joobs - 02 December 2008 03:32 PM

Does this allow the author (not a super admin) of the entry to delete any comments posted to it?

Nope it sure doesn’t, though I imagine it would be possible to add that kind of functionality to the plugin at some point.

 Signature 

Brian Warren // Be Good Not Bad // BeGoodNotBad.com

Profile
 
 
Posted: 27 January 2009 06:47 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  03-21-2006
dvancouver - 22 January 2009 05:18 AM

Hi, Looks like a very nice add and well on it’s way.  I did come across one issue, the previous link gave me grief and came back with this error notice causing the link not to populate correctly.  Anything I can do to correct it?

NoticeUndefined index1 in /var/www/vhosts/dvancouver/httpdocs/system/plugins/pi.admin_comment.php on line 165 

What do you mean by the “previous link”?

 Signature 

Brian Warren // Be Good Not Bad // BeGoodNotBad.com

Profile
 
 
Posted: 18 May 2009 08:54 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  385
Joined  11-12-2003

Hi MrWarren,

Great plugin!  I was wondering if there has been any new versions since the last post that allows the author to delete any comments?

Thanks
Ryan

 Signature 

version 1.6.7
Build:  20090515

Profile
 
 
Posted: 12 June 2009 04:25 AM   [ Ignore ]   [ # 9 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  461
Joined  12-20-2002

Just what I was asked to provide and didn’t know how to do. Perfect plugin. Thanks. Tipjar somewhere on begoodnotbad.com?

 Signature 

Who ain’t a slave? - Ishmael

Profile
 
 
Posted: 09 July 2009 10:06 PM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1122
Joined  04-14-2007

mrwarren - just what the Dr. ordered! This plugin looks to address a very specific need.
Thanks.

Noticed one thing in testing - FYI - the delete function seems to address everything but the update of the recent_comment_date variable in exp_weblog_titles. I only stumbled across this because I’m pulling that data in on my multiple listing pages and after “deleting” several recent comment entries, that date did not revert back to the prior “recent comment”.

Also, wondering if it would be at all possible to see a brief example of how you achieved the ajax delete without users seeing any intermediary message?

Thanks

 Signature 

Michael Rubens | hothousegraphix
Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that’s creativity. - Charles Mingus

Profile
 
 
Posted: 13 July 2009 04:11 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1122
Joined  04-14-2007

Would anyone happen to be able to lend some advice on how to achieve in conjunction with an ajax call?

Conceptually, I get it. Call the script, fire the delete function, and refresh the div.

Assuming I have the jQuery library installed, I can take advantage of their built in ajax functions.

$(document).ready(function() {});
 $(
"a.deletelink").click(function() {});
 $.
ajax({
   url
"someurl.php"// would this be the path to my delete_comment template?
   
success: function() {} // set-up a refresh of parent div
 
}); 

Because the plugin dynamically sets up each delete link, how does one bypass that in favor of a function? I also assume there would need to be some way of passing the comment_id onto the above function.

Anyone done this before?

 Signature 

Michael Rubens | hothousegraphix
Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that’s creativity. - Charles Mingus

Profile
 
 
Posted: 13 July 2009 09:08 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1122
Joined  04-14-2007

I too am getting the Undefined Index error displaying in the delete_comment template

Notice: Undefined index: 1 in /home/mysite/public_html/system/plugins/pi.admin_comment.php on line 165

Notice: Undefined index: 1 in /home/mysite/public_html/system/plugins/pi.admin_comment.php on line 165

Not sure what’s causing this but would really appreciate some guidance.

This is not related to my efforts to employ with ajax as it shows up regardless of implementation.

 Signature 

Michael Rubens | hothousegraphix
Making the simple complicated is commonplace; making the complicated simple, awesomely simple, that’s creativity. - Charles Mingus

Profile
 
 
Posted: 24 November 2009 10:44 PM   [ Ignore ]   [ # 13 ]  
Grad Student
Rank
Total Posts:  99
Joined  01-24-2006

@hothousegraphix, I have installed the plugin successfully on EE 1.6.8, with a boat load of other plugins and extensions running.  However I have not attempted the Ajax route yet so can’t offer you any advice on the errors you are getting.

Wondering if anyone here has had any success either modifying this plugin or knows of some other plugin that can enable non-super admin authors to delete comments associated with entries they have written via the front end? I have posted in the how-to forum already, but have not had any responses there so thought I would try this thread.

 Signature 

Vibe9 Design - Vancouver Web Design Company

Profile