Commit 1e5327d0 authored by Jesse Vincent's avatar Jesse Vincent
Browse files

Remove use of indirect object syntax programmatically for

    new RT::... -> RT::...->new
parent ef4d76ee
......@@ -149,7 +149,7 @@ have not been set already.
sub LoadConfig {
require RT::Config;
$Config = new RT::Config;
$Config = RT::Config->new;
$Config->LoadConfigs;
require RT::I18N;
......@@ -202,7 +202,7 @@ Get a database connection. See also </Handle>.
sub ConnectToDatabase {
require RT::Handle;
$Handle = new RT::Handle unless $Handle;
$Handle = RT::Handle->new unless $Handle;
$Handle->Connect;
return $Handle;
}
......@@ -511,11 +511,11 @@ sub InitSystemObjects {
#RT's system user is a genuine database user. its id lives here
require RT::CurrentUser;
$SystemUser = new RT::CurrentUser;
$SystemUser = RT::CurrentUser->new;
$SystemUser->LoadByName('RT_System');
#RT's "nobody user" is a genuine database user. its ID lives here.
$Nobody = new RT::CurrentUser;
$Nobody = RT::CurrentUser->new;
$Nobody->LoadByName('Nobody');
require RT::System;
......
......@@ -49,7 +49,7 @@
=head1 SYNOPSIS
use RT::ACE;
my $ace = new RT::ACE($CurrentUser);
my $ace = RT::ACE->new($CurrentUser);
=head1 DESCRIPTION
......
......@@ -53,7 +53,7 @@
=head1 SYNOPSIS
use RT::ACL;
my $ACL = new RT::ACL($CurrentUser);
my $ACL = RT::ACL->new($CurrentUser);
=head1 DESCRIPTION
......
......@@ -157,7 +157,7 @@ sub Create {
}
foreach my $part ( $Attachment->parts ) {
my $SubAttachment = new RT::Attachment( $self->CurrentUser );
my $SubAttachment = RT::Attachment->new( $self->CurrentUser );
my ($id) = $SubAttachment->Create(
TransactionId => $args{'TransactionId'},
Parent => $id,
......
......@@ -53,7 +53,7 @@ RT::Attributes - collection of RT::Attribute objects
=head1 SYNOPSIS
use RT::Attributes;
my $Attributes = new RT::Attributes($CurrentUser);
my $Attributes = RT::Attributes->new($CurrentUser);
=head1 DESCRIPTION
......
......@@ -87,7 +87,7 @@ sub CurrentUser {
$self->{'original_user'} = $self->{'user'};
my $current_user = $_[0];
if ( ref $current_user eq 'RT::User' ) {
$self->{'user'} = new RT::CurrentUser;
$self->{'user'} = RT::CurrentUser->new;
$self->{'user'}->Load( $current_user->id );
} else {
$self->{'user'} = $current_user;
......
......@@ -65,7 +65,7 @@ sub IsApplicable {
}
my $elapse = $e{'d'} * 24*60*60 + $e{'h'} * 60*60 + $e{'m'} * 60 + $e{'s'};
my $cur = new RT::Date( $RT::SystemUser );
my $cur = RT::Date->new( $RT::SystemUser );
$cur->SetToNow();
my $due = $self->TicketObj->DueObj;
return (undef) if $due->Unix <= 0;
......
......@@ -61,7 +61,7 @@ use File::Spec ();
# get config object
use RT::Config;
my $config = new RT::Config;
my $config = RT::Config->new;
$config->LoadConfigs;
# get or set option
......@@ -143,7 +143,7 @@ our %META = (
Description => 'Default queue', #loc
Callback => sub {
my $ret = { Values => [], ValuesLabel => {}};
my $q = new RT::Queues($HTML::Mason::Commands::session{'CurrentUser'});
my $q = RT::Queues->new($HTML::Mason::Commands::session{'CurrentUser'});
$q->UnLimit;
while (my $queue = $q->Next) {
next unless $queue->CurrentUserHasRight("CreateTicket");
......@@ -393,7 +393,7 @@ our %META = (
WidgetArguments => {
Description => 'Date format', #loc
Callback => sub { my $ret = { Values => [], ValuesLabel => {}};
my $date = new RT::Date($HTML::Mason::Commands::session{'CurrentUser'});
my $date = RT::Date->new($HTML::Mason::Commands::session{'CurrentUser'});
$date->Set;
foreach my $value ($date->Formatters) {
push @{$ret->{Values}}, $value;
......
......@@ -1261,7 +1261,7 @@ sub DecryptRFC3156 {
}
seek $tmp_fh, 0, 0;
my $parser = new RT::EmailParser;
my $parser = RT::EmailParser->new;
my $decrypted = $parser->ParseMIMEEntityFromFileHandle( $tmp_fh, 0 );
$decrypted->{'__store_link_to_object_to_avoid_early_cleanup'} = $parser;
$args{'Top'}->parts( [] );
......
......@@ -55,7 +55,7 @@
use RT::CurrentUser;
# laod
my $current_user = new RT::CurrentUser;
my $current_user = RT::CurrentUser->new;
$current_user->Load(...);
# or
my $current_user = RT::CurrentUser->new( $user_obj );
......
......@@ -1283,7 +1283,7 @@ sub AddValueForObject {
}
# For date, we need to store Content as ISO date
if ( $self->Type eq 'DateTime' ) {
my $DateObj = new RT::Date( $self->CurrentUser );
my $DateObj = RT::Date->new( $self->CurrentUser );
$DateObj->Set(
Format => 'unknown',
Value => $args{'Content'},
......@@ -1294,7 +1294,7 @@ sub AddValueForObject {
# in case user input date with time, let's omit it by setting timezone
# to utc so "hour" won't affect "day"
my $DateObj = new RT::Date( $self->CurrentUser );
my $DateObj = RT::Date->new( $self->CurrentUser );
$DateObj->Set(
Format => 'unknown',
Value => $args{'Content'},
......@@ -1435,7 +1435,7 @@ sub ValuesForObject {
my $self = shift;
my $object = shift;
my $values = new RT::ObjectCustomFieldValues($self->CurrentUser);
my $values = RT::ObjectCustomFieldValues->new($self->CurrentUser);
unless ($self->CurrentUserHasRight('SeeCustomField')) {
# Return an empty object if they have no rights to see
return ($values);
......
......@@ -56,7 +56,7 @@
=head1 SYNOPSIS
use RT::Group;
my $group = new RT::Group($CurrentUser);
my $group = RT::Group->new($CurrentUser);
=head1 DESCRIPTION
......
......@@ -233,13 +233,13 @@ sub CheckIntegrity {
RT::InitLogging();
require RT::CurrentUser;
my $test_user = new RT::CurrentUser;
my $test_user = RT::CurrentUser->new;
$test_user->Load('RT_System');
unless ( $test_user->id ) {
return (0, 'no system user', "Couldn't find RT_System user in the DB '$dsn'");
}
$test_user = new RT::CurrentUser;
$test_user = RT::CurrentUser->new;
$test_user->Load('Nobody');
unless ( $test_user->id ) {
return (0, 'no nobody user', "Couldn't find Nobody user in the DB '$dsn'");
......@@ -798,7 +798,7 @@ sub InsertData {
if ( $item->{'Name'} eq 'root' && $root_password ) {
$item->{'Password'} = $root_password;
}
my $new_entry = new RT::User( $RT::SystemUser );
my $new_entry = RT::User->new( $RT::SystemUser );
my ( $return, $msg ) = $new_entry->Create(%$item);
unless ( $return ) {
$RT::Logger->error( $msg );
......@@ -811,7 +811,7 @@ sub InsertData {
if ( @Queues ) {
$RT::Logger->debug("Creating queues...");
for my $item (@Queues) {
my $new_entry = new RT::Queue($RT::SystemUser);
my $new_entry = RT::Queue->new($RT::SystemUser);
my ( $return, $msg ) = $new_entry->Create(%$item);
unless ( $return ) {
$RT::Logger->error( $msg );
......@@ -824,7 +824,7 @@ sub InsertData {
if ( @CustomFields ) {
$RT::Logger->debug("Creating custom fields...");
for my $item ( @CustomFields ) {
my $new_entry = new RT::CustomField( $RT::SystemUser );
my $new_entry = RT::CustomField->new( $RT::SystemUser );
my $values = delete $item->{'Values'};
my @queues;
......@@ -965,7 +965,7 @@ sub InsertData {
$RT::Logger->debug("Creating templates...");
for my $item (@Templates) {
my $new_entry = new RT::Template($RT::SystemUser);
my $new_entry = RT::Template->new($RT::SystemUser);
my ( $return, $msg ) = $new_entry->Create(%$item);
unless ( $return ) {
$RT::Logger->error( $msg );
......@@ -980,7 +980,7 @@ sub InsertData {
$RT::Logger->debug("Creating scrips...");
for my $item (@Scrips) {
my $new_entry = new RT::Scrip($RT::SystemUser);
my $new_entry = RT::Scrip->new($RT::SystemUser);
my @queues = ref $item->{'Queue'} eq 'ARRAY'? @{ $item->{'Queue'} }: $item->{'Queue'} || 0;
push @queues, 0 unless @queues; # add global queue at least
......@@ -1048,7 +1048,7 @@ sub ACLEquivGroupId {
my $cu = $RT::SystemUser;
unless ( $cu ) {
require RT::CurrentUser;
$cu = new RT::CurrentUser;
$cu = RT::CurrentUser->new;
$cu->LoadByName('RT_System');
warn "Couldn't load RT_System user" unless $cu->id;
}
......
......@@ -144,7 +144,7 @@ sub GetCurrentUser {
#If the current user is 0, then RT will assume that the User object
#is that of the currentuser.
$CurrentUser = new RT::CurrentUser();
$CurrentUser = RT::CurrentUser->new();
$CurrentUser->LoadByGecos($Gecos);
unless ($CurrentUser->Id) {
......
......@@ -954,7 +954,7 @@ sub CreateUser {
}
#Load the new user object
my $CurrentUser = new RT::CurrentUser;
my $CurrentUser = RT::CurrentUser->new;
$CurrentUser->LoadByEmail( $Address );
unless ( $CurrentUser->id ) {
......
......@@ -68,7 +68,7 @@ sub GetCurrentUser {
return ( $args{'CurrentUser'}, -1 );
}
my $CurrentUser = new RT::CurrentUser;
my $CurrentUser = RT::CurrentUser->new;
$CurrentUser->LoadByEmail( $Address );
$CurrentUser->LoadByName( $Address ) unless $CurrentUser->Id;
if ( $CurrentUser->Id ) {
......
......@@ -886,9 +886,9 @@ sub CreateTicket {
my (@Actions);
my $Ticket = new RT::Ticket( $session{'CurrentUser'} );
my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
my $Queue = new RT::Queue( $session{'CurrentUser'} );
my $Queue = RT::Queue->new( $session{'CurrentUser'} );
unless ( $Queue->Load( $ARGS{'Queue'} ) ) {
Abort('Queue not found');
}
......@@ -899,12 +899,12 @@ sub CreateTicket {
my $due;
if ( defined $ARGS{'Due'} and $ARGS{'Due'} =~ /\S/ ) {
$due = new RT::Date( $session{'CurrentUser'} );
$due = RT::Date->new( $session{'CurrentUser'} );
$due->Set( Format => 'unknown', Value => $ARGS{'Due'} );
}
my $starts;
if ( defined $ARGS{'Starts'} and $ARGS{'Starts'} =~ /\S/ ) {
$starts = new RT::Date( $session{'CurrentUser'} );
$starts = RT::Date->new( $session{'CurrentUser'} );
$starts->Set( Format => 'unknown', Value => $ARGS{'Starts'} );
}
......
......@@ -53,7 +53,7 @@
=head1 SYNOPSIS
use RT::Links;
my $links = new RT::Links($CurrentUser);
my $links = RT::Links->new($CurrentUser);
=head1 DESCRIPTION
......
......@@ -452,7 +452,7 @@ sub ValidateName {
my $self = shift;
my $name = shift;
my $tempqueue = new RT::Queue($RT::SystemUser);
my $tempqueue = RT::Queue->new($RT::SystemUser);
$tempqueue->Load($name);
#If this queue exists, return undef
......
......@@ -378,7 +378,7 @@ sub LoadByCols {
sub LastUpdatedObj {
my $self = shift;
my $obj = new RT::Date( $self->CurrentUser );
my $obj = RT::Date->new( $self->CurrentUser );
$obj->Set( Format => 'sql', Value => $self->LastUpdated );
return $obj;
......@@ -390,7 +390,7 @@ sub LastUpdatedObj {
sub CreatedObj {
my $self = shift;
my $obj = new RT::Date( $self->CurrentUser );
my $obj = RT::Date->new( $self->CurrentUser );
$obj->Set( Format => 'sql', Value => $self->Created );
......@@ -520,7 +520,7 @@ It takes no options. Arguably, this is a bug
sub _SetLastUpdated {
my $self = shift;
use RT::Date;
my $now = new RT::Date( $self->CurrentUser );
my $now = RT::Date->new( $self->CurrentUser );
$now->SetToNow();
if ( $self->_Accessible( 'LastUpdated', 'auto' ) ) {
......@@ -1221,7 +1221,7 @@ sub _Links {
my $type = shift || "";
unless ( $self->{"$field$type"} ) {
$self->{"$field$type"} = new RT::Links( $self->CurrentUser );
$self->{"$field$type"} = RT::Links->new( $self->CurrentUser );
# at least to myself
$self->{"$field$type"}->Limit( FIELD => $field,
VALUE => $self->URI,
......@@ -1404,7 +1404,7 @@ sub _DeleteLink {
return ( 0, $self->loc('Either base or target must be specified') );
}
my $link = new RT::Link( $self->CurrentUser );
my $link = RT::Link->new( $self->CurrentUser );
$RT::Logger->debug( "Trying to load link: " . $args{'Base'} . " " . $args{'Type'} . " " . $args{'Target'} );
......@@ -1476,7 +1476,7 @@ sub _NewTransaction {
}
require RT::Transaction;
my $trans = new RT::Transaction( $self->CurrentUser );
my $trans = RT::Transaction->new( $self->CurrentUser );
my ( $transaction, $msg ) = $trans->Create(
ObjectId => $self->Id,
ObjectType => ref($self),
......@@ -1740,7 +1740,7 @@ sub _AddCustomFieldValue {
# For datetime, we need to display them in "human" format in result message
#XXX TODO how about date without time?
if ($cf->Type eq 'DateTime') {
my $DateObj = new RT::Date( $self->CurrentUser );
my $DateObj = RT::Date->new( $self->CurrentUser );
$DateObj->Set(
Format => 'ISO',
Value => $new_content,
......@@ -1847,7 +1847,7 @@ sub DeleteCustomFieldValue {
my $old_value = $TransactionObj->OldValue;
# For datetime, we need to display them in "human" format in result message
if ( $cf->Type eq 'DateTime' ) {
my $DateObj = new RT::Date( $self->CurrentUser );
my $DateObj = RT::Date->new( $self->CurrentUser );
$DateObj->Set(
Format => 'ISO',
Value => $old_value,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment