source: LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller.pm @ 521

Last change on this file since 521 was 521, checked in by nanardon, 15 years ago
  • always try to synchronise secondary bases
File size: 1.7 KB
Line 
1package LATMOS::Accounts::Web::Controller;
2
3use strict;
4use warnings;
5use base 'Catalyst::Controller';
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller - Base class Controller for LATMOS::Accounts::Web
10
11=head1 DESCRIPTION
12
13[enter your description here]
14
15=head1 METHODS
16
17=cut
18
19=head2 default
20
21=cut
22
23sub begin : Private {
24    my ( $self, $c ) = @_;
25
26    my $menu = '';
27    my @menus = (
28        [ 'users' => 'Utilisateurs' ],
29        ($c->model('Accounts')->db->check_acl('user', '@CREATE', 'w')
30            ? [ 'create/user' => 'Créer un Utilisateur' ]
31            : ()),
32        [ 'groups' => 'Groupes' ],
33        ($c->model('Accounts')->db->check_acl('group', '@CREATE', 'w')
34            ? [ 'create/group' => 'Créer un Groupe' ]
35            : ()),
36        [ 'sites' => 'Sites' ],
37        [ 'aliases' => 'Alias Mail' ],
38    );
39    foreach(@menus) {
40        $menu .= sprintf(
41            q{<a href="%s"><span%s>%s</span></a>},
42            $c->uri_for('/' . $_->[0]),
43            ($c->req->path =~ m:^$_->[0]: ? ' id="actif"' : ''),
44            $_->[1],
45        );
46
47    }
48    $c->stash->{mainmenu} = $menu;
49    if (!$c->user_exists) {
50        if ($c->req->path ne 'login') {
51            $c->forward('/login');
52        }
53    } else {
54        $c->model('Accounts')->db->connect($c->user->{username},
55            $c->user->{password});
56    }
57}
58
59=head2 end
60
61Attempt to render a view, if needed.
62
63=cut 
64
65sub end : ActionClass('RenderView') {
66    my ($self, $c) = @_;
67    $c->forward($c->view('TT'));
68    $c->model('Accounts')->db->rollback;
69    if (my $sync = $c->model('Accounts')->sync) {
70        $sync->process;
71    }
72}
73
74=head1 AUTHOR
75
76Thauvin Olivier
77
78=head1 LICENSE
79
80This library is free software, you can redistribute it and/or modify
81it under the same terms as Perl itself.
82
83=cut
84
851;
Note: See TracBrowser for help on using the repository browser.