Changeset 1284 for branches


Ignore:
Timestamp:
03/17/15 18:31:05 (9 years ago)
Author:
nanardon
Message:

backport changes from trunk

Location:
branches/4.0
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/4.0

  • branches/4.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r1257 r1284  
    2222        attrs => [ qw( 
    2323            sn givenName description 
     24            comment 
    2425            uid uidNumber gidNumber gecos homeDirectory loginShell 
    2526            mail initials nickname 
     
    102103            gidNumber 
    103104            description label 
     105            comment 
    104106            managedBy 
    105107            managedAlsoBy 
     
    115117            name 
    116118            description 
     119            comment 
    117120            serialNumber 
    118121            encryptKey 
     
    162165            forward 
    163166            expire 
     167            description 
     168            comment 
    164169            finalpoint 
    165170            parents 
  • branches/4.0/LATMOS-Accounts/Makefile.PL

    r1225 r1284  
    6060        bin/la-sql-updsshfp 
    6161        bin/la-test-mail 
     62        bin/la-sql-log 
    6263        ) ], 
    6364        macro => { 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm

    r1135 r1284  
    637637} 
    638638 
     639sub getobjectlogs { 
     640    my ($self, $otype, $name) = @_; 
     641 
     642    my $sth = $self->db->prepare(q{ 
     643        select ikey from objectslogs where 
     644            otype = ? and 
     645            name  = ? 
     646        group by ikey 
     647    }); 
     648    $sth->execute($otype, $name); 
     649    my @ids; 
     650    while (my $res = $sth->fetchrow_hashref) { 
     651        push(@ids, $res->{ikey}); 
     652    } 
     653    @ids or return; 
     654 
     655    my $sth2 = $self->db->prepare(sprintf( 
     656        q{ 
     657            select * from objectslogs where ikey IN (%s) 
     658            order by logdate asc 
     659        }, 
     660        join(',', ('?') x scalar(@ids)) 
     661    )); 
     662 
     663    $sth2->execute(@ids); 
     664    my @logs; 
     665    while (my $res = $sth2->fetchrow_hashref) { 
     666        push(@logs, $res); 
     667    } 
     668 
     669    return @logs; 
     670} 
     671 
     672sub getlogs { 
     673    my ($self) = @_; 
     674    my $sth2 = $self->db->prepare( 
     675        q{ 
     676            select * from objectslogs  
     677            where logdate > now() - '1 year'::interval  
     678            order by logdate asc 
     679        }, 
     680    ); 
     681 
     682    $sth2->execute(); 
     683    my @logs; 
     684    while (my $res = $sth2->fetchrow_hashref) { 
     685        push(@logs, $res); 
     686    } 
     687 
     688    return @logs; 
     689} 
     690 
    6396911; 
    640692 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm

    r1161 r1284  
    3333                mandatory => 1, 
    3434                multiple => 1, 
     35                notify => 1, 
    3536            }, 
    3637            finalpoint      => { ro => 1, multiple => 1 }, 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm

    r1238 r1284  
    6262            groupname  => { ro => 1 }, 
    6363            managedBy  => { 
     64                notify => 1, 
    6465                reference => 'user', 
    6566                can_values => sub { 
     
    7172            }, 
    7273            managedAlsoBy  => { 
     74                notify => 1, 
    7375                reference => 'user', 
    7476                multiple => 1, 
     
    8385            sutype => { 
    8486                reference => 'sutype', 
     87                notify => 1, 
    8588            }, 
    8689            autoMemberFilter => { 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r1225 r1284  
    3232            create  => { ro => 1, inline => 1, }, 
    3333            ip      => { 
     34                notify => 1, 
    3435                multiple => 1, 
    3536                uniq => 1, 
     
    4849            }, 
    4950            macaddr => { 
     51                notify => 1, 
    5052                multiple => 1, 
    5153                uniq => 1, 
     
    5658            }, 
    5759            cname   => { 
     60                notify => 1, 
    5861                multiple => 1, uniq => 1, 
    5962                input => sub { lc($_[0]) }  
    6063            }, 
    61             owner   => {  
     64            owner   => { 
     65                notify => 1, 
    6266                reference => 'user', 
    6367                delayed => 1, 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm

    r1064 r1284  
    3434            date    => { ro => 1, inline => 1, }, 
    3535            create  => { ro => 1, inline => 1, }, 
    36             net     => { multiple => 1 }, 
    37             netExclude => { multiple => 1 }, 
     36            net     => { multiple => 1, notify => 1, }, 
     37            netExclude => { multiple => 1, notify => 1, }, 
    3838            group   => { hide => 1 }, 
    3939            allow_dyn => { 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1219 r1284  
    5151                mandatory => 1, 
    5252                formopts => { length => 7 }, 
     53                notify => 1, 
    5354            }, 
    5455            uidnumber => { inline => 1, hide => 1, }, 
    55             gidNumber => {  
     56            gidNumber => { 
     57                notify => 1, 
    5658                inline => 1, 
    5759                iname => 'gidnumber', 
     
    8385                inline => 1, 
    8486                formtype => 'CHECKBOX', 
     87                notify => 1, 
    8588            }, 
    8689            locked    => { 
    8790                formtype => 'CHECKBOX', 
    8891                formopts => { rawvalue => 1, }, 
    89             }, 
    90             expire    => { inline => 1, formtype => 'DATE', }, 
     92                notify => 1, 
     93            }, 
     94            expire    => { inline => 1, formtype => 'DATE', notify => 1, }, 
    9195            name      => { inline => 1, ro => 1, }, 
    9296            cn        => { 
     
    144148                }, 
    145149                reference => 'user', 
     150                notify => 1, 
    146151            }, 
    147152            department => { 
     
    149154                can_values => sub { 
    150155                    $base->search_objects('group', 'sutype=dpmt') 
    151                 } 
     156                }, 
     157                notify => 1, 
    152158            }, 
    153159            contratType => { 
     
    155161                can_values => sub { 
    156162                    $base->search_objects('group', 'sutype=contrattype') 
    157                 } 
     163                }, 
     164                notify => 1, 
    158165            }, 
    159166            site => { 
  • branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r1153 r1284  
    101101        } 
    102102    } 
    103     $info->{exported}   = { inline => 1, formtype => 'CHECKBOX', hide => 1, }; 
     103    $info->{exported}   = { inline => 1, formtype => 'CHECKBOX', hide => 1, notify => 1 }; 
    104104    $info->{unexported} = { inline => 1, formtype => 'CHECKBOX', }; 
    105105 
     
    178178    $sth->execute(map { $first{$_} || undef } sort keys %first) or return; 
    179179 
    180     $class->new($base, $id)->set_fields(%second); 
     180    my $obj = $class->new($base, $id); 
     181    $obj->objectlog('Create', 'Object created'); 
     182    foreach (keys %first) { 
     183        my $attr = $obj->attribute($_); 
     184        $obj->objectlog('Attribute', '%s set to %s', $_, ( 
     185                defined($data{$_})  
     186                ? (ref $data{$_} 
     187                    ? join(', ', @{ $data{$_} }) 
     188                    : $data{$_}) 
     189                : '(none)')) 
     190            if ($attr->{notify}); 
     191    } 
     192    $obj->set_fields(%second); 
    181193 
    182194    1; 
     
    185197sub _delete { 
    186198    my ($class, $base, $id) = @_; 
     199 
     200    my $obj = $base->get_object($class->type, $id) 
     201        or return; 
     202    $obj->objectlog('Delete', 'Object deleted'); 
    187203 
    188204    my $sthd = $base->db->prepare_cached( 
     
    199215    my ($class, $base, $id, $newid) = @_; 
    200216 
     217    { 
     218        my $obj = $base->get_object($class->type, $id) 
     219            or return; 
     220        $obj->objectlog('Rename', 'Object rename to %s', $newid); 
     221    } 
     222 
    201223    my $sthr = $base->db->prepare_cached( 
    202224        sprintf( 
     
    214236        ); 
    215237        return; 
     238    } 
     239 
     240    { 
     241        my $obj = $base->get_object($class->type, $newid) 
     242            or return; 
     243        $obj->objectlog('Rename', 'Object renamed from %s', $id); 
    216244    } 
    217245    1; 
     
    290318sub set_fields { 
    291319    my ($self, %data) = @_; 
    292     my $updated_attributes = 0; 
     320    my @updated_attributes = (); 
    293321    my @fields; 
    294322    my @vals; 
     
    309337            push(@fields, sprintf("%s = ?", $self->db->quote_identifier($field))); 
    310338            push(@vals, $data{$field}); 
     339            push(@updated_attributes, $field); 
    311340        } else { 
    312341            $ext{$field} = $data{$field}; 
     
    330359            return; 
    331360        }; 
    332         $updated_attributes = scalar(@fields); 
    333361    } 
    334362     
     
    399427                        $updated++; 
    400428                    } 
    401                     $updated_attributes++ if ($updated); 
     429                    push(@updated_attributes, $uattr) if ($updated); 
    402430                } else { 
    403431                    my $res = $sthu->execute($ext{$uattr}, $okey, $uattr); 
     
    410438                            $self->base->db->errstr 
    411439                        ); 
    412                         $updated_attributes++; 
    413440                        return; 
    414441                    }; 
     
    423450                                $self->base->db->errstr 
    424451                            ); 
    425                             $updated_attributes++; 
    426452                            return; 
    427453                        }; 
    428454                    } 
     455                    push(@updated_attributes, $uattr); 
    429456                } 
    430457            } else { 
     
    440467                }; 
    441468            } 
    442             $updated_attributes++; 
    443469        } 
    444470    } 
    445471 
    446472    delete($self->base->{__cache}{"_" . $self->type}{$self->id}); 
    447     $updated_attributes; 
     473    $self->objectlog('Update', 'Attributes %s where updated', join(', ', @updated_attributes)) 
     474        if(@updated_attributes); 
     475    foreach (@updated_attributes) { 
     476        my $attr = $self->attribute($_); 
     477        $self->objectlog('Attribute', '%s set to %s', $_, ( 
     478                defined($data{$_})  
     479                ? (ref $data{$_} 
     480                    ? join(', ', @{ $data{$_} }) 
     481                    : $data{$_}) 
     482                : '(none)')) 
     483            if ($attr->{notify}); 
     484    } 
     485    scalar(@updated_attributes); 
    448486} 
    449487 
     
    483521        my $salt = join('', map { $salt_char[rand(scalar(@salt_char))] } (1 .. 8)); 
    484522        my $res = $self->set_fields($field, crypt($clear_pass, '$1$' . $salt)); 
     523        my $asymencrypted = 0; 
    485524        if ($res) { 
    486525 
     
    501540                    return; 
    502541                } 
     542                $asymencrypted = 1; 
    503543            } 
    504544            $self->base->log(LA_NOTICE, 
     
    506546                $self->id 
    507547            ); 
     548            $self->objectlog('Password', 'user password has changed%s', ($asymencrypted ? ' and stored using internal key' : '')); 
    508549            return 1; 
    509550        } 
     
    708749} 
    709750 
    710  
     751=head2 objectlog 
     752 
     753=cut 
     754 
     755sub objectlog { 
     756    my ($self, $changetype, $message, @args) = @_; 
     757 
     758    my $sth = $self->base->db->prepare(q{ 
     759        INSERT into objectslogs (ikey, otype, name, changetype, username, message) 
     760        VALUES (?,?,?,?,?,?) 
     761    }); 
     762 
     763    $sth->execute( 
     764        $self->_get_ikey, 
     765        $self->type, 
     766        $self->id, 
     767        $changetype, 
     768        $self->base->user || '@Console', 
     769        sprintf($message, @args), 
     770    ); 
     771} 
    711772 
    7127731; 
  • branches/4.0/LATMOS-Accounts/sqldata/attributes.csv

    r1258 r1284  
    107107"user","halReference","Identifiant dans la base HAL" 
    108108"user","wWWHomePage","Site web personnel" 
     109"user","comment","Comment" 
     110"group","comment","Comment" 
     111"nethost","comment","Comment" 
     112"aliases","comment","Comment" 
  • branches/4.0/LATMOS-Accounts/templates/mail/account_expire.mail

    r1267 r1284  
    1010de contacter svp@latmos.ipsl.fr afin de nous donner la nouvelle date.  
    1111 
     12 
     13Cas d'un nouvel arrivant: 
     14 
    1215Si vous êtes un nouvel arrivant, veuillez réaliser votre circuit d'entrée et 
    1316remettre la fiche à Brigitte Fromager (Guyancourt - bureau 2421) ou Irina 
     
    1518Si vous rencontrez des difficultés, n'hésitez pas à vous adresser à votre 
    1619responsable, ou à Brigitte et Irina. 
     20 
     21 
     22Votre statut: 
    1723 
    1824Société: [% obj.get_c_field('company') %] 
     
    3440svp@latmos.ipsl.fr to give us a new expiration date. 
    3541 
     42 
     43If you are new in laboratory: 
     44 
    3645If you are a newcomer, please make your entrance circuit and pass on the sheet 
    3746to Brigitte Fromager (Guyancourt - office 2421) or Irina Tchoumakova (Jussieu - 
     
    3948If you meet difficulties, don't hesitate to deal with your manager, or with 
    4049Brigitte and Irina. 
     50 
     51 
     52Your status: 
    4153 
    4254Company: [% obj.get_c_field('company') %] 
Note: See TracChangeset for help on using the changeset viewer.