[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rt-devel
Subject:    [rt-devel] PATCHES: Timer, Privacy Filter, Short Tag
From:       Florian Bischof <flo () fxb ! de>
Date:       2002-03-18 4:23:42
[Download RAW message or body]

Hi,

got some small patches (2.0.11) for you.

Timer Patch
  Javascript timing device to measure time worked on ticket updates:
  - Timer starts "invisible" on ticket display
  - Displays minute counter on update page (with blinking dot)
  - Timer stops if you click into the minute-field
  - It's still possible to change the time worked manually - the timer
    continues to count if you leave the field
  
Privacy Patch
  Shortens requestor names/email-addresses for more privacy:
  "Florian Bischof <flo@fxb.de>" becomes "Florian *** <flo@***>"
  if you are not the owner of the ticket and the privacy-option is
  enabled for the ticket queue (and you are not superuser who is still
  able to see everything).
  This patch needs a new database field. Just do
    ALTER TABLE Queues ADD Privacy smallint(6) DEFAULT 0;
  or something similar.
  Use this expression in your templates to use the privacy-filter
  in your notifications/autoreplys, too:
    {$Ticket->ApplyPrivacy($Transaction->ContentPrivacy())}
  
Short Tag Patch
  Stupid patch to use short ticket tags like "Subject (#NUMBER)".


Have fun,

Florian

-- 
Florian Bischof <flo@fxb.de>
Slurm: It's so delicious, you'll eat it until you explode!

["rt-2-0-11-fxb-Timer.patch" (rt-2-0-11-fxb-Timer.patch)]

diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Elements/ShowTransaction \
                ./WebRT/html/Ticket/Elements/ShowTransaction
--- ../rt2-orig/WebRT/html/Ticket/Elements/ShowTransaction	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Elements/ShowTransaction	Mon Mar 18 03:38:29 2002
@@ -140,19 +140,21 @@
 
 my $titlebar_commands='&nbsp;';
 
+my $time = time;
+
 # If the transaction has anything attached to it at all
 if ($Transaction->Message->First && $ShowTitleBarCommands) {
 	if ($Transaction->TicketObj->CurrentUserHasRight('ReplyToTicket')) {
 		$titlebar_commands .= 
 	  	  "[<a href=\"Update.html?id=".
 		  $Transaction->Ticket . "&QuoteTransaction=".$Transaction->Id.
-		  "&Action=Respond\">Reply</a>]&nbsp;";
+		  "&Action=Respond&Time=".$time."\">Reply</a>]&nbsp;";
 	}
 	if ($Transaction->TicketObj->CurrentUserHasRight('CommentOnTicket')) {
 	     $titlebar_commands .= 
 	     "[<a href=\"Update.html?id=".$Transaction->Ticket. 
 	     "&QuoteTransaction=".$Transaction->Id.
-	     "&Action=Comment\">Comment</a>]";
+	     "&Action=Comment&Time=".$time."\">Comment</a>]";
 	}
 }
 
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Elements/Tabs \
                ./WebRT/html/Ticket/Elements/Tabs
--- ../rt2-orig/WebRT/html/Ticket/Elements/Tabs	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Elements/Tabs	Thu Mar 14 01:21:08 2002
@@ -37,7 +37,7 @@
     $actions->{'Comment'} = 
       { 
        title => 'Comment',
-	path => "Ticket/Update.html?Action=Comment&id=".$id,
+	path => "Ticket/Update.html?Action=Comment&Time=".time."&id=".$id,
       }
   };
 
@@ -46,7 +46,7 @@
     $actions->{'Reply'} = 
       { 
        title => 'Reply',
-       path => "Ticket/Update.html?Action=Respond&id=".$id,
+       path => "Ticket/Update.html?Action=Respond&Time=".time."&id=".$id,
       }
   };
 
@@ -72,7 +72,7 @@
 	$actions->{'Resolve'} = 
 	  { 
 
-           path => "Ticket/Update.html?Action=Comment&DefaultStatus=resolved&id=".$id,
 +           path => \
"Ticket/Update.html?Action=Comment&DefaultStatus=resolved&Time=".time."&id=".$id,  \
title => 'Resolve'  };
     }	
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Update.html \
                ./WebRT/html/Ticket/Update.html
--- ../rt2-orig/WebRT/html/Ticket/Update.html	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Update.html	Mon Mar 18 02:22:49 2002
@@ -2,6 +2,7 @@
 <& /Ticket/Elements/Tabs, Ticket => $Ticket &>
 <& /Elements/TitleBoxStart, title => $title &>
 
+
 <FORM ACTION="Display.html" NAME="TicketUpdate" 
 	METHOD=POST enctype="multipart/form-data">
 
@@ -66,7 +67,40 @@
 <& /Elements/Submit &>
   </FORM>
 
+<script type="text/javascript">
+<!--
+
+secdot = 0;
+secs = 0;
+starttime = <% $ARGS{'Time'} %> - 60;	// -60 because we want to start with '1 min'
+function updateTimer() {
+	time = new Date();
+	secdot = secdot ? 0 : 1;
+	timer = Math.floor(((time.getTime()/1000) - starttime)/60);
+	if (secdot) timer += '.';
+	window.document.TicketUpdate.UpdateTimeWorked.value = timer;
+	timeout = window.setTimeout('updateTimer()',1000);
+}
+function startTimer() {
+	time = new Date();
+	mins = window.document.TicketUpdate.UpdateTimeWorked.value;
+	if (mins.length > 0) { 
+          starttime = time.getTime()/1000 - mins*60;  
+        }
+	secs = 0;
+	timeout = window.setTimeout('updateTimer()',1000);
+}
+function stopTimer() {
+	window.clearTimeout(timeout);
+	window.document.TicketUpdate.UpdateTimeWorked.onblur = startTimer;
+	time = new Date();
+	secs =  ((time.getTime()/1000 - starttime) % 60);
+}
+timeout = window.setTimeout('updateTimer()',1000);
+window.document.TicketUpdate.UpdateTimeWorked.onfocus = stopTimer;
 
+//-->
+</script>
 
 <%INIT>
 


["rt-2-0-11-fxb-Privacy.patch" (rt-2-0-11-fxb-Privacy.patch)]

diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Admin/Queues/Modify.html \
                ./WebRT/html/Admin/Queues/Modify.html
--- ../rt2-orig/WebRT/html/Admin/Queues/Modify.html	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Admin/Queues/Modify.html	Mon Mar 18 03:13:46 2002
@@ -58,6 +58,14 @@
 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>> Enabled \
(Unchecking this box disables this queue)<BR>  </TD>
 </TR>
+<TR>
+<TD>
+</TD>
+<TD COLSPAN=4><INPUT TYPE=HIDDEN NAME="SetPrivacy" VALUE="1">
+<INPUT TYPE=CHECKBOX NAME="Privacy" VALUE="1"
+		  <%$PrivacyChecked%>> Privacy Enabled (Checking this box enables privacy \
filters)<BR> +</TD>
+</TR>
 
 </TABLE>
 <& /Elements/TitleBoxEnd &>
@@ -69,7 +77,7 @@
 <%INIT>
 
 my $QueueObj = new RT::Queue($session{'CurrentUser'});
-my  ($title, @results, $Disabled, $EnabledChecked);
+my  ($title, @results, $Disabled, $EnabledChecked, $PrivacyChecked);
 
 if ($Create) {
     $title = "Create a queue";
@@ -112,10 +120,18 @@
     my  ($code, $msg) = $QueueObj->SetDisabled($Disabled);
     push @results, 'Enabled status '. $msg;
 }
+if  ( ($SetPrivacy) and ( $Privacy != $QueueObj->Privacy) ) { 
+    my  ($code, $msg) = $QueueObj->SetPrivacy($Privacy);
+    push @results, 'Privacy status '. $msg;
+}
 
 unless ($QueueObj->Disabled()) {
     $EnabledChecked ="CHECKED";
 }
+
+if ($QueueObj->Privacy()) {
+    $PrivacyChecked ="CHECKED";
+}
 </%INIT>
 
 
@@ -132,4 +148,6 @@
 $DefaultDueIn => undef
 $SetEnabled => undef
 $Enabled => undef
+$SetPrivacy => undef
+$Privacy => undef
 </%ARGS>
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Elements/MessageBox \
                ./WebRT/html/Elements/MessageBox
--- ../rt2-orig/WebRT/html/Elements/MessageBox	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Elements/MessageBox	Sun Mar 17 02:54:05 2002
@@ -10,7 +10,7 @@
 if ($QuoteTransaction) {
     my $transaction=RT::Transaction->new($session{'CurrentUser'});
     $transaction->Load($QuoteTransaction);
-    $message=$transaction->Content(Quote => 1);
+    $message=$transaction->TicketObj->ApplyPrivacy($transaction->Content(Quote => \
1));  }
 
 my $signature = '';
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Attachment/dhandler \
                ./WebRT/html/Ticket/Attachment/dhandler
--- ../rt2-orig/WebRT/html/Ticket/Attachment/dhandler	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Attachment/dhandler	Sun Mar 17 02:49:29 2002
@@ -11,7 +11,6 @@
      my $AttachmentObj = new RT::Attachment($session{'CurrentUser'});
      $AttachmentObj->Load($attach) || Abort("Attachment '$attach' could not be \
loaded");  
-
      unless ($AttachmentObj->id) {
         Abort("Bad attachment id. Couldn't find attachment '$attach'\n");
     }
@@ -21,7 +20,7 @@
      }
      my $content_type = $AttachmentObj->ContentType || 'text/plain';
      SetContentType($content_type);
-     $m->out($AttachmentObj->Content); 
+     $m->out($AttachmentObj->TransactionObj->TicketObj->ApplyPrivacy($AttachmentObj->Content));
  $m->abort; 
 </%perl>
 
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Elements/EditWatchers \
                ./WebRT/html/Ticket/Elements/EditWatchers
--- ../rt2-orig/WebRT/html/Ticket/Elements/EditWatchers	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Elements/EditWatchers	Sun Mar 17 21:47:04 2002
@@ -14,13 +14,13 @@
 <INPUT TYPE=CHECKBOX NAME="DelWatcher<%$watcher->id%>" UNCHECKED>
 %#If there's a principal backing this user, lets give a link to their
 %# account
-%if ($watcher->IsUser) { 
+%if (($watcher->IsUser) && ($TicketObj->IsOwner($TicketObj->CurrentUser))) { 
 <a href="<%$RT::WebPath%>/Admin/Users/Modify.html?id=<%$watcher->OwnerObj->id%>">
-<%$watcher->OwnerObj->RealName%></a>:
+<%$TicketObj->ApplyPrivacy($watcher->OwnerObj->RealName)%></a>:
 %} else {
 Email address:
 %}
-<i><%$watcher->Email%></i>
+<i><%$TicketObj->ApplyPrivacy($watcher->Email)%></i>
 %}
 </ul>
 <%INIT>
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Elements/ShowDates \
                ./WebRT/html/Ticket/Elements/ShowDates
--- ../rt2-orig/WebRT/html/Ticket/Elements/ShowDates	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Elements/ShowDates	Mon Mar 18 03:16:48 2002
@@ -45,7 +45,7 @@
 </TD>
 <TD>
 <A HREF="#lasttrans">
-<% $Ticket->LastUpdated ? ($Ticket->LastUpdatedAsString ." by \
".$Ticket->LastUpdatedByObj->Name) : "Never" | h %></a> +<% $Ticket->LastUpdated ? \
($Ticket->LastUpdatedAsString ." by \
".$Ticket->ApplyPrivacy($Ticket->LastUpdatedByObj->Name)) : "Never" | h %></a>  </TD>
 </TR>
 </TABLE>
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Elements/ShowRequestor \
                ./WebRT/html/Ticket/Elements/ShowRequestor
--- ../rt2-orig/WebRT/html/Ticket/Elements/ShowRequestor	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Elements/ShowRequestor	Sun Mar 17 21:55:32 2002
@@ -12,10 +12,14 @@
 		  ORDER => 'DESC');
 </%PERL>
 
-% unless ($user->Privileged) {
+% unless ($user->Privileged) { 
+% if ($Ticket->CurrentUserHasRight('SuperUser') || \
($Ticket->IsOwner($Ticket->CurrentUser))) {  <& /Elements/TitleBoxStart, 
 	title => "<a class='inverse' \
href=\"$RT::WebPath/Admin/Users/Modify.html?id=".$user->id."\">More about $name</a>" \
                &>
-
+% } else {
+<& /Elements/TitleBoxStart, 
+	title => "More about $name" &>
+% }
 Comments about this user:<BR>
 <B><% ($user->Comments || "No comment entered about this user") %></B><BR>
 
diff --exclude=*~ -dru ../rt2-orig/WebRT/html/Ticket/Elements/ShowTransaction \
                ./WebRT/html/Ticket/Elements/ShowTransaction
--- ../rt2-orig/WebRT/html/Ticket/Elements/ShowTransaction	Thu Mar 14 00:47:42 2002
+++ ./WebRT/html/Ticket/Elements/ShowTransaction	Mon Mar 18 03:38:29 2002
@@ -2,7 +2,7 @@
 <TD bgcolor="<%$bgcolor%>"><A NAME="#<%$Transaction->Id%>"></A>&nbsp&nbsp;</TD>
 <TD>&nbsp&nbsp;</TD>
 <TD><font size=-2><% $transdate|n %></font>&nbsp;</TD>
-<TD ALIGN="LEFT"><b><%$Transaction->CreatorObj->Name%> - <%$TicketString%> \
<%$Transaction->BriefDescription%> +<TD \
ALIGN="LEFT"><b><%$Ticket->ApplyPrivacy($Transaction->CreatorObj->Name)%> - \
<%$TicketString%> <%$Ticket->ApplyPrivacy($Transaction->BriefDescription)%>  
 </b></TD>
 <TD><%$TimeTaken%>&nbsp;</TD>
@@ -27,19 +27,19 @@
       } else {
 	  $headers = $message->NiceHeaders;
       }
+      $headers = $Ticket->ApplyPrivacy($headers);
       chomp $headers;
       $headers .= "\n\n" if ($headers);
   }
      # 13456 is a random # of about the biggest size we want to see inline text
-     if ($message->ContentType =~ m{^(text/plain|message|text$)}i && 
-				    length($message->Content)<13456) {
-
+     if ($message->ContentType =~ m{^(text/plain|message|text$)}i) {
 	 $content = $message->Content;
-
-	 my $wrapper = new Text::Wrapper (columns=>85);
-	 $content = $wrapper->wrap($content);
 	 $content =~ s/</&lt;/g;
 	 $content =~ s/>/&gt;/g;
+	 $content = substr($content, 0, 1024)."...\n<A \
HREF=\"Attachment/".$Transaction->Id.'/'.$message->Id.'/'.$message->Filename."\">[...]</A>\n...".substr($content, \
-512) if (length($content) > 1024*4); +	 $content = $Ticket->ApplyPrivacy($content);
+	 my $wrapper = new Text::Wrapper (columns=>85);
+	 $content = $wrapper->wrap($content);
 	 $content =~ s!((?:http|https|ftp|mailto):\S*?)([\s"']|&lt;)!<A \
HREF=\"$1\">$1</A>$2!g;  
      }
diff --exclude=*~ -dru ../rt2-orig/lib/RT/Queue.pm ./lib/RT/Queue.pm
--- ../rt2-orig/lib/RT/Queue.pm	Thu Mar 14 00:47:42 2002
+++ ./lib/RT/Queue.pm	Mon Mar 18 03:14:17 2002
@@ -92,6 +92,7 @@
 		 LastUpdatedBy => 'read/auto',
 		 LastUpdated => 'read/auto',
 		 Disabled => 'read/write',
+		 Privacy => 'read/write',
 		 
 	       );
     return($self->SUPER::_Accessible(@_, %Cols));
@@ -154,6 +155,18 @@
 Takes a boolean.
 1 will cause this queue to no longer be avaialble for tickets.
 0 will re-enable this queue
+
+=cut
+
+# }}}
+
+# {{{ sub SetPrivacy
+
+=head2 SetPrivacy
+
+Takes a boolean.
+1 will cause this queue to use some privacy filters.
+0 will disable this features for this queue
 
 =cut
 
diff --exclude=*~ -dru ../rt2-orig/lib/RT/Ticket.pm ./lib/RT/Ticket.pm
--- ../rt2-orig/lib/RT/Ticket.pm	Thu Mar 14 00:47:42 2002
+++ ./lib/RT/Ticket.pm	Mon Mar 18 03:10:38 2002
@@ -1006,7 +1006,7 @@
         return undef;
     }
     
-    return ($self->Requestors->EmailsAsString() );
+    return ($self->ApplyPrivacy($self->Requestors->EmailsAsString()));
 }
 
 =head2 WatchersAsString
@@ -1022,7 +1022,7 @@
 	return (0, "Permission Denied");
     }
     
-    return ($self->Watchers->EmailsAsString());
+    return ($self->ApplyPrivacy($self->Watchers->EmailsAsString()));
 
 }
 
@@ -1040,7 +1040,7 @@
 	return undef;
     }
     
-    return ($self->AdminCc->EmailsAsString());
+    return ($self->ApplyPrivacy($self->AdminCc->EmailsAsString()));
     
 }
 
@@ -1057,7 +1057,7 @@
         return undef; 
     }
     
-    return ($self->Cc->EmailsAsString());
+    return ($self->ApplyPrivacy($self->Cc->EmailsAsString()));
 
 }
 
@@ -2957,5 +2957,30 @@
     
     return($args{'Principal'}->HasQueueRight(TicketObj => $self,
 					     Right => $args{'Right'}));
+}
+
+# }}}
+
+# {{{ sub ApplyPrivacy 
+
+=head2 ApplyPrivacy
+
+Takes a string and applys some privacy filters:
+  flo@fxb.de -> flo@***
+  Florian Bischof <flo@***> -> Florian *** <flo@***>
+
+=cut
+
+sub ApplyPrivacy {
+    my $self = shift;
+    my ($content) = @_;
+    if ($self->QueueObj->Privacy && (!$self->CurrentUserHasRight('SuperUser')) && \
(!$self->IsOwner($self->CurrentUser))) { +      # flo@fxb.de -> flo@***
+      $content =~ s/([\w\-_\.]+)\@[\w\-_\.]+/$1\@\*\*\*/g;
+    
+      # Florian Bischof <flo@***> -> Florian *** <flo@***>
+      $content =~ s/([\w+\-]+\.?) \w+ ([<\(][\w\-_\.]+\@\*{3}[>\)])/$1 *** $2/g;
+    }
+    return ($content);
 }
 
 # }}}


["rt-2-0-11-fxb-ShortTag.patch" (rt-2-0-11-fxb-ShortTag.patch)]

diff -ubdr ./lib/RT/Action/SendEmail.pm /usr/local/rt2-fxb/lib/RT/Action/SendEmail.pm
--- ./lib/RT/Action/SendEmail.pm	Wed Nov  7 00:04:17 2001
+++ /usr/local/rt2-fxb/lib/RT/Action/SendEmail.pm	Fri Jan  4 03:19:50 2002
@@ -441,12 +441,14 @@
 
 sub SetSubjectToken {
   my $self=shift;
-  my $tag = "[$RT::rtname #".$self->TicketObj->id."]";
+  # Florian Bischof <flo@fxb.de>
+  # we're gonna use short rt-tags without 'rtname'
+  my $tag = "(#".$self->TicketObj->id.")";
   my $sub = $self->TemplateObj->MIMEObj->head->get('Subject');
   unless ($sub =~ /\Q$tag\E/) {
     $sub =~ s/(\r\n|\n|\s)/ /gi;
     chomp $sub;
-    $self->TemplateObj->MIMEObj->head->replace('Subject', "$tag $sub");
+    $self->TemplateObj->MIMEObj->head->replace('Subject', "$sub $tag");
   }
 }
 
diff -ubdr ./lib/RT/Interface/Email.pm /usr/local/rt2-fxb/lib/RT/Interface/Email.pm
--- ./lib/RT/Interface/Email.pm	Wed Nov  7 00:04:52 2001
+++ /usr/local/rt2-fxb/lib/RT/Interface/Email.pm	Fri Feb 22 01:55:07 2002
@@ -271,8 +271,11 @@
 	$Id = $1;
 	$RT::Logger->debug("Found a ticket ID. It's $Id");
 	return($Id);
-    }
-    else {
+    } elsif ($Subject =~ s/\(\#(\d+)\)//i) {
+        $Id = $1;
+        $RT::Logger->debug("Found a ticket ID. It's $Id");
+        return($Id);
+    } else {
 	return(undef);
     }
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic