Changeset 1014 for trunk/LATMOS-Accounts
- Timestamp:
- 05/22/12 00:15:11 (12 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/OCHelper/User.pm
r959 r1014 7 7 use base qw(LATMOS::Accounts::Bases::OCHelper); 8 8 use LATMOS::Accounts::Utils; 9 10 =head1 NAME 11 12 LATMOS::Accounts::Bases::OCHelper::User - 13 Helper to create user in L<LATMOS::Accounts> system 14 15 =cut 9 16 10 17 sub _step { … … 93 100 94 101 1; 102 103 __END__ 104 105 =head1 SEE ALSO 106 107 =head1 AUTHOR 108 109 Thauvin Olivier, E<lt>olivier.thauvin@latmos.ipsl.frE<gt> 110 111 =head1 COPYRIGHT AND LICENSE 112 113 Copyright (C) 2012 by Thauvin Olivier 114 115 This library is free software; you can redistribute it and/or modify 116 it under the same terms as Perl itself, either Perl version 5.10.0 or, 117 at your option, any later version of Perl 5 you may have available. 118 119 =cut -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r1002 r1014 34 34 my ($class, $base) = @_; 35 35 } 36 37 =cut 38 39 =head2 list_from_rev($base, $rev) 40 41 List objects create or modified after base revision C<$rev>. 36 42 37 43 =cut -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Accreq.pm
r971 r1014 27 27 sub _yaml_attr { qw(description notifyMail) } 28 28 29 sub object_table { 'accreq' }29 sub _object_table { 'accreq' } 30 30 31 sub key_field { 'name' }31 sub _key_field { 'name' } 32 32 33 sub has_extended_attributes { 1 }33 sub _has_extended_attributes { 1 } 34 34 35 35 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Address.pm
r943 r1014 37 37 =cut 38 38 39 sub object_table { 'address' }39 sub _object_table { 'address' } 40 40 41 sub key_field { 'name' }41 sub _key_field { 'name' } 42 42 43 sub has_extended_attributes { 1 }43 sub _has_extended_attributes { 1 } 44 44 45 45 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm
r959 r1014 38 38 =cut 39 39 40 sub object_table { 'aliases' }40 sub _object_table { 'aliases' } 41 41 42 sub key_field { 'name' }42 sub _key_field { 'name' } 43 43 44 sub has_extended_attributes { 1 }44 sub _has_extended_attributes { 1 } 45 45 46 46 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
r861 r1014 38 38 =cut 39 39 40 sub object_table { 'group' }40 sub _object_table { 'group' } 41 41 42 sub key_field { 'name' }42 sub _key_field { 'name' } 43 43 44 sub has_extended_attributes { 1 }44 sub _has_extended_attributes { 1 } 45 45 46 46 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm
r920 r1014 38 38 =cut 39 39 40 sub object_table { 'nethost' }41 42 sub key_field { 'name' }43 44 sub has_extended_attributes { 1 }40 sub _object_table { 'nethost' } 41 42 sub _key_field { 'name' } 43 44 sub _has_extended_attributes { 1 } 45 45 46 46 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm
r922 r1014 37 37 =cut 38 38 39 sub object_table { 'netzone' }40 41 sub key_field { 'name' }42 43 sub has_extended_attributes { 1 }39 sub _object_table { 'netzone' } 40 41 sub _key_field { 'name' } 42 43 sub _has_extended_attributes { 1 } 44 44 45 45 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Onlyaddress.pm
r830 r1014 18 18 order by %s.%s 19 19 }, 20 $base->db->quote_identifier($class-> object_table),21 $base->db->quote_identifier($class-> key_field),22 $base->db->quote_identifier($class-> object_table),23 $base->db->quote_identifier($class-> object_table),20 $base->db->quote_identifier($class->_object_table), 21 $base->db->quote_identifier($class->_key_field), 22 $base->db->quote_identifier($class->_object_table), 23 $base->db->quote_identifier($class->_object_table), 24 24 ($base->{wexported} ? '' : 'and "user".exported = true'), 25 $base->db->quote_identifier($class-> object_table),26 $base->db->quote_identifier($class-> object_table. '_attributes'), # attr25 $base->db->quote_identifier($class->_object_table), 26 $base->db->quote_identifier($class->_object_table. '_attributes'), # attr 27 27 ($base->{wexported} ? '' : 'and ' . 28 $base->db->quote_identifier($class-> object_table) . '.exported = true'),29 $base->db->quote_identifier($class-> object_table),30 $base->db->quote_identifier($class-> key_field),28 $base->db->quote_identifier($class->_object_table) . '.exported = true'), 29 $base->db->quote_identifier($class->_object_table), 30 $base->db->quote_identifier($class->_key_field), 31 31 ) 32 32 ); … … 46 46 q{select %s as k from %s where ikey not in (select okey from %s 47 47 where attr = 'isMainAddress') and rev > ? %s order by %s}, 48 $base->db->quote_identifier($class-> key_field),49 $base->db->quote_identifier($class-> object_table),50 $base->db->quote_identifier($class-> object_table. '_attributes'), # attr48 $base->db->quote_identifier($class->_key_field), 49 $base->db->quote_identifier($class->_object_table), 50 $base->db->quote_identifier($class->_object_table. '_attributes'), # attr 51 51 ($base->{wexported} ? '' : 'and exported = true'), 52 $base->db->quote_identifier($class-> key_field),52 $base->db->quote_identifier($class->_key_field), 53 53 ) 54 54 ); … … 65 65 my $sth = $base->db->prepare_cached( 66 66 sprintf(q{select 1 from %s where %s = ? %s and ikey not in (select okey from %s where attr = 'isMainAddress')}, 67 $base->db->quote_identifier($class-> object_table),68 $base->db->quote_identifier($class-> key_field),67 $base->db->quote_identifier($class->_object_table), 68 $base->db->quote_identifier($class->_key_field), 69 69 ($base->{wexported} ? '' : 'and exported = true'), 70 $base->db->quote_identifier($class-> object_table. '_attributes'),70 $base->db->quote_identifier($class->_object_table. '_attributes'), 71 71 ), 72 72 ); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Revaliases.pm
r916 r1014 38 38 =cut 39 39 40 sub object_table { 'revaliases' }40 sub _object_table { 'revaliases' } 41 41 42 sub key_field { 'name' }42 sub _key_field { 'name' } 43 43 44 sub has_extended_attributes { 0 }44 sub _has_extended_attributes { 0 } 45 45 46 46 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Site.pm
r861 r1014 37 37 =cut 38 38 39 sub object_table { 'site' }39 sub _object_table { 'site' } 40 40 41 sub key_field { 'name' }41 sub _key_field { 'name' } 42 42 43 sub has_extended_attributes { 1 }43 sub _has_extended_attributes { 1 } 44 44 45 45 sub _get_attr_schema { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Sutype.pm
r861 r1014 37 37 =cut 38 38 39 sub object_table { 'su_type' }39 sub _object_table { 'su_type' } 40 40 41 sub key_field { 'name' }41 sub _key_field { 'name' } 42 42 43 sub has_extended_attributes { 0 }43 sub _has_extended_attributes { 0 } 44 44 45 45 1; -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r959 r1014 33 33 =cut 34 34 35 sub object_table { 'user' }36 37 sub key_field { 'name' }38 39 sub has_extended_attributes { 1 }35 sub _object_table { 'user' } 36 37 sub _key_field { 'name' } 38 39 sub _has_extended_attributes { 1 } 40 40 41 41 sub _get_attr_schema { … … 206 206 q{select extract(epoch from expire) + 11644474161 as expire 207 207 from %s where %s = ?}, 208 $obj->db->quote_identifier($obj-> object_table),209 $obj->db->quote_identifier($obj-> key_field),208 $obj->db->quote_identifier($obj->_object_table), 209 $obj->db->quote_identifier($obj->_key_field), 210 210 ) 211 211 ); … … 226 226 q{select justify_hours(expire - '1/1/1970'::timestamp) as expire 227 227 from %s where %s = ?}, 228 $obj->db->quote_identifier($obj-> object_table),229 $obj->db->quote_identifier($obj-> key_field),228 $obj->db->quote_identifier($obj->_object_table), 229 $obj->db->quote_identifier($obj->_key_field), 230 230 ) 231 231 ); … … 293 293 q{select to_char(expire, 'YYYY/MM/DD') as expire 294 294 from %s where %s = ?}, 295 $obj->db->quote_identifier($obj-> object_table),296 $obj->db->quote_identifier($obj-> key_field),295 $obj->db->quote_identifier($obj->_object_table), 296 $obj->db->quote_identifier($obj->_key_field), 297 297 ) 298 298 ); … … 329 329 q{select to_char(expire AT TIME ZONE 'Z', 'YYYYMMDDHH24MISSZ') as expire 330 330 from %s where %s = ? and expire < now()}, 331 $obj->db->quote_identifier($obj-> object_table),332 $obj->db->quote_identifier($obj-> key_field),331 $obj->db->quote_identifier($obj->_object_table), 332 $obj->db->quote_identifier($obj->_key_field), 333 333 ) 334 334 ); … … 354 354 q{select date_part('epoch', expire)::int as expire 355 355 from %s where %s = ?}, 356 $self->db->quote_identifier($self-> object_table),357 $self->db->quote_identifier($self-> key_field),356 $self->db->quote_identifier($self->_object_table), 357 $self->db->quote_identifier($self->_key_field), 358 358 ) 359 359 ); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r944 r1014 42 42 =cut 43 43 44 sub attributes_table { $_[0]->object_table . '_attributes_list' }44 sub _attributes_table { $_[0]->_object_table . '_attributes_list' } 45 45 46 46 sub list { … … 50 50 sprintf( 51 51 q{select %s as k from %s %s order by %s}, 52 $base->db->quote_identifier($class-> key_field),53 $base->db->quote_identifier($class-> object_table),52 $base->db->quote_identifier($class->_key_field), 53 $base->db->quote_identifier($class->_object_table), 54 54 ($base->{wexported} ? '' : 'where exported = true'), 55 $base->db->quote_identifier($class-> key_field),55 $base->db->quote_identifier($class->_key_field), 56 56 ) 57 57 ); … … 69 69 sprintf( 70 70 q{select %s as k from %s where rev > ? %s order by %s}, 71 $base->db->quote_identifier($class-> key_field),72 $base->db->quote_identifier($class-> object_table),71 $base->db->quote_identifier($class->_key_field), 72 $base->db->quote_identifier($class->_object_table), 73 73 ($base->{wexported} ? '' : 'and exported = true'), 74 $base->db->quote_identifier($class-> key_field),74 $base->db->quote_identifier($class->_key_field), 75 75 ) 76 76 ); … … 83 83 } 84 84 85 sub has_extended_attributes { 0 }85 sub _has_extended_attributes { 0 } 86 86 87 87 sub _get_attr_schema { 88 88 my ($class, $base, $info) = @_; 89 89 $info ||= {}; 90 if (!$base->{__cache}{$class-> object_table}{inline}) {91 $base->{__cache}{$class-> object_table}{inline} = [];90 if (!$base->{__cache}{$class->_object_table}{inline}) { 91 $base->{__cache}{$class->_object_table}{inline} = []; 92 92 my $sth = $base->db->prepare( 93 93 q{SELECT column_name FROM information_schema.columns 94 94 WHERE table_name = ?} 95 95 ); 96 $sth->execute($class-> object_table);96 $sth->execute($class->_object_table); 97 97 while (my $res = $sth->fetchrow_hashref) { 98 push(@{$base->{__cache}{$class-> object_table}{inline}},98 push(@{$base->{__cache}{$class->_object_table}{inline}}, 99 99 $res->{column_name}); 100 100 } 101 101 } 102 foreach (@{$base->{__cache}{$class-> object_table}{inline}}) {102 foreach (@{$base->{__cache}{$class->_object_table}{inline}}) { 103 103 $info->{$_}{inline} = 1; 104 104 if (m/^(rev|date|create|ikey)$/) { … … 106 106 } 107 107 } 108 if ($class-> has_extended_attributes) {109 if (!$base->{__cache}{$class-> object_table}{extend}) {110 $base->{__cache}{$class-> object_table}{extend} = [];108 if ($class->_has_extended_attributes) { 109 if (!$base->{__cache}{$class->_object_table}{extend}) { 110 $base->{__cache}{$class->_object_table}{extend} = []; 111 111 my $sth = $base->db->prepare_cached( 112 112 sprintf( 113 113 q{select canonical from %s order by canonical}, 114 $base->db->quote_identifier($class-> attributes_table),114 $base->db->quote_identifier($class->_attributes_table), 115 115 ) 116 116 ); 117 117 $sth->execute; 118 118 while (my $res = $sth->fetchrow_hashref) { 119 push(@{$base->{__cache}{$class-> object_table}{extend}},119 push(@{$base->{__cache}{$class->_object_table}{extend}}, 120 120 $res->{canonical}); 121 121 } 122 122 } 123 foreach (@{$base->{__cache}{$class-> object_table}{extend}}) {123 foreach (@{$base->{__cache}{$class->_object_table}{extend}}) { 124 124 $info->{$_} ||= {}; 125 125 } … … 142 142 my $sth = $base->db->prepare_cached( 143 143 sprintf(q{select 1 from %s where %s = ? %s}, 144 $base->db->quote_identifier($class-> object_table),145 $base->db->quote_identifier($class-> key_field),144 $base->db->quote_identifier($class->_object_table), 145 $base->db->quote_identifier($class->_key_field), 146 146 ($base->{wexported} ? '' : 'and exported = true'), 147 147 ), … … 160 160 sprintf( 161 161 q{select ikey from %s where %s = ?}, 162 $base->db->quote_identifier($class-> object_table),163 $base->db->quote_identifier($class-> key_field),162 $base->db->quote_identifier($class->_object_table), 163 $base->db->quote_identifier($class->_key_field), 164 164 ) 165 165 ); … … 190 190 } 191 191 } 192 $first{$class-> key_field} = $id;192 $first{$class->_key_field} = $id; 193 193 194 194 my $sth = $base->db->prepare( 195 195 sprintf( 196 196 q{insert into %s (%s) values (%s)}, 197 $base->db->quote_identifier($class-> object_table),197 $base->db->quote_identifier($class->_object_table), 198 198 join(', ', map { $base->db->quote_identifier($_) } sort keys %first), 199 199 join(',', qw(?) x scalar(keys %first)), … … 213 213 sprintf( 214 214 q{delete from %s where %s = ?}, 215 $base->db->quote_identifier($class-> object_table),216 $base->db->quote_identifier($class-> key_field),215 $base->db->quote_identifier($class->_object_table), 216 $base->db->quote_identifier($class->_key_field), 217 217 ) 218 218 ); … … 226 226 sprintf( 227 227 q{update %s set %s = ? where %s = ?}, 228 $base->db->quote_identifier($class-> object_table),229 $base->db->quote_identifier($class-> key_field),230 $base->db->quote_identifier($class-> key_field),228 $base->db->quote_identifier($class->_object_table), 229 $base->db->quote_identifier($class->_key_field), 230 $base->db->quote_identifier($class->_key_field), 231 231 ) 232 232 ); … … 246 246 } 247 247 248 sub quote_ object_table {248 sub quote__object_table { 249 249 my ($self) = @_; 250 my $table = $self-> object_table or return;250 my $table = $self->_object_table or return; 251 251 $self->db->quote_identifier($table); 252 252 } 253 sub quote_ key_field {253 sub quote__key_field { 254 254 my ($self) = @_; 255 my $ key_field = $self->key_field or return;256 $self->db->quote_identifier($ key_field);255 my $_key_field = $self->key_field or return; 256 $self->db->quote_identifier($_key_field); 257 257 } 258 258 … … 268 268 q{select %s from %s where %s = ?}, 269 269 $self->db->quote_identifier(lc($field)), 270 $self->quote_ object_table,271 $self->quote_ key_field,270 $self->quote__object_table, 271 $self->quote__key_field, 272 272 ) 273 273 ); … … 276 276 $sth->finish; 277 277 return $res->{$field}; 278 } elsif ($self-> has_extended_attributes) { # else, then we mandatory have extend attr278 } elsif ($self->_has_extended_attributes) { # else, then we mandatory have extend attr 279 279 $self->base->{__cache}{"_" . $self->type} ||= {}; 280 280 my $__cache = $self->base->{__cache}{"_" . $self->type}; … … 288 288 where %s = ? 289 289 }, 290 $self->db->quote_identifier($self-> object_table. '_attributes'),291 $self->db->quote_identifier($self-> object_table),292 $self->db->quote_identifier($self-> key_field),290 $self->db->quote_identifier($self->_object_table. '_attributes'), 291 $self->db->quote_identifier($self->_object_table), 292 $self->db->quote_identifier($self->_key_field), 293 293 ) 294 294 ); … … 332 332 sprintf( 333 333 q{update %s set %s where %s = ?}, 334 $self->quote_ object_table,334 $self->quote__object_table, 335 335 join(', ', @fields), 336 $self->quote_ key_field,336 $self->quote__key_field, 337 337 ) 338 338 ); … … 348 348 } 349 349 350 if ($self-> has_extended_attributes) {350 if ($self->_has_extended_attributes) { 351 351 my $sthd = $self->db->prepare_cached( 352 352 sprintf( 353 353 q{delete from %s where okey = ? and attr = ?}, 354 $self->db->quote_identifier($self-> object_table. '_attributes'),354 $self->db->quote_identifier($self->_object_table. '_attributes'), 355 355 ), 356 356 ); … … 358 358 sprintf( 359 359 q{delete from %s where okey = ? and attr = ? and value = ?}, 360 $self->db->quote_identifier($self-> object_table. '_attributes'),360 $self->db->quote_identifier($self->_object_table. '_attributes'), 361 361 ), 362 362 ); … … 364 364 sprintf( 365 365 q{insert into %s (okey, attr, value) values (?,?,?)}, 366 $self->db->quote_identifier($self-> object_table. '_attributes'),366 $self->db->quote_identifier($self->_object_table. '_attributes'), 367 367 ) 368 368 ); … … 370 370 sprintf( 371 371 q{update %s set value = ? where okey = ? and attr = ?}, 372 $self->db->quote_identifier($self-> object_table. '_attributes'),372 $self->db->quote_identifier($self->_object_table. '_attributes'), 373 373 ) 374 374 ); … … 474 474 q{select %s as value from %s}, 475 475 $base->db->quote_identifier($attr->iname), 476 $base->db->quote_identifier($class-> object_table),476 $base->db->quote_identifier($class->_object_table), 477 477 ) 478 478 : sprintf( 479 479 q{select value from %s where attr = ? group by value}, 480 $base->db->quote_identifier($class-> object_table .480 $base->db->quote_identifier($class->_object_table . 481 481 '_attributes'), 482 482 ) … … 548 548 $sql = sprintf( 549 549 q{select ikey from %s where %s}, 550 $base->db->quote_identifier($class-> object_table),550 $base->db->quote_identifier($class->_object_table), 551 551 $val ? q{exported='f'} : q{exported='t'} 552 552 ) … … 554 554 $sql = sprintf( 555 555 q{select ikey from %s where %s %s}, 556 $base->db->quote_identifier($class-> object_table),556 $base->db->quote_identifier($class->_object_table), 557 557 $base->db->quote_identifier($attribute->iname), 558 558 $val eq '*' … … 567 567 q{select okey from %s where attr = ? %s}, 568 568 $base->db->quote_identifier( 569 $class-> object_table . '_attributes'569 $class->_object_table . '_attributes' 570 570 ), 571 571 $val eq '*' … … 587 587 push(@sqlintersec, sprintf( 588 588 q{select ikey from %s where exported = true}, 589 $base->db->quote_identifier($class-> object_table)589 $base->db->quote_identifier($class->_object_table) 590 590 ) 591 591 ); … … 602 602 order by name 603 603 }, 604 $base->db->quote_identifier($class-> object_table),604 $base->db->quote_identifier($class->_object_table), 605 605 @sqlintersec 606 606 ? "where ikey in (\n" . join("\n intersect\n", @sqlintersec) . ")\n" … … 627 627 insert into %s (canonical, description) 628 628 values (?,?) 629 }, $class-> attributes_table)629 }, $class->_attributes_table) 630 630 ); 631 631 my $res = $sth->execute($attribute, $comment); … … 638 638 sprintf(q{ 639 639 select 1 from %s where canonical = ? 640 }, $class-> attributes_table640 }, $class->_attributes_table 641 641 ) 642 642 ); … … 656 656 select description from %s 657 657 where canonical = ? 658 }, $class-> attributes_table)658 }, $class->_attributes_table) 659 659 ); 660 660 $sth->execute($attribute); … … 684 684 update %s set description = ? 685 685 where canonical = ? 686 }, $class-> attributes_table)686 }, $class->_attributes_table) 687 687 ); 688 688 my $res = $sth->execute($comment, $attribute); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix/Group.pm
r965 r1014 12 12 =head1 NAME 13 13 14 LATMOS::A d - Perl extension for blah blah blah14 LATMOS::Accounts::Bases::Unix::Group - Group management in Unix Base 15 15 16 16 =head1 SYNOPSIS … … 22 22 =head1 DESCRIPTION 23 23 24 Acc ount base access over standard unix file format.24 Access and modify group informations in Unix base. 25 25 26 26 =head1 FUNCTIONS … … 113 113 =head1 SEE ALSO 114 114 115 L<LATMOS::Accounts::Bases::Objects> 116 L<LATMOS::Accounts::Bases::Unix> 117 115 118 =head1 AUTHOR 116 119 … … 119 122 =head1 COPYRIGHT AND LICENSE 120 123 121 Copyright (C) 2008, 2009 CNRS SA/CETP/LATMOS124 Copyright (C) 2008, 2009, 2010, 2011, 2012 CNRS SA/CETP/LATMOS 122 125 123 126 This library is free software; you can redistribute it and/or modify -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Log.pm
r861 r1014 70 70 71 71 =cut 72 72 73 sub LA_CRIT { LOG_CRIT } # critical conditions 73 74 … … 217 218 218 219 1; 220 221 __END__ 222 223 =head1 SEE ALSO 224 225 =head1 AUTHOR 226 227 Thauvin Olivier, E<lt>olivier.thauvin@latmos.ipsl.frE<gt> 228 229 =head1 COPYRIGHT AND LICENSE 230 231 Copyright (C) 2009, 2010, 2011, 2012 by Thauvin Olivier 232 233 This library is free software; you can redistribute it and/or modify 234 it under the same terms as Perl itself, either Perl version 5.10.0 or, 235 at your option, any later version of Perl 5 you may have available. 236 237 =cut 238 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Maintenance.pm
r1011 r1014 6 6 use LATMOS::Accounts::Log; 7 7 use FindBin qw($Bin); 8 9 =head1 NAME 10 11 LATMOS::Accounts::Maintenance 12 13 =cut 8 14 9 15 sub _base {
Note: See TracChangeset
for help on using the changeset viewer.