source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Ajax/Services/Mailing.pm @ 1158

Last change on this file since 1158 was 1158, checked in by nanardon, 12 years ago

add attachment support in mail

File size: 2.5 KB
Line 
1package LATMOS::Accounts::Web::Controller::Ajax::Services::Mailing;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller::Ajax::Services::Mailing - 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    $c->response->body('Matched LATMOS::Accounts::Web::Controller::Ajax::Services::Mailing in Ajax::Services::Mailing.');
28}
29
30sub users_list :Local {
31    my ( $self, $c ) = @_;
32
33    $c->req->params->{attr} =    [ 'active', 'mail' ];
34    $c->req->params->{attrval} = [ '1',    , '*'    ];
35
36    for ($c->req->param('type')) {
37
38        /^dpmt$/ and do {
39            push(@{ $c->req->params->{attr} }, 'department');
40            push(@{ $c->req->params->{attrval} }, $c->req->param('obj'));
41            last;
42        };
43        /^dpmt_assoc$/ and do {
44            push(@{ $c->req->params->{attr} }, 'memberOf');
45            push(@{ $c->req->params->{attrval} }, $c->req->param('obj'));
46            last;
47        };
48        /^quick$/ and do {
49            last;
50        };
51
52        # Else
53        push(@{ $c->req->params->{attr} }, $_);
54        push(@{ $c->req->params->{attrval} }, $c->req->param('toto'));
55    }
56    $c->stash->{ofilter} = $c->model('AttrFilter', 'user');
57}
58
59sub dest_list :Private {}
60
61sub quick_input :Private {}
62
63sub empty :Local {
64    my ( $self, $c ) = @_;
65    $c->session->{to} = {};
66    $c->go('dest_list');
67}
68
69sub mod_to :Local {
70    my ( $self, $c ) = @_;
71
72    for ($c->req->param('act' || '')) {
73        /add_to/ and do {
74            foreach ($c->req->param('user')) {
75                $c->session->{to}{$_} = 1;
76            }
77        };
78        /remove_to/ and do {
79            foreach ($c->req->param('user')) {
80                delete($c->session->{to}{$_});
81            }
82        };
83    }
84
85    $c->go('dest_list');
86}
87
88sub attachments :Local {
89    my ( $self, $c ) = @_;
90    foreach ($c->req->param('rm_attachment')) {
91        $c->session->{mailing}{attachments}[$_ -1] = undef;
92    }
93
94    $c->session->{mailing}{attachments} = [
95        grep { $_ }
96        @{
97        $c->session->{mailing}{attachments} || []}
98    ];
99}
100
101sub end : Private {
102    my ( $self, $c ) = @_;
103    $c->forward($c->view('TTpart'));
104}
105
106=head1 AUTHOR
107
108olivier
109
110=head1 LICENSE
111
112This library is free software. You can redistribute it and/or modify
113it under the same terms as Perl itself.
114
115=cut
116
117__PACKAGE__->meta->make_immutable;
118
1191;
Note: See TracBrowser for help on using the repository browser.