Line | |
---|
1 | package LATMOS::Accounts::Web::Controller::Aliases; |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use base 'LATMOS::Accounts::Web::Controller'; |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | LATMOS::Accounts::Web::Controller::Aliases - Catalyst Controller |
---|
10 | |
---|
11 | =head1 DESCRIPTION |
---|
12 | |
---|
13 | Catalyst Controller. |
---|
14 | |
---|
15 | =head1 METHODS |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | |
---|
20 | =head2 index |
---|
21 | |
---|
22 | =cut |
---|
23 | |
---|
24 | sub index :Path :Args(0) { |
---|
25 | my ( $self, $c ) = @_; |
---|
26 | |
---|
27 | my $db = $c->model('Accounts')->db; |
---|
28 | my @al = $c->req->param('al'); |
---|
29 | my @name = $c->req->param('name'); |
---|
30 | my @forward = $c->req->param('forward'); |
---|
31 | foreach my $idx (0 .. scalar(@al) - 1) { |
---|
32 | |
---|
33 | if ($c->req->param('del' . ($idx+1))) { |
---|
34 | $db->delete_object('aliases', $al[$idx]); |
---|
35 | } elsif ($al[$idx] ne $name[$idx]) { |
---|
36 | # delete old, create new |
---|
37 | $db->delete_object('aliases', $al[$idx]); |
---|
38 | $db->create_object('aliases', $name[$idx], |
---|
39 | forward => [ split(/\s*,\s*/, $forward[$idx]) ], |
---|
40 | ); |
---|
41 | } else { |
---|
42 | my $obj = $db->get_object('aliases', $al[$idx]); |
---|
43 | $obj->set_c_fields( |
---|
44 | 'forward' => [ split(/\s*,\s*/, $forward[$idx]) ], |
---|
45 | ); |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | $db->commit; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | =head1 AUTHOR |
---|
54 | |
---|
55 | Olivier Thauvin |
---|
56 | |
---|
57 | =head1 LICENSE |
---|
58 | |
---|
59 | This library is free software. You can redistribute it and/or modify |
---|
60 | it under the same terms as Perl itself. |
---|
61 | |
---|
62 | =cut |
---|
63 | |
---|
64 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.