Software Freedom Law Center

root/tags/went-live-on-2006-03-14/agree.pl

Revision 44, 3.9 kB (checked in by orion, 3 years ago)


  • Property svn:executable set to *
Line 
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 print STDERR "entering agree.pl\n";
42 $id = param('rtid');
43 $opn = param('opn');
44
45 require "/var/www/stet/xmlpass.pl";
46 my ($username,$password) = userpass();
47 print STDERR "$username $password\n";
48 if (($name, $pass) = split(/:/, decode_base64(cookie('__ac')))) {
49      $name =~ s/\"//g;
50      $server = Frontier::Client->new(url => "http://$username:$password@gplv3.fsf.org:8800/launch/acl_users/Users/acl_users",
51                                     username => $username,
52                                     password =>  $password);
53    
54    
55      $resp = $server->call('authRemoteUser',$name,$pass);
56  }
57  else {
58      ${$resp} = 0;
59  }
60
61 RT::LoadConfig();
62 RT::Init();
63
64 #my $CurrentUser = new RT::CurrentUser();
65 #$CurrentUser->LoadByName($name);
66
67 $CurrentUser = RT::SystemUser();
68
69 $Ticket = new RT::Ticket($CurrentUser);
70 $Ticket->Load($id);
71
72 #$values = $cf->ValuesForObject( $Ticket );
73 $values = $Ticket->CustomFieldValues(7);
74 #print Dumper($values);
75 #print "ticket has ".$values->count." customfieldvalues\n";
76 # this is trusting the user input, but it really needs to check the values
77 if (($opn =~ /unagree/) && ($values->HasEntry($name))) {
78     ($bool, $message) = $Ticket->DeleteCustomFieldValue(Field => "7", Value => $name);
79     $agreebool = "unagree";
80     print STDERR "DeleteCustomFieldValue said $bool, $message\n";
81 }
82
83 else {
84     if  (!$values->HasEntry($name)) {
85         ($bool, $message) = $Ticket->AddCustomFieldValue(Field => "7", Value => $name);
86         print STDERR "AddCustomFieldValue said $bool, $message\n";
87         $agreebool = "agree";
88     }
89 }
90 if (!$agreebool) { $agreebool = "stop it"; }
91 # }
92 # }
93
94 # my $CustomFieldValues=$Ticket->CustomFieldValues($CustomField->Id);
95 #    $returnme .= " <e>" . $item->FirstCustomFieldValue('NoteEndNodeId') . "</e>\n";
96
97
98
99
100
101
102 # if (${$resp} == 0) {
103 if ($agreebool =~ /agree/) {
104 print header('text/xml');
105
106     print <<"EOF";
107 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
108  <response>
109   <agreement>
110     <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>
111     <id>$id</id>
112     <b>$agreebool</b>
113   </agreement>
114  </response>
115
116 EOF
117 }
118 elsif ($agreebool =~ "stop it") {
119 print header('text/xml');
120
121     print <<"EOF";
122 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
123  <response>
124   <agreement>
125     <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>
126     <id>$id</id>
127     <b>$agreebool</b>
128   </agreement>
129  </response>
130
131 EOF
132 }
133
134 #}
135
136
Note: See TracBrowser for help on using the browser.

SFLC Main Page

[frdm] Support SFLC