Changeset 249


Ignore:
Timestamp:
06/08/09 20:51:52 (15 years ago)
Author:
nanardon
Message:
  • review database schema
Location:
LATMOS-Accounts/lib/LATMOS/Accounts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm

    r218 r249  
    7171                q{ 
    7272                select value from group_attributes_users 
    73                 join group_attributes_list on 
    74                 group_attributes_users.attr = group_attributes_list.ikey 
    7573                join "group" on "group".ikey = group_attributes_users.okey 
    76                 where name = ? and canonical = ? 
     74                where name = ? and attr = ? 
    7775                } 
    7876            ); 
     
    9391    foreach my $attr (keys %data) { 
    9492        $attr =~ /^memberUID|member$/ and do { 
    95             my $attrid = $self->_get_field_name_db('memberUID', $self->base) or next; 
    9693            my %member; 
    9794            foreach (@{ $self->get_field('memberUID') }) { 
     
    109106                        q{insert into group_attributes_users (value, attr, okey) values (?,?,?)} 
    110107                    ); 
    111                     $sth->execute($_, $attrid, $self->_get_ikey); 
     108                    $sth->execute($_, 'memberUID', $self->_get_ikey); 
    112109                } elsif ($member{$_}{c}) { 
    113110                    my $sth = $self->db->prepare_cached( 
    114111                        q{delete from group_attributes_users where value = ? and attr = ? and okey = ?} 
    115112                    ); 
    116                     $sth->execute($_, $attrid, $self->_get_ikey); 
     113                    $sth->execute($_, 'memberUID', $self->_get_ikey); 
    117114                } # else {} # can't happend 
    118115            } 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r218 r249  
    8686            select name from "group" join 
    8787            group_attributes_users on group_attributes_users.okey = "group".ikey 
    88             join group_attributes_list on 
    89             group_attributes_users.attr = group_attributes_list.ikey 
    90             where value = ? and canonical = ? 
     88            where value = ? and attr = ? 
    9189            } 
    9290        ); 
     
    102100            select name from "user" join 
    103101            user_attributes on user_attributes.okey = "user".ikey 
    104             join user_attributes_list 
    105             on user_attributes_list.ikey = user_attributes.attr 
    106             where value = ? and canonical = ? 
     102            where value = ? and attr = ? 
    107103            } 
    108104        ); 
     
    118114            select name from "group" join 
    119115            group_attributes on "group".ikey = group_attributes.okey 
    120             join group_attributes_list on group_attributes_list.ikey = group_attributes.attr 
    121116            where okey in (select okey from group_attributes_users where value = ?) 
    122             and canonical = ? and value = ? 
     117            and attr = ? and value = ? 
    123118            } 
    124119        ); 
     
    134129            select name from "group" join 
    135130            group_attributes on group_attributes.okey = "group".ikey 
    136             join group_attributes_list 
    137             on group_attributes_list.ikey = group_attributes.attr 
    138             where value = ? and canonical = ? 
     131            where value = ? and attr = ? 
    139132            } 
    140133        ); 
     
    183176    foreach my $attr (keys %data) { 
    184177        $attr =~ /^memberOf$/ and do { 
    185             my $cl = $self->base->_load_obj_class('group') or next; 
    186             my $attrid = $cl->_get_field_name_db('memberUID', $self->base) or next; 
    187178            my %member; 
    188179            foreach (@{ $self->get_field('memberOf') }) { 
     
    200191                        q{insert into group_attributes_users (value, attr, okey) values (?,?,?)} 
    201192                    ); 
    202                     $sth->execute($self->id, $attrid, $group->_get_ikey); 
     193                    $sth->execute($self->id, 'memberUID', $group->_get_ikey); 
    203194                } elsif ($member{$_}{c}) { 
    204195                    my $sth = $self->db->prepare_cached( 
    205196                        q{delete from group_attributes_users where value = ? and attr = ? and okey = ?} 
    206197                    ); 
    207                     $sth->execute($self->id, $attrid, $group->_get_ikey); 
     198                    $sth->execute($self->id, 'memberUID', $group->_get_ikey); 
    208199                } # else {} # can't happend 
    209200            } 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r243 r249  
    142142    my $res = $sth->fetchrow_hashref; 
    143143    $sth->finish; 
    144     $res->{ikey} 
     144    return $c_field if($res->{ikey}); 
    145145} 
    146146 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm

    r205 r249  
    66use base qw(Config::IniFiles); 
    77use LATMOS::Accounts::Bases; 
     8use LATMOS::Accounts::Log; 
    89 
    910=head1 NAME 
     
    143144                    ); 
    144145                    if (defined $res) { 
    145                         warn sprintf( 
    146                             "%s::%s::%s => %s (%s)\n", 
     146                        la_log(LA_INFO, 
     147                            "%s::%s::%s => %s (%s)", 
    147148                            $self->from->label, $otype, $uid, 
    148149                            $destbase->label, $res 
    149150                        ) if ($res); 
    150151                    } else { 
    151                         warn sprintf( 
    152                             "Error syncing %s::%s::%s => %s\n", 
     152                        la_log(LA_ERR, 
     153                            "Error syncing %s::%s::%s => %s", 
    153154                            $self->from->label, $otype, $uid, $destbase->label 
    154155                        );  
     
    172173                        print "delete " . $destbase->label . '::' . $otype . '::' . "$_\n"; 
    173174                    } else { 
    174                         warn "cannot delete " . $destbase->label . '::' . $otype . '::' . "$_\n"; 
     175                        la_log(LA_ERR, "cannot delete " . $destbase->label . '::' . $otype . '::' . "$_"); 
    175176                    } 
    176177                } 
     
    183184    my ($self, $otype, $uid) = @_; 
    184185    my $sobj = $self->from->get_object($otype, $uid) or do { 
    185         warn "Cannot get object for synching $uid ($otype)\n"; 
     186        la_log(LA_WARNING, "Cannot get object for synching $uid ($otype)"); 
    186187        return; 
    187188    }; 
    188189    foreach ($self->to) { 
    189190        if (my $res = $_->sync_object($sobj)) { 
    190             warn $_->label . " $uid ($otype) $res\n"; 
    191         } else { warn "error synching $uid ($otype) to " . $_->label . "\n"; } 
     191                la_log(LA_INFO, $_->label . " $uid ($otype) $res"); 
     192        } else { 
     193            la_log(LA_ERR, "error synching $uid ($otype) to " . $_->label); 
     194        } 
    192195    } 
    193196    foreach ($self->to) { 
Note: See TracChangeset for help on using the changeset viewer.