source: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/OCHelper/Address.pm @ 2418

Last change on this file since 2418 was 2385, checked in by nanardon, 4 years ago

Add OCHelper for Address and Employment

File size: 1.7 KB
Line 
1package LATMOS::Accounts::Bases::OCHelper::Address;
2
3# $Id: OCHelper.pm 2932 2010-08-10 17:19:21Z nanardon $
4
5use strict;
6use warnings;
7use base qw(LATMOS::Accounts::Bases::OCHelper);
8use LATMOS::Accounts::Utils;
9use LATMOS::Accounts::Log;
10
11=head1 NAME
12
13LATMOS::Accounts::Bases::OCHelper - Object creation helper
14
15=head1 DESCRIPTION
16
17This module is designed to be subclassed.
18
19=head1 FUNCTIONS
20
21=cut
22
23# just return status, $info is reference
24sub _step {
25    my ($self, $info) = @_;
26
27    if ($info->{step} == 0) {
28        $info->{name}{ask} = 0;
29        foreach ($self->base->list_canonical_fields($self->otype, 'w')) {
30            /^oalias$/ and next;
31            /^template$/ and next;
32            push(@{$info->{ask}}, $_);
33        }
34        $info->{step} = 1;
35        return 'NEEDINFO';
36    } elsif ($info->{step} == 1) {
37        if (! $info->{name}{content} ) {
38            my $random = LATMOS::Accounts::Utils::genpassword();
39            $info->{name}{content} = $info->{contents}{user} . '-' . $random;
40        }
41        if ($self->base->create_c_object($self->otype,
42                $info->{name}{content},
43                %{$info->{contents} || {}},
44            )) {
45            return 'CREATED';
46        } else {
47            return 'ERROR';
48        }
49    } else {
50        return undef;
51    }
52}
53
541;
55
56__END__
57
58=head1 SEE ALSO
59
60L<LATMOS::Accounts::Bases>, L<LATMOS::Accounts::Bases::Objects>
61
62=head1 AUTHOR
63
64Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
65
66=head1 COPYRIGHT AND LICENSE
67
68Copyright (C) 2012 CNRS SA/CETP/LATMOS
69
70This library is free software; you can redistribute it and/or modify
71it under the same terms as Perl itself, either Perl version 5.10.0 or,
72at your option, any later version of Perl 5 you may have available.
73
74=cut
Note: See TracBrowser for help on using the repository browser.