[Rt-devel] DefaultOwner

Scott Worley sworley at chkno.net
Sun Jun 3 18:56:20 EDT 2007


A previous round a discussion on this topic:
http://lists.fsck.com/pipermail/rt-devel/2005-June/007291.html

I'm looking for something with a little less duct-tape nature.

Attached is a patch to add a per-Queue DefaultOwner property that can be
manipulated through the UI in the normal way ( Admin/Queues/Modify.html ).

Note: I am not familiar with the RT codebase.  Critique is welcome.

-------------- next part --------------
diff -Naur rt-3.6.3/lib/RT/Queue.pm rt-3.6.3.with-default-owner/lib/RT/Queue.pm
--- rt-3.6.3/lib/RT/Queue.pm	2006-06-19 22:44:04.000000000 +0000
+++ rt-3.6.3.with-default-owner/lib/RT/Queue.pm	2007-06-03 19:23:37.000000000 +0000
@@ -94,6 +94,7 @@
   int(11) 'InitialPriority'.
   int(11) 'FinalPriority'.
   int(11) 'DefaultDueIn'.
+  int(11) 'DefaultOwner'.
   smallint(6) 'Disabled'.
 
 =cut
@@ -111,6 +112,7 @@
                 InitialPriority => '0',
                 FinalPriority => '0',
                 DefaultDueIn => '0',
+                DefaultOwner => $RT::Nobody->Id,
                 Disabled => '0',
 
 		  @_);
@@ -122,6 +124,7 @@
                          InitialPriority => $args{'InitialPriority'},
                          FinalPriority => $args{'FinalPriority'},
                          DefaultDueIn => $args{'DefaultDueIn'},
+                         DefaultOwner => $args{'DefaultOwner'},
                          Disabled => $args{'Disabled'},
 );
 
@@ -264,6 +267,24 @@
 =cut
 
 
+=head2 DefaultOwner
+
+Returns the current value of DefaultOwner. 
+(In the database, DefaultOwner is stored as int(11).)
+
+
+
+=head2 SetDefaultOwner VALUE
+
+
+Set DefaultOwner to VALUE. 
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, DefaultOwner will be stored as a int(11).)
+
+
+=cut
+
+
 =head2 Creator
 
 Returns the current value of Creator. 
@@ -338,6 +359,8 @@
 		{read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         DefaultDueIn => 
 		{read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
+        DefaultOwner => 
+		{read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Creator => 
 		{read => 1, auto => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Created => 
diff -Naur rt-3.6.3/lib/RT/Queue_Overlay.pm rt-3.6.3.with-default-owner/lib/RT/Queue_Overlay.pm
--- rt-3.6.3/lib/RT/Queue_Overlay.pm	2006-09-26 15:06:31.000000000 +0000
+++ rt-3.6.3.with-default-owner/lib/RT/Queue_Overlay.pm	2007-06-03 19:23:37.000000000 +0000
@@ -327,6 +327,7 @@
   InitialPriority
   FinalPriority
   DefaultDueIn
+  DefaultOwner
  
 If you pass the ACL check, it creates the queue and returns its queue id.
 
@@ -353,6 +354,7 @@
         InitialPriority   => "0",
         FinalPriority     => "0",
         DefaultDueIn      => "0",
+        DefaultOwner      => $RT::Nobody->Id,
         @_
     );
 
diff -Naur rt-3.6.3/lib/RT/Ticket_Overlay.pm rt-3.6.3.with-default-owner/lib/RT/Ticket_Overlay.pm
--- rt-3.6.3/lib/RT/Ticket_Overlay.pm	2006-12-01 19:00:23.000000000 +0000
+++ rt-3.6.3.with-default-owner/lib/RT/Ticket_Overlay.pm	2007-06-03 19:39:57.000000000 +0000
@@ -507,6 +507,10 @@
           )
           unless ( $Owner->Id );
     }
+    else {
+        $Owner = RT::User->new( $self->CurrentUser );
+        $Owner->Load( $QueueObj->DefaultOwner );
+    }
 
     #If we have a proposed owner and they don't have the right
     #to own a ticket, scream about it and make them not the owner
diff -Naur rt-3.6.3/html/Admin/Queues/Modify.html rt-3.6.3.with-default-owner/html/Admin/Queues/Modify.html
--- rt-3.6.3/html/Admin/Queues/Modify.html	2006-06-19 22:44:04.000000000 +0000
+++ rt-3.6.3.with-default-owner/html/Admin/Queues/Modify.html	2007-06-03 19:26:29.000000000 +0000
@@ -97,6 +97,11 @@
 </td><td>
 <input name="DefaultDueIn" value="<% ($Create) ? "" : $QueueObj->DefaultDueIn%>" /> <&|/l&>days</&>.
 </td>
+<td align="right">
+<&|/l&>Default owner</&>:
+</td><td>
+<& /Elements/SelectOwner, Name => "DefaultOwner", QueueObj => $QueueObj, Default => ($Create) ? $RT::Nobody->Id : $QueueObj->DefaultOwner, DefaultValue => 0 &>
+</td>
 </tr>
 <tr>
 <td>
@@ -144,7 +149,7 @@
 if ($QueueObj->Id()) {
     delete $session{'create_in_queues'};
 my @attribs= qw(Description CorrespondAddress CommentAddress Name 
-                InitialPriority FinalPriority DefaultDueIn);
+                InitialPriority FinalPriority DefaultDueIn DefaultOwner);
 
   @results = UpdateRecordObject( AttributesRef => \@attribs, 
 				    Object => $QueueObj, 
@@ -186,6 +191,7 @@
 $InitialPriority => undef
 $FinalPriority => undef
 $DefaultDueIn => undef
+$DefaultOwner => undef
 $SetEnabled => undef
 $Enabled => undef
 </%ARGS>
diff -Naur rt-3.6.3/html/REST/1.0/Forms/queue/default rt-3.6.3.with-default-owner/html/REST/1.0/Forms/queue/default
--- rt-3.6.3/html/REST/1.0/Forms/queue/default	2006-06-19 22:44:04.000000000 +0000
+++ rt-3.6.3.with-default-owner/html/REST/1.0/Forms/queue/default	2007-06-03 19:26:29.000000000 +0000
@@ -56,7 +56,7 @@
 my %data = %$changes;
 my $queue = new RT::Queue $session{CurrentUser};
 my @fields = qw(Name Description CorrespondAddress CommentAddress
-                InitialPriority FinalPriority DefaultDueIn);
+                InitialPriority FinalPriority DefaultDueIn DefaultOwner);
 my %fields = map { lc $_ => $_ } @fields;
 
 if ($id ne 'new') {
@@ -79,6 +79,7 @@
                 InitialPriority => "",
                 FinalPriority => "",
                 DefaultDueIn => "",
+                DefaultOwner => "",
             },
             0
         ];
diff -Naur rt-3.6.3/html/Ticket/Create.html rt-3.6.3.with-default-owner/html/Ticket/Create.html
--- rt-3.6.3/html/Ticket/Create.html	2006-09-26 15:06:31.000000000 +0000
+++ rt-3.6.3.with-default-owner/html/Ticket/Create.html	2007-06-03 19:26:29.000000000 +0000
@@ -72,7 +72,7 @@
 <&|/l&>Owner</&>:
 </td>
 <td class="value">
-<& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj, Default => $ARGS{Owner}||$RT::Nobody->Id, DefaultValue => 0 &>
+<& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj, Default => $ARGS{Owner}||$QueueObj->DefaultOwner||$RT::Nobody->Id, DefaultValue => 0 &>
 </td>
 </tr>
 <tr>
diff -Naur rt-3.6.3/etc/schema.Informix rt-3.6.3.with-default-owner/etc/schema.Informix
--- rt-3.6.3/etc/schema.Informix	2004-04-02 13:43:44.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/schema.Informix	2007-06-03 19:23:37.000000000 +0000
@@ -32,6 +32,7 @@
 	InitialPriority 	INTEGER DEFAULT 0 NOT NULL,
 	FinalPriority 		INTEGER DEFAULT 0 NOT NULL,
 	DefaultDueIn 		INTEGER DEFAULT 0 NOT NULL,
+	DefaultOwner 		INTEGER DEFAULT 0 NOT NULL,
 	Creator 		INTEGER DEFAULT 0 NOT NULL,
 	Created 		DATETIME YEAR TO SECOND,
 	LastUpdatedBy 		INTEGER DEFAULT 0 NOT NULL,
diff -Naur rt-3.6.3/etc/schema.Oracle rt-3.6.3.with-default-owner/etc/schema.Oracle
--- rt-3.6.3/etc/schema.Oracle	2006-12-15 04:39:19.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/schema.Oracle	2007-06-03 19:23:37.000000000 +0000
@@ -30,6 +30,7 @@
 	InitialPriority 	NUMBER(11,0) DEFAULT 0 NOT NULL,
 	FinalPriority 		NUMBER(11,0) DEFAULT 0 NOT NULL,
 	DefaultDueIn 		NUMBER(11,0) DEFAULT 0 NOT NULL,
+	DefaultOwner 		NUMBER(11,0) DEFAULT 0 NOT NULL,
 	Creator 		NUMBER(11,0) DEFAULT 0 NOT NULL,
 	Created 		DATE,
 	LastUpdatedBy 		NUMBER(11,0) DEFAULT 0 NOT NULL,
diff -Naur rt-3.6.3/etc/schema.Pg rt-3.6.3.with-default-owner/etc/schema.Pg
--- rt-3.6.3/etc/schema.Pg	2004-11-11 08:46:17.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/schema.Pg	2007-06-03 19:23:37.000000000 +0000
@@ -53,6 +53,7 @@
   InitialPriority integer NOT NULL DEFAULT 0  ,
   FinalPriority integer NOT NULL DEFAULT 0  ,
   DefaultDueIn integer NOT NULL DEFAULT 0  ,
+  DefaultOwner integer NOT NULL DEFAULT 0  ,
   Creator integer NOT NULL DEFAULT 0  ,
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
diff -Naur rt-3.6.3/etc/schema.SQLite rt-3.6.3.with-default-owner/etc/schema.SQLite
--- rt-3.6.3/etc/schema.SQLite	2004-11-11 08:46:17.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/schema.SQLite	2007-06-03 19:23:37.000000000 +0000
@@ -31,6 +31,7 @@
   InitialPriority integer NULL  ,
   FinalPriority integer NULL  ,
   DefaultDueIn integer NULL  ,
+  DefaultOwner integer NULL  ,
   Creator integer NULL  ,
   Created DATETIME NULL  ,
   LastUpdatedBy integer NULL  ,
diff -Naur rt-3.6.3/etc/schema.Sybase rt-3.6.3.with-default-owner/etc/schema.Sybase
--- rt-3.6.3/etc/schema.Sybase	2004-11-11 08:03:05.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/schema.Sybase	2007-06-03 19:23:37.000000000 +0000
@@ -31,6 +31,7 @@
   InitialPriority integer NOT NULL   ,
   FinalPriority integer NOT NULL   ,
   DefaultDueIn integer NOT NULL   ,
+  DefaultOwner integer NOT NULL   ,
   Creator integer NOT NULL   ,
   Created DATETIME NULL  ,
   LastUpdatedBy integer NOT NULL   ,
diff -Naur rt-3.6.3/etc/schema.mysql rt-3.6.3.with-default-owner/etc/schema.mysql
--- rt-3.6.3/etc/schema.mysql	2006-01-19 15:11:21.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/schema.mysql	2007-06-03 19:23:37.000000000 +0000
@@ -30,6 +30,7 @@
   InitialPriority integer NOT NULL DEFAULT 0  ,
   FinalPriority integer NOT NULL DEFAULT 0  ,
   DefaultDueIn integer NOT NULL DEFAULT 0  ,
+  DefaultOwner integer NOT NULL DEFAULT 0  ,
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
diff -Naur rt-3.6.3/etc/upgrade/3.6.4/schema.Oracle rt-3.6.3.with-default-owner/etc/upgrade/3.6.4/schema.Oracle
--- rt-3.6.3/etc/upgrade/3.6.4/schema.Oracle	1970-01-01 00:00:00.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/upgrade/3.6.4/schema.Oracle	2007-06-03 19:46:54.000000000 +0000
@@ -0,0 +1 @@
+ALTER TABLE Queues ADD DefaultOwner NUMBER(11,0) NULL;
diff -Naur rt-3.6.3/etc/upgrade/3.6.4/schema.Pg rt-3.6.3.with-default-owner/etc/upgrade/3.6.4/schema.Pg
--- rt-3.6.3/etc/upgrade/3.6.4/schema.Pg	1970-01-01 00:00:00.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/upgrade/3.6.4/schema.Pg	2007-06-03 19:46:54.000000000 +0000
@@ -0,0 +1 @@
+alter table Queues add column DefaultOwner integer NULL;
diff -Naur rt-3.6.3/etc/upgrade/3.6.4/schema.mysql rt-3.6.3.with-default-owner/etc/upgrade/3.6.4/schema.mysql
--- rt-3.6.3/etc/upgrade/3.6.4/schema.mysql	1970-01-01 00:00:00.000000000 +0000
+++ rt-3.6.3.with-default-owner/etc/upgrade/3.6.4/schema.mysql	2007-06-03 19:46:54.000000000 +0000
@@ -0,0 +1 @@
+alter table Queues add column DefaultOwner integer NULL;



More information about the Rt-devel mailing list