1 | package LATMOS::Accounts::Bases::OCHelper::Address; |
---|
2 | |
---|
3 | # $Id: OCHelper.pm 2932 2010-08-10 17:19:21Z nanardon $ |
---|
4 | |
---|
5 | use strict; |
---|
6 | use warnings; |
---|
7 | use base qw(LATMOS::Accounts::Bases::OCHelper); |
---|
8 | use LATMOS::Accounts::Utils; |
---|
9 | use LATMOS::Accounts::Log; |
---|
10 | |
---|
11 | =head1 NAME |
---|
12 | |
---|
13 | LATMOS::Accounts::Bases::OCHelper - Object creation helper |
---|
14 | |
---|
15 | =head1 DESCRIPTION |
---|
16 | |
---|
17 | This module is designed to be subclassed. |
---|
18 | |
---|
19 | =head1 FUNCTIONS |
---|
20 | |
---|
21 | =cut |
---|
22 | |
---|
23 | # just return status, $info is reference |
---|
24 | sub _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 | |
---|
54 | 1; |
---|
55 | |
---|
56 | __END__ |
---|
57 | |
---|
58 | =head1 SEE ALSO |
---|
59 | |
---|
60 | L<LATMOS::Accounts::Bases>, L<LATMOS::Accounts::Bases::Objects> |
---|
61 | |
---|
62 | =head1 AUTHOR |
---|
63 | |
---|
64 | Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt> |
---|
65 | |
---|
66 | =head1 COPYRIGHT AND LICENSE |
---|
67 | |
---|
68 | Copyright (C) 2012 CNRS SA/CETP/LATMOS |
---|
69 | |
---|
70 | This library is free software; you can redistribute it and/or modify |
---|
71 | it under the same terms as Perl itself, either Perl version 5.10.0 or, |
---|
72 | at your option, any later version of Perl 5 you may have available. |
---|
73 | |
---|
74 | =cut |
---|