source: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Templates.pm @ 2358

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

Fix: internal name of atrribute

File size: 2.2 KB
Line 
1package LATMOS::Accounts::Bases::Sql::Templates;
2
3use 5.010000;
4use strict;
5use warnings;
6
7use base qw(LATMOS::Accounts::Bases::Sql::objects);
8use LATMOS::Accounts::Log;
9use LATMOS::Accounts::I18N;
10
11our $VERSION = (q$Rev: 341 $ =~ /^Rev: (\d+) /)[0];
12
13=head1 NAME
14
15LATMOS::Ad - Perl extension for blah blah blah
16
17=head1 SYNOPSIS
18
19  use LATMOS::Accounts::Bases;
20  my $base = LATMOS::Accounts::Bases->new('sql');
21  ...
22
23=head1 DESCRIPTION
24
25Account base access over standard unix file format.
26
27=head1 FUNCTIONS
28
29=cut
30
31sub _object_table { 'templates' }
32
33sub _key_field { 'name' }
34
35sub _has_extended_attributes { 0 }
36
37sub _get_attr_schema {
38    my ($class, $base) = @_;
39
40    $class->SUPER::_get_attr_schema($base,
41        {
42            objectType => {
43                iname => 'objecttype',
44                inline => 1,
45                ro => 1,
46                can_values => sub {
47                    $base->list_supported_objects;
48                },
49            },
50            data => {
51                inline => 1,
52                formtype => 'TEXTAREA',
53                multiple => 1,
54                set => sub {
55                    my ($self, $data) = @_;
56                    my @datas = $data
57                        ? (ref $data
58                            ? @$data
59                            : ($data))
60                        : ();
61                    my $sql = @datas
62                        ? '{' . join(',', map { $_ =~ s/\\/\\\\/g; '"' .$_.'"' } @datas) . '}'
63                        : undef;
64                    $base->db->do(
65                        q{UPDATE templates SET data = }
66                        . $base->db->quote($sql) . q{ where name = } .
67                        $base->db->quote($self->object->id)
68                    );
69                    return 1;
70                },
71            },
72        }
73    )
74}
75
761;
77
78__END__
79
80=head1 SEE ALSO
81
82L<LATMOS::Accounts::Bases::Sql::Aliases>, L<LATMOS::Accounts::Bases::Sql>
83
84=head1 AUTHOR
85
86Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
87
88=head1 COPYRIGHT AND LICENSE
89
90Copyright (C) 2008, 2009 CNRS SA/CETP/LATMOS
91
92This library is free software; you can redistribute it and/or modify
93it under the same terms as Perl itself, either Perl version 5.10.0 or,
94at your option, any later version of Perl 5 you may have available.
95
96
97=cut
Note: See TracBrowser for help on using the repository browser.