[Rt-commit] [svn] r941 - in rt/branches/rt-3.3: . bin html/Search html/Search/Elements html/Ticket lib/RT lib/RT/Action lib/t/data

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Sun May 23 22:29:52 EDT 2004


Author: jesse
Date: Sun May 23 22:29:51 2004
New Revision: 941

Added:
   rt/branches/rt-3.3/lib/t/data/rt-send-cc
Modified:
   rt/branches/rt-3.3/   (props changed)
   rt/branches/rt-3.3/bin/rt.in
   rt/branches/rt-3.3/html/Search/Build.html
   rt/branches/rt-3.3/html/Search/Elements/PickCFs
   rt/branches/rt-3.3/html/Ticket/Create.html
   rt/branches/rt-3.3/lib/RT/Action/CreateTickets.pm
   rt/branches/rt-3.3/lib/RT/Groups_Overlay.pm
   rt/branches/rt-3.3/lib/RT/Queue_Overlay.pm
Log:
Merge forward from 3.1


Modified: rt/branches/rt-3.3/bin/rt.in
==============================================================================
--- rt/branches/rt-3.3/bin/rt.in	(original)
+++ rt/branches/rt-3.3/bin/rt.in	Sun May 23 22:29:51 2004
@@ -195,7 +195,7 @@
 
 sub list {
     my ($q, $type, %data);
-    $orderby = $config{orderby};
+    my $orderby = $config{orderby};
     
     my $bad = 0;
 

Modified: rt/branches/rt-3.3/html/Search/Build.html
==============================================================================
--- rt/branches/rt-3.3/html/Search/Build.html	(original)
+++ rt/branches/rt-3.3/html/Search/Build.html	Sun May 23 22:29:51 2004
@@ -29,14 +29,16 @@
     Query => $Query,
     Rows => $ARGS{'Rows'} &>
 
-<FORM METHOD="POST" ACTION="Build.html" NAME="BuildQuery">
-<input type=hidden name=Query value="<%$Query%>">
-<input type=hidden name=Format value="<%$Format%>">
 <table width=100%>
 <tr>
 <td valign=top>
+<FORM METHOD="POST" ACTION="Build.html" NAME="BuildQuery">
+<input type=hidden name=SearchId value="<%$ARGS{'SearchId'}%>">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
 <& Elements/PickCriteria, query => $Query, cfqueues => \%queues, %ARGS &>
 <& /Elements/Submit, Caption => "Add additional criteria", Label => loc('Add'), Name => 'AddClause'&>
+
 </td>
 <td valign=top>
 <& /Elements/TitleBoxStart, title => loc("Query") . ": " .$search_hash->{'Description'} &>
@@ -56,15 +58,25 @@
 %#<input type=submit name="EditQuery" value="Advanced">
 </center>
 <& /Elements/TitleBoxEnd &>
+</form>
 <br>
+<FORM METHOD="POST" ACTION="Build.html" NAME="SavedSearch">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
 <& Elements/EditSearches, CurrentSearch => $search_hash &>
+</form>
 </td>
 </tr>
 <tr>
 <td colspan=2>
 
+<FORM METHOD="POST" ACTION="Build.html" NAME="EditFormat">
+<input type=hidden name=Query value="<%$Query%>">
+<input type=hidden name=Format value="<%$Format%>">
+<input type=hidden name=SearchId value="<%$ARGS{'SearchId'}%>">
 <& Elements/DisplayOptions, Format=> ($Format||$search_hash->{'Format'}),
 AvailableColumns => $AvailableColumns,  CurrentFormat => $CurrentFormat, %ARGS &>
+</form>
 </td>
 </tr>
 </table>
@@ -459,6 +471,7 @@
     my $depth = 1;
     my $query = {};
     my %depths;
+    my %items;
 
     setvalue($query, "{0.0}", {});
     setvalue($query, "{0.0}{Subkey}", {});
@@ -486,6 +499,7 @@
     # as a keyword or value.
 
     my $num = 0;
+    $depths{1} = 0;
     while ( $string =~ /(
                       $re_aggreg
                       |$re_op
@@ -520,14 +534,9 @@
         # Parens are highest priority
         if ( $current & PAREN ) {
             if ( $val eq "(" ) {
-                if ( !( defined $depths{$depth} ) ) {
-                    $depths{$depth} = 0;
-                }
-                else {
-                    $depths{$depth}++;
-                }
-                $depth++;
                 $num = 0;
+                $depth++;
+		$depths{$depth} = 0;
 
                 my $hashkey;
                 my @keys;
@@ -556,10 +565,12 @@
                 $depth--;
                 $num = $depths{$depth} + 1;
             }
+
             $want = KEYWORD | PAREN | AGGREG;
         }
         elsif ( $current & AGGREG ) {
             $ea = $val;
+	    $depths{$depth}++ if ($last & PAREN);
 
             $want = KEYWORD | PAREN;
         }
@@ -607,15 +618,9 @@
         }
 
         if ( $current & VALUE ) {
-            if ( !( defined $depths{$depth} ) ) {
-                $depths{$depth} = 0;
-            }
-            else {
-                $depths{$depth}++;
-            }
+	    $depths{$depth}++;
 
             my $keystring = "";
-	    my $pd = $parentdepth;
             $keystring = "{Subkey}{" . $parentdepth . ".$num" . "}";
             $parentdepth--;
 
@@ -630,6 +635,9 @@
 	    $ea = 'AND' if !$ea;
             $keystring = "{0.0}" . $keystring;
 
+	    if ( $key =~ /^CF./ ) {
+	        $key = "'" . $key . "'";
+	    }
             my $clause = {
                 Key   => $key,
                 Op    => $op,
@@ -694,16 +702,18 @@
     my $hash = shift;
     my $key  = shift;
 
-    my $nextkey;
-    if ( subkeyexists( $hash, nextkey($key) ) ) {
-        $nextkey = appendkey( $hash, subkey( nextkey($key) ) );
+    my $newkey;
+
+    # if the next key exists, get the last key
+    my $nextkey = nextkey($key);
+    if ( subkeyexists( $hash, $nextkey ) ) {
+        $newkey = appendkey( $hash, subkey( $nextkey ) );
     }
     else {
-        my ( $prefix, $depth, $num ) = parsekey($key);
-        $nextkey = subkey($key);
+        $newkey = subkey($key);
     }
 
-    return $nextkey;
+    return $newkey;
 }
 
 sub prevkey {
@@ -877,8 +887,8 @@
     setvalue($hash, $newkey, \%temp);
 
     $$currentkey = $orignewkey;
-    reworkkeys( $hash, $origkey, $currentkey );
     reworkkeys( $hash, $orignewkey, $currentkey );
+    reworkkeys( $hash, $origkey, $currentkey );
 
     return 1;
 }
@@ -932,10 +942,13 @@
     my $newhash;
     if ($prefix) {
 	my $parentkey = parentkey($key);
-	my $parent = gethash($hash, $parentkey);
+
+	my $parent;
 	if (!gethash($hash, $parentkey)) {
 	    setvalue($hash, $parentkey, {});
 	    $parent = gethash($hash, $parentkey);
+	} else {
+	    $parent = gethash($hash, $parentkey);
 	}
 
 	if (!exists $parent->{Subkey}) {
@@ -947,6 +960,13 @@
     }
 
     $newhash->{$depth + ($num / 10)} = $value;
+
+    # if there isn't an aggregator, set it to AND
+    my $ea = getaggregator( $hash, $key);
+    if (!$ea) {
+	setaggregator( $hash, $key, 'AND' );
+    }
+
 }
 
 sub deletevalue {
@@ -1081,6 +1101,7 @@
 	Format => $Format,
 	Rows =>$ARGS{'Rows'}) if ($Query);
 
+$ARGS{'SearchId'} =$search_hash->{'SearchId'};
 </%INIT>
 
 <%ARGS>

Modified: rt/branches/rt-3.3/html/Search/Elements/PickCFs
==============================================================================

Modified: rt/branches/rt-3.3/html/Ticket/Create.html
==============================================================================

Modified: rt/branches/rt-3.3/lib/RT/Action/CreateTickets.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/Action/CreateTickets.pm	(original)
+++ rt/branches/rt-3.3/lib/RT/Action/CreateTickets.pm	Sun May 23 22:29:51 2004
@@ -280,6 +280,7 @@
 ticket1,General,"foo, bar",root,blah
 ticket2,General,foo bar,root,blah
 ticket3,General,foo' bar,root,blah'boo
+ticket4,General,foo' bar,,blah'boo
 EOF
 
 # tab-delimited templates
@@ -288,6 +289,7 @@
 ticket10\tGeneral\t"foo' bar"\troot\tblah'
 ticket11\tGeneral\tfoo, bar\troot\tblah
 ticket12\tGeneral\tfoo' bar\troot\tblah'boo
+ticket13\tGeneral\tfoo' bar\t\tblah'boo
 EOF
 
 my %expected;
@@ -316,6 +318,14 @@
 ENDOFCONTENT
 EOF
 
+$expected{ticket4} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: 
+Content: blah'boo
+ENDOFCONTENT
+EOF
+
 $expected{ticket10} = <<EOF;
 Queue: General
 Subject: foo' bar
@@ -340,6 +350,14 @@
 ENDOFCONTENT
 EOF
 
+$expected{ticket13} = <<EOF;
+Queue: General
+Subject: foo' bar
+Owner: 
+Content: blah'boo
+ENDOFCONTENT
+EOF
+
 $action->Parse($commas);
 $action->Parse($tabs);
 
@@ -658,6 +676,7 @@
 	}
 	my $delimited = qr[[^$delimiter]+];
 	my @fields = split(/$delimiter/, $first);
+	my $empty = qr[[$delimiter][$delimiter]];
 
 	my $justquoted = qr[$RE{quoted}];
 
@@ -671,14 +690,19 @@
 	    # first item is $template_id
 	    my $i = 0;
 	    my $template_id;
-	    while ($line =~ /($justquoted|$delimited)/igx) {
+	    while ($line =~ /($justquoted|$delimited|$empty)/igx) {
 		if ($i == 0) {
 		    $queue = 0;
-		    $template_id = 'create-' . $1;
-		    $RT::Logger->debug("template_id: $1");
+		    my $tid = $1;
+		    $tid =~ s/^\s//;
+		    $tid =~ s/\s$//;
+		    next unless $tid;
+		    $template_id = 'create-' . $tid;
+		    $RT::Logger->debug("template_id: $tid");
 		    push @{$self->{'create_tickets'}},$template_id;
 		} else {
 		    my $value = $1;
+		    $value = '' if ($value =~ /^$empty$/);
 		    if ($value =~ /$justquoted/) {
 			$value =~ s/^\"|\'//;
 			$value =~ s/\"|\'$//;
@@ -696,12 +720,10 @@
 		    }
 		    if ( $field =~ /Queue/i) {
 			$queue = 1;
-			$RT::Logger->debug("queue!!: |$field|\n");
 			if (!$value) {
 			    $value = $qname;
 			}
 		    }
-		    $RT::Logger->debug("field: |$field|\n");
 		    $self->{'templates'}->{$template_id} .= $field . ": ";
 		    $self->{'templates'}->{$template_id} .= $value || "";
 		    $self->{'templates'}->{$template_id} .= "\n";

Modified: rt/branches/rt-3.3/lib/RT/Groups_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/Groups_Overlay.pm	(original)
+++ rt/branches/rt-3.3/lib/RT/Groups_Overlay.pm	Sun May 23 22:29:51 2004
@@ -228,6 +228,45 @@
 }
 
 
+=head2 WithRight { Right => RIGHTNAME, Object => RT::Record, IncludeSystemRights => 1, IncludeSuperusers => 0 }
+
+
+Find all groups which have RIGHTNAME for RT::Record. Optionally include global rights and superusers. By default, include the global rights, but not the superusers.
+
+=begin testing
+
+my $q = RT::Queue->new($RT::SystemUser);
+my ($id, $msg) =$q->Create( Name => 'GlobalACLTest');
+ok ($id, $msg);
+
+my $testuser = RT::User->new($RT::SystemUser);
+($id,$msg) = $testuser->Create(Name => 'JustAnAdminCc');
+ok ($id,$msg);
+
+my $global_admin_cc = RT::Group->new($RT::SystemUser);
+$global_admin_cc->LoadSystemRoleGroup('AdminCc');
+ok($global_admin_cc->id, "Found the global admincc group");
+my $groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'OwnTicket', Object => $q);
+is($groups->Count, 1);
+($id, $msg) = $global_admin_cc->PrincipalObj->GrantRight(Right =>'OwnTicket', Object=> $RT::System);
+ok ($id,$msg);
+ok (!$testuser->HasRight(Object => $q, Right => 'OwnTicket') , "The test user does not have the right to own tickets in the test queue");
+($id, $msg) = $q->AddWatcher(Type => 'AdminCc', PrincipalId => $testuser->id);
+ok($id,$msg);
+ok ($testuser->HasRight(Object => $q, Right => 'OwnTicket') , "The test user does have the right to own tickets now. thank god.");
+
+$groups = RT::Groups->new($RT::SystemUser);
+$groups->WithRight(Right => 'OwnTicket', Object => $q);
+ok ($id,$msg);
+is($groups->Count, 2);
+
+=end testing
+
+
+=cut
+
+
 sub WithRight {
     my $self = shift;
     my %args = ( Right                  => undef,
@@ -272,7 +311,7 @@
             $or_check_roles =
                 " OR ( ( (main.Domain = 'RT::Queue-Role' AND main.Instance = " .
                 $args{'Object'}->Id . ") $or_check_ticket_roles ) " .
-                " AND main.Type = $acl.PrincipalType AND main.id = $acl.PrincipalId) ";
+                " AND main.Type = $acl.PrincipalType) ";
         }
 
 	if ( $args{'IncludeSystemRights'} ) {
@@ -316,7 +355,7 @@
 	ALIAS1 => 'main',
 	FIELD1 => 'id',
 	TABLE2 => 'Principals',
-	FIELD2 => 'ObjectId'
+	FIELD2 => 'id'
     );
 
     $self->Limit( ALIAS => $alias,
@@ -342,7 +381,7 @@
 	ALIAS1 => 'main',
 	FIELD1 => 'id',
 	TABLE2 => 'Principals',
-	FIELD2 => 'ObjectId'
+	FIELD2 => 'id'
     );
 
     $self->{'find_disabled_rows'} = 1;

Modified: rt/branches/rt-3.3/lib/RT/Queue_Overlay.pm
==============================================================================
--- rt/branches/rt-3.3/lib/RT/Queue_Overlay.pm	(original)
+++ rt/branches/rt-3.3/lib/RT/Queue_Overlay.pm	Sun May 23 22:29:51 2004
@@ -574,6 +574,8 @@
 
 If the watcher you\'re trying to set has an RT account, set the Owner paremeter to their User Id. Otherwise, set the Email parameter to their Email address.
 
+Returns a tuple of (status/id, message).
+
 =cut
 
 sub AddWatcher {

Added: rt/branches/rt-3.3/lib/t/data/rt-send-cc
==============================================================================
--- (empty file)
+++ rt/branches/rt-3.3/lib/t/data/rt-send-cc	Sun May 23 22:29:51 2004
@@ -0,0 +1,5 @@
+From: rt at example.com
+subject: testing send-cc headers
+RT-Send-Cc: this-is-a-sample-test1e at example.com, second-this-is-a-sample-test2 at example.com,  test-sample-sample-sample-test3 at example.com,
+    afourthtest4 at example.com,
+ test5 at example.com


More information about the Rt-commit mailing list