| 1 |
#!/usr/bin/perl -wT |
|---|
| 2 |
# Copyright (C) 2006 Software Freedom Law Center, Inc. |
|---|
| 3 |
# Author: Orion Montoya <orion@mdcclv.com> |
|---|
| 4 |
# |
|---|
| 5 |
# This software gives you freedom; it is licensed to you under version |
|---|
| 6 |
# 3 of the GNU Affero General Public License, along with the |
|---|
| 7 |
# additional permission in the following paragraph. |
|---|
| 8 |
# |
|---|
| 9 |
# This notice constitutes a grant of such permission as is necessary |
|---|
| 10 |
# to combine or link this software, or a modified version of it, with |
|---|
| 11 |
# Request Tracker (RT), published by Jesse Vincent and Best Practical |
|---|
| 12 |
# Solutions, LLC, or a derivative work of RT, and to copy, modify, and |
|---|
| 13 |
# distribute the resulting work. RT is licensed under version 2 of |
|---|
| 14 |
# the GNU General Public License. |
|---|
| 15 |
# |
|---|
| 16 |
# This software is distributed WITHOUT ANY WARRANTY, without even the |
|---|
| 17 |
# implied warranties of MERCHANTABILITY and FITNESS FOR A PARTICULAR |
|---|
| 18 |
# PURPOSE. See the GNU Affero General Public License for further |
|---|
| 19 |
# details. |
|---|
| 20 |
# |
|---|
| 21 |
# You should have received a copy of the GNU Affero General Public |
|---|
| 22 |
# License, version 3, and the GNU General Public License, version 2, |
|---|
| 23 |
# along with this software. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 24 |
|
|---|
| 25 |
use CGI qw/:standard/; |
|---|
| 26 |
use Data::Dumper; |
|---|
| 27 |
|
|---|
| 28 |
use lib '/usr/share/request-tracker3.2/lib'; |
|---|
| 29 |
use lib '/usr/share/request-tracker3.2/libexec'; |
|---|
| 30 |
use lib '/usr/share/request-tracker3.4/lib'; |
|---|
| 31 |
use lib '/usr/share/request-tracker3.4/libexec'; |
|---|
| 32 |
use RT; |
|---|
| 33 |
use RT::Ticket; |
|---|
| 34 |
use RT::CustomField; |
|---|
| 35 |
use RT::CurrentUser; |
|---|
| 36 |
use RT::Record; |
|---|
| 37 |
|
|---|
| 38 |
use Frontier::Client; |
|---|
| 39 |
use MIME::Entity; |
|---|
| 40 |
use MIME::Base64; |
|---|
| 41 |
|
|---|
| 42 |
$id = param('rtid'); |
|---|
| 43 |
$opn = param('opn'); |
|---|
| 44 |
|
|---|
| 45 |
do "xmlpass.pl"; |
|---|
| 46 |
|
|---|
| 47 |
if (($name, $pass) = split(/:/, decode_base64(cookie('__ac')))) { |
|---|
| 48 |
$name =~ s/\"//g; |
|---|
| 49 |
$server = Frontier::Client->new(url => 'http://', |
|---|
| 50 |
username => $username, |
|---|
| 51 |
password => $password); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$resp = $server->call('authRemoteUser',$name,$pass); |
|---|
| 55 |
} |
|---|
| 56 |
else { |
|---|
| 57 |
${$resp} = 0; |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
RT::LoadConfig(); |
|---|
| 61 |
RT::Init(); |
|---|
| 62 |
|
|---|
| 63 |
#my $CurrentUser = new RT::CurrentUser(); |
|---|
| 64 |
#$CurrentUser->LoadByName($name); |
|---|
| 65 |
|
|---|
| 66 |
$CurrentUser = RT::SystemUser(); |
|---|
| 67 |
|
|---|
| 68 |
$Ticket = new RT::Ticket($CurrentUser); |
|---|
| 69 |
$Ticket->Load($id); |
|---|
| 70 |
|
|---|
| 71 |
#$values = $cf->ValuesForObject( $Ticket ); |
|---|
| 72 |
$values = $Ticket->CustomFieldValues(7); |
|---|
| 73 |
#print Dumper($values); |
|---|
| 74 |
#print "ticket has ".$values->count." customfieldvalues\n"; |
|---|
| 75 |
# this is trusting the user input, but it really needs to check the values |
|---|
| 76 |
if (($opn =~ /unagree/) && ($values->HasEntry($name))) { |
|---|
| 77 |
($bool, $message) = $Ticket->DeleteCustomFieldValue(Field => "7", Value => $name); |
|---|
| 78 |
$agreebool = "unagree"; |
|---|
| 79 |
print STDERR "DeleteCustomFieldValue said $bool, $message\n"; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
else { |
|---|
| 83 |
if (!$values->HasEntry($name)) { |
|---|
| 84 |
($bool, $message) = $Ticket->AddCustomFieldValue(Field => "7", Value => $name); |
|---|
| 85 |
print STDERR "AddCustomFieldValue said $bool, $message\n"; |
|---|
| 86 |
$agreebool = "agree"; |
|---|
| 87 |
} |
|---|
| 88 |
} |
|---|
| 89 |
if (!$agreebool) { $agreebool = "stop it"; } |
|---|
| 90 |
# } |
|---|
| 91 |
# } |
|---|
| 92 |
|
|---|
| 93 |
# my $CustomFieldValues=$Ticket->CustomFieldValues($CustomField->Id); |
|---|
| 94 |
# $returnme .= " <e>" . $item->FirstCustomFieldValue('NoteEndNodeId') . "</e>\n"; |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
# if (${$resp} == 0) { |
|---|
| 102 |
if ($agreebool =~ /agree/) { |
|---|
| 103 |
print header('text/xml'); |
|---|
| 104 |
|
|---|
| 105 |
print <<"EOF"; |
|---|
| 106 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|---|
| 107 |
<response> |
|---|
| 108 |
<agreement> |
|---|
| 109 |
<cs>You now $agreebool with <a href="/comments/rt/readsay.html?id=$id">$id</a>. <a href=\"/rt/NoAuth/changeshown.html\">change shown comments</a></cs> |
|---|
| 110 |
<id>$id</id> |
|---|
| 111 |
<b>$agreebool</b> |
|---|
| 112 |
</agreement> |
|---|
| 113 |
</response> |
|---|
| 114 |
|
|---|
| 115 |
EOF |
|---|
| 116 |
} |
|---|
| 117 |
elsif ($agreebool =~ "stop it") { |
|---|
| 118 |
print header('text/xml'); |
|---|
| 119 |
|
|---|
| 120 |
print <<"EOF"; |
|---|
| 121 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|---|
| 122 |
<response> |
|---|
| 123 |
<agreement> |
|---|
| 124 |
<cs>Hmm, I'm confused about your agreement. Try again later, or reload to toggle your opinion. <a href=\"/rt/NoAuth/changeshown.html\">change shown comments</a></cs> |
|---|
| 125 |
<id>$id</id> |
|---|
| 126 |
<b>$agreebool</b> |
|---|
| 127 |
</agreement> |
|---|
| 128 |
</response> |
|---|
| 129 |
|
|---|
| 130 |
EOF |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
#} |
|---|
| 134 |
|
|---|
| 135 |
|
|---|