source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/OAliases.pm @ 2054

Last change on this file since 2054 was 1865, checked in by nanardon, 8 years ago

Merge branch

File size: 1.8 KB
Line 
1package LATMOS::Accounts::Web::Controller::OAliases;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller::OAliases - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path :Args(0) {
25    my ( $self, $c ) = @_;
26
27}
28
29sub 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
45sub 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
75Olivier Thauvin,Guyancourt - B1428,+33 1 80285052,
76
77=head1 LICENSE
78
79This library is free software. You can redistribute it and/or modify
80it under the same terms as Perl itself.
81
82=cut
83
84__PACKAGE__->meta->make_immutable;
85
861;
Note: See TracBrowser for help on using the repository browser.