R6534 - in rt/branches/3.7-EXPERIMENTAL:

This change to RT::CurrentUser is kind of scary to me. I recall there
being some good reasons why we didn’t want currentuser to be a user
object. What’s your plan? What are you trying to do?

-jOn Sun, Nov 26, 2006 at 05:48:22PM -0500, ruz@bestpractical.com wrote:

Author: ruz
Date: Sun Nov 26 17:48:21 2006
New Revision: 6534

Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/CurrentUser.pm
rt/branches/3.7-EXPERIMENTAL/lib/RT/User_Overlay.pm

Log:

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/CurrentUser.pm

— rt/branches/3.7-EXPERIMENTAL/lib/RT/CurrentUser.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/CurrentUser.pm Sun Nov 26 17:48:21 2006
@@ -74,7 +74,7 @@
use RT::User;

use strict;
-use base qw/RT::Record/;
+use base qw/RT::User/;

{{{ sub _Init

@@ -90,11 +90,8 @@

 if ( defined $User ) {
  •    if (   UNIVERSAL::isa( $User, 'RT::User' )
    
  •        || UNIVERSAL::isa( $User, 'RT::CurrentUser' ) )
    
  •    {
    
  •        $self->Load( $User->id );
    
  •    if ( UNIVERSAL::isa( $User, 'RT::User' ) ) {
    
  •        $self->LoadById( $User->id );
       }
       elsif ( ref $User ) {
           $RT::Logger->crit(
    

@@ -149,37 +146,6 @@
}

}}}

-# {{{ sub PrincipalObj

-=head2 PrincipalObj

-Returns this user’s principal object. this is just a helper routine for
-$self->UserObj->PrincipalObj

-=cut

-sub PrincipalObj { return $_[0]->UserObj->PrincipalObj }

-# }}}

-# {{{ sub PrincipalId

-=head2 PrincipalId

-Returns this user’s principal Id. this is just a helper routine for
-$self->UserObj->PrincipalId

-=cut

-sub PrincipalId {

  • my $self = shift;
  • return($self->UserObj->PrincipalId);
    -}

-# }}}

{{{ sub _Accessible

sub _CoreAccessible {
@@ -195,25 +161,6 @@
}

}}}

-# {{{ sub LoadByEmail

-=head2 LoadByEmail

-Loads a User into this CurrentUser object.
-Takes the email address of the user to load.

-=cut

-sub LoadByEmail {

  • my $self = shift;
  • my $identifier = shift;
  • $identifier = RT::User::CanonicalizeEmailAddress( undef, $identifier );
  • return $self->LoadByCol( “EmailAddress”, $identifier );
    -}
    -# }}}

{{{ sub LoadByGecos

=head2 LoadByGecos
@@ -244,89 +191,6 @@
}

}}}

-# {{{ sub Load

-=head2 Load

-Loads a User into this CurrentUser object.
-Takes either an integer (users id column reference) or a Name
-The latter is deprecated. Instead, you should use LoadByName.
-Formerly, this routine also took email addresses.

-=cut

-sub Load {

  • my $self = shift;
  • my $identifier = shift;
  • #if it’s an int, load by id. otherwise, load by name.
  • if ( $identifier !~ /\D/ ) {
  •    return $self->SUPER::LoadById( $identifier );
    
  • }
  • elsif ( UNIVERSAL::isa( $identifier, ‘RT::User’ ) ) {
  •    # DWIM if they pass a user in
    
  •    return $self->SUPER::LoadById( $identifier->Id );
    
  • }
  • else {
  •    # This is a bit dangerous, we might get false authen if somebody
    
  •    # uses ambigous userids or real names:
    
  •    return $self->LoadByCol( "Name", $identifier );
    
  • }
    -}

-# }}}

-# {{{ sub IsPassword

-=head2 IsPassword

-Takes a password as a string. Passes it off to IsPassword in this
-user’s UserObj. If it is the user’s password and the user isn’t
-disabled, returns 1.

-Otherwise, returns undef.

-=cut

-sub IsPassword {

  • my $self = shift;
  • return $self->UserObj->IsPassword( shift );
    -}

-# }}}

-# {{{ sub Privileged

-=head2 Privileged

-Returns true if the current user can be granted rights and be
-a member of groups.

-=cut

-sub Privileged {

  • my $self = shift;
  • return $self->UserObj->Privileged;
    -}

-# }}}

-# {{{ sub HasRight

-=head2 HasRight

-calls $self->UserObj->HasRight with the arguments passed in

-=cut

-sub HasRight {

  • my $self = shift;
  • return ($self->UserObj->HasRight(@_));
    -}

-# }}}

{{{ Localization

=head2 LanguageHandle

Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/User_Overlay.pm

— rt/branches/3.7-EXPERIMENTAL/lib/RT/User_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/User_Overlay.pm Sun Nov 26 17:48:21 2006
@@ -519,21 +519,25 @@
=head2 Load

Load a user object from the database. Takes a single argument.
-If the argument is numerical, load by the column ‘id’. Otherwise, load by
-the “Name” column which is the user’s textual username.
+If the argument is numerical, load by the column ‘id’. If a user
+object or its subclass passed then loads the same user by id.
+Otherwise, load by the “Name” column which is the user’s textual
+username.

=cut

sub Load {

  • my $self = shift;
  • my $self = shift;
    my $identifier = shift || return undef;
  • #if it’s an int, load by id. otherwise, load by name.
    if ( $identifier !~ /\D/ ) {
  •    $self->SUPER::LoadById($identifier);
    
  •    return $self->SUPER::LoadById( $identifier );
    
  • }
  • elsif ( UNIVERSAL::isa( $identifier, ‘RT::User’ ) ) {
  •    return $self->SUPER::LoadById( $identifier->Id );
    
    }
    else {
  •    $self->LoadByCol( "Name", $identifier );
    
  •    return $self->LoadByCol( "Name", $identifier );
    
    }
    }

Rt-commit mailing list
Rt-commit@lists.bestpractical.com
rt-commit Info Page