1 | package LATMOS::Accounts::Web::Controller::OAliases; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN { extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | LATMOS::Accounts::Web::Controller::OAliases - 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 | } |
---|
28 | |
---|
29 | sub Create :Path('create') :Args(0) { |
---|
30 | my ( $self, $c ) = @_; |
---|
31 | |
---|
32 | my $otype = $c->req->param('otype'); |
---|
33 | my $name = $c->req->param('name'); |
---|
34 | |
---|
35 | if (my $for = $c->req->param('oalias')) { |
---|
36 | if ($c->model('Accounts')->db->CreateAlias($otype, $name, $for)) { |
---|
37 | $c->res->redirect($c->uri_for('/oaliases', $otype, $name)); |
---|
38 | $c->model('Accounts')->db->commit; |
---|
39 | } else { |
---|
40 | $c->model('Accounts')->db->rollback; |
---|
41 | } |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | sub Edit :Path :Args(2) { |
---|
46 | my ( $self, $c, $otype, $name ) = @_; |
---|
47 | |
---|
48 | my $oalias = $c->model('Accounts')->db->GetAlias($otype, $name) or do { |
---|
49 | $c->go('/no_object'); |
---|
50 | return; |
---|
51 | }; |
---|
52 | |
---|
53 | if ($c->req->param('delete')) { |
---|
54 | if ($c->model('Accounts')->db->RemoveAlias($otype, $name)) { |
---|
55 | $c->res->redirect($c->uri_for('/oaliases')); |
---|
56 | $c->model('Accounts')->db->commit; |
---|
57 | return 1; |
---|
58 | } |
---|
59 | } elsif (my $for = $c->req->param('oalias')) { |
---|
60 | my $exported = $c->req->param('exported') || 0; |
---|
61 | if($oalias->set_c_fields(oalias => $for, exported => $exported)) { |
---|
62 | $oalias->base->commit; |
---|
63 | |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | $c->stash->{objectalias} = $oalias; |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | =encoding utf8 |
---|
72 | |
---|
73 | =head1 AUTHOR |
---|
74 | |
---|
75 | Olivier Thauvin,Guyancourt - B1428,+33 1 80285052, |
---|
76 | |
---|
77 | =head1 LICENSE |
---|
78 | |
---|
79 | This library is free software. You can redistribute it and/or modify |
---|
80 | it under the same terms as Perl itself. |
---|
81 | |
---|
82 | =cut |
---|
83 | |
---|
84 | __PACKAGE__->meta->make_immutable; |
---|
85 | |
---|
86 | 1; |
---|