~ubuntu-branches/ubuntu/oneiric/request-tracker3.8/oneiric-updates

« back to all changes in this revision

Viewing changes to lib/RT/User_Overlay.pm

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves, Dominic Hargreaves, Christian Perrier
  • Date: 2009-06-16 21:46:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090616214659-5ji9k1n3qyc2br3n
Tags: 3.8.4-1
[ Dominic Hargreaves ]
* Add missing comma in Depends (fixes FTBFS on etch)
* Update debconf translations: pt.po, ja.po, sv.po, it.po, cs.po, ru.po
  (Closes: #519885, #519922, #520603, #520759, #521199, #521926)
* Document preference for not using SQLite in production
  (Closes: #512750)

[ Christian Perrier ]
* Debconf templates and debian/control reviewed by the debian-l10n-
  english team as part of the Smith review project.
  (Closes: #522367, #520959)
* [Debconf translation updates]
  - Japanese. Closes: #522896
  - German. Closes: #520958
  - Portuguese. Closes: #523481
  - Galician. Closes: #524256
  - Galician. Closes: #524256
  - Spanish. Closes: #524449
  - Italian. Closes: #524715
  - Russian. Closes: #524894
  - Swedish. Closes: #525171
  - French. Closes: #525281

[ Dominic Hargreaves ]
* Don't tell dbconfig to comment out unused variables, since this
  breaks MySQL and Postgres database configuration (Closes: #523090)
* Update Standards-Version (no changes)
* Switch dependency on sysklogd to rsyslog (Closes: #526914)
* New upstream release; includes
  - Minor security fix (Closes: #533069)
  - Add missing Postgres index (Closes: #512653)
* Patch webmux.pl to provide a better error message when the wrong
  major version of RT is in @INC (for example in a mod_perl context).
  (Closes: #518692)
* Add some more example Exim 4 configuration (Closes: #238345)
* Don't apply database ACLs in databases managed by dbconfig-common.
* Remove unused ACL patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
        $TempUser->Load( $args{'Name'} );
167
167
        return ( 0, $self->loc('Name in use') ) if ( $TempUser->Id );
168
168
 
169
 
        return ( 0, $self->loc('Email address in use') )
170
 
          unless ( $self->ValidateEmailAddress( $args{'EmailAddress'} ) );
 
169
        my ($val, $message) = $self->ValidateEmailAddress( $args{'EmailAddress'} );
 
170
        return (0, $message) unless ( $val );
171
171
    }
172
172
    else {
173
173
        $RT::Logger->warning( "$self couldn't check for pre-existing users");
530
530
    # if the email address is null, it's always valid
531
531
    return (1) if ( !$Value || $Value eq "" );
532
532
 
 
533
    if ( RT->Config->Get('ValidateUserEmailAddresses') ) {
 
534
        # We only allow one valid email address
 
535
        my @addresses = Email::Address->parse($Value);
 
536
        return ( 0, $self->loc('Invalid syntax for email address') ) unless ( ( scalar (@addresses) == 1 ) && ( $addresses[0]->address ) );
 
537
    }
 
538
 
 
539
 
533
540
    my $TempUser = RT::User->new($RT::SystemUser);
534
541
    $TempUser->LoadByEmail($Value);
535
542
 
536
543
    if ( $TempUser->id && ( !$self->id || $TempUser->id != $self->id ) )
537
544
    {    # if we found a user with that address
538
545
            # it's invalid to set this user's address to it
539
 
        return (undef);
 
546
        return ( 0, $self->loc('Email address in use') );
540
547
    }
541
548
    else {    #it's a valid email address
542
549
        return (1);
554
561
    my $self = shift;
555
562
    my $Value = shift;
556
563
 
557
 
    if ( $self->ValidateEmailAddress( $Value ) ) {
 
564
    my ($val, $message) = $self->ValidateEmailAddress( $Value );
 
565
    if ( $val ) {
558
566
        return $self->_Set( Field => 'EmailAddress', Value => $Value );
559
567
    } else {
560
 
        return ( 0, $self->loc('Email address in use') )
 
568
        return ( 0, $message )
561
569
    }
562
570
 
563
571
}
1122
1130
 
1123
1131
sub SetDisabled {
1124
1132
    my $self = shift;
 
1133
    my $val = shift;
1125
1134
    unless ( $self->CurrentUser->HasRight(Right => 'AdminUsers', Object => $RT::System) ) {
1126
1135
        return (0, $self->loc('Permission Denied'));
1127
1136
    }
1128
 
    return $self->PrincipalObj->SetDisabled(@_);
 
1137
 
 
1138
    $RT::Handle->BeginTransaction();
 
1139
    my $set_err = $self->PrincipalObj->SetDisabled($val);
 
1140
    unless ($set_err) {
 
1141
        $RT::Handle->Rollback();
 
1142
        $RT::Logger->warning("Couldn't ".($val == 1) ? "disable" : "enable"." user ".$self->PrincipalObj->Id);
 
1143
        return (undef);
 
1144
    }
 
1145
    $self->_NewTransaction( Type => ($val == 1) ? "Disabled" : "Enabled" );
 
1146
 
 
1147
    $RT::Handle->Commit();
 
1148
 
 
1149
    if ( $val == 1 ) {
 
1150
        return (1, $self->loc("User disabled"));
 
1151
    } else {
 
1152
        return (1, $self->loc("User enabled"));
 
1153
    }
 
1154
 
1129
1155
}
1130
1156
 
1131
1157
=head2 Disabled
1575
1601
 
1576
1602
    #If the user wants to see their own values, let them
1577
1603
    # TODO figure ouyt a better way to deal with this
1578
 
   elsif ( $self->CurrentUser->Id == $self->Id ) {
 
1604
   elsif ( defined($self->Id) && $self->CurrentUser->Id == $self->Id ) {
1579
1605
        return ( $self->SUPER::_Value($field) );
1580
1606
    }
1581
1607