[Bps-public-commit] r19723 - in RT-Extension-ReportSpam: . html/Callbacks html/Callbacks/RT-Extension-ReportSpam html/Callbacks/RT-Extension-ReportSpam/Ticket html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements/Tabs html/Helpers html/Helpers/Toggle html/Ticket html/Ticket/Elements lib lib/RT lib/RT/Extension
ruz at bestpractical.com
ruz at bestpractical.com
Tue May 19 09:16:12 EDT 2009
Author: ruz
Date: Tue May 19 09:16:11 2009
New Revision: 19723
Added:
RT-Extension-ReportSpam/README
RT-Extension-ReportSpam/html/
RT-Extension-ReportSpam/html/Callbacks/
RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/
RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/Ticket/
RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements/
RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements/Tabs/
RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements/Tabs/Default
RT-Extension-ReportSpam/html/Helpers/
RT-Extension-ReportSpam/html/Helpers/Toggle/
RT-Extension-ReportSpam/html/Helpers/Toggle/TicketSpam
RT-Extension-ReportSpam/html/Ticket/
RT-Extension-ReportSpam/html/Ticket/Elements/
RT-Extension-ReportSpam/html/Ticket/Elements/ReportSpam
RT-Extension-ReportSpam/lib/
RT-Extension-ReportSpam/lib/RT/
RT-Extension-ReportSpam/lib/RT/Extension/
RT-Extension-ReportSpam/lib/RT/Extension/ReportSpam.pm
Log:
* initial commit
Added: RT-Extension-ReportSpam/README
==============================================================================
--- (empty file)
+++ RT-Extension-ReportSpam/README Tue May 19 09:16:11 2009
@@ -0,0 +1,9 @@
+NAME
+ RT::Extension::ReportSpam - report a spam in one click in RT
+
+AUTHOR
+ Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
+
+LICENSE
+ Under the same terms as perl itself.
+
Added: RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements/Tabs/Default
==============================================================================
--- (empty file)
+++ RT-Extension-ReportSpam/html/Callbacks/RT-Extension-ReportSpam/Ticket/Elements/Tabs/Default Tue May 19 09:16:11 2009
@@ -0,0 +1,12 @@
+<%ARGS>
+$Ticket => undef
+$actions => {}
+</%ARGS>
+<%INIT>
+return unless $Ticket;
+
+$actions->{'_SS'} = {
+ html => $m->scomp( '/Ticket/Elements/ReportSpam', id => $Ticket->id ),
+};
+
+</%INIT>
Added: RT-Extension-ReportSpam/html/Helpers/Toggle/TicketSpam
==============================================================================
--- (empty file)
+++ RT-Extension-ReportSpam/html/Helpers/Toggle/TicketSpam Tue May 19 09:16:11 2009
@@ -0,0 +1,7 @@
+<%ARGS>
+$id
+</%ARGS>
+<%INIT>
+$m->comp('/Ticket/Elements/ReportSpam', id => $id, Toggle => 1);
+$m->abort();
+</%INIT>
Added: RT-Extension-ReportSpam/html/Ticket/Elements/ReportSpam
==============================================================================
--- (empty file)
+++ RT-Extension-ReportSpam/html/Ticket/Elements/ReportSpam Tue May 19 09:16:11 2009
@@ -0,0 +1,46 @@
+<span id="toggle-ticket-spam-<% $id %>">
+% my $url = $RT::WebPath ."/Helpers/Toggle/TicketSpam?id=". $id;
+<a align="right" href="<% $url %>" onclick="ahah('<% $url |n %>', 'toggle-ticket-spam-<% $id |n %>'); return false;" >
+% if ( $reported ) {
+<img src="<% $RT::WebPath %>/NoAuth/images/star.gif" alt="<% loc('Not Spam') %>" style="border-style: none" />
+% } else {
+<img src="<% $RT::WebPath %>/NoAuth/images/empty_star.gif" alt="<% loc('Report Spam') %>" style="border-style: none" />
+% }
+</a>
+</span>
+<%ARGS>
+$id
+$Toggle => 0
+</%ARGS>
+<%INIT>
+my $uid = $session{'CurrentUser'}->id;
+
+my $ticket = RT::Ticket->new( $session{'CurrentUser'} );
+$ticket->Load( $id );
+return unless $id = $ticket->id;
+
+my $reports = $ticket->FirstAttribute('SpamReports');
+$reports = $reports->Content if $reports;
+$reports ||= [];
+
+my $reported = grep $_ == $uid, @$reports;
+
+if ( $Toggle ) {
+ if ( $reported ) {
+ @$reports = grep $_ != $uid, @$reports;
+ } else {
+ push @$reports, $uid;
+ }
+ if ( @$reports ) {
+ $ticket->SetAttribute(
+ Name => 'SpamReports',
+ Content => $reports,
+ );
+ } else {
+ $ticket->DeleteAttribute(
+ Name => 'SpamReports',
+ );
+ }
+ $reported = !$reported;
+}
+</%INIT>
Added: RT-Extension-ReportSpam/lib/RT/Extension/ReportSpam.pm
==============================================================================
--- (empty file)
+++ RT-Extension-ReportSpam/lib/RT/Extension/ReportSpam.pm Tue May 19 09:16:11 2009
@@ -0,0 +1,38 @@
+package RT::Extension::ReportSpam;
+
+use 5.008;
+use strict;
+use warnings;
+
+our $VERSION = '0.01';
+
+=head1 NAME
+
+RT::Extension::ReportSpam - report a spam in one click in RT
+
+=head1 DESCRIPTION
+
+A simple extension that works with RT 3.6 and newer and allows users
+report a ticket as spam.
+
+To find all tickets reported as spam you have to use query builder in
+advanced mode for now with the following query:
+
+ HasAttribute = 'SpamReports'
+
+=cut
+
+require RT::Tickets;
+
+
+=head1 AUTHOR
+
+Ruslan Zakirov E<lt>Ruslan.Zakirov at gmail.comE<gt>
+
+=head1 LICENSE
+
+Under the same terms as perl itself.
+
+=cut
+
+1;
More information about the Bps-public-commit
mailing list