Changeset 182


Ignore:
Timestamp:
05/25/09 02:29:48 (15 years ago)
Author:
nanardon
Message:
  • Sql: support directReports attribute
Location:
LATMOS-Accounts/lib/LATMOS/Accounts/Bases
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ad/User.pm

    r153 r182  
    7070        ), 
    7171        ($mode !~ /w/ 
    72             ? qw(cn dn uSNCreated uSNChanged) 
     72            ? qw(cn dn uSNCreated uSNChanged directReports) 
    7373            : () 
    7474        ) 
     
    116116        return [ sort(@res) ]; 
    117117    }; 
     118    $field eq 'directReports' and do { 
     119        my $res = $self->SUPER::get_field($field); 
     120        return [ map { $self->base->get_value('cn') } @{ ref $res ? $res : [ $res ] } ]; 
     121    }; 
    118122    $field eq 'manager' and do { 
    119         my $entry = $self->SUPER::get_field($field); 
     123        my $entry = $self->SUPER::get_field($field) or return; 
    120124        return $entry->get_value('cn'); 
    121125    }; 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r175 r182  
    4646sub _delayed_fields { 
    4747    my ($self)= @_; 
    48     return qw(memberOf manager); 
     48    return qw(memberOf manager directReports); 
    4949} 
    5050 
     
    6262        accountExpires => 'accountExpires', 
    6363        shadowExpire => 'shadowExpire', 
     64        directReports => 'directReports', 
    6465        ) : ()), 
    6566    } 
     
    8788        ); 
    8889        $sth->execute($self->id, 'memberUID'); 
     90        my @res; 
     91        while (my $res = $sth->fetchrow_hashref) { 
     92            push(@res, $res->{id}); 
     93        } 
     94        return \@res; 
     95    } elsif ($field eq 'directReports') { 
     96        my $sth = $self->db->prepare_cached( 
     97            q{ 
     98            select id from user_attributes join user_attributes_list 
     99            on user_attributes_list.ikey = user_attributes.attr 
     100            where value = ? and canonical = ? 
     101            } 
     102        ); 
     103        $sth->execute($self->id, 'manager'); 
    89104        my @res; 
    90105        while (my $res = $sth->fetchrow_hashref) { 
Note: See TracChangeset for help on using the changeset viewer.