[Rt-commit] [svn] r1206 - in rt/branches/rt-3.1: . bin etc etc/upgrade/3.1.0 etc/upgrade/3.3.0 html html/Admin html/Admin/CustomFields html/Admin/Elements html/Admin/Global html/Admin/Groups html/Admin/Queues html/Admin/Users html/Download html/Elements html/NoAuth html/Search html/Search/Elements html/SelfService html/Ticket html/Ticket/Elements html/User lib lib/RT lib/RT/Action lib/RT/I18N lib/RT/Interface sbin spec

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Mon Jul 12 14:01:13 EDT 2004


Author: jesse
Date: Mon Jul 12 14:00:53 2004
New Revision: 1206

Added:
   rt/branches/rt-3.1/html/Admin/Global/CustomField.html   (props changed)
      - copied unchanged from r1200, rt/branches/rt-3.1/html/Admin/Global/CustomField.html
   rt/branches/rt-3.1/html/Admin/Global/CustomFields.html   (props changed)
      - copied unchanged from r1200, rt/branches/rt-3.1/html/Admin/Global/CustomFields.html
Removed:
   rt/branches/rt-3.1/etc/upgrade/3.3.0/
   rt/branches/rt-3.1/html/Admin/CustomFields/
   rt/branches/rt-3.1/html/Admin/Elements/CustomFieldTabs
   rt/branches/rt-3.1/html/Admin/Elements/ObjectCustomFields
   rt/branches/rt-3.1/html/Admin/Elements/PickCustomFields
   rt/branches/rt-3.1/html/Admin/Elements/PickObjects
   rt/branches/rt-3.1/html/Admin/Elements/SelectCustomFieldLookupType
   rt/branches/rt-3.1/html/Admin/Groups/CustomFields.html
   rt/branches/rt-3.1/html/Admin/Groups/History.html
   rt/branches/rt-3.1/html/Admin/Users/CustomFields.html
   rt/branches/rt-3.1/html/Admin/Users/History.html
   rt/branches/rt-3.1/html/Admin/Users/Memberships.html
   rt/branches/rt-3.1/html/Download/
   rt/branches/rt-3.1/html/Elements/EditCustomField
   rt/branches/rt-3.1/html/Elements/EditCustomFieldBinary
   rt/branches/rt-3.1/html/Elements/EditCustomFieldFreeform
   rt/branches/rt-3.1/html/Elements/EditCustomFieldImage
   rt/branches/rt-3.1/html/Elements/EditCustomFieldSelect
   rt/branches/rt-3.1/html/Elements/EditCustomFieldText
   rt/branches/rt-3.1/html/Elements/ShowCustomFieldImage
   rt/branches/rt-3.1/html/Elements/ShowCustomFields
   rt/branches/rt-3.1/html/Elements/ShowMemberships
   rt/branches/rt-3.1/html/Search/Elements/SelectGroup
   rt/branches/rt-3.1/lib/RT/ObjectCustomField.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomFieldValue.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomFieldValue_Overlay.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomFieldValues.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomFieldValues_Overlay.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomField_Overlay.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomFields.pm
   rt/branches/rt-3.1/lib/RT/ObjectCustomFields_Overlay.pm
   rt/branches/rt-3.1/sbin/rt-dump-database.in
   rt/branches/rt-3.1/spec/
Modified:
   rt/branches/rt-3.1/   (props changed)
   rt/branches/rt-3.1/README
   rt/branches/rt-3.1/bin/standalone_httpd.in
   rt/branches/rt-3.1/bin/webmux.pl.in
   rt/branches/rt-3.1/configure.ac
   rt/branches/rt-3.1/etc/RT_Config.pm.in
   rt/branches/rt-3.1/etc/acl.Pg
   rt/branches/rt-3.1/etc/acl.mysql
   rt/branches/rt-3.1/etc/schema.Informix
   rt/branches/rt-3.1/etc/schema.Oracle
   rt/branches/rt-3.1/etc/schema.Pg
   rt/branches/rt-3.1/etc/schema.SQLite
   rt/branches/rt-3.1/etc/schema.Sybase
   rt/branches/rt-3.1/etc/schema.mysql
   rt/branches/rt-3.1/etc/upgrade/3.1.0/acl.Oracle   (props changed)
   rt/branches/rt-3.1/etc/upgrade/3.1.0/acl.Pg   (props changed)
   rt/branches/rt-3.1/etc/upgrade/3.1.0/acl.SQLite   (props changed)
   rt/branches/rt-3.1/etc/upgrade/3.1.0/acl.mysql   (props changed)
   rt/branches/rt-3.1/etc/upgrade/3.1.0/schema.Pg   (props changed)
   rt/branches/rt-3.1/etc/upgrade/3.1.0/schema.mysql   (props changed)
   rt/branches/rt-3.1/html/Admin/Elements/AddCustomFieldValue
   rt/branches/rt-3.1/html/Admin/Elements/EditCustomFieldValues
   rt/branches/rt-3.1/html/Admin/Elements/EditCustomFields
   rt/branches/rt-3.1/html/Admin/Elements/EditScrip
   rt/branches/rt-3.1/html/Admin/Elements/GroupTabs
   rt/branches/rt-3.1/html/Admin/Elements/Header
   rt/branches/rt-3.1/html/Admin/Elements/QueueTabs
   rt/branches/rt-3.1/html/Admin/Elements/SelectCustomFieldType
   rt/branches/rt-3.1/html/Admin/Elements/SelectRights
   rt/branches/rt-3.1/html/Admin/Elements/SystemTabs
   rt/branches/rt-3.1/html/Admin/Elements/Tabs
   rt/branches/rt-3.1/html/Admin/Elements/UserTabs
   rt/branches/rt-3.1/html/Admin/Global/Templates.html
   rt/branches/rt-3.1/html/Admin/Global/index.html
   rt/branches/rt-3.1/html/Admin/Groups/Modify.html
   rt/branches/rt-3.1/html/Admin/Groups/index.html
   rt/branches/rt-3.1/html/Admin/Queues/CustomField.html
   rt/branches/rt-3.1/html/Admin/Queues/CustomFields.html
   rt/branches/rt-3.1/html/Admin/Queues/Modify.html
   rt/branches/rt-3.1/html/Admin/Queues/People.html
   rt/branches/rt-3.1/html/Admin/Users/Modify.html
   rt/branches/rt-3.1/html/Admin/Users/index.html
   rt/branches/rt-3.1/html/Admin/index.html
   rt/branches/rt-3.1/html/Elements/Header
   rt/branches/rt-3.1/html/Elements/SelectGroups
   rt/branches/rt-3.1/html/Elements/SelectUsers
   rt/branches/rt-3.1/html/Elements/SetupSessionCookie
   rt/branches/rt-3.1/html/Elements/Submit
   rt/branches/rt-3.1/html/NoAuth/webrt.css
   rt/branches/rt-3.1/html/Search/Bulk.html
   rt/branches/rt-3.1/html/Search/Elements/PickBasics
   rt/branches/rt-3.1/html/Search/Elements/PickCFs
   rt/branches/rt-3.1/html/Search/Elements/SelectPersonType
   rt/branches/rt-3.1/html/SelfService/Closed.html
   rt/branches/rt-3.1/html/SelfService/Display.html
   rt/branches/rt-3.1/html/Ticket/Create.html
   rt/branches/rt-3.1/html/Ticket/Elements/EditCustomFields
   rt/branches/rt-3.1/html/Ticket/Elements/EditPeople
   rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments   (contents, props changed)
   rt/branches/rt-3.1/html/Ticket/Elements/LoadTextAttachments
   rt/branches/rt-3.1/html/Ticket/Elements/ShowCustomFields
   rt/branches/rt-3.1/html/Ticket/Elements/ShowRequestor
   rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction
   rt/branches/rt-3.1/html/Ticket/Modify.html
   rt/branches/rt-3.1/html/Ticket/ModifyAll.html
   rt/branches/rt-3.1/html/Ticket/Update.html
   rt/branches/rt-3.1/html/User/Prefs.html
   rt/branches/rt-3.1/html/autohandler
   rt/branches/rt-3.1/lib/RT.pm.in
   rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm
   rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Base.pm
   rt/branches/rt-3.1/lib/RT/CurrentUser.pm
   rt/branches/rt-3.1/lib/RT/CustomField.pm
   rt/branches/rt-3.1/lib/RT/CustomField_Overlay.pm
   rt/branches/rt-3.1/lib/RT/CustomFields_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Group_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Groups_Overlay.pm
   rt/branches/rt-3.1/lib/RT/I18N.pm
   rt/branches/rt-3.1/lib/RT/I18N/cs.po
   rt/branches/rt-3.1/lib/RT/I18N/de.po
   rt/branches/rt-3.1/lib/RT/I18N/en.po
   rt/branches/rt-3.1/lib/RT/I18N/es.po
   rt/branches/rt-3.1/lib/RT/I18N/fr.po
   rt/branches/rt-3.1/lib/RT/I18N/he.po
   rt/branches/rt-3.1/lib/RT/I18N/it.po
   rt/branches/rt-3.1/lib/RT/I18N/ja.po
   rt/branches/rt-3.1/lib/RT/I18N/nl.po
   rt/branches/rt-3.1/lib/RT/I18N/pt_br.po
   rt/branches/rt-3.1/lib/RT/I18N/ru.po
   rt/branches/rt-3.1/lib/RT/Interface/Web.pm
   rt/branches/rt-3.1/lib/RT/Link_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Queue_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Record.pm
   rt/branches/rt-3.1/lib/RT/SearchBuilder.pm
   rt/branches/rt-3.1/lib/RT/StyleGuide.pod
   rt/branches/rt-3.1/lib/RT/System.pm
   rt/branches/rt-3.1/lib/RT/Template_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Tickets_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Tickets_Overlay_SQL.pm
   rt/branches/rt-3.1/lib/RT/Transaction.pm
   rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm
   rt/branches/rt-3.1/lib/RT/Transactions_Overlay.pm
   rt/branches/rt-3.1/lib/RT/User_Overlay.pm
   rt/branches/rt-3.1/releng.cnf
   rt/branches/rt-3.1/sbin/extract-message-catalog
Log:
Reverting change 1201, which was improperly merged from a dev branch

Modified: rt/branches/rt-3.1/README
==============================================================================
--- rt/branches/rt-3.1/README	(original)
+++ rt/branches/rt-3.1/README	Mon Jul 12 14:00:53 2004
@@ -197,8 +197,12 @@
     DocumentRoot /opt/rt3/share/html
     AddDefaultCharset UTF-8
 
-    # This line applies to Apache2+mod_perl2 only:
-    RedirectMatch permanent (.*)/$ $1/index.html
+    # these four lines apply to Apache2+mod_perl2 only: {{{
+    PerlSetVar MasonArgsMethod CGI
+    PerlModule Apache2 Apache::compat
+    RewriteEngine On
+    RewriteRule ^(.*)/$ $1/index.html
+    # }}}
 
     PerlModule Apache::DBI
     PerlRequire /opt/rt3/bin/webmux.pl

Modified: rt/branches/rt-3.1/bin/standalone_httpd.in
==============================================================================
--- rt/branches/rt-3.1/bin/standalone_httpd.in	(original)
+++ rt/branches/rt-3.1/bin/standalone_httpd.in	Mon Jul 12 14:00:53 2004
@@ -8,9 +8,6 @@
 
 use Socket;
 
-$SIG{CHLD} = "IGNORE"; # reap child processes
-
-
 RT::Init();
 
 my $port = shift || '8080';
@@ -35,8 +32,6 @@
 
         for ( ; accept( Remote, HTTPDaemon ); close Remote ) {
 
-	    fork and next;
-
             *STDIN  = *Remote;
             *STDOUT = *Remote;
 
@@ -90,7 +85,7 @@
                 $RT::Handle->ForceRollback;
                 $RT::Logger->crit( "Transaction not committed. Usually indicates a software fault. Data loss may have occurred");
             }
-	    exit(); # our forked process
+
         }
 
     }

Modified: rt/branches/rt-3.1/bin/webmux.pl.in
==============================================================================
--- rt/branches/rt-3.1/bin/webmux.pl.in	(original)
+++ rt/branches/rt-3.1/bin/webmux.pl.in	Mon Jul 12 14:00:53 2004
@@ -1,26 +1,26 @@
 #!@PERL@
 # BEGIN LICENSE BLOCK
-# 
+#
 # Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
-# 
+#
 # (Except where explictly superceded by other copyright notices)
-# 
+#
 # This work is made available to you under the terms of Version 2 of
 # the GNU General Public License. A copy of that license should have
 # been provided with this software, but in any event can be snarfed
 # from www.gnu.org.
-# 
+#
 # This work is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 # General Public License for more details.
-# 
+#
 # Unless otherwise specified, all modifications, corrections or
 # extensions to this work which alter its source code become the
 # property of Best Practical Solutions, LLC when submitted for
 # inclusion in the work.
-# 
-# 
+#
+#
 # END LICENSE BLOCK
 
 use strict;
@@ -32,9 +32,10 @@
     $ENV{'ENV'}    = '' if defined $ENV{'ENV'};
     $ENV{'IFS'}    = '' if defined $ENV{'IFS'};
 
-    eval { require Apache2; require APR::Table; require MasonX::Apache2Handler; 1 } or
-    eval { require Apache2; require Apache::compat; 1 } or die $@
-        if $ENV{'MOD_PERL'} and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:2|1\.9)};
+    eval { require Apache2; require Apache::compat }
+      if $ENV{'MOD_PERL'}
+      and $ENV{'MOD_PERL'} =~ m{mod_perl/(?:2|1\.9)};
+
 }
 
 use lib ( "@LOCAL_LIB_PATH@", "@RT_LIB_PATH@" );
@@ -46,29 +47,23 @@
                                    #set private_tempfiles
 
 BEGIN {
-    if ($MasonX::Apache2Handler::VERSION) {
-        $RT::MasonHandlerClass = 'MasonX::Apache2Handler';
+    if ( $mod_perl::VERSION && ( $mod_perl::VERSION >= 1.9908 ) ) {
+        require Apache::RequestUtil;
+        no warnings 'redefine';
+        my $sub = *Apache::request{CODE};
+        *Apache::request = sub {
+            my $r;
+            eval { $r = $sub->('Apache'); };
+
+            # warn $@ if $@;
+            return $r;
+        };
     }
-    elsif ($mod_perl::VERSION && ($mod_perl::VERSION >= 1.9908)) {
-	require Apache::RequestUtil;
-	no warnings 'redefine';
-	my $sub = *Apache::request{CODE};
-	*Apache::request = sub {
-	    my $r;
-	    eval { $r = $sub->('Apache'); };
-	    # warn $@ if $@;
-	    return $r;
-	};
-	require HTML::Mason::ApacheHandler;
-        $RT::MasonHandlerClass = 'HTML::Mason::ApacheHandler';
-    }
-    elsif ($CGI::MOD_PERL) {
-	require HTML::Mason::ApacheHandler;
-        $RT::MasonHandlerClass = 'HTML::Mason::ApacheHandler';
+    if ($CGI::MOD_PERL) {
+        require HTML::Mason::ApacheHandler;
     }
     else {
-	require HTML::Mason::CGIHandler;
-        $RT::MasonHandlerClass = 'HTML::Mason::CGIHandler';
+        require HTML::Mason::CGIHandler;
     }
 }
 
@@ -86,6 +81,21 @@
     package HTML::Mason::Commands;
     use vars qw(%session);
 
+    use RT::Tickets;
+    use RT::Transactions;
+    use RT::Users;
+    use RT::CurrentUser;
+    use RT::Templates;
+    use RT::Queues;
+    use RT::ScripActions;
+    use RT::ScripConditions;
+    use RT::Scrips;
+    use RT::Groups;
+    use RT::GroupMembers;
+    use RT::CustomFields;
+    use RT::CustomFieldValues;
+    use RT::TicketCustomFieldValues;
+
     use RT::Interface::Web;
     use MIME::Entity;
     use Text::Wrapper;

Modified: rt/branches/rt-3.1/configure.ac
==============================================================================
--- rt/branches/rt-3.1/configure.ac	(original)
+++ rt/branches/rt-3.1/configure.ac	Mon Jul 12 14:00:53 2004
@@ -7,7 +7,7 @@
 
 dnl Setup autoconf
 AC_PREREQ(2.53)
-AC_INIT(RT, [3.3.HEAD], [rt-3.1-bugs at fsck.com])
+AC_INIT(RT, [3.2.HEAD], [rt-bugs at fsck.com])
 AC_CONFIG_SRCDIR([lib/RT.pm.in])
 
 dnl Extract RT version number components

Modified: rt/branches/rt-3.1/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/rt-3.1/etc/RT_Config.pm.in	(original)
+++ rt/branches/rt-3.1/etc/RT_Config.pm.in	Mon Jul 12 14:00:53 2004
@@ -362,9 +362,8 @@
 
 # @MasonParameters is the list of parameters for the constructor of
 # HTML::Mason's Apache or CGI Handler.  This is normally only useful
-# for debugging, eg. profiling individual components with:
-#     use MasonX::Profiler; # available on CPAN
-#     @MasonParameters = (preamble => 'my $p = MasonX::Profiler->new($m, $r);');
+# for debugging, eg. profiling individual components with
+#     (preamble => 'my $p = MasonX::Profiler->new($m, $r);');
 
 @MasonParameters = () unless (@MasonParameters);
 

Modified: rt/branches/rt-3.1/etc/acl.Pg
==============================================================================
--- rt/branches/rt-3.1/etc/acl.Pg	(original)
+++ rt/branches/rt-3.1/etc/acl.Pg	Mon Jul 12 14:00:53 2004
@@ -10,39 +10,37 @@
       Attributes
       attributes_id_seq
       queues_id_seq
- Queues 
+      Queues
       links_id_seq
- Links 
+      Links
       principals_id_seq
- Principals 
+      Principals
       groups_id_seq
- Groups 
+      Groups
       scripconditions_id_seq
- ScripConditions 
+      ScripConditions
       transactions_id_seq
- Transactions 
+      Transactions
       scrips_id_seq
- Scrips 
+      Scrips
       acl_id_seq
- ACL 
+      ACL
       groupmembers_id_seq
- GroupMembers 
+      GroupMembers
       cachedgroupmembers_id_seq
- CachedGroupMembers 
+      CachedGroupMembers
       users_id_seq
- Users 
+      Users
       tickets_id_seq
- Tickets 
+      Tickets
       scripactions_id_seq
- ScripActions 
+      ScripActions
       templates_id_seq
- Templates 
- objectcustomfieldvalues_id_s
- ObjectCustomFieldValues 
+      Templates
+      ticketcustomfieldvalues_id_s
+      TicketCustomFieldValues
       customfields_id_seq
- CustomFields 
- objectcustomfields_id_s
- ObjectCustomFields 
+      CustomFields
       customfieldvalues_id_seq
       CustomFieldValues
       sessions

Modified: rt/branches/rt-3.1/etc/acl.mysql
==============================================================================
--- rt/branches/rt-3.1/etc/acl.mysql	(original)
+++ rt/branches/rt-3.1/etc/acl.mysql	Mon Jul 12 14:00:53 2004
@@ -1,5 +1,4 @@
 sub acl {
-return () if !$RT::DatabaseUser or $RT::DatabaseUser eq 'root';
 return  (
 "USE mysql;",
 "DELETE FROM user WHERE user = '${RT::DatabaseUser}';",

Modified: rt/branches/rt-3.1/etc/schema.Informix
==============================================================================
--- rt/branches/rt-3.1/etc/schema.Informix	(original)
+++ rt/branches/rt-3.1/etc/schema.Informix	Mon Jul 12 14:00:53 2004
@@ -103,22 +103,20 @@
 
 CREATE TABLE Transactions (
   	id 			SERIAL,
-  	ObjectType 		VARCHAR(255),
-  	ObjectId 		INTEGER DEFAULT 0 NOT NULL,
+  	EffectiveTicket 	INTEGER DEFAULT 0 NOT NULL,
+  	Ticket 			INTEGER DEFAULT 0 NOT NULL,
   	TimeTaken 		INTEGER DEFAULT 0 NOT NULL,
   	Type 			VARCHAR(20),
   	Field 			VARCHAR(40),
   	OldValue 		VARCHAR(255),
   	NewValue 		VARCHAR(255),
-  	ReferenceType 		VARCHAR(255),
-	OldReference		INTEGER DEFAULT 0,
-	NewReference		INTEGER DEFAULT 0,
   	Data 			VARCHAR(255),
   	Creator 		INTEGER DEFAULT 0 NOT NULL,
   	Created 		DATETIME YEAR TO SECOND,
         PRIMARY KEY (id)
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (Ticket);
+CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
 
 
 CREATE TABLE Scrips (
@@ -307,9 +305,7 @@
 	id		SERIAL,
 	Name		VARCHAR(200),
 	Type		VARCHAR(200),
-	MaxValues	INTEGER DEFAULT 0 NOT NULL,
-	Pattern		VARCHAR(255),
-	LookupType	VARCHAR(255),
+	Queue		INTEGER DEFAULT 0 NOT NULL,
 	Description	VARCHAR(255),
 	SortOrder	INTEGER DEFAULT 0 NOT NULL,
 	Creator		INTEGER DEFAULT 0 NOT NULL,
@@ -319,6 +315,7 @@
 	Disabled	SMALLINT DEFAULT 0 NOT NULL,
         PRIMARY KEY (id)
 );
+CREATE INDEX CustomFields1 ON CustomFields (Disabled, Queue);
 
 
 CREATE TABLE CustomFieldValues (

Modified: rt/branches/rt-3.1/etc/schema.Oracle
==============================================================================
--- rt/branches/rt-3.1/etc/schema.Oracle	(original)
+++ rt/branches/rt-3.1/etc/schema.Oracle	Mon Jul 12 14:00:53 2004
@@ -105,21 +105,19 @@
 CREATE TABLE Transactions (
   	id 			NUMBER(11,0) 
 		CONSTRAINT Transactions_Key PRIMARY KEY,
-  	ObjectType 		VARCHAR2(255),
-  	ObjectId		NUMBER(11,0) DEFAULT 0 NOT NULL,
+  	EffectiveTicket 	NUMBER(11,0) DEFAULT 0 NOT NULL,
+  	Ticket 			NUMBER(11,0) DEFAULT 0 NOT NULL,
   	TimeTaken 		NUMBER(11,0) DEFAULT 0 NOT NULL,
   	Type 			VARCHAR2(20),
   	Field 			VARCHAR2(40),
   	OldValue 		VARCHAR2(255),
   	NewValue 		VARCHAR2(255),
-  	ReferenceType 		VARCHAR2(255),
-  	OldReference 		NUMBER(11,0),
-  	NewReference 		NUMBER(11,0),
   	Data 			VARCHAR2(255),
   	Creator 		NUMBER(11,0) DEFAULT 0 NOT NULL,
   	Created 		DATE
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (Ticket);
+CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
 
 
 CREATE SEQUENCE SCRIPS_seq;
@@ -319,9 +317,7 @@
 		CONSTRAINT CustomFields_Key PRIMARY KEY,
 	Name		VARCHAR2(200),
 	Type		VARCHAR2(200),
-	MaxValues	NUMBER(11,0) DEFAULT 0 NOT NULL,
-	Pattern		VARCHAR2(255),
-	LookupType	VARCHAR2(255),
+	Queue		NUMBER(11,0) DEFAULT 0 NOT NULL,
 	Description	VARCHAR2(255),
 	SortOrder	NUMBER(11,0) DEFAULT 0 NOT NULL,
 	Creator		NUMBER(11,0) DEFAULT 0 NOT NULL,
@@ -330,6 +326,7 @@
 	LastUpdated	DATE,
 	Disabled	NUMBER(11,0) DEFAULT 0 NOT NULL
 );
+CREATE INDEX CustomFields1 ON CustomFields (Disabled, Queue);
 
 
 CREATE SEQUENCE CUSTOMFIELDVALUES_seq;

Modified: rt/branches/rt-3.1/etc/schema.Pg
==============================================================================
--- rt/branches/rt-3.1/etc/schema.Pg	(original)
+++ rt/branches/rt-3.1/etc/schema.Pg	Mon Jul 12 14:00:53 2004
@@ -57,7 +57,7 @@
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated TIMESTAMP NULL  ,
-  Disabled integer NOT NULL DEFAULT 0 ,
+  Disabled int2 NOT NULL DEFAULT 0 ,
   PRIMARY KEY (id)
 
 );
@@ -108,7 +108,7 @@
         id INTEGER DEFAULT nextval('principals_id_seq') not null,
         PrincipalType VARCHAR(16) not null,
         ObjectId integer, 
-        Disabled integer NOT NULL DEFAULT 0 ,
+        Disabled int2 NOT NULL DEFAULT 0 ,
         PRIMARY KEY (id)
 
 );
@@ -183,16 +183,13 @@
 
 CREATE TABLE Transactions (
   id INTEGER DEFAULT nextval('transactions_id_seq'),
-  ObjectType varchar(255) NOT NULL  ,
-  ObjectId integer NOT NULL DEFAULT 0  ,
+  EffectiveTicket integer NOT NULL DEFAULT 0  ,
+  Ticket integer NOT NULL DEFAULT 0  ,
   TimeTaken integer NOT NULL DEFAULT 0  ,
   Type varchar(20) NULL  ,
   Field varchar(40) NULL  ,
   OldValue varchar(255) NULL  ,
   NewValue varchar(255) NULL  ,
-  ReferenceType varchar(255) NULL,
-  OldReference integer NULL  ,
-  NewReference integer NULL  ,
   Data varchar(255) NULL  ,
 
   Creator integer NOT NULL DEFAULT 0  ,
@@ -200,7 +197,8 @@
   PRIMARY KEY (id)
 
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (Ticket);
+CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
 
 -- }}}
 
@@ -301,7 +299,7 @@
         MemberId int, 
         Via int, 
         ImmediateParentId int, 
-        Disabled integer NOT NULL DEFAULT 0 , 
+        Disabled int2 NOT NULL DEFAULT 0 , 
         PRIMARY KEY (id)
 
 );
@@ -408,7 +406,7 @@
   LastUpdated TIMESTAMP NULL  ,
   Creator integer NOT NULL DEFAULT 0  ,
   Created TIMESTAMP NULL  ,
-  Disabled integer NOT NULL DEFAULT 0 ,
+  Disabled int2 NOT NULL DEFAULT 0 ,
   PRIMARY KEY (id)
 
 );
@@ -476,7 +474,7 @@
 
 -- }}}
 
--- {{{ ObjectCustomFieldValues 
+-- {{{ TicketCustomFieldValues 
 
 
 
@@ -484,18 +482,13 @@
 -- Sequences for table TICKETCUSTOMFIELDVALUES
 --
 
-CREATE SEQUENCE objectcustomfieldvalues_id_s;
+CREATE SEQUENCE ticketcustomfieldvalues_id_s;
 
-CREATE TABLE ObjectCustomFieldValues (
-  id INTEGER DEFAULT nextval('objectcustomfieldvalues_id_s'),
+CREATE TABLE TicketCustomFieldValues (
+  id INTEGER DEFAULT nextval('ticketcustomfieldvalues_id_s'),
+  Ticket int NOT NULL  ,
   CustomField int NOT NULL  ,
-  ObjectType varchar(255) NULL  ,
-  ObjectId int NOT NULL  ,
-  Current int DEFAULT 1,
   Content varchar(255) NULL  ,
-  LargeContent text NULL,
-  ContentType varchar(80) NULL,
-  ContentEncoding varchar(80) NULL  ,
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created TIMESTAMP NULL  ,
@@ -505,8 +498,8 @@
 
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content); 
-CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
+CREATE INDEX TicketCustomFieldValues1 ON TicketCustomFieldValues (CustomField,Ticket,Content); 
+CREATE INDEX TicketCustomFieldValues2 ON TicketCustomFieldValues (CustomField,Ticket); 
 
 -- }}}
 
@@ -524,10 +517,7 @@
   id INTEGER DEFAULT nextval('customfields_id_seq'),
   Name varchar(200) NULL  ,
   Type varchar(200) NULL  ,
-  MaxValues integer NOT NULL DEFAULT 0  ,
-  Repeated integer NOT NULL DEFAULT 0 , 
-  Pattern varchar(255) NULL  ,
-  LookupType varchar(255) NOT NULL  ,
+  Queue integer NOT NULL DEFAULT 0 ,
   Description varchar(255) NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
 
@@ -535,27 +525,7 @@
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated TIMESTAMP NULL  ,
-  Disabled integer NOT NULL DEFAULT 0 ,
-  PRIMARY KEY (id)
-
-);
-
--- }}}
-
--- {{{ ObjectCustomFields 
-
-CREATE SEQUENCE objectcustomfields_id_s;
-
-CREATE TABLE ObjectCustomFields (
-  id INTEGER DEFAULT nextval('objectcustomfields_id_s'),
-  CustomField integer NOT NULL,
-  ObjectId integer NOT NULL,
-  SortOrder integer NOT NULL DEFAULT 0  ,
-
-  Creator integer NOT NULL DEFAULT 0  ,
-  Created TIMESTAMP NULL  ,
-  LastUpdatedBy integer NOT NULL DEFAULT 0  ,
-  LastUpdated TIMESTAMP NULL  ,
+  Disabled int2 NOT NULL DEFAULT 0 ,
   PRIMARY KEY (id)
 
 );

Modified: rt/branches/rt-3.1/etc/schema.SQLite
==============================================================================
--- rt/branches/rt-3.1/etc/schema.SQLite	(original)
+++ rt/branches/rt-3.1/etc/schema.SQLite	Mon Jul 12 14:00:53 2004
@@ -112,23 +112,21 @@
 --- {{{ Transactions
 CREATE TABLE Transactions (
   id INTEGER PRIMARY KEY  ,
-  ObjectType varchar(255) NULL  ,
-  ObjectId integer NULL  ,
+  EffectiveTicket integer NULL  ,
+  Ticket integer NULL  ,
   TimeTaken integer NULL  ,
   Type varchar(20) NULL  ,
   Field varchar(40) NULL  ,
   OldValue varchar(255) NULL  ,
   NewValue varchar(255) NULL  ,
-  ReferenceType varchar(255) NULL  ,
-  OldReference integer NULL  ,
-  NewReference integer NULL  ,
   Data varchar(255) NULL  ,
 
   Creator integer NULL  ,
   Created DATETIME NULL  
   
 ) ;
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (Ticket);
+CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
 
 --- }}}
 
@@ -357,9 +355,7 @@
   id INTEGER PRIMARY KEY  ,
   Name varchar(200) NULL  ,
   Type varchar(200) NULL  ,
-  MaxValues int NULL ,
-  Pattern varchar(255) NULL  ,
-  LookupType varchar(255) NULL  ,
+  Queue int NULL ,
   Description varchar(255) NULL  ,
   SortOrder integer NULL  ,
 

Modified: rt/branches/rt-3.1/etc/schema.Sybase
==============================================================================
--- rt/branches/rt-3.1/etc/schema.Sybase	(original)
+++ rt/branches/rt-3.1/etc/schema.Sybase	Mon Jul 12 14:00:53 2004
@@ -1,5 +1,3 @@
-NEEDS UPDATE FOR 3.3
-
 # {{{ Attachments
 
 CREATE TABLE rt3.Attachments (

Modified: rt/branches/rt-3.1/etc/schema.mysql
==============================================================================
--- rt/branches/rt-3.1/etc/schema.mysql	(original)
+++ rt/branches/rt-3.1/etc/schema.mysql	Mon Jul 12 14:00:53 2004
@@ -118,23 +118,21 @@
 # {{{ Transactions
 CREATE TABLE Transactions (
   id INTEGER NOT NULL  AUTO_INCREMENT,
-  ObjectType varchar(64) NOT NULL,
-  ObjectId integer NOT NULL DEFAULT 0  ,
+  EffectiveTicket integer NOT NULL DEFAULT 0  ,
+  Ticket integer NOT NULL DEFAULT 0  ,
   TimeTaken integer NOT NULL DEFAULT 0  ,
   Type varchar(20) NULL  ,
   Field varchar(40) NULL  ,
   OldValue varchar(255) NULL  ,
   NewValue varchar(255) NULL  ,
-  ReferenceType varchar(255) NULL,
-  OldReference integer NULL  ,
-  NewReference integer NULL  ,
   Data varchar(255) NULL  ,
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
   PRIMARY KEY (id)
 ) TYPE=InnoDB;
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (Ticket);
+CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
 
 # }}}
 
@@ -339,19 +337,13 @@
 
 # }}}
 
-# {{{ ObjectCustomFieldValues 
+# {{{ TicketCustomFieldValues 
 
-CREATE TABLE ObjectCustomFieldValues (
+CREATE TABLE TicketCustomFieldValues (
   id INTEGER NOT NULL  AUTO_INCREMENT,
+  Ticket int NOT NULL  ,
   CustomField int NOT NULL  ,
-  ObjectType varchar(255) NOT NULL,	    # Final target of the Object
-  ObjectId int NOT NULL  ,		    # New -- Replaces Ticket
-
-  Current BOOL DEFAULT 1,		    # New -- whether the value was current
   Content varchar(255) NULL  ,
-  LargeContent LONGTEXT NULL,		    # New -- to hold 255+ strings
-  ContentType varchar(80) NULL,		    # New -- only text/* gets searched
-  ContentEncoding varchar(80) NULL  ,	    # New -- for binary Content
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
@@ -360,8 +352,7 @@
   PRIMARY KEY (id)
 ) TYPE=InnoDB;
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (Content); 
-CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
+CREATE INDEX TicketCustomFieldValues1 ON TicketCustomFieldValues (CustomField,Ticket,Content); 
 
 # }}}
 
@@ -370,13 +361,10 @@
 CREATE TABLE CustomFields (
   id INTEGER NOT NULL  AUTO_INCREMENT,
   Name varchar(200) NULL  ,
-  Type varchar(200) NULL  ,	# Changed -- 'Single' and 'Multiple' is moved out
-  MaxValues integer,		# New -- was 'Single'(1) and 'Multiple'(0)
-  Pattern varchar(255) NULL  ,	# New -- Must validate against this
-  Repeated int2 NOT NULL DEFAULT 0 , # New -- repeated table entry
+  Type varchar(200) NULL  ,
+  Queue integer NOT NULL DEFAULT 0 ,
   Description varchar(255) NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
-  LookupType varchar(255) NOT NULL,
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created DATETIME NULL  ,
@@ -386,22 +374,8 @@
   PRIMARY KEY (id)
 ) TYPE=InnoDB;
 
-# }}}
-
-# {{{ ObjectCustomFields 
-
-CREATE TABLE ObjectCustomFields (
-  id INTEGER NOT NULL  AUTO_INCREMENT,
-  CustomField int NOT NULL  ,
-  ObjectId integer NOT NULL,
-  SortOrder integer NOT NULL DEFAULT 0  ,
+CREATE INDEX CustomFields1 on CustomFields (Disabled, Queue);
 
-  Creator integer NOT NULL DEFAULT 0  ,
-  Created DATETIME NULL  ,
-  LastUpdatedBy integer NOT NULL DEFAULT 0  ,
-  LastUpdated DATETIME NULL  ,
-  PRIMARY KEY (id)
-) TYPE=InnoDB;
 
 # }}}
 

Modified: rt/branches/rt-3.1/html/Admin/Elements/AddCustomFieldValue
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/AddCustomFieldValue	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/AddCustomFieldValue	Mon Jul 12 14:00:53 2004
@@ -25,15 +25,15 @@
 <TABLE BORDER="0">
 <TR><TD><small>
 <&|/l&>Sort</&>:<br>
-<input size=3 name="CustomField-<%$CustomField->Id%>-Value-new-SortOrder" >
+<input name="CustomField-<% $CustomField->Id %>-AddValue-SortOrder" size="5">
 </TD>
 <TD><small>
 <&|/l&>Name</&>:<br>
-<input type="text" size=30 name="CustomField-<%$CustomField->Id%>-Value-new-Name" >
+<input size=20 name="CustomField-<% $CustomField->Id %>-AddValue-Name">
 </TD>
 <TD><small>
 <&|/l&>Description</&>:<br>
-<input type="text" size=50 name="CustomField-<%$CustomField->Id%>-Value-new-Description">
+<input size="60" name="CustomField-<% $CustomField->Id %>-AddValue-Description">
 </TD></TR>
 </TABLE>
 

Modified: rt/branches/rt-3.1/html/Admin/Elements/EditCustomFieldValues
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/EditCustomFieldValues	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/EditCustomFieldValues	Mon Jul 12 14:00:53 2004
@@ -21,41 +21,21 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-% if (!$values->Count) {
-<p><em><&|/l&>(no values)</&></em></p>
-%    return;
-% }
 <i><&|/l&>(Check box to delete)</&></i>
-<table>
-<tr>
-<td>&nbsp;</td>
-<td><&|/l&>Sort</&></td>
-<td><&|/l&>Name</&></td>
-<td><&|/l&>Description</&></td>
-</tr>
-% while (my $value = $values->Next) {
-<tr>
-<td>
-<input type="checkbox" name="Delete-CustomField-<%$CustomField->Id%>-Value-<%$value->Id%>">
-</td>
-<td>
-<input size=3 name="CustomField-<%$CustomField->Id%>-Value-<%$value->Id%>-SortOrder" value="<%$value->SortOrder%>">
-</td>
-<td>
-<input type="text" size=30 name="CustomField-<%$CustomField->Id%>-Value-<%$value->Id%>-Name" value="<%$value->Name%>">
-</td>
-<td>
-<font size="-1">
-<input type="text" size=50 name="CustomField-<%$CustomField->Id%>-Value-<%$value->Id%>-Description" value="<%$value->Description%>">
-</font>
-</td>
-</tr>
+<ul>
+% while (my $v = $values->Next) {
+<li>
+<INPUT TYPE="text" SIZE="2" NAME="CustomField-<%$CustomField->Id%>-SortOrder<%$v->Id()%>" VALUE="<%$v->SortOrder()%>">
+<input type="checkbox" name="CustomField-<%$CustomField->Id%>-DeleteValue" value="<%$v->id%>">
+<%$v->Name%>
+% if ($v->Description) {
+<i>(<%$v->Description%>)</i>
+% }
+</li>
 % }
-</table>
+</ul>
 <%init>
-
-my $values = $CustomField->ValuesObj();
-
+my $values = $CustomField->Values();
 </%init>
 <%args>
 $CustomField => undef

Modified: rt/branches/rt-3.1/html/Admin/Elements/EditCustomFields
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/EditCustomFields	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/EditCustomFields	Mon Jul 12 14:00:53 2004
@@ -21,63 +21,94 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /Elements/ListActions, actions => \@results &>
+<& /Elements/ListActions, actions => \@actions &>
 
-<FORM ACTION="CustomFields.html" METHOD=POST>
-<INPUT TYPE=HIDDEN NAME="id" VALUE="<% $Object->Id %>">
-<INPUT TYPE=HIDDEN NAME="ObjectType" VALUE="<% $ObjectType %>">
-<INPUT TYPE=HIDDEN NAME="SubType" VALUE="<% $SubType %>">
-<INPUT TYPE=HIDDEN NAME="UpdateCFs" VALUE="1">
-
-% if ($Object->Id) {
-<h2><&|/l&>Global Custom Fields</&></h2>
-<& PickCustomFields, CustomFields => \@GlobalCFs, ReadOnly => 1, id => $id &>
+<TABLE>
+<TR>
+<TD VALIGN=TOP>
+<h2><%$caption%></h2>
+</TD></TR></TABLE>
+% if ($CustomFields->Count == 0 ) {
+<P><i><&|/l&>(No custom fields)</&></i></P>
+% } else {
+<TABLE cellspacing=0 cellpadding=2>
+% my $count;
+% while (my $CustomFieldObj = $CustomFields->Next) { 
+<TR>
+  <TD valign="TOP">
+% if ($CustomFieldObj->Name) {
+    <A HREF="CustomField.html?Queue=<%$id%>&CustomField=<%$CustomFieldObj->id()%>"><b><%$CustomFieldObj->Name%></b></a><br>
+% } else {
+    <A HREF="CustomField.html?Queue=<%$id%>&CustomField=<%$CustomFieldObj->id()%>"><i>(<%loc("no name")%>)</i></a><br>
+% }
+    <%$CustomFieldObj->Description%>
+  </TD>
+  <TD valign="TOP">
+    <i><% $CustomFieldObj->FriendlyType %></i>
+  </TD>
+%  # show 'move up' unless it's the first item
+%  if ($count++) {
+  <TD valign="TOP">
+    <a href="CustomFields.html?id=<%$id%>&CustomField=<%$CustomFieldObj->id%>&Move=-1"><&|/l&>Move up</&></a>
+%  } else {
+  <TD valign="TOP" ALIGN=RIGHT>
+%  }
+
+%  # show 'move down' unless it's the last item
+%  if (!$CustomFields->IsLast) {
+%  $m->print(' | ') if $count > 1;
+    <a href="CustomFields.html?id=<%$id%>&CustomField=<%$CustomFieldObj->id%>&Move=1"><&|/l&>Move down</&></a>
+%  }
+</TD>
+</TR>
 % }
-<h2><&|/l&>Selected Custom Fields</&></h2>
-<& PickCustomFields, CustomFields => [$ObjectCFs->CustomFields], id => $id, Checked => 1 &>
-<h2><&|/l&>Unselected Custom Fields</&></h2>
-<& PickCustomFields, CustomFields => \@UnassignedCFs, id => $id &>
 
-<& /Elements/Submit, CheckAll => 1, ClearAll => 1 &>
+</TABLE>
+% }
+<FORM METHOD=GET ACTION="CustomFields.html">
+% if ($id) {
+<INPUT TYPE="Hidden" NAME="id" VALUE="<%$id%>">
+% }
+<input type="checkbox" name="FindDisabledCustomFields"> <&|/l&>Include disabled custom fields in listing.</&>
+<input type=submit value="<&|/l&>Go!</&>">
 </FORM>
 
 
 <%INIT>
 my $CustomFields = RT::CustomFields->new($session{'CurrentUser'});
-my @results;
-my (@GlobalCFs, @UnassignedCFs);
+my $QueueObj = RT::Queue->new($session{'CurrentUser'});
+my $caption;
 
-my $id = $Object->Id;
-if ($id and !$Object->CurrentUserHasRight('AssignCustomFields')) {
-    $m->print('<P><i>', loc('(No custom fields)'), '</i></P>');
-    return;
+if ($id)  {
+        $QueueObj->Load($id);                        
 }
 
-my $lookup = $ObjectType;
-$lookup .= "-$SubType" if $SubType;
-
-$CustomFields->LimitToLookupType($lookup);
-$CustomFields->OrderBy( FIELD => 'Name' );
-
-
-my ($GlobalCFs, $ObjectCFs);
-$ObjectCFs = RT::ObjectCustomFields->new($session{'CurrentUser'});
-$ObjectCFs->UnLimit;
-$ObjectCFs->LimitToObjectId($id);
-$ObjectCFs->LimitToLookupType($lookup);
+if ($QueueObj->id) {
+	$CustomFields->LimitToQueue($id);
+}                                            
+else {                                       
+        $CustomFields->LimitToGlobal();
+}                                           
+
+if ($FindDisabledCustomFields) {
+    $caption = loc("All Custom Fields");
+    $CustomFields->{'find_disabled_rows'} = 1;
+} else {
+    $caption = loc("Enabled Custom Fields");
+}
 
 # {{{ deal with moving sortorder of custom fields
 if ($CustomField and $Move) {
-    my $SourceObj = RT::ObjectCustomField->new($session{'CurrentUser'});
-    $SourceObj->LoadByCols( ObjectId => $id, CustomField => $CustomField );
+    my $SourceObj = RT::CustomField->new($session{'CurrentUser'});
+    $SourceObj->Load($CustomField) || Abort(loc('No CustomField'));
 
     my $TargetObj;
     my $target_order = $SourceObj->SortOrder + $Move;
-    while (my $ObjectCF = $ObjectCFs->Next) { 
-	my $this_order = $ObjectCF->SortOrder;
+    while (my $CustomFieldObj = $CustomFields->Next) { 
+	my $this_order = $CustomFieldObj->SortOrder;
 
 	# if we have an exact match, finish the loop now
-	($TargetObj = $ObjectCF, last) if $this_order == $target_order;
+	($TargetObj = $CustomFieldObj, last) if $this_order == $target_order;
 
 	# otherwise, we need to apropos toward the general direction
 	# ... first, check the sign is correct
@@ -91,7 +122,7 @@
 	    next if $orig_delta < $this_delta;
 	}
 
-	$TargetObj = $ObjectCF;
+	$TargetObj = $CustomFieldObj;
     }
 
     if ($TargetObj) {
@@ -100,66 +131,83 @@
 	$TargetObj->SetSortOrder($s);
 	$SourceObj->SetSortOrder($t);
 	# because order changed, we must redo search for subsequent uses
+	$CustomFields->RedoSearch;
     }
 
-    $ObjectCFs->GotoFirstItem;
+    $CustomFields->GotoFirstItem;
 }
 # }}}
 
-if ($id) {
-    $GlobalCFs = RT::ObjectCustomFields->new($session{'CurrentUser'});
-    $GlobalCFs->LimitToObjectId(0);
-    $GlobalCFs->LimitToLookupType($lookup);
-}
-
-while (my $cf = $CustomFields->Next) { 
-    my $cf_id = $cf->Id;
+# {{{ now process the 'copy queue' action
+my @actions;
+if ($Source and $Source ne $id) {
+    my $SourceQueue = RT::Queue->new($session{'CurrentUser'});
+    $SourceQueue->Load($Source) || Abort(loc("Couldn't load queue"));
+    my $SourceCustomFields = RT::CustomFields->new($session{'CurrentUser'});
+    $SourceCustomFields->LimitToQueue($SourceQueue->id);
+
+    # delete old fields
+    foreach my $CustomFieldObj ( @{$CustomFields->ItemsArrayRef} ) { 
+	$CustomFieldObj->Delete;
+    }
 
-    if ($GlobalCFs and $GlobalCFs->HasEntryForCustomField($cf_id)) {
-	push @GlobalCFs, $cf;
-	next;
-    }
-
-    if ($UpdateCFs) {
-	# Go through and delete all the custom field relationships that this object
-	# no longer has
-	my $key = "Object-$id-CF-$cf_id";
-	if ($ARGS{$key}) {
-	    if (!$ObjectCFs->HasEntryForCustomField($cf_id)) {
-		my ($val, $msg) = $cf->AddToObject($Object);
-		push (@results, $msg);
-		push @UnassignedCFs, $cf if !$val;
-	    }
-	}
-	else {
-	    push @UnassignedCFs, $cf;
-	    if ($ObjectCFs->HasEntryForCustomField($cf_id)) {
-		my ($val, $msg) = $cf->RemoveFromObject($Object);
-		push (@results, $msg);
-		pop @UnassignedCFs if !$val;
-	    }
+    # add new fields
+    while (my $SourceCustomFieldObj = $SourceCustomFields->Next) {
+	my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'});
+	my ($val, $msg) =  $CustomFieldObj->Create(
+	    id => $SourceCustomFieldObj->id,
+	    Queue => $id,
+	    Name => $SourceCustomFieldObj->Name,
+	    Type => $SourceCustomFieldObj->Type,
+	    Description => $SourceCustomFieldObj->Description,
+	);
+	Abort(loc("Could not create CustomField") . ": $msg") unless ($val);
+	push @actions, $msg;
+
+	$CustomFieldObj->SetSortOrder($SourceCustomFieldObj->SortOrder);
+
+	# add new values
+	my $values = $SourceCustomFieldObj->Values();
+	while (my $v = $values->Next) {
+	    my ( $addval, $addmsg ) = $CustomFieldObj->AddValue(
+		Name => $v->Name,
+		Description => $v->Description,
+		SortOrder => $v->SortOrder
+	    );
 	}
     }
-    elsif (!$ObjectCFs->HasEntryForCustomField($cf_id)) {
-	push @UnassignedCFs, $cf;
-    }
+
+    # because content changed, we must redo search for subsequent uses
+    $CustomFields->RedoSearch;
+    $CustomFields->GotoFirstItem;
 }
+# }}}
 
-# redo search...
-$ObjectCFs = RT::ObjectCustomFields->new($session{'CurrentUser'});
-$ObjectCFs->UnLimit;
-$ObjectCFs->LimitToObjectId($id);
-$ObjectCFs->LimitToLookupType($lookup);
+# {{{ deal with deleting existing custom fields
+foreach my $key (keys %ARGS) {
+  # {{{ if we're trying to delete the custom field
+  if ($key =~ /^DeleteCustomField-(\d+)/) {
+    my $id = $1;
+    my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'});
+    $CustomFieldObj->Load($id);
+    my ($retval, $msg) = $CustomFieldObj->Delete;
+    if ($retval) {
+      push @actions, loc("Custom field deleted");
+    }
+    else {
+      push @actions, $msg;
+    }
+  }
+  # }}}
+}
+# }}}
 
 </%INIT>
 <%ARGS>
+$id => 0
 $title => undef
 $Move => undef
 $Source => undef
 $CustomField => undef
 $FindDisabledCustomFields => undef
-$UpdateCFs => 0
-$Object
-$ObjectType
-$SubType => ''
 </%ARGS>

Modified: rt/branches/rt-3.1/html/Admin/Elements/EditScrip
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/EditScrip	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/EditScrip	Mon Jul 12 14:00:53 2004
@@ -109,7 +109,6 @@
 
 <& /Elements/Submit, Label => loc('Create'), Reset => 1 &>
 
-
 </FORM>
 <%init>
 my (@actions);

Modified: rt/branches/rt-3.1/html/Admin/Elements/GroupTabs
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/GroupTabs	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/GroupTabs	Mon Jul 12 14:00:53 2004
@@ -45,18 +45,14 @@
                path  => "Admin/Groups/GroupRights.html?id=" . $GroupObj->id, },
         G => { title => loc('User Rights'),
                path  => "Admin/Groups/UserRights.html?id=" . $GroupObj->id, },
-        H => { title => loc('History'),
-               path  => "Admin/Groups/History.html?id=" . $GroupObj->id },
     }
 }
 }
 $tabs->{"A"} = { title => loc('Select group'),
                  path  => "Admin/Groups/", };
 $tabs->{"B"} = { title     => loc('New group'),
-                 path      => "Admin/Groups/Modify.html?Create=1", };
-$tabs->{"C"} = { title => loc('Custom Fields'),
-		 path => "Admin/Groups/CustomFields.html",
-		 separator => 1, };
+                 path      => "Admin/Groups/Modify.html?Create=1",
+                 separator => 1, };
 
 # Now let callbacks add their extra tabs
 $m->comp( '/Elements/Callback', tabs => $tabs, %ARGS );

Modified: rt/branches/rt-3.1/html/Admin/Elements/Header
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/Header	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/Header	Mon Jul 12 14:00:53 2004
@@ -21,7 +21,7 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /Elements/Header, %ARGS &>
+<& /Elements/Header, Title => $Title &>
 
 <%ARGS>
 $Title => undef

Modified: rt/branches/rt-3.1/html/Admin/Elements/QueueTabs
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/QueueTabs	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/QueueTabs	Mon Jul 12 14:00:53 2004
@@ -49,12 +49,8 @@
 				path => "Admin/Queues/Templates.html?id=".$id,
 			      },
 
-                 G1 => { title => loc('Ticket Custom Fields'),
-                        path => 'Admin/Queues/CustomFields.html?SubType=RT::Ticket&id='.$id,
-                        },
-
-                 G2 => { title => loc('Transaction Custom Fields'),
-                        path => 'Admin/Queues/CustomFields.html?SubType=RT::Ticket-RT::Transaction&id='.$id,
+                 G => { title => loc('Custom Fields'),
+                        path => 'Admin/Queues/CustomFields.html?id='.$id,
                         },
 
 		 H => { title => loc('Group Rights'),
@@ -72,13 +68,8 @@
 			   };
   $tabs->{"B"} = { title => loc('New queue'),
   		     	path => "Admin/Queues/Modify.html?Create=1",
+			separator => 1,
 			   };
-  $tabs->{"G1"} = { title => loc('Ticket Custom Fields'),
-  		     	path => 'Admin/Queues/CustomFields.html?SubType=RT::Ticket',
-			   };
-  $tabs->{"G2"} = { title => loc('Transaction Custom Fields'),
-  		     	path => 'Admin/Queues/CustomFields.html?SubType=RT::Ticket-RT::Transaction',
-		 separator => 1, };
 }
 
   # Now let callbacks add their extra tabs

Modified: rt/branches/rt-3.1/html/Admin/Elements/SelectCustomFieldType
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/SelectCustomFieldType	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/SelectCustomFieldType	Mon Jul 12 14:00:53 2004
@@ -22,8 +22,8 @@
 %# 
 %# END LICENSE BLOCK
 <SELECT NAME ="<%$Name%>">
-%for my $option ($cf->TypeComposites) {
-<OPTION VALUE="<%$option%>" <%$option eq $Default && "SELECTED"%>><% $cf->FriendlyTypeComposite($option) %></OPTION>
+%for my $option ($cf->Types) {
+<OPTION VALUE="<%$option%>" <%$option eq $Default && "SELECTED"%>><% $cf->FriendlyType($option) %></OPTION>
 %}
 </SELECT>
 <%INIT>
@@ -32,5 +32,5 @@
 </%INIT>
 <%ARGS>
 $Default=>undef
-$Name => 'TypeComposite'
+$Name => 'Type'
 </%ARGS>

Modified: rt/branches/rt-3.1/html/Admin/Elements/SelectRights
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/SelectRights	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/SelectRights	Mon Jul 12 14:00:53 2004
@@ -78,7 +78,7 @@
     } 
 
         else {
-                %Rights = ( loc('System Error') => loc("No rights found") );
+                %Rights = { loc('System Error') => loc("No rights found")};
         }
         
     $ACLDesc = "$PrincipalId-".ref($Object)."-".$Object->Id;

Modified: rt/branches/rt-3.1/html/Admin/Elements/SystemTabs
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/SystemTabs	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/SystemTabs	Mon Jul 12 14:00:53 2004
@@ -36,9 +36,9 @@
                         path => 'Admin/Global/Templates.html',
                       },
               
-#                F => { title => loc('Custom Fields'),
-#                        path => 'Admin/Global/CustomFields.html',
-#                        },
+                F => { title => loc('Custom Fields'),
+                        path => 'Admin/Global/CustomFields.html',
+                        },
 
                 G => { title => loc('Group Rights'),
                                 path => 'Admin/Global/GroupRights.html',

Modified: rt/branches/rt-3.1/html/Admin/Elements/Tabs
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/Tabs	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/Tabs	Mon Jul 12 14:00:53 2004
@@ -37,13 +37,10 @@
 	       C => { title => loc('Queues'),
 			   path => 'Admin/Queues/',
 			 },
-	       D => { 'title' => loc('Custom Fields'),
-			   path => 'Admin/CustomFields/',
-			 },
-	       E => { 'title' => loc('Global'),
+	       D => { 'title' => loc('Global'),
 			   path => 'Admin/Global/',
 			 },
-	       F => { 'title' => loc('Tools'),
+	       E => { 'title' => loc('Tools'),
 			   path => 'Admin/Tools/',
 			 },
 	     };

Modified: rt/branches/rt-3.1/html/Admin/Elements/UserTabs
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Elements/UserTabs	(original)
+++ rt/branches/rt-3.1/html/Admin/Elements/UserTabs	Mon Jul 12 14:00:53 2004
@@ -21,63 +21,51 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /Admin/Elements/Tabs, 
+<& /Admin/Elements/Tabs,
     subtabs => $tabs,
-    current_tab => 'Admin/Users/', 
-    current_subtab => $current_tab, 
+    current_tab => 'Admin/Users/',
+    current_subtab => $current_tab,
     Title => $Title &>
 <%INIT>
 my $tabs;
 if ($id) {
-$tabs->{'this'} = { title => eval { $UserObj->Name },
-
+	$tabs->{'this'} = {
+		title => eval { $UserObj->Name },
 		path => "Admin/Users/Modify.html?id=".$id,
-subtabs => {
-	       Basics => { title => loc('Basics'),
+		current_subtab => $current_tab,
+		subtabs => {
+			A => { title => loc('Basics'),
 				path => "Admin/Users/Modify.html?id=".$id
 			},
-	       Memberships => { title => loc('Memberships'),
-			   path => "Admin/Users/Memberships.html?id=".$id
-			 },
-	       History => { title => loc('History'),
-			   path => "Admin/Users/History.html?id=".$id
-			 },
-#	       Scrips => { title => loc('Rights'),
-#			   path => "Admin/Users/Rights.html?id=".$id
-#			 }
-	       
+		}
 	}
 }
-}
-if ($session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'AdminUsers')) {
-  $tabs->{"A"} = { title => loc('Select user'),
-  		     	path => "Admin/Users/",
-			   };
-  $tabs->{"B"} = { title => loc('New user'),
-  		     	path => "Admin/Users/Modify.html?Create=1",
+
+if ( $session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'AdminUsers') ) {
+	$tabs->{"A"} = {
+		title => loc('Select user'),
+		path => "Admin/Users/",
 	};
-  $tabs->{"C"} = { title => loc('Custom Fields'),
-  		     	path => "Admin/Users/CustomFields.html",
+	$tabs->{"B"} = {
+		title => loc('New user'),
+		path => "Admin/Users/Modify.html?Create=1",
 		separator => 1,
 	};
 }
 
-  # Now let callbacks add their extra tabs
-  $m->comp('/Elements/Callback', tabs => $tabs, %ARGS);
-                                                                                
-#foreach my $tab ( sort keys %{$tabs} ) {                                        
-#    if ( $tabs->{$tab}->{'path'} eq $current_subtab ) {                         
-#        $tabs->{$tab}->{"current_subtab"} = $current_subtab;                    
-#    }                                                                           
-#}                                                                               
-foreach my $tab ( sort keys %{$tabs->{'this'}->{'subtabs'}} ) {  
-    if ( $tabs->{'this'}->{'subtabs'}->{$tab}->{'path'} eq $current_tab ) {
-        $tabs->{'this'}->{'subtabs'}->{$tab}->{"subtabs"}        = $subtabs; 
-        $tabs->{'this'}->{'subtabs'}->{$tab}->{"current_subtab"} = $current_subtab; 
-    }                                                                           
-}   
-$tabs->{'this'}->{"current_subtab"} = $current_tab; 
+# Now let callbacks add their extra tabs
+$m->comp('/Elements/Callback', tabs => $tabs, %ARGS);
+
+foreach my $tab ( sort keys %{$tabs->{'this'}->{'subtabs'}} ) {
+	if ( $tabs->{'this'}->{'subtabs'}->{$tab}->{'path'} eq $current_tab ) {
+		$tabs->{'this'}->{"current_subtab"} = $current_tab; 
+		$tabs->{'this'}->{'subtabs'}->{$tab}->{"current_subtab"} = $current_subtab; 
+		$tabs->{'this'}->{'subtabs'}->{$tab}->{"subtabs"} = $subtabs; 
+	}
+}
+
 $current_tab = "Admin/Users/Modify.html?id=".$id if $id;
+
 </%INIT>
 <%ARGS>
 $UserObj => undef

Modified: rt/branches/rt-3.1/html/Admin/Global/Templates.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Global/Templates.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Global/Templates.html	Mon Jul 12 14:00:53 2004
@@ -21,7 +21,7 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /Admin/Elements/Header, Title => $title, FeedURI => 'templates' &>
+<& /Admin/Elements/Header, Title => $title &>
 <& /Admin/Elements/SystemTabs, 
     current_tab => 'Admin/Global/Templates.html', 
     current_subtab => 'Admin/Global/Templates.html', 

Modified: rt/branches/rt-3.1/html/Admin/Global/index.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Global/index.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Global/index.html	Mon Jul 12 14:00:53 2004
@@ -46,10 +46,10 @@
                         path => 'Templates.html',
                       },
               
-#                F => { title => loc('Custom Fields'),
-#                        text => loc('Modify Custom Fields which apply to all queues'),
-#                        path => 'CustomFields.html',
-#                        },
+                F => { title => loc('Custom Fields'),
+                        text => loc('Modify Custom Fields which apply to all queues'),
+                        path => 'CustomFields.html',
+                        },
 
                 G => { title => loc('Group Rights'),
                                 text => loc('Modify global group rights'),

Modified: rt/branches/rt-3.1/html/Admin/Groups/Modify.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Groups/Modify.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Groups/Modify.html	Mon Jul 12 14:00:53 2004
@@ -31,7 +31,7 @@
 
 
 
-<FORM ACTION="<%$RT::WebPath%>/Admin/Groups/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
+<FORM ACTION="<%$RT::WebPath%>/Admin/Groups/Modify.html" METHOD=POST>
 
 %unless ($Group->Id) {
 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
@@ -43,20 +43,10 @@
 <&|/l&>Name</&>:
 </TD>
 <TD><INPUT name="Name" value="<%$Group->Name%>"></TD>
-</TR>
-<TR>
+</TR><TR>
 <TD ALIGN=RIGHT>
 <&|/l&>Description</&>:</TD><TD COLSPAN=3><INPUT name="Description" value="<%$Group->Description%>" size=60></TD>
-</TR>
-% my $CFs = $Group->CustomFields;
-% while (my $CF = $CFs->Next) {
-<TR VALIGN="TOP"><TD ALIGN="RIGHT">
-<% $CF->Name %>:
-</TD><TD>
-<& /Elements/EditCustomField, CustomField => $CF, Object => $Group &>
-</TD></TR>
-% }
-<TR>
+</TR><TR>
 <TD COLSPAN=2>
 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>> <&|/l&>Enabled (Unchecking this box disables this group)</&><BR>
@@ -112,7 +102,6 @@
 					    Object => $Group,
 					    ARGSRef => \%ARGS );
     push (@results, at fieldresults);
-    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $Group );
 }
 
 #we're asking about enabled on the web page but really care about disabled.

Modified: rt/branches/rt-3.1/html/Admin/Groups/index.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Groups/index.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Groups/index.html	Mon Jul 12 14:00:53 2004
@@ -25,19 +25,13 @@
 <& /Admin/Elements/GroupTabs, current_tab => 'Admin/Groups/',
     current_subtab => 'Admin/Groups/', 
     Title => $title &>
-<%$caption%>:<BR> <UL> 
-%if ($Groups->Count == 0) {
-<LI> <i><&|/l&>No groups matching search criteria found.</&></i>
-% }
-%my @ids;
+
+
+<UL>
 %while ( my $Group = $Groups->Next) {
-%    push @ids, $Group->Id;
 <LI><A HREF="Modify.html?id=<%$Group->id%>"><%$Group->Name || loc('(empty)')%></a><BR>
 %}
 </UL>
-%if (my $ids = join(',', @ids)) {
-<em>(<a href="/Download/Tabular/Group/<% $ids %>/Groups.tsv"><&|/l&>Download as a tab-delimited file</&></a>)</em><br>
-%}
 <br><br>
 <FORM METHOD=POST ACTION="<% $RT::WebPath %>/Admin/Groups/index.html">
 <input type="checkbox" name="FindDisabledGroups"> <&|/l&>Include disabled groups in listing.</&>
@@ -45,41 +39,17 @@
 <div align=right><input type=submit value="<&|/l&>Go!</&>"></div> 
 </FORM>
 
-<br><br>
-<FORM METHOD=POST ACTION="<% $RT::WebPath %>/Admin/Groups/index.html">
-<&|/l&>Find groups whose</&> <& /Elements/SelectGroups &><BR>
-<div align=right><input type=submit value="<&|/l&>Go!</&>"></div> 
-</FORM>
 <%INIT>
 my $Groups = RT::Groups->new($session{'CurrentUser'});
+
+if ($FindDisabledGroups) {
+  $Groups->{'find_disabled_rows'} = 1;
+}
+
 $Groups->LimitToUserDefinedGroups();
 my $title = loc('Select a group');
-my $caption;
 
-if (length $GroupString) {
-    $caption = loc("Groups matching search criteria");
-    if ($GroupField =~ /^CustomField-(\d+)/) {
-	$Groups->LimitCustomField(
-	    CUSTOMFIELD => $1,
-	    OPERATOR => $GroupOp,
-	    VALUE => $GroupString,
-	); 
-    }
-    else {
-	$Groups->Limit(
-	    FIELD => $GroupField,
-	    OPERATOR => $GroupOp,
-	    VALUE => $GroupString,
-	); 
-    }
-}
-else {
-    $caption = loc("User-defined groups");
-}
 </%INIT>
 <%ARGS>
-$GroupString => undef
-$GroupOp => '='
-$GroupField => 'Name'
 $FindDisabledGroups => 0
 </%ARGS>

Modified: rt/branches/rt-3.1/html/Admin/Queues/CustomField.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Queues/CustomField.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Queues/CustomField.html	Mon Jul 12 14:00:53 2004
@@ -56,5 +56,5 @@
 </%INIT>
 <%ARGS>
 $CustomField => undef
-$Queue => 0
+$Queue => undef
 </%ARGS>

Modified: rt/branches/rt-3.1/html/Admin/Queues/CustomFields.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Queues/CustomFields.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Queues/CustomFields.html	Mon Jul 12 14:00:53 2004
@@ -21,4 +21,29 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /Admin/Elements/ObjectCustomFields, %ARGS, ObjectType => 'RT::Queue' &>
+<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/QueueTabs, id => $Queue->id, 
+    current_tab => 'Admin/Queues/CustomFields.html?id='.$id, 
+    QueueObj => $Queue,                                                      
+    subtabs => $subtabs,
+    Title => $title
+    &>
+
+<& /Admin/Elements/EditCustomFields, title => $title, %ARGS &>
+<%INIT>
+my $Queue = new RT::Queue($session{'CurrentUser'});
+$Queue->Load($id) || Abort(loc("Couldn't load queue", $id));
+
+my $CustomFields = RT::CustomFields->new($RT::SystemUser);
+$CustomFields->LimitToQueue($Queue->Id);
+my $subtabs = {
+	 A => { title => loc('New custom field'),
+	     	path => "Admin/Queues/CustomField.html?create=1&Queue=".$id,
+			   }
+	      };
+
+my $title=  loc('Edit Custom Fields for [_1]', $Queue->Name);
+</%INIT>
+<%ARGS>
+$id => undef
+</%ARGS>

Modified: rt/branches/rt-3.1/html/Admin/Queues/Modify.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Queues/Modify.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Queues/Modify.html	Mon Jul 12 14:00:53 2004
@@ -137,7 +137,7 @@
   }
   if  ( ($SetEnabled) and ( $Disabled != $QueueObj->Disabled) ) { 
       my  ($code, $msg) = $QueueObj->SetDisabled($Disabled);
-      push @results, loc('Enabled status: [_1]', loc_fuzzy($msg));
+      push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
   }
   
   if ($QueueObj->Disabled()) {

Modified: rt/branches/rt-3.1/html/Admin/Queues/People.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Queues/People.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Queues/People.html	Mon Jul 12 14:00:53 2004
@@ -57,7 +57,7 @@
 <& /Elements/SelectUsers &>
 <input type=submit name="OnlySearchForPeople" value="<&|/l&>Go!</&>">
 <BR>
-<&|/l&>Find groups whose</&><BR>
+<&|/l&>Find group whose</&><BR>
 <& /Elements/SelectGroups &>
 <input type=submit name="OnlySearchForGroup" value="<&|/l&>Go!</&>">
 

Modified: rt/branches/rt-3.1/html/Admin/Users/Modify.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Users/Modify.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Users/Modify.html	Mon Jul 12 14:00:53 2004
@@ -30,7 +30,7 @@
 
 <& /Elements/ListActions, actions => \@results &>
 
-<FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
+<FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST>
 %if ($Create) {
 <INPUT TYPE=HIDDEN NAME=id VALUE="new">
 % } else {
@@ -69,11 +69,6 @@
 <input name="Gecos" value="<%$UserObj->Gecos%>">
 </TD></TR>
 <TR><TD ALIGN="RIGHT">
-<&|/l&>Language</&>: 
-</TD><TD>
-<& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
-</TD></TR>
-<TR><TD ALIGN="RIGHT">
 <&|/l&>Extra info</&>: 
 </TD><TD>
 <textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
@@ -182,21 +177,6 @@
 <TR>
 </TR>
 </TABLE>
-<BR>
-<& /Elements/TitleBoxStart, title => loc('Custom Fields') &>
-<TABLE>
-% my $CFs = $UserObj->CustomFields;
-% while (my $CF = $CFs->Next) {
-<TR VALIGN="TOP"><TD ALIGN="RIGHT">
-<% $CF->Name %>:
-</TD><TD>
-<& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
-</TD></TR>
-% }
-<TR>
-</TR>
-</TABLE>
-<& /Elements/TitleBoxEnd &>
 <TR>
 <TD colspan="2">
 <& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
@@ -308,7 +288,6 @@
 					    Object => $UserObj,
 					    ARGSRef => \%ARGS );
     push (@results, at fieldresults);
-    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
 
 
 # {{{ Deal with special fields: Privileged, Enabled and Password

Modified: rt/branches/rt-3.1/html/Admin/Users/index.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Users/index.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Users/index.html	Mon Jul 12 14:00:53 2004
@@ -34,16 +34,11 @@
 %if ($users->Count == 0) {
 <LI> <i><&|/l&>No users matching search criteria found.</&></i>
 % }
-%my @ids;
 %while ( $user = $users->Next) {
-%    push @ids, $user->Id;
 <LI><A HREF="Modify.html?id=<%$user->id%>"><%$user->Name || loc('(no name listed)')%></a></LI>
 %}
-</UL>
-%if (my $ids = join(',', @ids)) {
-<em>(<a href="/Download/Tabular/User/<% $ids %>/Users.tsv"><&|/l&>Download as a tab-delimited file</&></a>)</em><br>
-%}
 
+</UL>
 <br><br>
 <FORM METHOD=POST ACTION="<% $RT::WebPath %>/Admin/Users/index.html">
 
@@ -61,26 +56,19 @@
 	$users->{'find_disabled_rows'} = 1;
 }
 
-if (length $UserString) {
-    $caption = loc("Users matching search criteria");
-    if ($UserField =~ /^CustomField-(\d+)/) {
-	$users->LimitCustomField(
-	    CUSTOMFIELD => $1,
-	    OPERATOR => $UserOp,
-	    VALUE => $UserString,
-	); 
-    }
-    else {
-	$users->Limit(
-	    FIELD => $UserField,
-	    OPERATOR => $UserOp,
-	    VALUE => $UserString,
-	); 
-    }
+unless (defined $UserString) {
+    $users->LimitToPrivileged();
+    $caption = loc("Privileged users");
 }
 else {
-    $caption = loc("Privileged users");
-    $users->LimitToPrivileged;
+    $caption = loc("Users matching search criteria");
+
+  if ($UserString) {
+	$users->Limit( FIELD => $UserField,
+		        OPERATOR => $UserOp,
+		       VALUE => $UserString); 
+
+}
 }
 </%INIT>
 <%ARGS>

Modified: rt/branches/rt-3.1/html/Admin/index.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/index.html	(original)
+++ rt/branches/rt-3.1/html/Admin/index.html	Mon Jul 12 14:00:53 2004
@@ -34,9 +34,6 @@
 <li><font size="+2"><a href="Queues/"><&|/l&>Queues</&></a></font><br>
 <&|/l&>Manage queues and queue-specific properties</&>
 </li>
-<li><font size="+2"><a href="CustomFields/"><&|/l&>Custom Fields</&></a></font><br>
-<&|/l&>Manage custom fields and custom field values</&>
-</li>
 <li><font size="+2"><a href="Global/"><&|/l&>Global</&></a></font><br>
 <&|/l&>Manage properties and configuration which apply to all queues</&>
 </li>

Modified: rt/branches/rt-3.1/html/Elements/Header
==============================================================================
--- rt/branches/rt-3.1/html/Elements/Header	(original)
+++ rt/branches/rt-3.1/html/Elements/Header	Mon Jul 12 14:00:53 2004
@@ -31,11 +31,6 @@
 
 <link rel="shortcut icon" href="<%$RT::WebImagesURL%>/favicon.png" type="image/png">
 <link rel="stylesheet" href="<%$RT::WebPath%>/NoAuth/webrt.css" type="text/css">
-<link rel="" href="<%$RT::WebImagesURL%>/favicon.png" type="image/png">
-% foreach my $service (qw( Feed Post Edit )) {
-%     my $uri = $ARGS{$service."URI"} or next;
-<link rel="service.<% lc($service) %>" type="application/x.atom+xml" href="<% $RT::WebPath %>/REST/2.0/<% $uri %>" title="Atom <% $service %>" />
-% }
 <script>
 function hideshow(num) {
     idstring = "element-" + num;
@@ -80,8 +75,8 @@
 </table>
 <%INIT>
 
-$r->headers_out->{'Pragma'} = 'no-cache';
-$r->headers_out->{'Cache-control'} = 'no-cache';
+$r->header_out('Pragma' => 'no-cache');
+$r->header_out('Cache-control' => 'no-cache');
 </%INIT>
 
 <%ARGS>

Modified: rt/branches/rt-3.1/html/Elements/SelectGroups
==============================================================================
--- rt/branches/rt-3.1/html/Elements/SelectGroups	(original)
+++ rt/branches/rt-3.1/html/Elements/SelectGroups	Mon Jul 12 14:00:53 2004
@@ -22,17 +22,8 @@
 %# 
 %# END LICENSE BLOCK
 <select name="GroupField">
-% foreach my $col (RT::Group->BasicColumns) {
-<option value="<% $col->[0] %>"><% loc($col->[1]) %>
-% }
-% while (my $CF = $CFs->Next) {
-<option value="CustomField-<% $CF->Id %>"><&|/l&>CustomField</&>: <% $CF->Name %>
-% }
+<option value="Name"><&|/l&>Name</&>
+<option value="Description"><&|/l&>Description</&>
 </select>
 <& /Elements/SelectMatch, Name=> 'GroupOp' &>
 <input size=8 name="GroupString">
-<%INIT>
-my $CFs = RT::CustomFields->new($session{'CurrentUser'});
-$CFs->LimitToChildType('RT::Group');
-$CFs->OrderBy( FIELD => 'Name' );
-</%INIT>

Modified: rt/branches/rt-3.1/html/Elements/SelectUsers
==============================================================================
--- rt/branches/rt-3.1/html/Elements/SelectUsers	(original)
+++ rt/branches/rt-3.1/html/Elements/SelectUsers	Mon Jul 12 14:00:53 2004
@@ -22,17 +22,10 @@
 %# 
 %# END LICENSE BLOCK
 <select name="UserField">
-% foreach my $col (RT::User->BasicColumns) {
-<option value="<% $col->[0] %>"><% loc($col->[1]) %>
-% }
-% while (my $CF = $CFs->Next) {
-<option value="CustomField-<% $CF->Id %>"><&|/l&>CustomField</&>: <% $CF->Name %>
-% }
+<option value="Name"><&|/l&>User Id</&>
+<option value="EmailAddress"><&|/l&>Email</&>
+<option value="RealName"><&|/l&>Name</&>
+<option value="Organization"><&|/l&>Organization</&>
 </select>
 <& /Elements/SelectMatch, Name=> 'UserOp' &>
 <input size=8 name="UserString">
-<%INIT>
-my $CFs = RT::CustomFields->new($session{'CurrentUser'});
-$CFs->LimitToChildType('RT::User');
-$CFs->OrderBy( FIELD => 'Name' );
-</%INIT>

Modified: rt/branches/rt-3.1/html/Elements/SetupSessionCookie
==============================================================================
--- rt/branches/rt-3.1/html/Elements/SetupSessionCookie	(original)
+++ rt/branches/rt-3.1/html/Elements/SetupSessionCookie	Mon Jul 12 14:00:53 2004
@@ -74,7 +74,7 @@
             -value => $session{_session_id},
             -path  => '/',
         );
-        $r->headers_out->{'Set-Cookie'} = $cookie->as_string;
+        $r->header_out('Set-Cookie', $cookie->as_string);
 
     } 
 

Modified: rt/branches/rt-3.1/html/Elements/Submit
==============================================================================
--- rt/branches/rt-3.1/html/Elements/Submit	(original)
+++ rt/branches/rt-3.1/html/Elements/Submit	Mon Jul 12 14:00:53 2004
@@ -21,32 +21,15 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-% if ($CheckAll or $ClearAll) {
-<script><!--
-function set_checkbox (obj, val) {
-    var i;
-    var myfield = obj.form.getElementsByTagName('input');
-    for (i = 0; i < myfield.length; i++) {
-	if (myfield[i].type == 'checkbox') {
-	    myfield[i].checked = val;
-	}
-    }
-}
---></script>
-% }
 <TABLE WIDTH=100% BGCOLOR="<%$color%>" CELLSPACING=0 BORDER=0 CELLPADDING=0 >
 <TR>
-<TD>
-% if ($CheckAll) {
-<INPUT TYPE=BUTTON VALUE="<%$CheckAllLabel%>" ONCLICK="set_checkbox(this, true)">
-% }
-% if ($ClearAll) {
-<INPUT TYPE=BUTTON VALUE="<%$ClearAllLabel%>" ONCLICK="set_checkbox(this, false)">
-% }
 % if ($Reset) {
+<TD>
+<FONT COLOR=#ffd800 >
 <INPUT TYPE=RESET VALUE="<%$ResetLabel%>">
-%}
+</FONT>
 </TD>
+%}
 <TD>
 &nbsp;
 </TD>
@@ -74,10 +57,6 @@
 $AlternateLabel => undef
 $Label => loc('Submit')
 $Name => undef
-$CheckAll => undef
-$CheckAllLabel => loc('Check All')
-$ClearAll => undef
-$ClearAllLabel => loc('Clear All')
 $Reset => undef
 $ResetLabel => loc('Reset')
 </%ARGS>

Modified: rt/branches/rt-3.1/html/NoAuth/webrt.css
==============================================================================
--- rt/branches/rt-3.1/html/NoAuth/webrt.css	(original)
+++ rt/branches/rt-3.1/html/NoAuth/webrt.css	Mon Jul 12 14:00:53 2004
@@ -359,5 +359,5 @@
 </%flags>
 <%init>
 $r->content_type('text/css');
-$r->headers_out->{'Expires'} = '+30m';
+$r->header_out('Expires' ,'+30m');
 </%init>

Modified: rt/branches/rt-3.1/html/Search/Bulk.html
==============================================================================
--- rt/branches/rt-3.1/html/Search/Bulk.html	(original)
+++ rt/branches/rt-3.1/html/Search/Bulk.html	Mon Jul 12 14:00:53 2004
@@ -131,12 +131,6 @@
 </select> 
 </td></tr>
 <tr><td align=right><&|/l&>Subject</&>:</td><td> <input name="UpdateSubject" size=60 value=""></td></tr>
-% while (my $CF = $TxnCFs->Next()) {
-<TR>
-<TD ALIGN=RIGHT><% $CF->Name %>:</TD>
-<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
-</TD></TR>
-% } # end if while
  <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="UpdateAttachment" type="file"></td></tr>
  <tr><td class=labeltop><&|/l&>Message</&>:</td><td>
  <& /Elements/MessageBox, Name=>"UpdateContent"&>
@@ -184,10 +178,7 @@
 my @linkresults;
 
 $Tickets->RedoSearch();
-
-my %queues;
 while (my $Ticket = $Tickets->Next) {
-    $queues{$Ticket->Queue}++;
     $RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
     next unless ($ARGS{"UpdateTicket".$Ticket->Id});
     $RT::Logger->debug ("Matched\n");
@@ -227,8 +218,4 @@
     @results = (@results, @tempresults);
 }
 
-my $TxnCFs = RT::CustomFields->new($session{CurrentUser});
-$TxnCFs->LimitToLookupType("RT::Queue-RT::Ticket-RT::Transaction");
-$TxnCFs->LimitToGlobalOrObjectId(sort keys %queues);
-
 </%INIT>

Modified: rt/branches/rt-3.1/html/Search/Elements/PickBasics
==============================================================================
--- rt/branches/rt-3.1/html/Search/Elements/PickBasics	(original)
+++ rt/branches/rt-3.1/html/Search/Elements/PickBasics	Mon Jul 12 14:00:53 2004
@@ -128,26 +128,15 @@
 <& /Elements/SelectMatch, Name => "WatcherOp" &>
 </td><td>
 <Input Name="ValueOfWatcher" Size=20>
-% } elsif ($field eq 'WatcherGroup') {
-<& SelectPersonType, Name => 'WatcherGroupField', Default => 'RequestorGroup', Suffix => 'Group' &>
-</td><td>
-<& /Elements/SelectBoolean, Name => "WatcherGroupOp", 
-					  True=> 'belongs to', 
-					  False=> 'does not belong to', 
-					  TrueVal=> '=', 
-					  FalseVal => '!='
-&>
-</td><td>
-<& SelectGroup, Name => 'ValueOfWatcherGroup' &>
 % } else {
-<% loc($field) %>
+<&|/l&><%$field%></&>
 <& /Elements/SelectMatch, Name => "$field" . "Op" &>
 <INPUT Name="<%"ValueOf" . $field%>" value=""SIZE=20>
 % }
 </td></tr>
 % }
 % } else {
-<% loc($field) %>
+<&|/l&><%$field%></&>
 </td><td>
 <& /Elements/SelectMatch, Name => "$field" . "Op" &>
 </td><td>
@@ -171,6 +160,5 @@
 
 my @people = ('Actor',
 	      'Watcher',
-	      'WatcherGroup',
 	      );
 </%INIT>

Modified: rt/branches/rt-3.1/html/Search/Elements/PickCFs
==============================================================================
--- rt/branches/rt-3.1/html/Search/Elements/PickCFs	(original)
+++ rt/branches/rt-3.1/html/Search/Elements/PickCFs	Mon Jul 12 14:00:53 2004
@@ -24,7 +24,14 @@
 <table cellspacing=0 border=0>
 % while ( my $CustomField = $CustomFields->Next ) {
 <tr><td>
-% my $name = "'CF." . $CustomField->Name . "'";
+
+% my $name;
+% if ($CustomField->QueueObj->id) {
+%   $name = "'CF." . $CustomField->QueueObj->Name . 
+%	".{" . $CustomField->Name . "}'";
+% } else {
+%   $name = "'CF." . $CustomField->Name . "'";
+% }
 <% $CustomField->Name %> 
         <& /Elements/SelectCustomFieldOperator, Name => $name . "Op", 
                                     True => loc("is"), 
@@ -40,9 +47,10 @@
 
 <%INIT>
 my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'});
-foreach my $id (keys %cfqueues) {
+foreach (keys %cfqueues) {
+    my $id = $_;
     $id =~ s/^.'*(.*).'*$/$1/;
-    # Gotta load up the $queue object, since queues get stored by name now. my $id
+    # Gotta load up the $queue object, since queues get stored by name now.
     my $queue = RT::Queue->new($session{'CurrentUser'});
     $queue->Load($id);
     $CustomFields->LimitToQueue($queue->Id);

Modified: rt/branches/rt-3.1/html/Search/Elements/SelectPersonType
==============================================================================
--- rt/branches/rt-3.1/html/Search/Elements/SelectPersonType	(original)
+++ rt/branches/rt-3.1/html/Search/Elements/SelectPersonType	Mon Jul 12 14:00:53 2004
@@ -25,15 +25,11 @@
 % if ($AllowNull) {
 <OPTION VALUE="">-</OPTION>
 % }
-% for my $option (@types) {
-%  if ($Suffix) {
-<OPTION VALUE="<% $option %><% $Suffix %>" <%$option eq $Default && "SELECTED"%> ><%loc($option)%></OPTION>
-%   next;
-%  }
-%  foreach my $subtype (@subtypes) {
+%for my $option (@types) {
+%foreach my $subtype (@subtypes) {
 <OPTION VALUE="<%"$option.$subtype"%>" <%$option eq $Default && $subtype eq 'EmailAddress' && "SELECTED"%> ><%loc("[_1] [_2]",$option, $subtype)%></OPTION>
-%  }
 % }
+%}
 </SELECT>
 
 <%INIT>
@@ -41,9 +37,6 @@
 if ($Scope =~ 'queue') {
    @types = qw(Cc AdminCc);
 }
-elsif ($Suffix eq 'Group') {
-   @types = qw(Requestor Cc AdminCc Watcher);
-}
 else { 
    @types = qw(Requestor Cc AdminCc Watcher Owner);
 }
@@ -53,7 +46,6 @@
 </%INIT>
 <%ARGS>
 $AllowNull => 1
-$Suffix => ''
 $Default=>undef
 $Scope => 'ticket'
 $Name => 'WatcherType'

Modified: rt/branches/rt-3.1/html/SelfService/Closed.html
==============================================================================
--- rt/branches/rt-3.1/html/SelfService/Closed.html	(original)
+++ rt/branches/rt-3.1/html/SelfService/Closed.html	Mon Jul 12 14:00:53 2004
@@ -21,7 +21,7 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /SelfService/Elements/Header, Title => loc('Closed tickets') &>
+<& /SelfService/Elements/Header, Title => loc('Closed Tickets') &>
 
 <& /SelfService/Elements/MyRequests, status => ['rejected', 'resolved'], friendly_status =>
 loc('closed') &>

Modified: rt/branches/rt-3.1/html/SelfService/Display.html
==============================================================================
--- rt/branches/rt-3.1/html/SelfService/Display.html	(original)
+++ rt/branches/rt-3.1/html/SelfService/Display.html	Mon Jul 12 14:00:53 2004
@@ -174,7 +174,9 @@
 
 my $Transactions = $Ticket->Transactions;
 
+#!!pape: selfservice_find_attachments.patch {{
 my $attachments = $m->comp('/Ticket/Elements/FindAttachments', Ticket => $Ticket);
+#!!pape: selfservice_find_attachments.patch }}
 
 </%INIT>
 

Modified: rt/branches/rt-3.1/html/Ticket/Create.html
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Create.html	(original)
+++ rt/branches/rt-3.1/html/Ticket/Create.html	Mon Jul 12 14:00:53 2004
@@ -91,14 +91,6 @@
 <& /Ticket/Elements/EditCustomFields, QueueObj => $QueueObj &>
 </TD>
 </TR>
-% if ($TxnCFs->Count) {
-% while (my $CF = $TxnCFs->Next()) {
-<TR>
-<TD ALIGN=RIGHT><% $CF->Name %>:</TD>
-<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
-</TD></TR>
-% }
-% }
 <TR>
 % if (exists $session{'Attachments'}) {
 <TD class=label>
@@ -214,8 +206,7 @@
 
 my $QueueObj = new RT::Queue($session{'CurrentUser'});
 $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
-my $CFs = $QueueObj->TicketCustomFields();
-my $TxnCFs = $QueueObj->TicketTransactionCustomFields();
+my $CFs = $QueueObj->CustomFields();
 
 # if no due date has been set explicitly, then use the
 # queue's default if it exists

Modified: rt/branches/rt-3.1/html/Ticket/Elements/EditCustomFields
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/EditCustomFields	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/EditCustomFields	Mon Jul 12 14:00:53 2004
@@ -44,7 +44,7 @@
       <b><%$CustomField->Name%></b><br>
       <i><%$CustomField->FriendlyType%></i>
     </td>
-    <td class="entry"><& /Elements/EditCustomField, Object => $TicketObj, CustomField => $CustomField, NamePrefix => $NamePrefix &></td>
+    <td class="entry"><& EditCustomField, TicketObj => $TicketObj, CustomField => $CustomField, NamePrefix => $NamePrefix &></td>
   </tr>
 % }
 </table>
@@ -57,12 +57,12 @@
 my $NamePrefix;
 
 if ($TicketObj) {
- $CustomFields = $TicketObj->CustomFields();
-  $NamePrefix = "Object-RT::Ticket-".$TicketObj->Id."-CustomField-";
+ $CustomFields = $TicketObj->QueueObj->CustomFields();
+  $NamePrefix = "Ticket-".$TicketObj->Id."-CustomField-";
 
 } else {
- $CustomFields = $QueueObj->TicketCustomFields();
-  $NamePrefix = "Object-RT::Ticket--CustomField-";
+ $CustomFields = $QueueObj->CustomFields();
+  $NamePrefix = "CustomField-";
 }
 
 

Modified: rt/branches/rt-3.1/html/Ticket/Elements/EditPeople
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/EditPeople	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/EditPeople	Mon Jul 12 14:00:53 2004
@@ -30,7 +30,7 @@
 <& /Elements/SelectUsers &>
 <input type=submit name="OnlySearchForPeople" value="<&|/l&>Go!</&>">
 <BR>
-<&|/l&>Find groups whose</&><BR>
+<&|/l&>Find group whose</&><BR>
 <& /Elements/SelectGroups &>
 <input type=submit name="OnlySearchForGroup" value="<&|/l&>Go!</&>">
 

Modified: rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/FindAttachments	Mon Jul 12 14:00:53 2004
@@ -18,14 +18,11 @@
     
 my $tickets = $attachments->NewAlias('Tickets');
 
-  $attachments->Join( ALIAS1 => $transactions,                         
-                        FIELD1 => 'ObjectId',
-                        ALIAS2 => $tickets,
-                        FIELD2 => 'id' );
-    
-    $attachments->Limit( ALIAS => $transactions,
-                         FIELD => 'ObjectType',
-                        VALUE => 'RT::Ticket');
+$attachments->Join( ALIAS1 => $transactions,
+		    FIELD1 => 'Ticket',
+		    ALIAS2 => $tickets,
+		    FIELD2 => 'id' );
+
 if ($Tickets) {
     while ($Ticket = $Tickets->Next) {
 	$attachments->Limit( ALIAS => $tickets,

Modified: rt/branches/rt-3.1/html/Ticket/Elements/LoadTextAttachments
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/LoadTextAttachments	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/LoadTextAttachments	Mon Jul 12 14:00:53 2004
@@ -13,17 +13,11 @@
     
     my $tickets = $attachments->NewAlias('Tickets');
 
-
     $attachments->Join( ALIAS1 => $transactions,
-                        FIELD1 => 'ObjectId',
+                        FIELD1 => 'Ticket',
                         ALIAS2 => $tickets,
                         FIELD2 => 'id' );
 
-    $attachments->Limit( ALIAS => $transactions,
-                         FIELD => 'ObjectType',
-                        VALUE => 'RT::Ticket');
-
-
     $attachments->Limit( ALIAS => $tickets,
                          FIELD => 'EffectiveId',
                          VALUE => $Ticket->id() );

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowCustomFields
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowCustomFields	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowCustomFields	Mon Jul 12 14:00:53 2004
@@ -21,7 +21,26 @@
 %# 
 %# 
 %# END LICENSE BLOCK
-<& /Elements/ShowCustomFields, Object => $Ticket &>
+<table>
+% my @entry_fields;
+% while (my $CustomField = $CustomFields->Next()) {
+% my $Values = $Ticket->CustomFieldValues($CustomField->Id);
+  <tr>
+    <td class="label"><%$CustomField->Name%>:</td>
+    <td class="value">
+% while (my $Value = $Values->Next()) {
+<%$Value->Content%><br>        
+% }
+% unless ($Values->Count()) {
+<i><&|/l&>(no value)</&></i>
+% }
+    </td>
+  </tr>
+% }
+</table>
+<%INIT>
+my $CustomFields = $Ticket->QueueObj->CustomFields();
+</%INIT>
 <%ARGS>
 $Ticket => undef
 </%ARGS>

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowRequestor
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowRequestor	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowRequestor	Mon Jul 12 14:00:53 2004
@@ -51,11 +51,6 @@
 <LI><a href="<%$RT::WebPath%><%$DisplayPath%>?id=<%$w->id%>"><%$w->Id%>: <%$w->Subject%></a> (<%$w->Status%>)
 %}
 </UL>
-
-<&|/l&>Groups this user belongs to</&>:<BR>
-
-<& /Elements/ShowMemberships, UserObj => $requestor &>
-
 <& /Elements/TitleBoxEnd &>
 
 % }

Modified: rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction	(original)
+++ rt/branches/rt-3.1/html/Ticket/Elements/ShowTransaction	Mon Jul 12 14:00:53 2004
@@ -34,9 +34,6 @@
 <TD ALIGN="RIGHT"><font size=-1><%$titlebar_commands|n%></font></TD>
 </TR>
 <TR class="<% $RowNum%2 ? 'oddline' : 'evenline'%>"><TD colspan=5>
-% if ($Transaction->CustomFieldValues->Count) {
-<& /Elements/ShowCustomFields, Object => $Transaction &>
-% }
 % $m->comp('ShowTransactionAttachments', %ARGS, Parent => 0) unless ($Collapsed ||!$ShowBody);
 </TD>
 </TR>

Modified: rt/branches/rt-3.1/html/Ticket/Modify.html
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Modify.html	(original)
+++ rt/branches/rt-3.1/html/Ticket/Modify.html	Mon Jul 12 14:00:53 2004
@@ -27,7 +27,7 @@
     Title => loc('Modify ticket #[_1]', $TicketObj->Id) &>
 
 <& /Elements/ListActions, actions => \@results &>
-<FORM METHOD=POST ACTION="Modify.html" ENCTYPE="multipart/form-data">
+<FORM METHOD=POST ACTION="Modify.html">
 <INPUT TYPE=HIDDEN NAME=id VALUE="<%$TicketObj->Id%>">
 
 <& /Elements/TitleBoxStart, title => loc('Modify ticket #[_1]',$TicketObj->Id),   color=> "#993333", width => "100%" &>
@@ -46,7 +46,7 @@
 $m->comp('/Elements/Callback', TicketObj => $TicketObj, CustomFields => $CustomFields, %ARGS);
 
 my @results = ProcessTicketBasics(TicketObj => $TicketObj, ARGSRef => \%ARGS);
-my @cf_results = ProcessObjectCustomFieldUpdates(Object => $TicketObj, ARGSRef => \%ARGS);
+my @cf_results = ProcessTicketCustomFieldUpdates(TicketObj => $TicketObj, ARGSRef => \%ARGS);
 push (@results, @cf_results);
 
 # TODO: display the results, even if we can't display the ticket

Modified: rt/branches/rt-3.1/html/Ticket/ModifyAll.html
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/ModifyAll.html	(original)
+++ rt/branches/rt-3.1/html/Ticket/ModifyAll.html	Mon Jul 12 14:00:53 2004
@@ -78,14 +78,6 @@
     <td class="label"><&|/l&>Subject</&>:</td>
     <td class="entry"><input name="UpdateSubject" size=60 value="<%$Ticket->Subject%>"></td>
   </tr>
-% if (my $TxnCFs = $Ticket->TransactionCustomFields) {
-%    while (my $CF = $TxnCFs->Next()) {
-<TR>
-<TD class="label"><% $CF->Name %>:</TD>
-<TD class="entry"><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
-</TD></TR>
-%    } # end if while
-% } # end of if
   <tr>
     <td class="label"><&|/l&>Attach</&>:</td>
     <td class="entry"><input name="UpdateAttachment" type=file></td>
@@ -123,7 +115,7 @@
 unless ($OnlySearchForPeople) {
     @wresults = ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS);
     @results = ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS);
- @cf_results = ProcessObjectCustomFieldUpdates( Object => $Ticket, ARGSRef => \%ARGS);
+ @cf_results = ProcessTicketCustomFieldUpdates( TicketObj => $Ticket, ARGSRef => \%ARGS);
     @dresults = ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
     @lresults = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);
 

Modified: rt/branches/rt-3.1/html/Ticket/Update.html
==============================================================================
--- rt/branches/rt-3.1/html/Ticket/Update.html	(original)
+++ rt/branches/rt-3.1/html/Ticket/Update.html	Mon Jul 12 14:00:53 2004
@@ -78,16 +78,6 @@
 </TR>
 <TR>
 % } # end of if
-
-% if (my $TxnCFs = $TicketObj->TransactionCustomFields) {
-%    while (my $CF = $TxnCFs->Next()) {
-<TR>
-<TD ALIGN=RIGHT><% $CF->Name %>:</TD>
-<TD><& /Elements/EditCustomField, CustomField => $CF, NamePrefix => "TransactionCustomField-" &><em><% $CF->FriendlyType %></em></TD>
-</TD></TR>
-%    } # end if while
-% } # end of if
-
 <tr><td align=right><&|/l&>Attach</&>:</td><td><input name="Attach" type="file"><INPUT TYPE=SUBMIT NAME="AddMoreAttach" VALUE="<&|/l&>Add More Files</&>"><input type="hidden" name="UpdateAttach" value="1">
 </td></tr>
 <tr><td align="right" valign="top"><&|/l&>Message</&>:</td><td>
@@ -188,7 +178,6 @@
     $m->comp('Display.html', TicketObj => $TicketObj, %ARGS);
     return;
 }
-
 </%INIT>
 
 <%ARGS>

Modified: rt/branches/rt-3.1/html/User/Prefs.html
==============================================================================
--- rt/branches/rt-3.1/html/User/Prefs.html	(original)
+++ rt/branches/rt-3.1/html/User/Prefs.html	Mon Jul 12 14:00:53 2004
@@ -188,10 +188,9 @@
 					    Object => $UserObj,
 					    ARGSRef => \%ARGS );
     if ($Lang) {
-	$session{'CurrentUser'}->LanguageHandle($Lang);
-	$session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
+        $session{'CurrentUser'}->LanguageHandle($Lang);
+        $session{'CurrentUser'}= $session{'CurrentUser'}; # Force writeback
     }
-
     push (@results, at fieldresults);
 
 

Modified: rt/branches/rt-3.1/html/autohandler
==============================================================================
--- rt/branches/rt-3.1/html/autohandler	(original)
+++ rt/branches/rt-3.1/html/autohandler	Mon Jul 12 14:00:53 2004
@@ -147,7 +147,7 @@
     elsif ($RT::WebFallbackToInternalAuth) {
   	unless (defined($session{'CurrentUser'})) {
 	        $m->comp('/Elements/Login', %ARGS,
-                         Error=> loc('You are not an authorized user'));
+                         Error=> loc('XXX CHANGEME You are not an authorized user'));
                 $m->abort();
 	}
     } else {

Modified: rt/branches/rt-3.1/lib/RT.pm.in
==============================================================================
--- rt/branches/rt-3.1/lib/RT.pm.in	(original)
+++ rt/branches/rt-3.1/lib/RT.pm.in	Mon Jul 12 14:00:53 2004
@@ -131,8 +131,7 @@
   
     $System = RT::System->new();
 
-    InitClasses();
-    InitLogging(); 
+   InitLogging(); 
 }
 
   
@@ -268,29 +267,6 @@
 
 }
 
-=head2 InitClasses
-
-Load all modules that define base classes
-
-=cut
-sub InitClasses {
-    require RT::Tickets;
-    require RT::Transactions;
-    require RT::Users;
-    require RT::CurrentUser;
-    require RT::Templates;
-    require RT::Queues;
-    require RT::ScripActions;
-    require RT::ScripConditions;
-    require RT::Scrips;
-    require RT::Groups;
-    require RT::GroupMembers;
-    require RT::CustomFields;
-    require RT::CustomFieldValues;
-    require RT::ObjectCustomFields;
-    require RT::ObjectCustomFieldValues;
-}
-
 # }}}
 
 

Modified: rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Action/CreateTickets.pm	Mon Jul 12 14:00:53 2004
@@ -126,8 +126,8 @@
          push (@admins, $admin->EmailAddress); 
      }
  }
- Queue: ___Approvals
- Type: approval
+ Queue: Approvals
+ Type: Approval
  AdminCc: {join ("\nAdminCc: ", at admins) }
  Depended-On-By: TOP
  Refers-To: TOP
@@ -142,7 +142,7 @@
  Subject: Manager approval
  Depended-On-By: TOP
  Refers-On: {$Tickets{"approval"}->Id}
- Queue: ___Approvals
+ Queue: Approvals
  Content-Type: text/plain
  Content: 
  Your approval is requred for this ticket, too.
@@ -221,8 +221,8 @@
 
 my $approvals = 
 '===Create-Ticket: approval
-Queue: ___Approvals
-Type: approval
+Queue: Approvals
+Type: Approval
 AdminCc: {join ("\nAdminCc: ", at admins) }
 Depended-On-By: {$Tickets{"TOP"}->Id}
 Refers-To: TOP 
@@ -236,7 +236,7 @@
 ===Create-Ticket: two
 Subject: Manager approval.
 Depended-On-By: approval
-Queue: ___Approvals
+Queue: Approvals
 Content-Type: text/plain
 Content: 
 Your minion approved ticket {$Tickets{"TOP"}->Id}. you ok with that?

Modified: rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Attachment_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -212,7 +212,26 @@
 
 sub Content {
   my $self = shift;
-   $self->_DecodeLOB($self->ContentType, $self->ContentEncoding, $self->_Value('Content', decode_utf8 => 0));
+  my $decode_utf8 = (($self->ContentType =~ qr{^text/plain}i) ? 1 : 0);
+
+  if ( $self->ContentEncoding eq 'none' || ! $self->ContentEncoding ) {
+      return $self->_Value(
+	  'Content',
+	  decode_utf8 => $decode_utf8,
+      );
+  } elsif ( $self->ContentEncoding eq 'base64' ) {
+      return ( $decode_utf8
+        ? Encode::decode_utf8(MIME::Base64::decode_base64($self->_Value('Content')))
+        : MIME::Base64::decode_base64($self->_Value('Content'))
+      );
+  } elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
+      return ( $decode_utf8
+        ? Encode::decode_utf8(MIME::QuotedPrint::decode($self->_Value('Content')))
+        : MIME::QuotedPrint::decode($self->_Value('Content'))
+      );
+  } else {
+      return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
+  }
 }
 
 

Modified: rt/branches/rt-3.1/lib/RT/Base.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Base.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Base.pm	Mon Jul 12 14:00:53 2004
@@ -103,18 +103,6 @@
     }
 }
 
-sub loc_fuzzy {
-    my $self = shift;
-    if (my $user = $self->OriginalUser) {
-        return $user->loc_fuzzy(@_);
-    }
-    else {
-        use Carp;
-        Carp::confess("No currentuser");
-        return ("Critical error:$self has no CurrentUser", $self);
-    }
-}
-
 eval "require RT::Base_Vendor";
 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Base_Vendor.pm});
 eval "require RT::Base_Local";

Modified: rt/branches/rt-3.1/lib/RT/CurrentUser.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/CurrentUser.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/CurrentUser.pm	Mon Jul 12 14:00:53 2004
@@ -328,12 +328,12 @@
 =begin testing
 
 ok (my $cu = RT::CurrentUser->new('root'));
-ok (my $lh = $cu->LanguageHandle('en-us'));
+ok (my $lh = $cu->LanguageHandle);
 ok ($lh != undef);
 ok ($lh->isa('Locale::Maketext'));
-is ($cu->loc('TEST_STRING'), "Concrete Mixer", "Localized TEST_STRING into English");
+ok ($cu->loc('TEST_STRING') eq "Concrete Mixer", "Localized TEST_STRING into English");
 ok ($lh = $cu->LanguageHandle('fr'));
-is ($cu->loc('Before'), "Avant", "Localized TEST_STRING into Frenc");
+ok ($cu->loc('Before') eq "Avant", "Localized TEST_STRING into Frenc");
 
 =end testing
 
@@ -401,48 +401,6 @@
 
 }
 
-=head2 Authenticate
-
-Takes $password, $created and $nonce, and returns a boolean value
-representing whether the authentication succeeded.
-
-If both $nonce and $created are specified, validate $password against:
-
-    encode_base64(sha1(
-	$nonce .
-	$created .
-	sha1_hex( "$username:$realm:$server_pass" )
-    ))
-
-where $server_pass is the md5_hex(password) digest stored in the
-database, $created is in ISO time format, and $nonce is a random
-string no longer than 32 bytes.
-
-=cut
-
-sub Authenticate { 
-    my ($self, $password, $created, $nonce, $realm) = @_;
-
-    require Digest::MD5;
-    require Digest::SHA1;
-    require MIME::Base64;
-
-    my $username = $self->UserObj->Name or return;
-    my $server_pass = $self->UserObj->__Value('Password') or return;
-    my $auth_digest = MIME::Base64::encode_base64(Digest::SHA1::sha1(
-	$nonce .
-	$created .
-	Digest::MD5::md5_hex("$username:$realm:$server_pass")
-    ));
-
-    chomp($password);
-    chomp($auth_digest);
-
-    return ($password eq $auth_digest);
-}
-
-# }}}
-
 
 eval "require RT::CurrentUser_Vendor";
 die $@ if ($@ && $@ !~ qr{^Can't locate RT/CurrentUser_Vendor.pm});

Modified: rt/branches/rt-3.1/lib/RT/CustomField.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/CustomField.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/CustomField.pm	Mon Jul 12 14:00:53 2004
@@ -46,6 +46,7 @@
 
 package RT::CustomField;
 use RT::Record; 
+use RT::Queue;
 
 
 use vars qw( @ISA );
@@ -68,12 +69,9 @@
 
   varchar(200) 'Name'.
   varchar(200) 'Type'.
-  int(11) 'MaxValues'.
-  varchar(255) 'Pattern'.
-  smallint(6) 'Repeated'.
+  int(11) 'Queue'.
   varchar(255) 'Description'.
   int(11) 'SortOrder'.
-  varchar(255) 'LookupType'.
   smallint(6) 'Disabled'.
 
 =cut
@@ -86,24 +84,18 @@
     my %args = ( 
                 Name => '',
                 Type => '',
-                MaxValues => '',
-                Pattern => '',
-                Repeated => '0',
+                Queue => '0',
                 Description => '',
                 SortOrder => '0',
-                LookupType => '',
                 Disabled => '0',
 
 		  @_);
     $self->SUPER::Create(
                          Name => $args{'Name'},
                          Type => $args{'Type'},
-                         MaxValues => $args{'MaxValues'},
-                         Pattern => $args{'Pattern'},
-                         Repeated => $args{'Repeated'},
+                         Queue => $args{'Queue'},
                          Description => $args{'Description'},
                          SortOrder => $args{'SortOrder'},
-                         LookupType => $args{'LookupType'},
                          Disabled => $args{'Disabled'},
 );
 
@@ -156,59 +148,37 @@
 =cut
 
 
-=head2 MaxValues
+=head2 Queue
 
-Returns the current value of MaxValues. 
-(In the database, MaxValues is stored as int(11).)
+Returns the current value of Queue. 
+(In the database, Queue is stored as int(11).)
 
 
 
-=head2 SetMaxValues VALUE
+=head2 SetQueue VALUE
 
 
-Set MaxValues to VALUE. 
+Set Queue to VALUE. 
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, MaxValues will be stored as a int(11).)
+(In the database, Queue will be stored as a int(11).)
 
 
 =cut
 
 
-=head2 Pattern
+=head2 QueueObj
 
-Returns the current value of Pattern. 
-(In the database, Pattern is stored as varchar(255).)
-
-
-
-=head2 SetPattern VALUE
-
-
-Set Pattern to VALUE. 
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, Pattern will be stored as a varchar(255).)
-
-
-=cut
-
-
-=head2 Repeated
-
-Returns the current value of Repeated. 
-(In the database, Repeated is stored as smallint(6).)
-
-
-
-=head2 SetRepeated VALUE
-
-
-Set Repeated to VALUE. 
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, Repeated will be stored as a smallint(6).)
+Returns the Queue Object which has the id returned by Queue
 
 
 =cut
 
+sub QueueObj {
+	my $self = shift;
+	my $Queue =  RT::Queue->new($self->CurrentUser);
+	$Queue->Load($self->__Value('Queue'));
+	return($Queue);
+}
 
 =head2 Description
 
@@ -246,24 +216,6 @@
 =cut
 
 
-=head2 LookupType
-
-Returns the current value of LookupType. 
-(In the database, LookupType is stored as varchar(255).)
-
-
-
-=head2 SetLookupType VALUE
-
-
-Set LookupType to VALUE. 
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, LookupType will be stored as a varchar(255).)
-
-
-=cut
-
-
 =head2 Creator
 
 Returns the current value of Creator. 
@@ -328,18 +280,12 @@
 		{read => 1, write => 1, type => 'varchar(200)', default => ''},
         Type => 
 		{read => 1, write => 1, type => 'varchar(200)', default => ''},
-        MaxValues => 
-		{read => 1, write => 1, type => 'int(11)', default => ''},
-        Pattern => 
-		{read => 1, write => 1, type => 'varchar(255)', default => ''},
-        Repeated => 
-		{read => 1, write => 1, type => 'smallint(6)', default => '0'},
+        Queue => 
+		{read => 1, write => 1, type => 'int(11)', default => '0'},
         Description => 
 		{read => 1, write => 1, type => 'varchar(255)', default => ''},
         SortOrder => 
 		{read => 1, write => 1, type => 'int(11)', default => '0'},
-        LookupType => 
-		{read => 1, write => 1, type => 'varchar(255)', default => ''},
         Creator => 
 		{read => 1, auto => 1, type => 'int(11)', default => '0'},
         Created => 

Modified: rt/branches/rt-3.1/lib/RT/CustomField_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/CustomField_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/CustomField_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -24,47 +24,24 @@
 use strict;
 no warnings qw(redefine);
 
-use vars qw(@TYPES %TYPES $RIGHTS %FRIENDLY_OBJECT_TYPES);
+use vars qw(@TYPES %TYPES);
 
 use RT::CustomFieldValues;
-use RT::ObjectCustomFieldValues;
+use RT::TicketCustomFieldValues;
 
 # Enumerate all valid types for this custom field
 @TYPES = (
-    'Freeform',	# loc
-    'Select',	# loc
-    'Text',     # loc
-    'Image',    # loc
-    'Binary',   # loc
+    'SelectSingle',	# loc
+    'SelectMultiple',	# loc
+    'FreeformSingle',	# loc
+    'FreeformMultiple', # loc
 );
 
 # Populate a hash of types of easier validation
 for (@TYPES) { $TYPES{$_} = 1};
 
 
-%FRIENDLY_OBJECT_TYPES =  (
-    'RT::Queue-RT::Ticket'                 => "Tickets",		# loc
-    'RT::Queue-RT::Ticket-RT::Transaction' => "Ticket Transactions",	# loc
-    'RT::User'                             => "Users",			# loc
-    'RT::Group'                            => "Groups",			# loc
-);
-
-$RIGHTS = {
-    SeeCustomField            => 'See custom fields',       # loc_pair
-    AdminCustomField          => 'Create, delete and modify custom fields',        # loc_pair
-};
-
-# Tell RT::ACE that this sort of object can get acls granted
-$RT::ACE::OBJECT_TYPES{'RT::CustomField'} = 1;
-
-foreach my $right ( keys %{$RIGHTS} ) {
-    $RT::ACE::LOWERCASERIGHTNAMES{ lc $right } = $right;
-}
 
-sub AvailableRights {
-    my $self = shift;
-    return($RIGHTS);
-}
 
 =head1 NAME
 
@@ -84,8 +61,7 @@
 
   varchar(200) 'Name'.
   varchar(200) 'Type'.
-  int(11) 'MaxValues'.
-  varchar(255) 'Pattern'.
+  int(11) 'Queue'.
   varchar(255) 'Description'.
   int(11) 'SortOrder'.
   smallint(6) 'Disabled'.
@@ -100,31 +76,19 @@
     my %args = ( 
                 Name => '',
                 Type => '',
-		MaxValues => '0',
-		Pattern  => '',
+                Queue => '0',
                 Description => '',
+                SortOrder => '0',
                 Disabled => '0',
-		LookupType  => '',
-		Repeated  => '0',
 
 		  @_);
 
-    if ($args{TypeComposite}) {
-	@args{'Type', 'MaxValues'} = split(/-/, $args{TypeComposite}, 2);
-    }
-    elsif ($args{Type} =~ s/(?:(Single)|Multiple)$//) {
-	# old style Type string
-	$args{'MaxValues'} = $1 ? 1 : 0;
-    }
     
-    if ( !exists $args{'Queue'}) {
-	# do nothing -- things below are strictly backward compat
-    }
-    elsif (  ! $args{'Queue'} ) {
-        unless ( $self->CurrentUser->HasRight( Object => $RT::System, Right => 'AssignCustomFields') ) {
+
+    if (  ! $args{'Queue'} ) {
+        unless ( $self->CurrentUser->HasRight( Object => $RT::System, Right => 'AdminCustomFields') ) {
             return ( 0, $self->loc('Permission Denied') );
         }
-	$args{'LookupType'} = 'RT::Queue-RT::Ticket';
     }
     else {
         my $queue = RT::Queue->new($self->CurrentUser);
@@ -132,32 +96,19 @@
         unless ($queue->Id) {
             return (0, $self->loc("Queue not found"));
         }
-        unless ( $queue->CurrentUserHasRight('AssignCustomFields') ) {
+        unless ( $queue->CurrentUserHasRight('AdminCustomFields') ) {
             return ( 0, $self->loc('Permission Denied') );
         }
-	$args{'LookupType'} = 'RT::Queue-RT::Ticket';
     }
-    my $rv = $self->SUPER::Create(
+    $self->SUPER::Create(
                          Name => $args{'Name'},
                          Type => $args{'Type'},
-                         MaxValues => $args{'MaxValues'},
-                         Pattern  => $args{'Pattern'},
+                         Queue => $args{'Queue'},
                          Description => $args{'Description'},
+                         SortOrder => $args{'SortOrder'},
                          Disabled => $args{'Disabled'},
-			 LookupType => $args{'LookupType'},
-			 Repeated => $args{'Repeated'},
 );
 
-    return $rv unless exists $args{'Queue'};
-
-    # Compat code -- create a new ObjectCustomField mapping
-    my $OCF = RT::ObjectCustomField->new($self->CurrentUser);
-    $OCF->Create(
-	CustomField => $self->Id,
-	ObjectId => $args{'Queue'},
-    );
-
-    return $rv;
 }
 
 
@@ -187,15 +138,7 @@
 	$args{'Queue'} = $QueueObj->Id;
     }
 
-    # XXX - really naive implementation.  Slow.
-
-    my $CFs = RT::CustomFields->new($self->CurrentUser);
-    $CFs->Limit( FIELD => 'Name', VALUE => $args{'Name'} );
-    $CFs->LimitToQueue( $args{'Queue'} );
-    $CFs->RowsPerPage(1);
-
-    my $CF = $CFs->First or return;
-    return $self->Load($CF->Id);
+    return ( $self->LoadByCols( Name => $args{'Name'}, Queue => $args{'Queue'} ) );
 
 }
 
@@ -213,12 +156,10 @@
                                  Type=> 'SelectSingle'), 'Created a global CustomField');
 ok($id != 0, 'Global custom field correctly created');
 ok ($cf->SingleValue);
-is($cf->Type, 'Select');
-is($cf->MaxValues, 1);
+ok($cf->Type eq 'SelectSingle');
 
 ok($cf->SetType('SelectMultiple'));
-is($cf->Type, 'Select');
-is($cf->MaxValues, 0);
+ok($cf->Type eq 'SelectMultiple');
 ok(!$cf->SingleValue );
 ok(my ($bogus_val, $bogus_msg) = $cf->SetType('BogusType') , "Trying to set a custom field's type to a bogus type");
 ok($bogus_val == 0, "Unable to set a custom field's type to a bogus type");
@@ -262,7 +203,7 @@
 		     SortOrder => undef,
 		     @_ );
 
-    unless ($self->CurrentUserHasRight('AdminCustomField')) {
+    unless ($self->CurrentUserHasRight('AdminCustomFields')) {
         return (0, $self->loc('Permission Denied'));
     }
 
@@ -294,7 +235,7 @@
 sub DeleteValue {
 	my $self = shift;
     my $id = shift;
-    unless ($self->CurrentUserHasRight('AdminCustomField')) {
+    unless ($self->CurrentUserHasRight('AdminCustomFields')) {
         return (0, $self->loc('Permission Denied'));
     }
 
@@ -330,17 +271,12 @@
     my $self = shift;
 
     my $cf_values = RT::CustomFieldValues->new($self->CurrentUser);
-    if ( $self->CurrentUserHasRight( 'SeeCustomField') ) {
+    if ( $self->__Value('Queue') == 0 || $self->CurrentUserHasRight( 'SeeQueue') ) {
         $cf_values->LimitToCustomField($self->Id);
     }
     return ($cf_values);
 }
 
-sub ValuesObj {
-    my $self = shift;
-    return $self->Values(@_);
-}
-
 # }}}
 
 # }}}
@@ -351,7 +287,7 @@
 
 =head2 ValuesForTicket TICKET
 
-Returns a RT::ObjectCustomFieldValues object of this Field's values for TICKET.
+Returns a RT::TicketCustomFieldValues object of this Field's values for TICKET.
 TICKET is a ticket id.
 
 
@@ -361,7 +297,7 @@
 	my $self = shift;
     my $ticket_id = shift;
 
-	my $values = new RT::ObjectCustomFieldValues($self->CurrentUser);
+	my $values = new RT::TicketCustomFieldValues($self->CurrentUser);
 	$values->LimitToCustomField($self->Id);
     $values->LimitToTicket($ticket_id);
 
@@ -384,9 +320,8 @@
                  Content => undef,
 		     @_ );
 
-	my $newval = RT::ObjectCustomFieldValue->new($self->CurrentUser);
-	my $val = $newval->Create(ObjectType => 'RT::Ticket',
-	                    ObjectId => $args{'Ticket'},
+	my $newval = RT::TicketCustomFieldValue->new($self->CurrentUser);
+	my $val = $newval->Create(Ticket => $args{'Ticket'},
                             Content => $args{'Content'},
                             CustomField => $self->Id);
 
@@ -411,7 +346,7 @@
                  Content => undef,
 		     @_ );
 
-	my $oldval = RT::ObjectCustomFieldValue->new($self->CurrentUser);
+	my $oldval = RT::TicketCustomFieldValue->new($self->CurrentUser);
     $oldval->LoadByTicketContentAndCustomField (Ticket => $args{'Ticket'}, 
                                                 Content =>  $args{'Content'}, 
                                                 CustomField => $self->Id );
@@ -473,61 +408,35 @@
 # }}}
 
 
-=head2 FriendlyType [TYPE, MAX_VALUES]
+=head2 FriendlyType [TYPE]
 
 Returns a localized human-readable version of the custom field type.
 If a custom field type is specified as the parameter, the friendly type for that type will be returned
 
 =cut
 
-my %FriendlyTypes = (
-    Select => [
-        'Select multiple values',	# loc
-        'Select one value',		# loc
-        'Select up to [_1] values',	# loc
-    ],
-    Freeform => [
-        'Enter multiple values',	# loc
-        'Enter one value',		# loc
-        'Enter up to [_1] values',	# loc
-    ],
-    Text => [
-        'Fill in multiple text areas',	# loc
-        'Fill in one text area',	# loc
-        'Fill in up to [_1] text areas',# loc
-    ],
-    Image => [
-        'Upload multiple images',	# loc
-        'Upload one image',		# loc
-        'Upload up to [_1] images',	# loc
-    ],
-    Binary => [
-        'Upload multiple files',	# loc
-        'Upload one file',		# loc
-        'Upload up to [_1] files',	# loc
-    ],
-);
-
 sub FriendlyType {
     my $self = shift;
 
-    my $type = @_ ? shift : $self->Type;
-    my $max  = @_ ? shift : $self->MaxValues;
+    my $type = shift || $self->Type;
 
-    if (my $friendly_type = $FriendlyTypes{$type}[$max>2 ? 2 : $max]) {
-	return ( $self->loc( $friendly_type, $max ) );
+    if ( $type eq 'SelectSingle' ) {
+        return ( $self->loc('Select one value') );
+    }
+    elsif ( $type eq 'SelectMultiple' ) {
+        return ( $self->loc('Select multiple values') );
+    }
+    elsif ( $type eq 'FreeformSingle' ) {
+        return ( $self->loc('Enter one value') );
+    }
+    elsif ( $type eq 'FreeformMultiple' ) {
+        return ( $self->loc('Enter multiple values') );
     }
     else {
-        return ( $self->loc( $type ) );
+        return ( $self->loc( $self->Type ) );
     }
 }
 
-sub FriendlyTypeComposite {
-    my $self = shift;
-    my $composite = shift || $self->TypeComposite;
-    return $self->FriendlyType(split(/-/, $composite, 2));
-}
-
 
 =head2 ValidateType TYPE
 
@@ -549,10 +458,6 @@
     my $self = shift;
     my $type = shift;
 
-    if ($type =~ s/(?:Single|Multiple)$//) {
-	warn "Prefix 'Single' and 'Multiple' to Type deprecated, use MaxValues instead";
-    }
-
     if( $TYPES{$type}) {
         return(1);
     }
@@ -561,17 +466,6 @@
     }
 }
 
-
-sub SetType {
-    my $self = shift;
-    my $type = shift;
-    if ($type =~ s/(?:(Single)|Multiple)$//) {
-	warn "'Single' and 'Multiple' on SetType deprecated, use SetMaxValues instead";
-	$self->SetMaxValues($1 ? 1 : 0);
-    }
-    $self->SUPER::SetType($type);
-}
-
 # {{{ SingleValue
 
 =head2 SingleValue
@@ -583,17 +477,7 @@
 
 sub SingleValue {
     my $self = shift;
-    if ($self->MaxValues == 1) {
-        return 1;
-    } 
-    else {
-        return undef;
-    }
-}
-
-sub UnlimitedValues {
-    my $self = shift;
-    if ($self->MaxValues == 0) {
+    if ($self->Type =~  /Single$/) {
         return 1;
     } 
     else {
@@ -612,13 +496,14 @@
 =cut
 
 sub CurrentUserHasRight {
-    my $self  = shift;
+    my $self = shift;
     my $right = shift;
-
-    return $self->CurrentUser->HasRight(
-	Object => $self,
-	Right  => $right,
-    );
+    # if there's no queue, we want to know about a global right
+    if ( ( !defined $self->__Value('Queue') ) || ( $self->__Value('Queue') == 0 ) ) {
+         return $self->CurrentUser->HasRight( Object => $RT::System, Right => $right); 
+    } else {
+        return ( $self->QueueObj->CurrentUserHasRight($right) );
+    }
 }
 
 # }}}
@@ -628,7 +513,7 @@
 sub _Set {
     my $self = shift;
 
-    unless ( $self->CurrentUserHasRight('AdminCustomField') ) {
+    unless ( $self->CurrentUserHasRight('AdminCustomFields') ) {
         return ( 0, $self->loc('Permission Denied') );
     }
     return ( $self->SUPER::_Set(@_) );
@@ -651,10 +536,16 @@
     my $self  = shift;
     my $field = shift;
 
-    # we need to do the rights check
-    unless ( $self->CurrentUserHasRight( 'SeeCustomField') ) {
-	return (undef);
-    }
+    # We need to expose the queue so that we can do things like ACL checks
+    if ( $field eq 'Queue') {
+          return ( $self->SUPER::_Value($field) );
+     }
+
+
+    #Anybody can see global custom fields, otherwise we need to do the rights check
+        unless ( $self->__Value('Queue') == 0 || $self->CurrentUserHasRight( 'SeeQueue') ) {
+            return (undef);
+        }
     return ( $self->__Value($field) );
 
 }
@@ -672,212 +563,4 @@
 
 # }}}
 
-sub Queue {
-    return 0;
-}
-
-sub SetQueue {
-    return 0;
-}
-
-sub QueueObj {
-    return undef;
-}
-
-sub SetTypeComposite {
-    my $self = shift;
-    my $composite = shift;
-    my ($type, $max_values) = split(/-/, $composite, 2);
-    $self->SetType($type);
-    $self->SetMaxValues($max_values);
-}
-
-sub SetLookupType {
-    my $self = shift;
-    my $lookup = shift;
-    if ($lookup ne $self->LookupType) {
-	# Okay... We need to invalidate our existing relationships
-	my $ObjectCustomFields = RT::ObjectCustomFields->new($self->CurrentUser);
-	$ObjectCustomFields->LimitToCustomField($self->Id);
-	$_->Delete foreach @{$ObjectCustomFields->ItemsArrayRef};
-    }
-    $self->SUPER::SetLookupType($lookup);
-}
-
-sub TypeComposite {
-    my $self = shift;
-    join('-', $self->Type, $self->MaxValues);
-}
-
-sub TypeComposites {
-    my $self = shift;
-    return grep !/Text-0/, map { ("$_-1", "$_-0") } $self->Types;
-}
-
-sub LookupTypes {
-    my $self = shift;
-    qw(
-	RT::Queue-RT::Ticket
-	RT::Queue-RT::Ticket-RT::Transaction
-	RT::User
-	RT::Group
-    );
-}
-
-my @FriendlyObjectTypes = (
-    "[_1] objects",		    # loc
-    "[_1]'s [_2] objects",	    # loc
-    "[_1]'s [_2]'s [_3] objects",   # loc
-);
-
-sub FriendlyLookupType {
-    my $self = shift;
-    my $lookup = shift || $self->LookupType;
-   
-    return ($self->loc( $FRIENDLY_OBJECT_TYPES{$lookup} ))
-      	           if (defined  $FRIENDLY_OBJECT_TYPES{$lookup} );
-
-    my @types = map { s/^RT::// ? $self->loc($_) : $_ }
-      grep { defined and length }
-      split( /-/, $lookup )
-      or return;
-    return ( $self->loc( $FriendlyObjectTypes[$#types], @types ) );
-}
-
-sub AddToObject {
-    my $self  = shift;
-    my $object = shift;
-    my $id = $object->Id || 0;
-
-    unless (index($self->LookupType, ref($object)) == 0) {
-	return ( 0, $self->loc('Lookup type mismatch') );
-    }
-
-    unless ( $object->CurrentUserHasRight('AssignCustomFields') ) {
-        return ( 0, $self->loc('Permission Denied') );
-    }
-
-    my $ObjectCF = RT::ObjectCustomField->new( $self->CurrentUser );
-
-    $ObjectCF->LoadByCols( ObjectId => $id, CustomField => $self->Id );
-    if ( $ObjectCF->Id ) {
-        return ( 0, $self->loc("That is already the current value") );
-    }
-    my ( $id, $msg ) =
-      $ObjectCF->Create( ObjectId => $id, CustomField => $self->Id );
-
-    return ( $id, $msg );
-}
-
-sub RemoveFromObject {
-    my $self = shift;
-    my $object = shift;
-    my $id = $object->Id || 0;
-
-    unless (index($self->LookupType, ref($object)) == 0) {
-	return ( 0, $self->loc('Object type mismatch') );
-    }
-
-    unless ( $object->CurrentUserHasRight('AssignCustomFields') ) {
-        return ( 0, $self->loc('Permission Denied') );
-    }
-
-    my $ObjectCF = RT::ObjectCustomField->new( $self->CurrentUser );
-
-    $ObjectCF->LoadByCols( ObjectId => $id, CustomField => $self->Id );
-    unless ( $ObjectCF->Id ) {
-        return ( 0, $self->loc("This custom field does not apply to that object") );
-    }
-    my ( $id, $msg ) = $ObjectCF->Delete;
-
-    return ( $id, $msg );
-}
-
-# {{{ AddValueForObject
-
-=head2 AddValueForObject HASH
-
-Adds a custom field value for a ticket. Takes a param hash of Object and Content
-
-=cut
-
-sub AddValueForObject {
-	my $self = shift;
-	my %args = ( Object => undef,
-                 Content => undef,
-		 LargeContent => undef,
-		 ContentType => undef,
-		     @_ );
-	my $obj = $args{'Object'} or return;
-
-	my $newval = RT::ObjectCustomFieldValue->new($self->CurrentUser);
-	my $val = $newval->Create(ObjectType => ref($obj),
-	                    ObjectId => $obj->Id,
-                            Content => $args{'Content'},
-                            LargeContent => $args{'LargeContent'},
-                            ContentType => $args{'ContentType'},
-                            CustomField => $self->Id);
-
-    return($val);
-
-}
-
-
-# }}}
-
-# {{{ DeleteValueForObject
-
-=head2 DeleteValueForObject HASH
-
-Adds a custom field value for a ticket. Takes a param hash of Object and Content
-
-=cut
-
-sub DeleteValueForObject {
-    my $self = shift;
-    my %args = ( Object => undef,
-                 Content => undef,
-                 Id => undef,
-		     @_ );
-
-    my $oldval = RT::ObjectCustomFieldValue->new($self->CurrentUser);
-
-    if (my $id = $args{'Id'}) {
-	$oldval->Load($id);
-    }
-    else {
-	$oldval->LoadByObjectContentAndCustomField(
-	    Object => $args{'Object'}, 
-	    Content =>  $args{'Content'}, 
-	    CustomField => $self->Id
-	);
-    }
-
-    # check ot make sure we found it
-    unless ($oldval->Id) {
-        return(0, $self->loc("Custom field value [_1] could not be found for custom field [_2]", $args{'Content'}, $self->Name));
-    }
-    # delete it
-
-    my $ret = $oldval->Delete();
-    unless ($ret) {
-        return(0, $self->loc("Custom field value could not be found"));
-    }
-    return($oldval->Id, $self->loc("Custom field value deleted"));
-}
-
-sub ValuesForObject {
-	my $self = shift;
-    my $object = shift;
-
-	my $values = new RT::ObjectCustomFieldValues($self->CurrentUser);
-	$values->LimitToCustomField($self->Id);
-    $values->LimitToObject($object);
-
-	return ($values);
-}
-
-
-# }}}
-
 1;

Modified: rt/branches/rt-3.1/lib/RT/CustomFields_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/CustomFields_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/CustomFields_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -46,12 +46,6 @@
 no warnings qw(redefine);
 
 
-sub _OCFAlias {
-    my $self = shift;
-    $self->{_sql_ocfalias} ||= $self->NewAlias('ObjectCustomFields');
-}
-
-
 # {{{ sub LimitToGlobalOrQueue 
 
 =item LimitToGlobalOrQueue QUEUEID
@@ -63,8 +57,8 @@
 sub LimitToGlobalOrQueue {
     my $self = shift;
     my $queue = shift;
-    $self->LimitToGlobalOrObjectId( $queue );
-    $self->LimitToLookupType( 'RT::Queue-RT::Ticket' );
+    $self->LimitToQueue($queue);
+    $self->LimitToGlobal();
 }
 
 # }}}
@@ -83,12 +77,11 @@
    my $self = shift;
   my $queue = shift;
  
-  $self->Limit (ALIAS => $self->_OCFAlias,
-                ENTRYAGGREGATOR => 'OR',
-		FIELD => 'ObjectId',
+  $self->Limit (ENTRYAGGREGATOR => 'OR',
+		FIELD => 'Queue',
 		VALUE => "$queue")
       if defined $queue;
-  $self->LimitToLookupType( 'RT::Queue-RT::Ticket' );
+  
 }
 # }}}
 
@@ -106,24 +99,13 @@
 sub LimitToGlobal  {
    my $self = shift;
  
-  $self->Limit (ALIAS => $self->_OCFAlias,
-                ENTRYAGGREGATOR => 'OR',
-		FIELD => 'ObjectId',
+  $self->Limit (ENTRYAGGREGATOR => 'OR',
+		FIELD => 'Queue',
 		VALUE => 0);
-  $self->LimitToLookupType( 'RT::Queue-RT::Ticket' );
+  
 }
 # }}}
 
-sub LimitToObjectType {
-    my $self = shift;
-    my $type = shift;
-
-    return if $self->{_sql_limit_objectype}{$type}++;
-    $self->Limit (ALIAS => $self->_OCFAlias,
-		    ENTRYAGGREGATOR => 'OR',
-		    FIELD => 'ObjectType',
-		    VALUE => $type);
-}
 
 # {{{ sub _DoSearch 
 
@@ -148,95 +130,6 @@
 }
 
 # }}}
-
-# {{{ sub Next 
-
-=head2 Next
-
-Returns the next custom field that this user can see.
-
-=cut
-  
-sub Next {
-    my $self = shift;
-    
-    
-    my $CF = $self->SUPER::Next();
-    if ((defined($CF)) and (ref($CF))) {
-
-	if ($CF->CurrentUserHasRight('SeeCustomField')) {
-	    return($CF);
-	}
-	
-	#If the user doesn't have the right to show this queue
-	else {	
-	    return($self->Next());
-	}
-    }
-    #if there never was any queue
-    else {
-	return(undef);
-    }	
-    
-}
-# }}}
-
-sub LimitToLookupType  {
-    my $self = shift;
-    my $lookup = shift;
- 
-    $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
-}
-
-sub LimitToChildType  {
-    my $self = shift;
-    my $lookup = shift;
- 
-    $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
-    $self->Limit( FIELD => 'LookupType', ENDSWITH => "$lookup" );
-}
-
-sub LimitToParentType  {
-    my $self = shift;
-    my $lookup = shift;
- 
-    $self->Limit( FIELD => 'LookupType', VALUE => "$lookup" );
-    $self->Limit( FIELD => 'LookupType', STARTSWITH => "$lookup" );
-}
-
-sub LimitToGlobalOrObjectId {
-    my $self = shift;
-    my $global_only = 1;
-
-    $self->Join( ALIAS1 => 'main',
-                FIELD1 => 'id',
-                ALIAS2 => $self->_OCFAlias,
-                FIELD2 => 'CustomField' );
-
-    foreach my $id (@_) {
-	$self->Limit( ALIAS           => $self->_OCFAlias,
-		    FIELD           => 'ObjectId',
-		    OPERATOR        => '=',
-		    VALUE           => $id || 0,
-		    ENTRYAGGREGATOR => 'OR' );
-	$global_only = 0 if $id;
-    }
-
-    $self->Limit( ALIAS           => $self->_OCFAlias,
-                 FIELD           => 'ObjectId',
-                 OPERATOR        => '=',
-                 VALUE           => 0,
-                 ENTRYAGGREGATOR => 'OR' ) unless $global_only;
-
-    $self->OrderByCols(
-	{ ALIAS => $self->_OCFAlias, FIELD => 'ObjectId' },
-	{ ALIAS => $self->_OCFAlias, FIELD => 'SortOrder' },
-    );
-    
-    # This doesn't work on postgres. 
-    #$self->OrderBy( ALIAS => $class_cfs , FIELD => "SortOrder", ORDER => 'ASC');
-
-}
   
 1;
 

Modified: rt/branches/rt-3.1/lib/RT/Group_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Group_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Group_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -447,7 +447,6 @@
         Type        => undef,
         Instance    => '0',
         InsideTransaction => undef,
-        _RecordTransaction => 1,
         @_
     );
 
@@ -493,12 +492,8 @@
     $cgm->Create(Group =>$self->PrincipalObj, Member => $self->PrincipalObj, ImmediateParent => $self->PrincipalObj);
 
 
-    if ( $args{'_RecordTransaction'} ) {
-	$self->_NewTransaction( Type => "Create" );
-    }
 
     $RT::Handle->Commit() unless ($args{'InsideTransaction'});
-
     return ( $id, $self->loc("Group created") );
 }
 
@@ -1153,13 +1148,6 @@
 # {{{ sub _Set
 sub _Set {
     my $self = shift;
-    my %args = (
-        Field => undef,
-        Value => undef,
-	TransactionType   => 'Set',
-	RecordTransaction => 1,
-        @_
-    );
 
 	if ($self->Domain eq 'Personal') {
    		if ($self->CurrentUser->PrincipalId == $self->Instance) {
@@ -1177,30 +1165,7 @@
         	return ( 0, $self->loc('Permission Denied') );
     	}
 	}
-
-    my $Old = $self->SUPER::_Value("$args{'Field'}");
-    
-    my ($ret, $msg) = $self->SUPER::_Set( Field => $args{'Field'},
-					  Value => $args{'Value'} );
-    
-    #If we can't actually set the field to the value, don't record
-    # a transaction. instead, get out of here.
-    if ( $ret == 0 ) { return ( 0, $msg ); }
-
-    if ( $args{'RecordTransaction'} == 1 ) {
-
-        my ( $Trans, $Msg, $TransObj ) = $self->_NewTransaction(
-                                               Type => $args{'TransactionType'},
-                                               Field     => $args{'Field'},
-                                               NewValue  => $args{'Value'},
-                                               OldValue  => $Old,
-                                               TimeTaken => $args{'TimeTaken'},
-        );
-        return ( $Trans, scalar $TransObj->Description );
-    }
-    else {
-        return ( $ret, $msg );
-    }
+    return ( $self->SUPER::_Set(@_) );
 }
 
 # }}}
@@ -1288,13 +1253,5 @@
 }
 
 # }}}
-
-sub BasicColumns {
-    (
-	[ Name => 'Name' ],
-	[ Description => 'Description' ],
-    );
-}
-
 1;
 

Modified: rt/branches/rt-3.1/lib/RT/Groups_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Groups_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Groups_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -123,7 +123,8 @@
     $self->Limit(FIELD => 'Domain', OPERATOR => '=', VALUE => 'Personal');
     $self->Limit(   FIELD => 'Instance',   
                     OPERATOR => '=', 
-                    VALUE => $princ);
+                    VALUE => $princ,
+                    ENTRY_AGGREGATOR => 'OR');
 }
 
 

Modified: rt/branches/rt-3.1/lib/RT/I18N.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N.pm	Mon Jul 12 14:00:53 2004
@@ -76,11 +76,9 @@
 =cut
 
 sub Init {
-    require File::Glob;
-
     # Load language-specific functions
-    foreach my $language ( File::Glob::bsd_glob(substr(__FILE__, 0, -3) . "/*.pm")) {
-        if ($language =~ /^([-\w\s.\/\\~:]+)$/) {
+    foreach my $language ( glob(substr(__FILE__, 0, -3) . "/*.pm")) {
+        if ($language =~ /^([-\w.\/\\~:]+)$/) {
             require $1;
         }
         else {
@@ -97,7 +95,6 @@
 	    $_	=> [
 		Gettext => (substr(__FILE__, 0, -3) . "/$_.po"),
 		Gettext => "$RT::LocalLexiconPath/*/$_.po",
-		Gettext => "$RT::LocalLexiconPath/$_.po",
 	    ],
 	} @lang
     });

Modified: rt/branches/rt-3.1/lib/RT/I18N/cs.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/cs.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/cs.po	Mon Jul 12 14:00:53 2004
@@ -16,7 +16,7 @@
 
 #: NOT FOUND IN SOURCE
 msgid "#%1"
-msgstr "#%1"	
+msgstr "#%1"
 
 #: html/Approvals/Elements/Approve:26 html/Approvals/Elements/ShowDependency:49 html/SelfService/Display.html:24 html/Ticket/Display.html:25 html/Ticket/Display.html:29
 #. ($TicketObj->Id, $TicketObj->Subject)

Modified: rt/branches/rt-3.1/lib/RT/I18N/de.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/de.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/de.po	Mon Jul 12 14:00:53 2004
@@ -344,7 +344,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Gib Anfragenummern oder URLs getrennt durch Leerzeichen ein)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/en.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/en.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/en.po	Mon Jul 12 14:00:53 2004
@@ -58,7 +58,7 @@
 msgid "Open it"
 msgstr "Open"
 
-#: html/Admin/Users/Modify.html:163 html/User/Prefs.html:63
+#: html/Admin/Users/Modify.html:156 html/User/Prefs.html:63
 msgid "Residence"
 msgstr "Home"
 

Modified: rt/branches/rt-3.1/lib/RT/I18N/es.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/es.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/es.po	Mon Jul 12 14:00:53 2004
@@ -357,7 +357,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Introduzca los identificadores de ticket o URLs, separados por espacios)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/fr.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/fr.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/fr.po	Mon Jul 12 14:00:53 2004
@@ -379,7 +379,7 @@
 msgstr "(Cocher les cases pour activer les notifications aux destinataires listés)"
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Entrer les numéros de tickets ou les URLs, séparés par des espaces)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/he.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/he.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/he.po	Mon Jul 12 14:00:53 2004
@@ -442,7 +442,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr ""
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/it.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/it.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/it.po	Mon Jul 12 14:00:53 2004
@@ -440,7 +440,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Inserire il numero di tickets o gli URL, separati da spazi)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/ja.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/ja.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/ja.po	Mon Jul 12 14:00:53 2004
@@ -446,7 +446,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(チケットIDまたはURLsを空欄で区切って入力してください)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/nl.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/nl.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/nl.po	Mon Jul 12 14:00:53 2004
@@ -440,7 +440,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Vul ticket ids of URLs in, gescheiden door spaties)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/pt_br.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/pt_br.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/pt_br.po	Mon Jul 12 14:00:53 2004
@@ -445,7 +445,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Entre com identificadores de tíquetes ou URLs, separados por espaços)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/I18N/ru.po
==============================================================================
--- rt/branches/rt-3.1/lib/RT/I18N/ru.po	(original)
+++ rt/branches/rt-3.1/lib/RT/I18N/ru.po	Mon Jul 12 14:00:53 2004
@@ -442,7 +442,7 @@
 msgstr ""
 
 #: html/Ticket/Create.html:178
-msgid "(Enter ticket ids or URLs, seperated with spaces)"
+msgid "(Enter ticket ids or URLs, separated with spaces)"
 msgstr "(Введите номера или ссылки на тикеты. Несколько тикетов разделяются пробелами.)"
 
 #: NOT FOUND IN SOURCE

Modified: rt/branches/rt-3.1/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Interface/Web.pm	Mon Jul 12 14:00:53 2004
@@ -462,7 +462,6 @@
                 TimeTaken    => $args{ARGSRef}->{'UpdateTimeWorked'}
             );
             push ( @{ $args{Actions} }, $Description );
-	    $Object->UpdateCustomFields( ARGSRef => $args{ARGSRef} ) if $Object;
         }
         elsif ( $args{ARGSRef}->{'UpdateType'} eq 'response' ) {
             my ( $Transaction, $Description, $Object ) = $args{TicketObj}->Correspond(
@@ -472,7 +471,6 @@
                 TimeTaken    => $args{ARGSRef}->{'UpdateTimeWorked'}
             );
             push ( @{ $args{Actions} }, $Description );
-	    $Object->UpdateCustomFields( ARGSRef => $args{ARGSRef} ) if $Object;
         }
         else {
             push ( @{ $args{'Actions'} },
@@ -1072,145 +1070,112 @@
 
 # }}}
 
-sub ProcessTicketCustomFieldUpdates {
-    my %args = @_;
-    $args{'Object'} = delete $args{'TicketObj'};
-    my $ARGSRef = { %{ $args{'ARGSRef'} } };
+# {{{ Sub ProcessTicketCustomFieldUpdates
 
-    # Build up a list of objects that we want to work with
-    my %custom_fields_to_mod;
-    foreach my $arg ( keys %$ARGSRef ) {
-        if ( $arg =~ /^Ticket-(\d+-.*)/) {
-	    $ARGSRef->{"Object-RT::Ticket-$1"} = delete $ARGSRef->{$arg};
-	}
-        elsif ( $arg =~ /^CustomField-(\d+-.*)/) {
-	    $ARGSRef->{"Object-RT::Ticket--$1"} = delete $ARGSRef->{$arg};
-	}
-    }
+sub ProcessTicketCustomFieldUpdates {
+    my %args = (
+        ARGSRef => undef,
+        @_
+    );
 
-    return ProcessObjectCustomFieldUpdates(%args, ARGSRef => $ARGSRef);
-}
+    my @results;
 
-sub ProcessObjectCustomFieldUpdates {
-    my %args = @_;
     my $ARGSRef = $args{'ARGSRef'};
-    my @results;
 
-    # Build up a list of objects that we want to work with
+    # Build up a list of tickets that we want to work with
+    my %tickets_to_mod;
     my %custom_fields_to_mod;
-    foreach my $arg ( keys %$ARGSRef ) {
-        if ( $arg =~ /^Object-([\w:]+)-(\d*)-CustomField-(\d+)-/ ) {
-            # For each of those objects, find out what custom fields we want to work with.
-            $custom_fields_to_mod{$1}{$2 || $args{'Object'}->Id}{$3} = 1;
+    foreach my $arg ( keys %{$ARGSRef} ) {
+        if ( $arg =~ /^Ticket-(\d+)-CustomField-(\d+)-/ ) {
+
+            # For each of those tickets, find out what custom fields we want to work with.
+            $custom_fields_to_mod{$1}{$2} = 1;
         }
     }
 
-    # For each of those objects
-    foreach my $class ( keys %custom_fields_to_mod ) {
-	foreach my $id ( keys %{$custom_fields_to_mod{$class}} ) {
-	    my $Object = $args{'Object'};
-	    if (!$Object or ref($Object) ne $class or $Object->id != $id) {
-		$Object = $class->new( $session{'CurrentUser'} );
-		$Object->Load($id);
+    # For each of those tickets
+    foreach my $tick ( keys %custom_fields_to_mod ) {
+        my $Ticket = $args{'TicketObj'};
+	if (!$Ticket or $Ticket->id != $tick) {
+	    $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
+	    $Ticket->Load($tick);
 	}
 
-	    # For each custom field  
-	    foreach my $cf ( keys %{ $custom_fields_to_mod{$class}{$id} } ) {
+        # For each custom field  
+        foreach my $cf ( keys %{ $custom_fields_to_mod{$tick} } ) {
+
 	    my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'});
 	    $CustomFieldObj->LoadById($cf);
 
-		foreach my $arg ( keys %{$ARGSRef} ) {
-		    # since http won't pass in a form element with a null value, we need
-		    # to fake it
-		    if ($arg =~ /^(.*?)-Values-Magic$/ ) {
-			# We don't care about the magic, if there's really a values element;
-			next if (exists $ARGSRef->{$1.'-Values'}) ;
-
-			$arg = $1."-Values";
-			$ARGSRef->{$1."-Values"} = undef;
-		    
-		    }
-		    next unless ( $arg =~ /^Object-$class-(?:$id)?-CustomField-$cf-/ );
-		    my @values =
-		    ( ref( $ARGSRef->{$arg} ) eq 'ARRAY' ) 
-		    ? @{ $ARGSRef->{$arg} }
-		    : split /\n/, $ARGSRef->{$arg} ;
-		    if ( ( $arg =~ /-AddValue$/ ) || ( $arg =~ /-Value$/ ) ) {
-			foreach my $value (@values) {
-			    next unless length($value);
-			    my ( $val, $msg ) = $Object->AddCustomFieldValue(
-				Field => $cf,
-				Value => $value
-			    );
-			    push ( @results, $msg );
-			}
-		    }
-		    elsif ( $arg =~ /-Upload$/ ) {
-			my $cgi_object = $m->cgi_object;
-			my $fh = $cgi_object->upload($arg) or next;
-			my $upload_info = $cgi_object->uploadInfo($fh);
-			my $filename = "$fh";
-			$filename =~ s#^.*[\\/]##;
-			my ( $val, $msg ) = $Object->AddCustomFieldValue(
-			    Field => $cf,
-			    Value => $filename,
-			    LargeContent => do { local $/; scalar <$fh> },
-			    ContentType => $upload_info->{'Content-Type'},
-			);
-			push ( @results, $msg );
-		    }
-		    elsif ( $arg =~ /-DeleteValues$/ ) {
-			foreach my $value (@values) {
-			    next unless length($value);
-			    my ( $val, $msg ) = $Object->DeleteCustomFieldValue(
-				Field => $cf,
-				Value => $value
-			    );
-			    push ( @results, $msg );
-			}
-		    }
-		    elsif ( $arg =~ /-DeleteValueIds$/ ) {
-			foreach my $value (@values) {
-			    next unless length($value);
-			    my ( $val, $msg ) = $Object->DeleteCustomFieldValue(
-				Field => $cf,
-				ValueId => $value,
-			    );
-			    push ( @results, $msg );
-			}
-		    }
-		    elsif ( $arg =~ /-Values$/ and !$CustomFieldObj->Repeated) {
-			my $cf_values = $Object->CustomFieldValues($cf);
-
-			my %values_hash;
-			foreach my $value (@values) {
-			    next unless length($value);
-
-			    # build up a hash of values that the new set has
-			    $values_hash{$value} = 1;
-
-			    unless ( $cf_values->HasEntry($value) ) {
-				my ( $val, $msg ) = $Object->AddCustomFieldValue(
-				    Field => $cf,
-				    Value => $value
-				);
-				push ( @results, $msg );
-			    }
-
-			}
-			while ( my $cf_value = $cf_values->Next ) {
-			    unless ( $values_hash{ $cf_value->Content } == 1 ) {
-				my ( $val, $msg ) = $Object->DeleteCustomFieldValue(
-				    Field => $cf,
-				    Value => $cf_value->Content
-				);
-				push ( @results, $msg);
-
-			    }
-			}
-		    }
-		    elsif ( $arg =~ /-Values$/ ) {
-			my $cf_values = $Object->CustomFieldValues($cf);
+            foreach my $arg ( keys %{$ARGSRef} ) {
+                # since http won't pass in a form element with a null value, we need
+                # to fake it
+                if ($arg =~ /^(.*?)-Values-Magic$/ ) {
+                    # We don't care about the magic, if there's really a values element;
+                    next if (exists $ARGSRef->{$1.'-Values'}) ;
+
+                    $arg = $1."-Values";
+                    $ARGSRef->{$1."-Values"} = undef;
+                
+                }
+                next unless ( $arg =~ /^Ticket-$tick-CustomField-$cf-/ );
+                my @values =
+                  ( ref( $ARGSRef->{$arg} ) eq 'ARRAY' ) 
+                  ? @{ $ARGSRef->{$arg} }
+                  : split /\n/, $ARGSRef->{$arg} ;
+                if ( ( $arg =~ /-AddValue$/ ) || ( $arg =~ /-Value$/ ) ) {
+                    foreach my $value (@values) {
+                        next unless length($value);
+                        my ( $val, $msg ) = $Ticket->AddCustomFieldValue(
+                            Field => $cf,
+                            Value => $value
+                        );
+                        push ( @results, $msg );
+                    }
+                }
+                elsif ( $arg =~ /-DeleteValues$/ ) {
+                    foreach my $value (@values) {
+                        next unless length($value);
+                        my ( $val, $msg ) = $Ticket->DeleteCustomFieldValue(
+                            Field => $cf,
+                            Value => $value
+                        );
+                        push ( @results, $msg );
+                    }
+                }
+                elsif ( $arg =~ /-Values$/ and $CustomFieldObj->Type !~ /Entry/) {
+                    my $cf_values = $Ticket->CustomFieldValues($cf);
+
+                    my %values_hash;
+                    foreach my $value (@values) {
+                        next unless length($value);
+
+                        # build up a hash of values that the new set has
+                        $values_hash{$value} = 1;
+
+                        unless ( $cf_values->HasEntry($value) ) {
+                            my ( $val, $msg ) = $Ticket->AddCustomFieldValue(
+                                Field => $cf,
+                                Value => $value
+                            );
+                            push ( @results, $msg );
+                        }
+
+                    }
+                    while ( my $cf_value = $cf_values->Next ) {
+                        unless ( $values_hash{ $cf_value->Content } == 1 ) {
+                            my ( $val, $msg ) = $Ticket->DeleteCustomFieldValue(
+                                Field => $cf,
+                                Value => $cf_value->Content
+                            );
+                            push ( @results, $msg);
+
+                        }
+
+                    }
+                }
+                elsif ( $arg =~ /-Values$/ ) {
+                    my $cf_values = $Ticket->CustomFieldValues($cf);
 
 		    # keep everything up to the point of difference, delete the rest
 		    my $delete_flag;
@@ -1226,23 +1191,24 @@
 
 		    # now add/replace extra things, if any
 		    foreach my $value (@values) {
-			    my ( $val, $msg ) = $Object->AddCustomFieldValue(
+			my ( $val, $msg ) = $Ticket->AddCustomFieldValue(
 			    Field => $cf,
 			    Value => $value
 			);
 			push ( @results, $msg );
 		    }
 		}
-		    else {
-			push ( @results, loc("User asked for an unknown update type for custom field [_1] for [_2] object #[_3]", $cf->Name, $class, $Object->id ) );
-		    }
-		}
-	    }
-	    return (@results);
-	}
+                else {
+                    push ( @results, "User asked for an unknown update type for custom field " . $cf->Name . " for ticket " . $Ticket->id );
+                }
+            }
+        }
+        return (@results);
     }
 }
 
+# }}}
+
 # {{{ sub ProcessTicketWatchers
 
 =head2 ProcessTicketWatchers ( TicketObj => $Ticket, ARGSRef => \%ARGS );

Modified: rt/branches/rt-3.1/lib/RT/Link_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Link_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Link_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -81,31 +81,23 @@
     my $base = RT::URI->new( $self->CurrentUser );
     $base->FromURI( $args{'Base'} );
 
-    unless ( $base->Resolver && $base->Scheme ) {
-	my $msg = $self->loc("Couldn't resolve base '[_1]' into a URI.", 
-			     $args{'Base'});
-        $RT::Logger->warning( "$self $msg\n" );
-
-	if (wantarray) {
-	    return(undef, $msg);
-	} else {
-	    return (undef);
-	}
+    unless ( $base->Resolver and $base->Scheme ) {
+        $RT::Logger->warning( "$self couldn't resolve base:'"
+                              . $args{'Base'} . " - "
+                              . "' into a URI\n" );
+
+        return (undef);
     }
 
     my $target = RT::URI->new( $self->CurrentUser );
     $target->FromURI( $args{'Target'} );
 
     unless ( $target->Resolver ) {
-	my $msg = $self->loc("Couldn't resolve target '[_1]' into a URI.", 
-			     $args{'Target'});
-        $RT::Logger->warning( "$self $msg\n" );
-
-	if (wantarray) {
-	    return(undef, $msg);
-	} else {
-	    return (undef);
-	}
+        $RT::Logger->warning( "$self couldn't resolve target:'"
+                              . $args{'Target'} . " - "
+                              . "' into a URI\n" );
+
+        return (undef);
     }
 
     my $base_id   = 0;

Modified: rt/branches/rt-3.1/lib/RT/Queue_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Queue_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Queue_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -70,7 +70,7 @@
     ShowACL             => 'Display Access Control List',             # loc_pair
     ModifyACL           => 'Modify Access Control List',              # loc_pair
     ModifyQueueWatchers => 'Modify the queue watchers',               # loc_pair
-    AssignCustomFields  => 'Assign and remove custom fields',         # loc_pair
+    AdminCustomFields   => 'Create, delete and modify custom fields', # loc_pair
     ModifyTemplate      => 'Modify Scrip templates for this queue',   # loc_pair
     ShowTemplate        => 'Display Scrip templates for this queue',  # loc_pair
 
@@ -457,32 +457,12 @@
 
 =cut
 
-# XXX XXX - this should become TicketCustomFields
-
 sub CustomFields {
     my $self = shift;
-    warn "Queue->CustomFields is deprecated, use Queue->TicketCustomFields instead";
-    return $self->TicketCustomFields(@_);
-}
-
-sub TicketCustomFields {
-    my $self = shift;
-
-    my $cfs = RT::CustomFields->new( $self->CurrentUser );
-    if ( $self->CurrentUserHasRight('SeeQueue') ) {
-	$cfs->LimitToGlobalOrObjectId( $self->Id );
-	$cfs->LimitToLookupType( 'RT::Queue-RT::Ticket' );
-    }
-    return ($cfs);
-}
-
-sub TicketTransactionCustomFields {
-    my $self = shift;
 
     my $cfs = RT::CustomFields->new( $self->CurrentUser );
     if ( $self->CurrentUserHasRight('SeeQueue') ) {
-	$cfs->LimitToGlobalOrObjectId( $self->Id );
-	$cfs->LimitToLookupType( 'RT::Queue-RT::Ticket-RT::Transaction' );
+        $cfs->LimitToGlobalOrQueue( $self->Id );
     }
     return ($cfs);
 }
@@ -1063,7 +1043,7 @@
     }
     return (
         $args{'Principal'}->HasRight(
-            Object => $self->Id ? $self : $RT::System,
+            Object => $self,
             Right    => $args{'Right'}
           )
     );

Modified: rt/branches/rt-3.1/lib/RT/Record.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Record.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Record.pm	Mon Jul 12 14:00:53 2004
@@ -676,28 +676,6 @@
 
 }
 
-sub _DecodeLOB {
-    my $self            = shift;
-    my $ContentType     = shift;
-    my $ContentEncoding = shift;
-    my $Content         = shift;
-
-    if ( $ContentEncoding eq 'base64' ) {
-        $Content = MIME::Base64::decode_base64($Content);
-    }
-    elsif ( $ContentEncoding eq 'quoted-printable' ) {
-        $Content = MIME::QuotedPrint::decode($Content);
-    }
-    elsif ( $ContentEncoding && $ContentEncoding ne 'none' ) {
-        return ( $self->loc( "Unknown ContentEncoding [_1]", $ContentEncoding ) );
-    }
-    if ( $ContentType eq 'text/plain' ) {
-        return Encode::decode_utf8($Content);
-    }
-    else {
-        return ($Content);
-    }
-}
 
 # {{{ LINKDIRMAP
 # A helper table for links mapping to make it easier
@@ -1215,431 +1193,6 @@
 
 # }}}
 
-# {{{ sub _NewTransaction
-
-=head2 _NewTransaction  PARAMHASH
-
-Private function to create a new RT::Transaction object for this ticket update
-
-=cut
-
-sub _NewTransaction {
-    my $self = shift;
-    my %args = (
-        TimeTaken => undef,
-        Type      => undef,
-        OldValue  => undef,
-        NewValue  => undef,
-        OldReference  => undef,
-        NewReference  => undef,
-        ReferenceType => undef,
-        Data      => undef,
-        Field     => undef,
-        MIMEObj   => undef,
-        ActivateScrips => 1,
-        CommitScrips => 1,
-        @_
-    );
-
-    my $old_ref = $args{'OldReference'};
-    my $new_ref = $args{'NewReference'};
-    my $ref_type = $args{'ReferenceType'};
-    if ($old_ref or $new_ref) {
-	$ref_type ||= ref($old_ref) || ref($new_ref);
-	if (!$ref_type) {
-	    $RT::Logger->error("Reference type not specified for transaction");
-	    return;
-	}
-	$old_ref = $old_ref->Id if ref($old_ref);
-	$new_ref = $new_ref->Id if ref($new_ref);
-    }
-
-    require RT::Transaction;
-    my $trans = new RT::Transaction( $self->CurrentUser );
-    my ( $transaction, $msg ) = $trans->Create(
-	ObjectId  => $self->Id,
-	ObjectType => ref($self),
-        TimeTaken => $args{'TimeTaken'},
-        Type      => $args{'Type'},
-        Data      => $args{'Data'},
-        Field     => $args{'Field'},
-        NewValue  => $args{'NewValue'},
-        OldValue  => $args{'OldValue'},
-        NewReference  => $new_ref,
-        OldReference  => $old_ref,
-        ReferenceType => $ref_type,
-        MIMEObj   => $args{'MIMEObj'},
-        ActivateScrips => $args{'ActivateScrips'},
-        CommitScrips => $args{'CommitScrips'},
-    );
-
-    # Rationalize the object since we may have done things to it during the caching.
-    $self->Load($self->Id);
-
-    $RT::Logger->warning($msg) unless $transaction;
-
-    $self->_SetLastUpdated;
-
-    if ( defined $args{'TimeTaken'} ) {
-        $self->_UpdateTimeTaken( $args{'TimeTaken'} );
-    }
-    if ( $RT::UseTransactionBatch and $transaction ) {
-	    push @{$self->{_TransactionBatch}}, $trans;
-    }
-    return ( $transaction, $msg, $trans );
-}
-
-# }}}
-
-# {{{ sub Transactions 
-
-=head2 Transactions
-
-  Returns an RT::Transactions object of all transactions on this ticket
-
-=cut
-
-sub Transactions {
-    my $self = shift;
-
-    use RT::Transactions;
-    my $transactions = RT::Transactions->new( $self->CurrentUser );
-
-    #If the user has no rights, return an empty object
-    $transactions->Limit(
-	FIELD => 'ObjectId',
-	VALUE => $self->id,
-    );
-    $transactions->Limit(
-	FIELD    => 'ObjectType',
-	VALUE    => ref($self),
-    );
-
-    return ($transactions);
-}
-
-# }}}
-
-# {{{ Routines dealing with custom fields
-
-sub CustomFields {
-    my $self = shift;
-    my $cfs = RT::CustomFields->new( $self->CurrentUser );
-    $cfs->UnLimit;
-
-    # XXX handle multiple types properly
-    foreach my $lookup ($self->_LookupTypes) {
-	$cfs->LimitToLookupType($lookup);
-	$cfs->LimitToGlobalOrObjectId($self->_LookupId($lookup));
-    }
-
-    return $cfs;
-}
-
-sub _LookupId {
-    my $self = shift;
-    my $lookup = shift;
-    my @classes = ($lookup =~ /RT::(\w+)-/g);
-
-    foreach my $class (reverse @classes) {
-	my $method = "${class}Obj";
-	$self = $self->$method;
-    }
-
-    return $self->Id;
-}
-
-sub _LookupTypes { ref($_[0]) }
-
-# {{{ AddCustomFieldValue
-
-=item AddCustomFieldValue { Field => FIELD, Value => VALUE }
-
-VALUE should be a string.
-FIELD can be a CustomField object OR a CustomField ID.
-
-
-Adds VALUE as a value of CustomField FIELD.  If this is a single-value custom field,
-deletes the old value. 
-If VALUE isn't a valid value for the custom field, returns 
-(0, 'Error message' ) otherwise, returns (1, 'Success Message')
-
-=cut
-
-sub AddCustomFieldValue {
-    my $self = shift;
-#    unless ( $self->CurrentUserHasRight('ModifyTicket') ) {
-#        return ( 0, $self->loc("Permission Denied") );
-#    }
-    $self->_AddCustomFieldValue(@_);
-}
-
-sub _AddCustomFieldValue {
-    my $self = shift;
-    my %args = (
-        Field => undef,
-        Value => undef,
-	RecordTransaction => 1,
-        @_
-    );
-
-    my $cf = RT::CustomField->new( $self->CurrentUser );
-    if ( UNIVERSAL::isa( $args{'Field'}, "RT::CustomField" ) ) {
-        $cf->Load( $args{'Field'}->id );
-    }
-    else {
-        $cf->Load( $args{'Field'} );
-    }
-
-    unless ( $cf->Id ) {
-        return ( 0, $self->loc("Custom field [_1] not found", $args{'Field'}) );
-    }
-
-    my $OCFs = $self->CustomFields;
-    $OCFs->Limit( FIELD => 'id', VALUE => $cf->Id );
-    unless ($OCFs->Count) {
-        return ( 0, $self->loc("Custom field [_1] does not apply to this object", $args{'Field'}) );
-    }
-
-    # Load up a ObjectCustomFieldValues object for this custom field and this ticket
-    my $values = $cf->ValuesForObject( $self );
-
-    unless ( $cf->ValidateValue( $args{'Value'} ) ) {
-        return ( 0, $self->loc("Invalid value for custom field") );
-    }
-
-    # If the custom field only accepts a single value, delete the existing
-    # value and record a "changed from foo to bar" transaction
-    if ( $cf->SingleValue ) {
-
-        # We need to whack any old values here.  In most cases, the custom field should
-        # only have one value to delete.  In the pathalogical case, this custom field
-        # used to be a multiple and we have many values to whack....
-        my $cf_values = $values->Count;
-
-        if ( $cf_values > 1 ) {
-            my $i = 0;   #We want to delete all but the last one, so we can then
-                 # execute the same code to "change" the value from old to new
-            while ( my $value = $values->Next ) {
-                $i++;
-                if ( $i < $cf_values ) {
-                    my ($val, $msg) = $cf->DeleteValueForObject(Object => $self, Content => $value->Content);
-                    unless ($val) {
-                        return (0,$msg);
-                    }
-                    my ( $TransactionId, $Msg, $TransactionObj ) =
-                      $self->_NewTransaction(
-                        Type     => 'CustomField',
-                        Field    => $cf->Id,
-                        OldReference => $value,
-                      );
-                }
-            }
-        }
-
-        my ($old_value, $old_content);
-        if ($old_value = $cf->ValuesForObject( $self )->First) {
-	    $old_content = $old_value->Content();
-	    return (1) if $old_content eq $args{'Value'};
-	}
-
-        my ( $new_value_id, $value_msg ) = $cf->AddValueForObject(
-            Object  => $self,
-            Content => $args{'Value'},
-            LargeContent => $args{'LargeContent'},
-            ContentType => $args{'ContentType'},
-        );
-
-        unless ($new_value_id) {
-            return ( 0,
-                $self->loc("Could not add new custom field value for ticket. [_1] ",
-                  ,$value_msg) );
-        }
-
-        my $new_value = RT::ObjectCustomFieldValue->new( $self->CurrentUser );
-        $new_value->Load($new_value_id);
-
-        # now that adding the new value was successful, delete the old one
-	if ($old_value) {
-	    my ($val, $msg) = $cf->DeleteValueForObject(Object => $self, Content => $old_content);
-	    unless ($val) { 
-	    		return (0,$msg);
-	    }
-	}
-
-	if ($args{'RecordTransaction'}) {
-        my ( $TransactionId, $Msg, $TransactionObj ) = $self->_NewTransaction(
-            Type     => 'CustomField',
-            Field    => $cf->Id,
-            OldReference => $old_value,
-            NewReference => $new_value,
-        );
-	}
-
-        if ( $old_value eq '' ) {
-            return ( 1, $self->loc("[_1] [_2] added", $cf->Name, $new_value->Content) );
-        }
-        elsif ( $new_value->Content eq '' ) {
-            return ( 1, $self->loc("[_1] [_2] deleted", $cf->Name, $old_content) );
-        }
-        else {
-            return ( 1, $self->loc("[_1] [_2] changed to [_3]", $cf->Name, $old_content, $new_value->Content ) );
-        }
-
-    }
-
-    # otherwise, just add a new value and record "new value added"
-    else {
-        my ( $new_value_id ) = $cf->AddValueForObject(
-            Object  => $self,
-            Content => $args{'Value'},
-            LargeContent => $args{'LargeContent'},
-            ContentType => $args{'ContentType'},
-        );
-
-        unless ($new_value_id) {
-            return ( 0,
-                $self->loc("Could not add new custom field value for ticket. "));
-        }
-    if ( $args{'RecordTransaction'} ) {
-        my ( $TransactionId, $Msg, $TransactionObj ) = $self->_NewTransaction(
-            Type     => 'CustomField',
-            Field    => $cf->Id,
-            NewReference => $new_value_id,
-	    ReferenceType => 'RT::ObjectCustomFieldValue',
-        );
-        unless ($TransactionId) {
-            return ( 0,
-                $self->loc( "Couldn't create a transaction: [_1]", $Msg ) );
-        }
-    }
-        return ( 1, $self->loc("[_1] added as a value for [_2]",$args{'Value'}, $cf->Name));
-    }
-
-}
-
-# }}}
-
-# {{{ DeleteCustomFieldValue
-
-=item DeleteCustomFieldValue { Field => FIELD, Value => VALUE }
-
-Deletes VALUE as a value of CustomField FIELD. 
-
-VALUE can be a string, a CustomFieldValue or a ObjectCustomFieldValue.
-
-If VALUE isn't a valid value for the custom field, returns 
-(0, 'Error message' ) otherwise, returns (1, 'Success Message')
-
-=cut
-
-sub DeleteCustomFieldValue {
-    my $self = shift;
-    my %args = (
-        Field => undef,
-        Value => undef,
-	ValueId => undef,
-        @_);
-
-#    XXX - normalise CF related ACLs... ask obra!
-#    unless ( $self->CurrentUserHasRight('ModifyTicket') ) {
-#        return ( 0, $self->loc("Permission Denied") );
-#    }
-    my $cf = RT::CustomField->new( $self->CurrentUser );
-    if ( UNIVERSAL::isa( $args{'Field'}, "RT::CustomField" ) ) {
-        $cf->LoadById( $args{'Field'}->id );
-    }
-    else {
-        $cf->LoadById( $args{'Field'} );
-    }
-
-    unless ( $cf->Id ) {
-        return ( 0, $self->loc("Custom field not found") );
-    }
-
-
-     my ($val, $msg) = $cf->DeleteValueForObject(
-	 Object => $self,
-	 Id => $args{'ValueId'},
-	 Content => $args{'Value'},
-     );
-     unless ($val) { 
-            return (0,$msg);
-     }
-        my ( $TransactionId, $Msg, $TransactionObj ) = $self->_NewTransaction(
-            Type     => 'CustomField',
-            Field    => $cf->Id,
-            OldReference => $val,
-	    ReferenceType => 'RT::ObjectCustomFieldValue',
-        );
-        unless($TransactionId) {
-            return(0, $self->loc("Couldn't create a transaction: [_1]", $Msg));
-        } 
-
-        return($TransactionId, $self->loc("[_1] is no longer a value for custom field [_2]", $TransactionObj->OldValue, $cf->Name));
-}
-
-# }}}
-
-# {{{ FirstCustomFieldValue
-
-=item FirstCustomFieldValue FIELD
-
-Return the content of the first value of CustomField FIELD for this ticket
-Takes a field id or name
-
-=cut
-
-sub FirstCustomFieldValue {
-    my $self = shift;
-    my $field = shift;
-    my $values = $self->CustomFieldValues($field);
-    if ($values->First) {
-        return $values->First->Content;
-    } else {
-        return undef;
-    }
-
-}
-
-
-
-# {{{ CustomFieldValues
-
-=item CustomFieldValues FIELD
-
-Return a ObjectCustomFieldValues object of all values of CustomField FIELD for this ticket.  
-Takes a field id.
-
-
-=cut
-
-sub CustomFieldValues {
-    my $self  = shift;
-    my $field = shift;
-
-    my $cf_values = RT::ObjectCustomFieldValues->new( $self->CurrentUser );
-    $cf_values->LimitToObject($self);
-    $cf_values->OrderBy( FIELD => 'id' );
-
-    if (length $field) {
-	$field =~ /^\d+$/ or die "LoadByNameAndQueue impossible for Record.pm";
-	my $cf = RT::CustomField->new($self->CurrentUser);
-        $cf->LoadById($field);
-	$cf_values->LimitToCustomField($cf->id);
-    }
-
-    # @values is a CustomFieldValues object;
-    return ($cf_values);
-}
-
-# }}}
-
-# }}}
-
-sub BasicColumns {
-}
-
 eval "require RT::Record_Vendor";
 die $@ if ($@ && $@ !~ qr{^Can't locate RT/Record_Vendor.pm});
 eval "require RT::Record_Local";

Modified: rt/branches/rt-3.1/lib/RT/SearchBuilder.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/SearchBuilder.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/SearchBuilder.pm	Mon Jul 12 14:00:53 2004
@@ -109,42 +109,14 @@
 Takes NAME, OPERATOR and VALUE to find records that has the
 matching Attribute.
 
-If EMPTY is set, also select rows with an empty string as
-Attribute's Content.
-
-If NULL is set, also select rows without the named Attribute.
-
 =cut
 
-my %Negate = qw(
-    =		!=
-    !=		=
-    >		<=
-    <		>=
-    >=		<
-    <=		>
-    LIKE	NOT LIKE
-    NOT LIKE	LIKE
-    IS		IS NOT
-    IS NOT	IS
-);
-
 sub LimitAttribute {
     my ($self, %args) = @_;
-    my $clause = 'ALIAS';
-    my $operator = ($args{OPERATOR} || '=');
-    
-    if ($args{NULL} and exists $args{VALUE}) {
-	$clause = 'LEFTJOIN';
-	$operator = $Negate{$operator};
-    }
-    elsif ($args{NEGATE}) {
-	$operator = $Negate{$operator};
-    }
     
     my $alias = $self->Join(
 	TYPE   => 'left',
-	ALIAS1 => $args{ALIAS} || 'main',
+	ALIAS1 => 'main',
 	FIELD1 => 'id',
 	TABLE2 => 'Attributes',
 	FIELD2 => 'ObjectId'
@@ -154,13 +126,13 @@
     $type =~ s/(?:s|Collection)$//; # XXX - Hack!
 
     $self->Limit(
-	$clause	   => $alias,
+	ALIAS	   => $alias,
 	FIELD      => 'ObjectType',
 	OPERATOR   => '=',
 	VALUE      => $type,
     );
     $self->Limit(
-	$clause	   => $alias,
+	ALIAS	   => $alias,
 	FIELD      => 'Name',
 	OPERATOR   => '=',
 	VALUE      => $args{NAME},
@@ -169,91 +141,27 @@
     return unless exists $args{VALUE};
 
     $self->Limit(
-	$clause	   => $alias,
+	ALIAS	   => $alias,
 	FIELD      => 'Content',
-	OPERATOR   => $operator,
+	OPERATOR   => ($args{OPERATOR} || '='),
 	VALUE      => $args{VALUE},
+	ENTRYAGGREGATOR => 'OR',
     );
 
-    # Capture rows with the attribute defined as an empty string.
-    $self->Limit(
-	$clause    => $alias,
-	FIELD      => 'Content',
-	OPERATOR   => '=',
-	VALUE      => '',
-	ENTRYAGGREGATOR => $args{NULL} ? 'AND' : 'OR',
-    ) if $args{EMPTY};
-
-    # Capture rows without the attribute defined
-    $self->Limit(
-	%args,
-	ALIAS      => $alias,
-	FIELD	   => 'id',
-	OPERATOR   => ($args{NEGATE} ? 'IS NOT' : 'IS'),
-	VALUE      => 'NULL',
-    ) if $args{NULL};
+    if ($args{EMPTY}) {
+	# Capture rows without the attribute defined by testing IS NULL.
+	$self->Limit(
+	    ALIAS      => $alias,
+	    FIELD      => $_,
+	    OPERATOR   => 'IS',
+	    VALUE      => 'NULL',
+	    ENTRYAGGREGATOR => 'OR',
+	) for qw( ObjectType Name Content );
+    }
 }
 # }}}
 
-# {{{ sub LimitCustomField
-
-=head2 LimitCustomField
-
-Takes a paramhash of key/value pairs with the following keys:
-
-=over 4
-
-=item CUSTOMFIELD - CustomField name or id.  If a name is passed, an additional
-parameter QUEUE may also be passed to distinguish the custom field.
-
-=item OPERATOR - The usual Limit operators
-
-=item VALUE - The value to compare against
-
-=back
-
-=cut
-
-sub _SingularClass {
-    my $self = shift;
-    my $class = ref($self);
-    $class =~ s/s$// or die "Cannot deduce SingularClass for $class";
-    return $class;
-}
-
-sub LimitCustomField {
-    my $self = shift;
-    my %args = ( VALUE        => undef,
-                 CUSTOMFIELD  => undef,
-                 OPERATOR     => '=',
-                 @_ );
-
-    my $alias = $self->Join(
-	TYPE       => 'left',
-	ALIAS1     => 'main',
-	FIELD1     => 'id',
-	TABLE2     => 'ObjectCustomFieldValues',
-	FIELD2     => 'ObjectId'
-    );
-    $self->Limit(
-	ALIAS      => $alias,
-	FIELD      => 'CustomField',
-	OPERATOR   => '=',
-	VALUE      => $args{'CUSTOMFIELD'},
-    );
-    $self->Limit(
-	ALIAS      => $alias,
-	FIELD      => 'ObjectType',
-	OPERATOR   => '=',
-	VALUE      => $self->_SingularClass,
-    );
-    $self->Limit(
-	ALIAS      => $alias,
-	FIELD      => 'Content',
-	OPERATOR   => $args{'OPERATOR'},
-	VALUE      => $args{'VALUE'},
-    );
-}
+1;
 
 # {{{ sub FindAllRows
 

Modified: rt/branches/rt-3.1/lib/RT/StyleGuide.pod
==============================================================================
--- rt/branches/rt-3.1/lib/RT/StyleGuide.pod	(original)
+++ rt/branches/rt-3.1/lib/RT/StyleGuide.pod	Mon Jul 12 14:00:53 2004
@@ -857,28 +857,7 @@
 Send patches to rt-<major-version>-bugs at fsck.com, too.  Use C<diff
 -u> for patches.
 
-=head1 SCHEMA DESIGN
 
-RT uses a convention to denote the foreign key status in its tables.
-The rule of thumb is:
-
-=over 4
-
-=item When it references to another table, always use the table name
-
-For example, the C<Template> field in the C<Scrips> table refers to
-the C<Id> of the same-named C<Template> table.
-
-=item Otherwise, always use the C<Id> suffix
-
-For example, the C<ObjectId> field in the C<ACL> table can refer
-to any object, so it has the C<Id> suffix.
-
-=back
-
-There are some legacy fields that did not follow this rule, namely
-C<ACL.PrincipalId>, C<GroupMembers.GroupId> and C<Attachments.TransactionId>,
-but new tables are expected to be consistent.
 
 =head1 TO DO
 

Modified: rt/branches/rt-3.1/lib/RT/System.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/System.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/System.pm	Mon Jul 12 14:00:53 2004
@@ -96,14 +96,12 @@
 
     my $queue = RT::Queue->new($RT::SystemUser);
     my $group = RT::Group->new($RT::SystemUser);
-    my $cf    = RT::CustomField->new($RT::SystemUser);
 
     my $qr =$queue->AvailableRights();
     my $gr = $group->AvailableRights();
-    my $cr = $cf->AvailableRights();
 
     # Build a merged list of all system wide rights, queue rights and group rights.
-    my %rights = (%{$RIGHTS}, %{$gr}, %{$qr}, %{$cr});
+    my %rights = (%{$RIGHTS}, %{$gr}, %{$qr});
     return(\%rights);
 }
 

Modified: rt/branches/rt-3.1/lib/RT/Template_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Template_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Template_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -381,15 +381,7 @@
         SOURCE => $content
     );
 
-    my $is_broken = 0;
-    my $retval = $template->fill_in( PACKAGE => 'T', BROKEN => sub {
-        my (%args) = @_;
-        $RT::Logger->error("Template parsing error: $args{error}")
-	    unless $args{error} =~ /^Died at /; # ignore intentional die()
-        $is_broken++;
-	return undef;
-    } );
-    return undef if $is_broken;
+    my $retval = $template->fill_in( PACKAGE => 'T' );
 
     # MIME::Parser has problems dealing with high-bit utf8 data.
     Encode::_utf8_off($retval);

Modified: rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Ticket_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -85,8 +85,8 @@
 
 ok(my $t2 = RT::Ticket->new($RT::SystemUser));
 ok($t2->Load($id));
-is($t2->Subject, 'Testing');
-is($t2->QueueObj->Id, $testqueue->id);
+ok($t2->Subject eq 'Testing');
+ok($t2->QueueObj->Id eq $testqueue->id);
 ok($t2->OwnerObj->Id == $u->Id);
 
 my $t3 = RT::Ticket->new($RT::SystemUser);
@@ -120,6 +120,7 @@
 use RT::Links;
 use RT::Date;
 use RT::CustomFields;
+use RT::TicketCustomFieldValues;
 use RT::Tickets;
 use RT::URI::fsck_com_rt;
 use RT::URI;
@@ -458,7 +459,7 @@
     }
 
     #If we've been handed something else, try to load the user.
-    elsif ( defined $args{'Owner'} ) {
+    elsif ( $args{'Owner'} ) {
         $Owner = RT::User->new( $self->CurrentUser );
         $Owner->Load( $args{'Owner'} );
 
@@ -2678,7 +2679,6 @@
 # {{{ sub MergeInto
 
 =head2 MergeInto
-
 MergeInto take the id of the ticket to merge this ticket into.
 
 =cut
@@ -2877,9 +2877,9 @@
 my $t = RT::Ticket->new($RT::SystemUser);
 $t->Load(1);
 $t->SetOwner('root');
-is ($t->OwnerObj->Name, 'root' , "Root owns the ticket");
+ok ($t->OwnerObj->Name eq 'root' , "Root owns the ticket");
 $t->Steal();
-is ($t->OwnerObj->id, $RT::SystemUser->id , "SystemUser owns the ticket");
+ok ($t->OwnerObj->id eq $RT::SystemUser->id , "SystemUser owns the ticket");
 my $txns = RT::Transactions->new($RT::SystemUser);
 $txns->OrderBy(FIELD => 'id', ORDER => 'DESC');
 $txns->Limit(FIELD => 'Ticket', VALUE => '1');
@@ -3109,14 +3109,14 @@
 my ($id, $tid, $msg)= $tt->Create(Queue => 'general',
             Subject => 'test');
 ok($id, $msg);
-is($tt->Status, 'new', "New ticket is created as new");
+ok($tt->Status eq 'new', "New ticket is created as new");
 
 ($id, $msg) = $tt->SetStatus('open');
 ok($id, $msg);
-like($msg, qr/open/i, "Status message is correct");
+ok ($msg =~ /open/i, "Status message is correct");
 ($id, $msg) = $tt->SetStatus('resolved');
 ok($id, $msg);
-like($msg, qr/resolved/i, "Status message is correct");
+ok ($msg =~ /resolved/i, "Status message is correct");
 ($id, $msg) = $tt->SetStatus('resolved');
 ok(!$id,$msg);
 
@@ -3268,6 +3268,282 @@
 
 # }}}
 
+# {{{ Routines dealing with custom fields
+
+
+# {{{ FirstCustomFieldValue
+
+=item FirstCustomFieldValue FIELD
+
+Return the content of the first value of CustomField FIELD for this ticket
+Takes a field id or name
+
+=cut
+
+sub FirstCustomFieldValue {
+    my $self = shift;
+    my $field = shift;
+    my $values = $self->CustomFieldValues($field);
+    if ($values->First) {
+        return $values->First->Content;
+    } else {
+        return undef;
+    }
+
+}
+
+
+
+# {{{ CustomFieldValues
+
+=item CustomFieldValues FIELD
+
+Return a TicketCustomFieldValues object of all values of CustomField FIELD for this ticket.  
+Takes a field id or name.
+
+
+=cut
+
+sub CustomFieldValues {
+    my $self  = shift;
+    my $field = shift;
+
+    my $cf = RT::CustomField->new($self->CurrentUser);
+
+    if ($field =~ /^\d+$/) {
+        $cf->LoadById($field);
+    } else {
+        $cf->LoadByNameAndQueue(Name => $field, Queue => $self->QueueObj->Id);
+        unless( $cf->id ) {
+            $cf->LoadByNameAndQueue(Name => $field, Queue => '0');
+        }
+    }
+    my $cf_values = RT::TicketCustomFieldValues->new( $self->CurrentUser );
+    $cf_values->LimitToCustomField($cf->id);
+    $cf_values->LimitToTicket($self->Id());
+    $cf_values->OrderBy( FIELD => 'id' );
+
+    # @values is a CustomFieldValues object;
+    return ($cf_values);
+}
+
+# }}}
+
+# {{{ AddCustomFieldValue
+
+=item AddCustomFieldValue { Field => FIELD, Value => VALUE }
+
+VALUE should be a string.
+FIELD can be a CustomField object OR a CustomField ID.
+
+
+Adds VALUE as a value of CustomField FIELD.  If this is a single-value custom field,
+deletes the old value. 
+If VALUE isn't a valid value for the custom field, returns 
+(0, 'Error message' ) otherwise, returns (1, 'Success Message')
+
+=cut
+
+sub AddCustomFieldValue {
+    my $self = shift;
+    unless ( $self->CurrentUserHasRight('ModifyTicket') ) {
+        return ( 0, $self->loc("Permission Denied") );
+    }
+    $self->_AddCustomFieldValue(@_);
+}
+
+sub _AddCustomFieldValue {
+    my $self = shift;
+    my %args = (
+        Field => undef,
+        Value => undef,
+	RecordTransaction => 1,
+        @_
+    );
+
+    my $cf = RT::CustomField->new( $self->CurrentUser );
+    if ( UNIVERSAL::isa( $args{'Field'}, "RT::CustomField" ) ) {
+        $cf->Load( $args{'Field'}->id );
+    }
+    else {
+        $cf->Load( $args{'Field'} );
+    }
+
+    unless ( $cf->Id ) {
+        return ( 0, $self->loc("Custom field [_1] not found", $args{'Field'}) );
+    }
+
+    # Load up a TicketCustomFieldValues object for this custom field and this ticket
+    my $values = $cf->ValuesForTicket( $self->id );
+
+    unless ( $cf->ValidateValue( $args{'Value'} ) ) {
+        return ( 0, $self->loc("Invalid value for custom field") );
+    }
+
+    # If the custom field only accepts a single value, delete the existing
+    # value and record a "changed from foo to bar" transaction
+    if ( $cf->SingleValue ) {
+
+        # We need to whack any old values here.  In most cases, the custom field should
+        # only have one value to delete.  In the pathalogical case, this custom field
+        # used to be a multiple and we have many values to whack....
+        my $cf_values = $values->Count;
+
+        if ( $cf_values > 1 ) {
+            my $i = 0;   #We want to delete all but the last one, so we can then
+                 # execute the same code to "change" the value from old to new
+            while ( my $value = $values->Next ) {
+                $i++;
+                if ( $i < $cf_values ) {
+                    my $old_value = $value->Content;
+                    my ($val, $msg) = $cf->DeleteValueForTicket(Ticket => $self->Id, Content => $value->Content);
+                    unless ($val) {
+                        return (0,$msg);
+                    }
+                    my ( $TransactionId, $Msg, $TransactionObj ) =
+                      $self->_NewTransaction(
+                        Type     => 'CustomField',
+                        Field    => $cf->Id,
+                        OldValue => $old_value
+                      );
+                }
+            }
+        }
+
+        my $old_value;
+        if (my $value = $cf->ValuesForTicket( $self->Id )->First) {
+	    $old_value = $value->Content();
+	    return (1) if $old_value eq $args{'Value'};
+	}
+
+        my ( $new_value_id, $value_msg ) = $cf->AddValueForTicket(
+            Ticket  => $self->Id,
+            Content => $args{'Value'}
+        );
+
+        unless ($new_value_id) {
+            return ( 0,
+                $self->loc("Could not add new custom field value for ticket. [_1] ",
+                  ,$value_msg) );
+        }
+
+        my $new_value = RT::TicketCustomFieldValue->new( $self->CurrentUser );
+        $new_value->Load($new_value_id);
+
+        # now that adding the new value was successful, delete the old one
+	if ($old_value) {
+	    my ($val, $msg) = $cf->DeleteValueForTicket(Ticket => $self->Id, Content => $old_value);
+	    unless ($val) { 
+	    		return (0,$msg);
+	    }
+	}
+
+	if ($args{'RecordTransaction'}) {
+        my ( $TransactionId, $Msg, $TransactionObj ) = $self->_NewTransaction(
+            Type     => 'CustomField',
+            Field    => $cf->Id,
+            OldValue => $old_value,
+            NewValue => $new_value->Content
+        );
+	}
+
+        if ( $old_value eq '' ) {
+            return ( 1, $self->loc("[_1] [_2] added", $cf->Name, $new_value->Content) );
+        }
+        elsif ( $new_value->Content eq '' ) {
+            return ( 1, $self->loc("[_1] [_2] deleted", $cf->Name, $old_value) );
+        }
+        else {
+            return ( 1, $self->loc("[_1] [_2] changed to [_3]", $cf->Name, $old_value, $new_value->Content ) );
+        }
+
+    }
+
+    # otherwise, just add a new value and record "new value added"
+    else {
+        my ( $new_value_id ) = $cf->AddValueForTicket(
+            Ticket  => $self->Id,
+            Content => $args{'Value'}
+        );
+
+        unless ($new_value_id) {
+            return ( 0,
+                $self->loc("Could not add new custom field value for ticket. "));
+        }
+    if ( $args{'RecordTransaction'} ) {
+        my ( $TransactionId, $Msg, $TransactionObj ) = $self->_NewTransaction(
+            Type     => 'CustomField',
+            Field    => $cf->Id,
+            NewValue => $args{'Value'}
+        );
+        unless ($TransactionId) {
+            return ( 0,
+                $self->loc( "Couldn't create a transaction: [_1]", $Msg ) );
+        }
+    }
+        return ( 1, $self->loc("[_1] added as a value for [_2]",$args{'Value'}, $cf->Name));
+    }
+
+}
+
+# }}}
+
+# {{{ DeleteCustomFieldValue
+
+=item DeleteCustomFieldValue { Field => FIELD, Value => VALUE }
+
+Deletes VALUE as a value of CustomField FIELD. 
+
+VALUE can be a string, a CustomFieldValue or a TicketCustomFieldValue.
+
+If VALUE isn't a valid value for the custom field, returns 
+(0, 'Error message' ) otherwise, returns (1, 'Success Message')
+
+=cut
+
+sub DeleteCustomFieldValue {
+    my $self = shift;
+    my %args = (
+        Field => undef,
+        Value => undef,
+        @_);
+
+    unless ( $self->CurrentUserHasRight('ModifyTicket') ) {
+        return ( 0, $self->loc("Permission Denied") );
+    }
+    my $cf = RT::CustomField->new( $self->CurrentUser );
+    if ( UNIVERSAL::isa( $args{'Field'}, "RT::CustomField" ) ) {
+        $cf->LoadById( $args{'Field'}->id );
+    }
+    else {
+        $cf->LoadById( $args{'Field'} );
+    }
+
+    unless ( $cf->Id ) {
+        return ( 0, $self->loc("Custom field not found") );
+    }
+
+
+     my ($val, $msg) = $cf->DeleteValueForTicket(Ticket => $self->Id, Content => $args{'Value'});
+     unless ($val) { 
+            return (0,$msg);
+     }
+        my ( $TransactionId, $Msg, $TransactionObj ) = $self->_NewTransaction(
+            Type     => 'CustomField',
+            Field    => $cf->Id,
+            OldValue => $args{'Value'}
+        );
+        unless($TransactionId) {
+            return(0, $self->loc("Couldn't create a transaction: [_1]", $Msg));
+        } 
+
+        return($TransactionId, $self->loc("[_1] is no longer a value for custom field [_2]", $args{'Value'}, $cf->Name));
+}
+
+# }}}
+
+# }}}
+
 # {{{ Actions + Routines dealing with transactions
 
 # {{{ sub SetTold and _SetTold
@@ -3322,6 +3598,113 @@
 
 # }}}
 
+# {{{ sub Transactions 
+
+=head2 Transactions
+
+  Returns an RT::Transactions object of all transactions on this ticket
+
+=cut
+
+sub Transactions {
+    my $self = shift;
+
+    use RT::Transactions;
+    my $transactions = RT::Transactions->new( $self->CurrentUser );
+
+    #If the user has no rights, return an empty object
+    if ( $self->CurrentUserHasRight('ShowTicket') ) {
+        my $tickets = $transactions->NewAlias('Tickets');
+        $transactions->Join(
+            ALIAS1 => 'main',
+            FIELD1 => 'Ticket',
+            ALIAS2 => $tickets,
+            FIELD2 => 'id'
+        );
+        $transactions->Limit(
+            ALIAS => $tickets,
+            FIELD => 'EffectiveId',
+            VALUE => $self->id()
+        );
+
+        # if the user may not see comments do not return them
+        unless ( $self->CurrentUserHasRight('ShowTicketComments') ) {
+            $transactions->Limit(
+                FIELD    => 'Type',
+                OPERATOR => '!=',
+                VALUE    => "Comment",
+                ENTRYAGGREGATOR => 'AND'
+            );
+            $transactions->Limit(
+                FIELD    => 'Type',
+                OPERATOR => '!=',
+                VALUE    => "CommentEmailRecord",
+                ENTRYAGGREGATOR => 'AND'
+            );
+        }
+    }
+
+    return ($transactions);
+}
+
+# }}}
+
+# {{{ sub _NewTransaction
+
+=head2 _NewTransaction  PARAMHASH
+
+Private function to create a new RT::Transaction object for this ticket update
+
+=cut
+
+sub _NewTransaction {
+    my $self = shift;
+    my %args = (
+        TimeTaken => 0,
+        Type      => undef,
+        OldValue  => undef,
+        NewValue  => undef,
+        Data      => undef,
+        Field     => undef,
+        MIMEObj   => undef,
+        ActivateScrips => 1,
+        CommitScrips => 1,
+        @_
+    );
+
+    require RT::Transaction;
+    my $trans = new RT::Transaction( $self->CurrentUser );
+    my ( $transaction, $msg ) = $trans->Create(
+        Ticket    => $self->Id,
+        TimeTaken => $args{'TimeTaken'},
+        Type      => $args{'Type'},
+        Data      => $args{'Data'},
+        Field     => $args{'Field'},
+        NewValue  => $args{'NewValue'},
+        OldValue  => $args{'OldValue'},
+        MIMEObj   => $args{'MIMEObj'},
+        ActivateScrips => $args{'ActivateScrips'},
+        CommitScrips => $args{'CommitScrips'},
+    );
+
+    # Rationalize the object since we may have done things to it during the caching.
+    $self->Load($self->Id);
+
+    $RT::Logger->warning($msg) unless $transaction;
+
+    $self->_SetLastUpdated;
+
+    if ( defined $args{'TimeTaken'} ) {
+        $self->_UpdateTimeTaken( $args{'TimeTaken'} );
+    }
+    if ( $RT::UseTransactionBatch and $transaction ) {
+	    push @{$self->{_TransactionBatch}}, $trans;
+    }
+    return ( $transaction, $msg, $trans );
+}
+
+# }}}
+
 =head2 TransactionBatch
 
   Returns an array reference of all transactions created on this ticket during
@@ -3574,86 +3957,6 @@
 
 # }}}
 
-# {{{ sub Transactions 
-
-=head2 Transactions
-
-  Returns an RT::Transactions object of all transactions on this ticket
-
-=cut
-
-sub Transactions {
-    my $self = shift;
-
-    use RT::Transactions;
-    my $transactions = RT::Transactions->new( $self->CurrentUser );
-
-    #If the user has no rights, return an empty object
-    if ( $self->CurrentUserHasRight('ShowTicket') ) {
-        my $tickets = $transactions->NewAlias('Tickets');
-        $transactions->Join(
-            ALIAS1 => 'main',
-            FIELD1 => 'ObjectId',
-            ALIAS2 => $tickets,
-            FIELD2 => 'id'
-        );
-        $transactions->Limit(
-            ALIAS => $tickets,
-            FIELD => 'EffectiveId',
-            VALUE => $self->id()
-        );
-	$transactions->Limit(
-	    FIELD    => 'ObjectType',
-	    VALUE    => ref($self),
-	);
-
-        # if the user may not see comments do not return them
-        unless ( $self->CurrentUserHasRight('ShowTicketComments') ) {
-            $transactions->Limit(
-                FIELD    => 'Type',
-                OPERATOR => '!=',
-                VALUE    => "Comment"
-            );
-            $transactions->Limit(
-                FIELD    => 'Type',
-                OPERATOR => '!=',
-                VALUE    => "CommentEmailRecord",
-                ENTRYAGGREGATOR => 'AND'
-            );
-
-        }
-    }
-
-    return ($transactions);
-}
-
-# }}}
-
-sub TransactionCustomFields {
-    my $self = shift;
-    return $self->QueueObj->TicketTransactionCustomFields;
-}
-
-# Do name => id mapping (if needed) before falling back to
-# RT::Record's CustomFieldValues
-sub CustomFieldValues {
-    my $self = shift;
-    my $field = shift;
-    unless ($field =~ /^\d+$/) {
-	my $cf = RT::CustomField->new($self->CurrentUser);
-	$cf->LoadByNameAndQueue(Name => $field, Queue => $self->QueueObj->Id);
-	unless( $cf->id ) {
-            $cf->LoadByNameAndQueue(Name => $field, Queue => '0');
-        }
-	$field = $cf->id;
-    }
-    return $self->SUPER::CustomFieldValues($field);
-}
-
-sub _LookupTypes {
-    "RT::Queue-RT::Ticket";
-}
-
 1;
 
 =head1 AUTHOR

Modified: rt/branches/rt-3.1/lib/RT/Tickets_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Tickets_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Tickets_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -108,10 +108,6 @@
     LinkedTo	    => ['LINKFIELD',],
     CustomFieldValue =>['CUSTOMFIELD',],
     CF              => ['CUSTOMFIELD',],
-    RequestorGroup  => ['MEMBERSHIPFIELD' => 'Requestor',],
-    CCGroup         => ['MEMBERSHIPFIELD' => 'Cc',],
-    AdminCCGroup    => ['MEMBERSHIPFIELD' => 'AdminCc',],
-    WatcherGroup    => ['MEMBERSHIPFIELD',],
   );
 
 # Mapping of Field Type to Function
@@ -124,9 +120,8 @@
     TRANSFIELD	    => \&_TransLimit,
     TRANSDATE	    => \&_TransDateLimit,
     WATCHERFIELD    => \&_WatcherLimit,
-    MEMBERSHIPFIELD => \&_WatcherMembershipLimit,
     LINKFIELD	    => \&_LinkFieldLimit,
-    CUSTOMFIELD     => \&_CustomFieldLimit,
+    CUSTOMFIELD    => \&_CustomFieldLimit,
   );
 my %can_bundle =
   ( WATCHERFIELD => "yeps",
@@ -247,7 +242,7 @@
     $o->Load( $value );
     $value = $o->Id;
   }
-  $sb->_SQLLimit( FIELD => $field,
+  $sb->_SQLLimit( FIELD => $field,,
 	      VALUE => $value,
 	      OPERATOR => $op,
 	      @rest,
@@ -543,14 +538,6 @@
 
   $sb->_OpenParen;
 
-  # Join Transactions To Attachments
-  $sb->_SQLJoin( ALIAS1 => $sb->{_sql_trattachalias}, FIELD1 => 'TransactionId',
-	     ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'id');
-
-  # Join Transactions to Tickets
-  $sb->_SQLJoin( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, # UGH!
-	     ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'Ticket');
-
   #Search for the right field
   $sb->_SQLLimit(ALIAS => $sb->{_sql_trattachalias},
 		 FIELD =>    $field,
@@ -560,6 +547,14 @@
 		 @rest
 		);
 
+  # Join Transactions To Attachments
+  $sb->_SQLJoin( ALIAS1 => $sb->{_sql_trattachalias}, FIELD1 => 'TransactionId',
+	     ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'id');
+
+  # Join Transactions to Tickets
+  $sb->_SQLJoin( ALIAS1 => 'main', FIELD1 => $sb->{'primary_key'}, # UGH!
+	     ALIAS2 => $sb->{_sql_transalias}, FIELD2 => 'Ticket');
+
   $sb->_CloseParen;
 
 }
@@ -647,112 +642,6 @@
 
 }
 
-=head2 _WatcherMembershipLimit
-
-Handle watcher membership limits, i.e. whether the watcher belongs to a
-specific group or not.
-
-Meta Data:
-  1: Field to query on
-
-SELECT DISTINCT main.*
-FROM
-    Tickets main,
-    Groups Groups_1,
-    CachedGroupMembers CachedGroupMembers_2,
-    Users Users_3
-WHERE (
-    (main.EffectiveId = main.id)
-) AND (
-    (main.Status != 'deleted')
-) AND (
-    (main.Type = 'ticket')
-) AND (
-    (
-	(Users_3.EmailAddress = '22')
-	    AND
-	(Groups_1.Domain = 'RT::Ticket-Role')
-	    AND
-	(Groups_1.Type = 'RequestorGroup')
-    )
-) AND
-    Groups_1.Instance = main.id
-AND
-    Groups_1.id = CachedGroupMembers_2.GroupId
-AND
-    CachedGroupMembers_2.MemberId = Users_3.id
-ORDER BY main.id ASC
-LIMIT 25
-=cut
-
-sub _WatcherMembershipLimit {
-  my ($self,$field,$op,$value, at rest) = @_;
-  my %rest = @rest;
-
-  $self->_OpenParen;
-
-  my $groups	    = $self->NewAlias('Groups');
-  my $groupmembers  = $self->NewAlias('CachedGroupMembers');
-  my $users	    = $self->NewAlias('Users');
-  my $memberships   = $self->NewAlias('CachedGroupMembers');
-
-  if (ref $field) { # gross hack
-    my @bundle = @$field;
-    $self->_OpenParen;
-    for my $chunk (@bundle) {
-      ($field,$op,$value, at rest) = @$chunk;
-      $self->_SQLLimit(ALIAS => $memberships,
-   		   FIELD => 'GroupId',
-   		   VALUE           => $value,
-   		   OPERATOR        => $op,
-   		   @rest,
-   		  );
-    }
-    $self->_CloseParen;
-  } else {
-     $self->_SQLLimit(ALIAS => $memberships,
-   		   FIELD => 'GroupId',
-   		   VALUE           => $value,
-   		   OPERATOR        => $op,
-   		   @rest,
-   		  );
-  }
-
-  # {{{ Tie to groups for tickets we care about
-  $self->_SQLLimit(ALIAS => $groups,
-		   FIELD => 'Domain',
-		   VALUE => 'RT::Ticket-Role',
-		   ENTRYAGGREGATOR => 'AND');
-
-  $self->Join(ALIAS1 => $groups, FIELD1 => 'Instance',
-	      ALIAS2 => 'main',   FIELD2 => 'id');
-  # }}}
-
-  # If we care about which sort of watcher
-  my $meta = $FIELDS{$field};
-  my $type = ( defined $meta->[1] ? $meta->[1] : undef );
-
-  if ( $type ) {
-    $self->_SQLLimit(ALIAS => $groups,
-		     FIELD => 'Type',
-		     VALUE => $type,
-		     ENTRYAGGREGATOR => 'AND');
-  }
-
-  $self->Join (ALIAS1 => $groups,  FIELD1 => 'id',
-	       ALIAS2 => $groupmembers, FIELD2 => 'GroupId');
-
-  $self->Join( ALIAS1 => $groupmembers, FIELD1 => 'MemberId',
-	       ALIAS2 => $users, FIELD2 => 'id');
-
-  $self->Join( ALIAS1 => $memberships, FIELD1 => 'MemberId',
-	       ALIAS2 => $users, FIELD2 => 'id');
-
- $self->_CloseParen;
-
-}
-
-
 sub _LinkFieldLimit {
   my $restriction;
   my $self;
@@ -821,102 +710,93 @@
 =cut
 
 sub _CustomFieldLimit {
-    my ( $self, $_field, $op, $value, @rest ) = @_;
+  my ($self,$_field,$op,$value, at rest) = @_;
+
+  my %rest = @rest;
+  my $field = $rest{SUBKEY} || die "No field specified";
+
+  # For our sanity, we can only limit on one queue at a time
+  my $queue = 0;
 
-    my %rest  = @rest;
-    my $field = $rest{SUBKEY} || die "No field specified";
 
-    # For our sanity, we can only limit on one queue at a time
-    my $queue = 0;
+  if ($field =~ /^(.+?)\.{(.+)}$/) {
+    $queue =  $1;
+    $field = $2;
+   }
+    $field = $1 if $field =~ /^{(.+)}$/; # trim { }
 
-    if ( $field =~ /^(.+?)\.{(.+)}$/ ) {
-        $queue = $1;
-        $field = $2;
+    my $q = RT::Queue->new($self->CurrentUser);
+    $q->Load($queue) if ($queue);
+
+    my $cf;
+    if ($q->id) {
+        $cf = $q->CustomField($field);
+    }
+    else { 
+        $cf = RT::CustomField->new($self->CurrentUser);
+        $cf->LoadByNameAndQueue(Queue => '0', Name => $field);
     }
-    $field = $1 if $field =~ /^{(.+)}$/;    # trim { }
 
 
 
-# If we're trying to find custom fields that don't match something, we want tickets
-# where the custom field has no value at all
 
-    my $null_columns_ok;
-    if ( ( $op =~ /^IS$/i ) or ( $op =~ /^NOT LIKE$/i ) or ( $op eq '!=' ) ) {
-        $null_columns_ok = 1;
-    }
 
+  my $cfid = $cf->id;
 
+  die "No custom field named $field found\n" unless $cfid;
 
-    my $q = RT::Queue->new( $self->CurrentUser );
-    $q->Load($queue) if ($queue);
 
-    my $cf;
-    if ( $q->id ) {
-        $cf = $q->CustomField($field);
-    }
-    else {
-        $cf = RT::CustomField->new( $self->CurrentUser );
-        $cf->LoadByNameAndQueue( Queue => '0', Name => $field );
-    }
 
-    my $cfid = $cf->id;
+  my $null_columns_ok;
 
-    die "No custom field named $field found\n" unless $cfid;
+  my $TicketCFs;
+  # Perform one Join per CustomField
+  if ($self->{_sql_keywordalias}{$cfid}) {
+    $TicketCFs = $self->{_sql_keywordalias}{$cfid};
+  } else {
+    $TicketCFs = $self->{_sql_keywordalias}{$cfid} =
+      $self->_SQLJoin( TYPE   => 'left',
+		   ALIAS1 => 'main',
+		   FIELD1 => 'id',
+		   TABLE2 => 'TicketCustomFieldValues',
+		   FIELD2 => 'Ticket' );
+  }
 
+  $self->_OpenParen;
 
-    my $TicketCFs;
+  $self->_SQLLimit( ALIAS      => $TicketCFs,
+		    FIELD      => 'Content',
+		    OPERATOR   => $op,
+		    VALUE      => $value,
+		    QUOTEVALUE => 1,
+		    @rest );
 
-    # Perform one Join per CustomField
-    if ( $self->{_sql_keywordalias}{$cfid} ) {
-        $TicketCFs = $self->{_sql_keywordalias}{$cfid};
-    }
-    else {
-        $TicketCFs = $self->{_sql_keywordalias}{$cfid} = $self->_SQLJoin(
-            TYPE   => 'left',
-            ALIAS1 => 'main',
-            FIELD1 => 'id',
-            TABLE2 => 'ObjectCustomFieldValues',
-            FIELD2 => 'ObjectId'
-        );
-
-    $self->_SQLLimit(
-        LEFTJOIN        => $TicketCFs,
-        FIELD => 'ObjectType',
-        VALUE => ref($self->NewItem), # we want a single item, not a collection
-        ENTRYAGGREGATOR => 'AND'
-    );
-
-    $self->_SQLLimit(
-        LEFTJOIN        => $TicketCFs,
-        FIELD           => 'CustomField',
-        VALUE           => $cfid,
-        ENTRYAGGREGATOR => 'AND'
-    );
 
-    }
+   # If we're trying to find custom fields that don't match something, we want tickets
+   # where the custom field has no value at all
 
-    $self->_OpenParen;
+  if (   ($op =~ /^IS$/i) or ($op =~ /^NOT LIKE$/i) or ( $op eq '!=' ) ) {
+    $null_columns_ok = 1;
+  }
+    
 
-    $self->_SQLLimit(
-        ALIAS      => $TicketCFs,
-        FIELD      => 'Content',
-        OPERATOR   => $op,
-        VALUE      => $value,
-        QUOTEVALUE => 1,
-        @rest
-    );
-    if ($null_columns_ok) {
-        $self->_SQLLimit(
-            ALIAS           => $TicketCFs,
-            FIELD           => 'Content',
-            OPERATOR        => 'IS',
-            VALUE           => 'NULL',
-            QUOTEVALUE      => 0,
-            ENTRYAGGREGATOR => 'OR',
-        );
-    }
+  if ( $null_columns_ok) {
+    $self->_SQLLimit( ALIAS           => $TicketCFs,
+		      FIELD           => 'Content',
+		      OPERATOR        => 'IS',
+		      VALUE           => 'NULL',
+		      QUOTEVALUE      => 0,
+		      ENTRYAGGREGATOR => 'OR', );
+  }
 
-    $self->_CloseParen;
+  $self->_SQLLimit( LEFTJOIN => $TicketCFs,
+		    FIELD    => 'CustomField',
+		    VALUE    => $cfid,
+		    ENTRYAGGREGATOR => 'OR' );
+
+
+
+  $self->_CloseParen;
 
 }
 
@@ -990,13 +870,8 @@
 
 sub FreezeLimits {
 	my $self = shift;
-	require Storable;
-	require MIME::Base64;
-	MIME::Base64::base64_encode(
-	    Storable::freeze(
-		\@{$self}{$self->_FreezeThawKeys}
-	    )
-	);
+	require FreezeThaw;
+	return (FreezeThaw::freeze(@{$self}{$self->_FreezeThawKeys}));
 }
 
 # }}}
@@ -1018,14 +893,13 @@
 
     	$self->{'RecalcTicketLimits'} = 1;
 
-	require Storable;
-	require MIME::Base64;
-
+	require FreezeThaw;
+	
 	#We don't need to die if the thaw fails.
-	@{$self}{$self->_FreezeThawKeys} = eval {
-	    @{Storable::thaw( MIME::Base64::base64_decode($in) )};
-	};
 	
+	eval {
+		@{$self}{$self->_FreezeThawKeys} = FreezeThaw::thaw($in);
+	};
 	$RT::Logger->error( $@ ) if $@;
 
 }
@@ -2098,9 +1972,9 @@
     }
 
     # Two special case
-    # Handle subkey fields with a different real field
-    if ($field =~ /^(\w+)\./) {
-      $realfield = $1;
+    # CustomFields have a different real field
+    if ($field =~ /^CF\./) {
+      $realfield = "CF"
     }
 
     die "I don't know about $field yet"

Modified: rt/branches/rt-3.1/lib/RT/Tickets_Overlay_SQL.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Tickets_Overlay_SQL.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Tickets_Overlay_SQL.pm	Mon Jul 12 14:00:53 2004
@@ -129,14 +129,9 @@
 use constant OP => 4;
 use constant PAREN => 8;
 use constant KEYWORD => 16;
-use constant SELECT => 32;
-use constant WHERE => 64;
-use constant COLUMN => 128;
-my @tokens = qw[VALUE AGGREG OP PAREN KEYWORD SELECT WHERE COLUMN];
+my @tokens = qw[VALUE AGGREG OP PAREN KEYWORD];
 
 my $re_aggreg = qr[(?i:AND|OR)];
-my $re_select = qr[(?i:SELECT)];
-my $re_where = qr[(?i:WHERE)];
 my $re_value  = qr[$RE{delimited}{-delim=>qq{\'\"}}|\d+];
 my $re_keyword = qr[$RE{delimited}{-delim=>qq{\'\"}}|(?:\{|\}|\w|\.)+];
 my $re_op     = qr[=|!=|>=|<=|>|<|(?i:IS NOT)|(?i:IS)|(?i:NOT LIKE)|(?i:LIKE)]; # long to short
@@ -176,7 +171,7 @@
 
 sub _parser {
   my ($self,$string) = @_;
-  my $want = SELECT | KEYWORD | PAREN;
+  my $want = KEYWORD | PAREN;
   my $last = undef;
 
   my $depth = 0;
@@ -193,9 +188,7 @@
 
 
   while ($string =~ /(
-                      $re_select
-                      |$re_where
-                      |$re_aggreg
+                      $re_aggreg
                       |$re_op
                       |$re_keyword
                       |$re_value
@@ -210,9 +203,6 @@
     $current = KEYWORD if _match($re_keyword,$val) && ($want & KEYWORD);
     $current = AGGREG  if _match($re_aggreg,$val);
     $current = PAREN   if _match($re_paren,$val);
-    $current = COLUMN if _match($re_keyword,$val) && ($want & COLUMN);
-    $current = WHERE if _match($re_where,$val) && ($want & WHERE);
-    $current = SELECT if _match($re_select,$val);
 
 
     unless ($current && $want & $current) {
@@ -240,26 +230,7 @@
 
       $want = KEYWORD | PAREN | AGGREG;
     }
-    elsif ($current & SELECT ) {
-        $want = COLUMN | WHERE;
-    }
-
-    elsif ($current & COLUMN ) {
-      if ($val =~ /$RE{delimited}{-delim=>qq{\'\"}}/) {
-        substr($val,0,1) = "";
-        substr($val,-1,1) = "";
-      }
-      # Unescape escaped characters
-      $val =~ s!\\(.)!$1!g;     
-        $self->_DisplayColumn($val);
-
-        $want = COLUMN | WHERE;
 
-    } 
-    elsif ($current & WHERE ) {
-        $want = KEYWORD | PAREN;
-
-    }
     elsif ( $current & AGGREG ) {
       $ea = $val;
       $want = KEYWORD | PAREN;
@@ -405,60 +376,63 @@
 
 use RT::Tickets;
 
-my $query = "SELECT id WHERE Status = 'open'";
+
 
 my $tix = RT::Tickets->new($RT::SystemUser);
 
+my $query = "Status = 'open'";
 my ($id, $msg)  = $tix->FromSQL($query);
 
 ok ($id, $msg);
 
-my @cols =  $tix->DisplayColumns;
-
-ok ($cols[0]->{'attribute'} == 'id', "We're  displaying the ticket id");
-ok ($cols[1] == undef, "We're  displaying the ticket id");
 
+my (@ids, @expectedids);
 
-my $query = "SELECT id, Status WHERE Status = 'open'";
+my $t = RT::Ticket->new($RT::SystemUser);
 
-my $tix = RT::Tickets->new($RT::SystemUser);
+my $string = 'subject/content SQL test';
+ok( $t->Create(Queue => 'General', Subject => $string), "Ticket Created");
 
-my ($id, $msg)  = $tix->FromSQL($query);
+push @ids, $t->Id;
 
-ok ($id, $msg);
+my $Message = MIME::Entity->build(
+			     Subject     => 'this is my subject',
+			     From        => 'jesse at example.com',
+			     Data        => [ $string ],
+        );
 
-my @cols =  $tix->DisplayColumns;
+ok( $t->Create(Queue => 'General', Subject => 'another ticket', MIMEObj => $Message, MemberOf => $ids[0]), "Ticket Created");
 
-ok ($cols[0]->{'attribute'} == 'id', "We're only displaying the ticket id");
-ok ($cols[1]->{'attribute'} == 'Status', "We're only displaying the ticket id");
+push @ids, $t->Id;
 
-my $query = qq[SELECT id, Status, '<A href="/Ticket/Display.html?id=##id##">Subject, this: ##Subject##</a>' WHERE Status = 'open'];
+$query = ("Subject LIKE '$string' OR Content LIKE '$string'");
 
-my $tix = RT::Tickets->new($RT::SystemUser);
-
-my ($id, $msg)  = $tix->FromSQL($query);
+my ($id, $msg) = $tix->FromSQL($query);
 
 ok ($id, $msg);
 
-my @cols =  $tix->DisplayColumns;
+is ($tix->Count, scalar @ids, "number of returned tickets same as entered");
 
-ok ($cols[0]->{'attribute'} == 'id', "We're only displaying the ticket id");
-ok ($cols[1]->{'attribute'} == 'Status', "We're only displaying the ticket id");
+while (my $tick = $tix->Next) {
+    push @expectedids, $tick->Id;
+}
 
+ok (eq_array(\@ids, \@expectedids), "returned expected tickets");
 
+$query = ("id = $ids[0] OR MemberOf = $ids[0]");
 
-$query = "Status = 'open'";
-my ($id, $msg)  = $tix->FromSQL($query);
+my ($id, $msg) = $tix->FromSQL($query);
 
 ok ($id, $msg);
 
-my @cols =  $tix->DisplayColumns;
-
-ok ($cols[0] == undef, "We haven't explicitly asked to display anything");
-
-
+is ($tix->Count, scalar @ids, "number of returned tickets same as entered");
 
+ at expectedids = ();
+while (my $tick = $tix->Next) {
+    push @expectedids, $tick->Id;
+}
 
+ok (eq_array(\@ids, \@expectedids), "returned expected tickets");
 
 =end testing
 
@@ -525,22 +499,6 @@
 
 Returns the query that this object was initialized with
 
-=begin testing
-
-my $query = "SELECT id, Status WHERE Status = 'open'";
-
-my $tix = RT::Tickets->new($RT::SystemUser);
-
-my ($id, $msg)  = $tix->FromSQL($query);
-
-ok ($id, $msg);
-
-my $newq = $tix->Query();
-
-is ($query, $newq);
-
-=end testing
-
 =cut
 
 sub Query {
@@ -549,71 +507,6 @@
 }
 
 
-=head2 _DisplayColumn COL
-
-Add COL to this search's list of "Columns to display"
-
-COL can either be a
-
-LiteralColumnName
-"QuotedString" (Containing ##LiteralColumnName## to embed the colum name inside it)
-
-What else?
-
-
-
-=cut
-
-sub _DisplayColumn {
-    my $self = shift;
-    my $col  = shift;
-
-    my $colref;
-    if ( $col =~ s/\/STYLE:(.*?)$//io ) {
-        $colref->{'style'} = $1;
-    }
-    if ( $col =~ s/\/CLASS:(.*?)$//io ) {
-        $colref->{'class'} = $1;
-    }
-    if ( $col =~ s/\/TITLE:(.*?)$//io ) {
-        $colref->{'title'} = $1;
-    }
-    if ( $col =~ /__(.*?)__/gio ) {
-        my @subcols;
-        while ( $col =~ s/^(.*?)__(.*?)__//o ) {
-            push ( @subcols, $1 ) if ($1);
-            push ( @subcols, "__$2__" );
-            $colref->{'attribute'} = $2;
-        }
-        push ( @subcols, $col );
-        @{ $colref->{'output'} } = @subcols;
-    }
-    else {
-        @{ $colref->{'output'} } = ( "__" . $col . "__" );
-        $colref->{'attribute'} = $col;
-    }
-
-    if ( !$colref->{'title'} && grep { /^__(.*?)__$/io }
-        @{ $colref->{'output'} } )
-    {
-        $colref->{'title'}     = $1;
-        $colref->{'attribute'} = $1;
-    }
-    push @{ $self->{'_sql_columns_to_display'} }, $colref;
-
-}
-
-=head2 DisplayColumns 
-
-Returns an array of the columns to show in the printed results of this object
-
-=cut
-
-sub DisplayColumns {
-    my $self = shift;
-    return (@{$self->{'_sql_columns_to_display'}});
-}
-
 
 1;
 

Modified: rt/branches/rt-3.1/lib/RT/Transaction.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Transaction.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Transaction.pm	Mon Jul 12 14:00:53 2004
@@ -46,6 +46,7 @@
 
 package RT::Transaction;
 use RT::Record; 
+use RT::Ticket;
 
 
 use vars qw( @ISA );
@@ -66,16 +67,13 @@
 
 Create takes a hash of values and creates a row in the database:
 
-  varchar(64) 'ObjectType'.
-  int(11) 'ObjectId'.
+  int(11) 'EffectiveTicket'.
+  int(11) 'Ticket'.
   int(11) 'TimeTaken'.
   varchar(20) 'Type'.
   varchar(40) 'Field'.
   varchar(255) 'OldValue'.
   varchar(255) 'NewValue'.
-  varchar(255) 'ReferenceType'.
-  int(11) 'OldReference'.
-  int(11) 'NewReference'.
   varchar(255) 'Data'.
 
 =cut
@@ -86,30 +84,24 @@
 sub Create {
     my $self = shift;
     my %args = ( 
-                ObjectType => '',
-                ObjectId => '0',
+                EffectiveTicket => '0',
+                Ticket => '0',
                 TimeTaken => '0',
                 Type => '',
                 Field => '',
                 OldValue => '',
                 NewValue => '',
-                ReferenceType => '',
-                OldReference => '',
-                NewReference => '',
                 Data => '',
 
 		  @_);
     $self->SUPER::Create(
-                         ObjectType => $args{'ObjectType'},
-                         ObjectId => $args{'ObjectId'},
+                         EffectiveTicket => $args{'EffectiveTicket'},
+                         Ticket => $args{'Ticket'},
                          TimeTaken => $args{'TimeTaken'},
                          Type => $args{'Type'},
                          Field => $args{'Field'},
                          OldValue => $args{'OldValue'},
                          NewValue => $args{'NewValue'},
-                         ReferenceType => $args{'ReferenceType'},
-                         OldReference => $args{'OldReference'},
-                         NewReference => $args{'NewReference'},
                          Data => $args{'Data'},
 );
 
@@ -126,42 +118,56 @@
 =cut
 
 
-=head2 ObjectType
+=head2 EffectiveTicket
 
-Returns the current value of ObjectType. 
-(In the database, ObjectType is stored as varchar(64).)
+Returns the current value of EffectiveTicket. 
+(In the database, EffectiveTicket is stored as int(11).)
 
 
 
-=head2 SetObjectType VALUE
+=head2 SetEffectiveTicket VALUE
 
 
-Set ObjectType to VALUE. 
+Set EffectiveTicket to VALUE. 
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, ObjectType will be stored as a varchar(64).)
+(In the database, EffectiveTicket will be stored as a int(11).)
 
 
 =cut
 
 
-=head2 ObjectId
+=head2 Ticket
 
-Returns the current value of ObjectId. 
-(In the database, ObjectId is stored as int(11).)
+Returns the current value of Ticket. 
+(In the database, Ticket is stored as int(11).)
 
 
 
-=head2 SetObjectId VALUE
+=head2 SetTicket VALUE
 
 
-Set ObjectId to VALUE. 
+Set Ticket to VALUE. 
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, ObjectId will be stored as a int(11).)
+(In the database, Ticket will be stored as a int(11).)
 
 
 =cut
 
 
+=head2 TicketObj
+
+Returns the Ticket Object which has the id returned by Ticket
+
+
+=cut
+
+sub TicketObj {
+	my $self = shift;
+	my $Ticket =  RT::Ticket->new($self->CurrentUser);
+	$Ticket->Load($self->__Value('Ticket'));
+	return($Ticket);
+}
+
 =head2 TimeTaken
 
 Returns the current value of TimeTaken. 
@@ -252,60 +258,6 @@
 =cut
 
 
-=head2 ReferenceType
-
-Returns the current value of ReferenceType. 
-(In the database, ReferenceType is stored as varchar(255).)
-
-
-
-=head2 SetReferenceType VALUE
-
-
-Set ReferenceType to VALUE. 
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, ReferenceType will be stored as a varchar(255).)
-
-
-=cut
-
-
-=head2 OldReference
-
-Returns the current value of OldReference. 
-(In the database, OldReference is stored as int(11).)
-
-
-
-=head2 SetOldReference VALUE
-
-
-Set OldReference to VALUE. 
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, OldReference will be stored as a int(11).)
-
-
-=cut
-
-
-=head2 NewReference
-
-Returns the current value of NewReference. 
-(In the database, NewReference is stored as int(11).)
-
-
-
-=head2 SetNewReference VALUE
-
-
-Set NewReference to VALUE. 
-Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, NewReference will be stored as a int(11).)
-
-
-=cut
-
-
 =head2 Data
 
 Returns the current value of Data. 
@@ -348,9 +300,9 @@
      
         id =>
 		{read => 1, type => 'int(11)', default => ''},
-        ObjectType => 
-		{read => 1, write => 1, type => 'varchar(64)', default => ''},
-        ObjectId => 
+        EffectiveTicket => 
+		{read => 1, write => 1, type => 'int(11)', default => '0'},
+        Ticket => 
 		{read => 1, write => 1, type => 'int(11)', default => '0'},
         TimeTaken => 
 		{read => 1, write => 1, type => 'int(11)', default => '0'},
@@ -362,12 +314,6 @@
 		{read => 1, write => 1, type => 'varchar(255)', default => ''},
         NewValue => 
 		{read => 1, write => 1, type => 'varchar(255)', default => ''},
-        ReferenceType => 
-		{read => 1, write => 1, type => 'varchar(255)', default => ''},
-        OldReference => 
-		{read => 1, write => 1, type => 'int(11)', default => ''},
-        NewReference => 
-		{read => 1, write => 1, type => 'int(11)', default => ''},
         Data => 
 		{read => 1, write => 1, type => 'varchar(255)', default => ''},
         Creator => 

Modified: rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Transaction_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -75,6 +75,7 @@
     my %args = (
         id             => undef,
         TimeTaken      => 0,
+        Ticket         => 0,
         Type           => 'undefined',
         Data           => '',
         Field          => undef,
@@ -83,36 +84,24 @@
         MIMEObj        => undef,
         ActivateScrips => 1,
         CommitScrips => 1,
-	ObjectType => 'RT::Ticket',
-	ObjectId => 0,
-	ReferenceType => undef,
-        OldReference       => undef,
-        NewReference       => undef,
         @_
     );
 
-    $args{ObjectId} ||= $args{Ticket};
-
     #if we didn't specify a ticket, we need to bail
-    unless ( $args{'ObjectId'} && $args{'ObjectType'}) {
-        return ( 0, $self->loc( "Transaction->Create couldn't, as you didn't specify an object type and id"));
+    unless ( $args{'Ticket'} ) {
+        return ( 0, $self->loc( "Transaction->Create couldn't, as you didn't specify a ticket id"));
     }
 
 
 
     #lets create our transaction
-    my %params = (
+    my %params = (Ticket    => $args{'Ticket'},
         Type      => $args{'Type'},
         Data      => $args{'Data'},
         Field     => $args{'Field'},
         OldValue  => $args{'OldValue'},
         NewValue  => $args{'NewValue'},
-        Created   => $args{'Created'},
-	ObjectType => $args{'ObjectType'},
-	ObjectId => $args{'ObjectId'},
-	ReferenceType => $args{'ReferenceType'},
-	OldReference => $args{'OldReference'},
-	NewReference => $args{'NewReference'},
+        Created   => $args{'Created'}
     );
 
     # Parameters passed in during an import that we probably don't want to touch, otherwise
@@ -127,7 +116,7 @@
 
     #Provide a way to turn off scrips if we need to
         $RT::Logger->debug('About to think about scrips for transaction' .$self->Id);            
-    if ( $args{'ActivateScrips'} and $args{'ObjectType'} eq 'RT::Ticket' ) {
+    if ( $args{'ActivateScrips'} ) {
        $self->{'scrips'} = RT::Scrips->new($RT::SystemUser);
 
         $RT::Logger->debug('About to prepare scrips for transaction' .$self->Id);            
@@ -135,7 +124,7 @@
         $self->{'scrips'}->Prepare(
             Stage       => 'TransactionCreate',
             Type        => $args{'Type'},
-            Ticket      => $args{'ObjectId'},
+            Ticket      => $args{'Ticket'},
             Transaction => $self->id,
         );
         if ($args{'CommitScrips'} ) {
@@ -504,15 +493,13 @@
         return $self->loc("No transaction type specified");
     }
 
-    my $obj_type = $self->FriendlyObjectType;
-
     if ( $type eq 'Create' ) {
-        return ($self->loc("[_1] created", $obj_type));
+        return ($self->loc("Ticket created"));
     }
     elsif ( $type =~ /Status/ ) {
         if ( $self->Field eq 'Status' ) {
             if ( $self->NewValue eq 'deleted' ) {
-                return ($self->loc("[_1] deleted", $obj_type));
+                return ($self->loc("Ticket deleted"));
             }
             else {
                 return ( $self->loc("Status changed from [_1] to [_2]", $self->loc($self->OldValue), $self->loc($self->NewValue) ));
@@ -734,7 +721,6 @@
 
 sub IsInbound {
     my $self = shift;
-    $self->ObjectType eq 'RT::Ticket' or return undef;
     return ( $self->TicketObj->IsRequestor( $self->CreatorObj->PrincipalId ) );
 }
 
@@ -851,77 +837,6 @@
 
 # }}}
 
-sub Ticket {
-    my $self = shift;
-    return $self->ObjectId;
-}
-
-sub TicketObj {
-    my $self = shift;
-    return $self->Object;
-}
-
-sub OldValue {
-    my $self = shift;
-    if (my $type = $self->__Value('ReferenceType')) {
-	my $Object = $type->new($self->CurrentUser);
-	$Object->Load($self->__Value('OldReference'));
-	return $Object->Content;
-    }
-    else {
-	return $self->__Value('OldValue');
-    }
-}
-
-sub NewValue {
-    my $self = shift;
-    if (my $type = $self->__Value('ReferenceType')) {
-	my $Object = $type->new($self->CurrentUser);
-	$Object->Load($self->__Value('NewReference'));
-	return $Object->Content;
-    }
-    else {
-	return $self->__Value('NewValue');
-    }
-}
-
-sub Object {
-    my $self  = shift;
-    my $Object = $self->__Value('ObjectType')->new($self->CurrentUser);
-    $Object->Load($self->__Value('ObjectId'));
-    return($Object);
-}
-
-sub FriendlyObjectType {
-    my $self = shift;
-    my $type = $self->ObjectType or return undef;
-    $type =~ s/^RT:://;
-    return $self->loc($type);
-}
-
-sub UpdateCustomFields {
-    my ($self, %args) = @_;
-    my $args_ref = $args{ARGSRef} or return;
-
-    foreach my $arg ( keys %$args_ref ) {
-        $arg =~ /^(?:Transaction)?CustomField-(\d+).*?(?<!-Magic)$/ or next;
-	my $cfid = $1;
-	my $values = $args_ref->{$arg};
-	foreach my $value ( UNIVERSAL::isa($values, 'ARRAY') ? @$values : $values ) {
-	    next unless length($value);
-	    $self->_AddCustomFieldValue(
-		Field => $cfid,
-		Value => $value,
-		RecordTransaction => 0,
-	    );
-	}
-    }
-}
-
-sub _LookupTypes {
-    "RT::Queue-RT::Ticket-RT::Transaction";
-}
-
 # Transactions don't change. by adding this cache congif directiove, we don't lose pathalogically on long tickets.
 sub _CacheConfig {
   {

Modified: rt/branches/rt-3.1/lib/RT/Transactions_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/Transactions_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/Transactions_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -63,30 +63,6 @@
 }
 # }}}
 
-=head2 Limit
-
-A wrapper around SUPER::Limit to catch migration issues
-
-=cut
-
-sub Limit {
-	my $self = shift;
-	my %args = (@_);
-
-	if ($args{'FIELD'} eq 'Ticket') {
-		Carp::cluck("Historical code calling RT::Transactions::Limit with a 'Ticket'.  This deprecated API will be deleted in 3.6");
-		$self->SUPER::Limit(FIELD => 'ObjectType', OPERATOR => '=', VALUE =>'RT::Ticket');
-		$args{'FIELD'} = 'ObjectId';
-		$self->SUPER::Limit(%args);
-
-	} else {
-
-		$self->SUPER::Limit(%args);
-	}
-
-
-}
-
 # {{{ sub Next
 sub Next {
     my $self = shift;

Modified: rt/branches/rt-3.1/lib/RT/User_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/User_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/User_Overlay.pm	Mon Jul 12 14:00:53 2004
@@ -149,13 +149,9 @@
         Privileged => 0,
         Disabled => 0,
         EmailAddress => '',
-        _RecordTransaction => 1,
         @_    # get the real argumentlist
     );
 
-    # remove the value so it does not cripple SUPER::Create
-    my $record_transaction = delete $args{'_RecordTransaction'};
-
     #Check the ACL
     unless ( $self->CurrentUser->HasRight(Right => 'AdminUsers', Object => $RT::System) ) {
         return ( 0, $self->loc('No permission to create users') );
@@ -296,12 +292,7 @@
     }
 
 
-    if ( $record_transaction ) {
-	$self->_NewTransaction( Type => "Create" );
-    }
-
     $RT::Handle->Commit;
-
     return ( $id, $self->loc('User created') );
 }
 
@@ -1011,7 +1002,7 @@
 
 =head2 _GeneratePassword PASSWORD
 
-returns an MD5 hash of the password passed in, in hexadecimal encoding.
+returns an MD5 hash of the password passed in, in base64 encoding.
 
 =cut
 
@@ -1021,23 +1012,6 @@
 
     my $md5 = Digest::MD5->new();
     $md5->add($password);
-    return ($md5->hexdigest);
-
-}
-
-=head2 _GeneratePasswordBase64 PASSWORD
-
-returns an MD5 hash of the password passed in, in base64 encoding
-(obsoleted now).
-
-=cut
-
-sub _GeneratePasswordBase64 {
-    my $self = shift;
-    my $password = shift;
-
-    my $md5 = Digest::MD5->new();
-    $md5->add($password);
     return ($md5->b64digest);
 
 }
@@ -1081,12 +1055,9 @@
     }
 
     #  if it's a historical password we say ok.
-    if ($self->__Value('Password') eq crypt($value, $self->__Value('Password'))
-        or $self->_GeneratePasswordBase64($value) eq $self->__Value('Password'))
-    {
-        # ...but upgrade the legacy password inplace.
-        $self->SUPER::SetPassword( $self->_GeneratePassword($value) );
-        return(1);
+
+    if ( $self->__Value('Password') eq crypt( $value, $self->__Value('Password') ) ) {
+        return (1);
     }
 
     # no password check has succeeded. get out
@@ -1138,7 +1109,7 @@
 ok(my $u = RT::User->new($RT::SystemUser));
 ok($u->Load(1), "Loaded the first user");
 ok($u->PrincipalObj->ObjectId == 1, "user 1 is the first principal");
-is($u->PrincipalObj->PrincipalType, 'User' , "Principal 1 is a user, not a group");
+ok($u->PrincipalObj->PrincipalType eq 'User' , "Principal 1 is a user, not a group");
 
 =end testing
 
@@ -1302,7 +1273,7 @@
 my $new_tick2 = RT::Ticket->new($RT::SystemUser);
 my ($tick2id, $tickmsg) = $new_tick2->Create(Subject=> 'ACL Test 2', Queue =>$q_as_system->Id);
 ok($tick2id, "Created ticket: $tick2id");
-is($new_tick2->QueueObj->id, $q_as_system->Id, "Created a new ticket in queue 1");
+ok($new_tick2->QueueObj->id eq $q_as_system->Id, "Created a new ticket in queue 1");
 
 
 # make sure that the user can't do this without subgroup membership
@@ -1552,8 +1523,6 @@
     my %args = (
         Field => undef,
         Value => undef,
-	TransactionType   => 'Set',
-	RecordTransaction => 1,
         @_
     );
 
@@ -1567,29 +1536,13 @@
         return ( 0, $self->loc("Permission Denied") );
     }
 
-    my $Old = $self->SUPER::_Value("$args{'Field'}");
-    
-    my ($ret, $msg) = $self->SUPER::_Set( Field => $args{'Field'},
-					  Value => $args{'Value'} );
-    
-    #If we can't actually set the field to the value, don't record
-    # a transaction. instead, get out of here.
-    if ( $ret == 0 ) { return ( 0, $msg ); }
-
-    if ( $args{'RecordTransaction'} == 1 ) {
-
-        my ( $Trans, $Msg, $TransObj ) = $self->_NewTransaction(
-                                               Type => $args{'TransactionType'},
-                                               Field     => $args{'Field'},
-                                               NewValue  => $args{'Value'},
-                                               OldValue  => $Old,
-                                               TimeTaken => $args{'TimeTaken'},
-        );
-        return ( $Trans, scalar $TransObj->Description );
-    }
-    else {
-        return ( $ret, $msg );
-    }
+    #Set the new value
+    my ( $ret, $msg ) = $self->SUPER::_Set(
+        Field => $args{'Field'},
+        Value => $args{'Value'}
+    );
+
+    return ( $ret, $msg );
 }
 
 # }}}
@@ -1639,14 +1592,6 @@
 
 # }}}
 
-sub BasicColumns {
-    (
-	[ Name => 'User Id' ],
-	[ EmailAddress => 'Email' ],
-	[ RealName => 'Name' ],
-	[ Organization => 'Organization' ],
-    );
-}
 
 1;
 

Modified: rt/branches/rt-3.1/releng.cnf
==============================================================================
--- rt/branches/rt-3.1/releng.cnf	(original)
+++ rt/branches/rt-3.1/releng.cnf	Mon Jul 12 14:00:53 2004
@@ -1,7 +1,7 @@
 PRODUCT			        = rt
-TAG			            = 3.3.4
+TAG			            = 3.2.0
 CANONICAL_REPO		    = svn+ssh://svn.bestpractical.com/svn/bps-public/rt/
 TAGS		            = tags/
-TRUNK	                = branches/rt-3.3/
+TRUNK	                = branches/rt-3.1/
 TMP_DIR			        = /tmp
 RELEASE_DIR		        = /home/ftp/pub/rt/devel

Modified: rt/branches/rt-3.1/sbin/extract-message-catalog
==============================================================================
--- rt/branches/rt-3.1/sbin/extract-message-catalog	(original)
+++ rt/branches/rt-3.1/sbin/extract-message-catalog	Mon Jul 12 14:00:53 2004
@@ -174,7 +174,6 @@
     while (@lines) {
         my $msghdr = "";
         $msghdr .= shift @lines while ( $lines[0] && $lines[0] !~ /^msgid/ );
-        
         my $msgid  = shift @lines;
         my $msgstr = "";
         $msgstr .= shift @lines while ( $lines[0] && $lines[0] =~ /^(msgstr|")/ );
@@ -183,8 +182,8 @@
 
         chomp $msgid;
         chomp $msgstr;
-        $msgid  =~ s/^msgid "(.*)"\s*?$/$1/ms    or warn "$msgid in $file";
-        $msgstr =~ s/^msgstr "(.*)"\s*?$/$1/ms or warn "$msgstr  in $file";
+        $msgid  =~ s/^msgid "(.*)"$/$1/    or warn $msgid;
+        $msgstr =~ s/^msgstr "(.*)"$/$1/ms or warn $msgstr;
 
         $Lexicon{$msgid} = $msgstr;
         $Header{$msgid}  = $msghdr;
@@ -209,10 +208,6 @@
 
         my %seen;
         $out .= $Header{$_} if exists $Header{$_};
-
-
-
-        next if (!$f && $_ && !$Lexicon{$_});
         if ( $f && $f !~ /^\s+$/ ) {
 
             $out .= "#: $f\n";


More information about the Rt-commit mailing list