[Rt-commit] r8282 - in rtir/branches/2.3-EXPERIMENTAL: . html/RTIR html/RTIR/Elements

thayes at bestpractical.com thayes at bestpractical.com
Wed Jul 25 12:49:02 EDT 2007


Author: thayes
Date: Wed Jul 25 12:48:58 2007
New Revision: 8282

Removed:
   rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/ShowLock
Modified:
   rtir/branches/2.3-EXPERIMENTAL/   (props changed)
   rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Display.html
   rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/QueueTabs
   rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html
   rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR/Ticket.pm

Log:
 r8422 at toth:  toth | 2007-07-25 12:48:03 -0400
 * Adapted RTIR locking to use RT locking
 


Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Display.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Display.html	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Display.html	Wed Jul 25 12:48:58 2007
@@ -30,7 +30,8 @@
     current_subtab => 'RTIR/Display.html?id='.$Ticket->id,
     Title => $Title &>
 
-<& /RTIR/Elements/ShowLock, Ticket => $Ticket &>
+% $duration ||= $ARGS{'duration'};
+<& /Elements/ShowLock, Ticket => $Ticket, duration => $duration &>
 <& /Elements/ListActions, actions => \@results &>
 <table border="0" cellpadding="0" cellspacing="2" width="100%">
 <tr>
@@ -208,6 +209,7 @@
 <%INIT>
 my ($name);
 my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
+my $duration;
 
 my $QueueObj;
 unless ( $id eq 'new' ) {
@@ -259,20 +261,23 @@
     if ( $ARGS{'Lock'} ) {
 
         if ( $ARGS{'Lock'} eq 'add' ) {
-            if ( $Ticket->RT::IR::Ticket::Lock() ) {
+            if ( $Ticket->RT::Ticket::Lock() ) {
                 push @results, loc('You now have a lock on this ticket');
             } else {
                 push @results, loc('Your attempt to lock this ticket failed');
 
             }
         } elsif ( $ARGS{'Lock'} eq 'remove' ) {
-            my $lock = $Ticket->RT::IR::Ticket::Locked();
+            my $lock = $Ticket->RT::Ticket::Locked();
             if ( !$lock ) {
                 push @results, loc('This ticket was not locked');
 
                 } elsif ( $lock->Content->{'User'} == $session{'CurrentUser'}->id ) {
-                $Ticket->RT::IR::Ticket::Unlock();
-                push @results, loc('You have unlocked this ticket');
+                $duration = time() - $lock->Content->{'Timestamp'};
+				my $date = RT::Date->new($session{'CurrentUser'});
+				$duration = $date->DurationAsString($duration);
+				$Ticket->RT::Ticket::Unlock();
+                push @results, loc('You have unlocked this ticket (locked for ' . $duration . ')');
             } else {
                 push @results,
                     loc("You can't unlock tickets that you did not lock");
@@ -280,7 +285,7 @@
             }
 
         } elsif ( $ARGS{'Lock'} eq 'break' ) {
-            $Ticket->RT::IR::Ticket::BreakLock();
+            $Ticket->RT::Ticket::BreakLock();
             push @results, loc('You have broken the lock on this ticket');
         }
     }

Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/QueueTabs
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/QueueTabs	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Elements/QueueTabs	Wed Jul 25 12:48:58 2007
@@ -343,7 +343,7 @@
 }
 
 if ($Ticket) {
-if (my $Lock = $Ticket->RT::IR::Ticket::Locked()) {
+if (my $Lock = $Ticket->RT::Ticket::Locked()) {
     if ($Lock->Content->{'User'} == $session{'CurrentUser'}->id) {
     $actions->{'Lock'} = { 
                     path  => "Ticket/Display.html?Lock=remove&id=$id",

Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Update.html	Wed Jul 25 12:48:58 2007
@@ -28,7 +28,8 @@
     current_subtab => "RTIR/Edit.html?id=$id",
     Title => $title &>
 
-<& /RTIR/Elements/ShowLock, Ticket => $Ticket &>
+
+<& /Elements/ShowLock, Ticket => $Ticket, noUnlock => 1 &>
 <form action="Update.html" name="TicketUpdate" 
 	method="post" enctype="multipart/form-data">
 <input type="hidden" name="QuoteTransaction" value="<% $ARGS{'QuoteTransaction'} || '' %>" />
@@ -106,6 +107,7 @@
 
 my $title;
 my $Ticket = LoadTicket($id);
+$Ticket->RT::Ticket::Lock() unless $Ticket->RT::Ticket::Locked();
 $id = $ARGS{'id'} = $Ticket->Id;
 
 my $Type = RT::IR::TicketType( Ticket => $Ticket );
@@ -166,6 +168,7 @@
 $m->comp( '/RTIR/Create.html:ProcessAttachments', %ARGS );
 
 if ( exists $ARGS{SubmitTicket} ) {
+	$ARGS{'Lock'} = 'remove';
     return $m->comp('/RTIR/Display.html', %ARGS);
 }
 

Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR/Ticket.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR/Ticket.pm	(original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR/Ticket.pm	Wed Jul 25 12:48:58 2007
@@ -50,43 +50,5 @@
     return $tickets->Count;
 }
 
-sub Locked {
-    my $ticket =shift;
-    return $ticket->FirstAttribute('RTIR_Lock');
-}
-
-sub Lock {
-    my $ticket = shift;
-
-    if ( $ticket->RT::IR::Ticket::Locked ) {
-        return undef;
-    } else {
-        $ticket->SetAttribute(
-            Name    => 'RTIR_Lock',
-            Content => {
-                User      => $ticket->CurrentUser->id,
-                Timestamp => time()
-
-            }
-        );
-    }
-}
-
 
-sub Unlock {
-    my $ticket = shift;
-
-    my $lock = $ticket->RT::IR::Ticket::Locked();
-     return undef unless $lock;
-     return undef unless $lock->Content->{User} ==  $ticket->CurrentUser->id;
-    $ticket->DeleteAttribute('RTIR_Lock');
-}
-
-
-sub BreakLock {
-    my $ticket = shift;
-    my $lock = $ticket->RT::IR::Ticket::Locked();
-     return undef unless $lock;
-    $ticket->DeleteAttribute('RTIR_Lock');
-}
 1;


More information about the Rt-commit mailing list