Changeset 163


Ignore:
Timestamp:
05/23/09 04:52:03 (15 years ago)
Author:
nanardon
Message:
  • change db structure again
Location:
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
Files:
2 edited

Legend:

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

    r162 r163  
    7070            my $sth = $self->db->prepare_cached( 
    7171                q{ 
    72                 select id from user_attributes_groups 
    73                 join user_attributes_list on 
    74                 user_attributes_groups.attr = user_attributes_list.ikey 
    75                 where value = ? and canonical = ? 
     72                select value from group_attributes_users 
     73                join group_attributes_list on 
     74                group_attributes_users.attr = group_attributes_list.ikey 
     75                where id = ? and canonical = ? 
    7676                } 
    7777            ); 
    78             $sth->execute($self->id, 'memberOf'); 
     78            $sth->execute($self->id, 'memberUID'); 
    7979            my @res; 
    8080            while (my $res = $sth->fetchrow_hashref) { 
    81                 push(@res, $res->{id}); 
     81                push(@res, $res->{value}); 
    8282            } 
    8383            return \@res; 
     
    9292    foreach my $attr (keys %data) { 
    9393        $attr =~ /^memberUID$/ and do { 
    94             my $cl = $self->base->_load_obj_class('user') or next; 
    95             my $attrid = $cl->_get_field_name_db('memberOf', $self->base) or next; 
     94            my $attrid = $self->_get_field_name_db('memberUID', $self->base) or next; 
    9695            my %member; 
    9796            foreach (@{ $self->get_field('memberUID') }) { 
     
    107106                if ($member{$_}{n}) { 
    108107                    my $sth = $self->db->prepare_cached( 
    109                         q{insert into user_attributes_groups (id, attr, value) values (?,?,?)} 
     108                        q{insert into group_attributes_users (value, attr, id) values (?,?,?)} 
    110109                    ); 
    111110                    $sth->execute($_, $attrid, $self->id); 
    112111                } elsif ($member{$_}{c}) { 
    113112                    my $sth = $self->db->prepare_cached( 
    114                         q{delete from user_attributes_groups where id = ? and attr = ? and value = ?} 
     113                        q{delete from group_attributes_users where value = ? and attr = ? and id = ?} 
    115114                    ); 
    116115                    $sth->execute($_, $attrid, $self->id); 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r159 r163  
    7474        my $sth = $self->db->prepare_cached( 
    7575            q{ 
    76             select value from user_attributes_groups 
    77             join user_attributes_list on 
    78             user_attributes_groups.attr = user_attributes_list.ikey 
    79             where id = ? and canonical = ? 
     76            select id from group_attributes_users 
     77            join group_attributes_list on 
     78            group_attributes_users.attr = group_attributes_list.ikey 
     79            where value = ? and canonical = ? 
    8080            } 
    8181        ); 
    82         $sth->execute($self->id, 'memberOf'); 
     82        $sth->execute($self->id, 'memberUID'); 
    8383        my @res; 
    8484        while (my $res = $sth->fetchrow_hashref) { 
    85             push(@res, $res->{value}); 
     85            push(@res, $res->{id}); 
    8686        } 
    8787        return \@res; 
     
    124124    foreach my $attr (keys %data) { 
    125125        $attr =~ /^memberOf$/ and do { 
    126             my $attrid = $self->_get_field_name_db('memberOf', $self->base) or next; 
     126            my $cl = $self->base->_load_obj_class('group') or next; 
     127            my $attrid = $cl->_get_field_name_db('memberUID', $self->base) or next; 
    127128            my %member; 
    128129            foreach (@{ $self->get_field('memberOf') }) { 
     
    138139                if ($member{$_}{n}) { 
    139140                    my $sth = $self->db->prepare_cached( 
    140                         q{insert into user_attributes_groups (id, attr, value) values (?,?,?)} 
     141                        q{insert into group_attributes_users (value, attr, id) values (?,?,?)} 
    141142                    ); 
    142143                    $sth->execute($self->id, $attrid, $_); 
    143144                } elsif ($member{$_}{c}) { 
    144145                    my $sth = $self->db->prepare_cached( 
    145                         q{delete from user_attributes_groups where id = ? and attr = ? and value = ?} 
     146                        q{delete from group_attributes_users where value = ? and attr = ? and id = ?} 
    146147                    ); 
    147148                    $sth->execute($self->id, $attrid, $_); 
Note: See TracChangeset for help on using the changeset viewer.