...
|
...
|
@@ -4,7 +4,7 @@ use warnings;
|
4
|
4
|
use DBI;
|
5
|
5
|
use utf8;
|
6
|
6
|
use POSIX qw(strftime);
|
7
|
|
-use Data::Dumper;
|
|
7
|
+#use Data::Dumper;
|
8
|
8
|
use Email::Send::SMTP::Gmail;
|
9
|
9
|
|
10
|
10
|
my $scriptconf = $ENV{PWD} . "/$0";
|
...
|
...
|
@@ -115,38 +115,39 @@ foreach my $category (keys(%{$polls})) {
|
115
|
115
|
# $dbh->commit();
|
116
|
116
|
$dbh->disconnect();
|
117
|
117
|
|
118
|
|
-my %data = (
|
119
|
|
- admin => "Salut,<br><br>voici les liens d'administration vers les actions<br><br>",
|
120
|
|
- normal => "Salut,<br><br>tu trouveras les actions de la section sur lesquelles tu peux t'inscrire<br><br>",
|
121
|
|
- );
|
|
118
|
+my ($mail,$error)=Email::Send::SMTP::Gmail->new(%{$cfg::config{notification}{from}});
|
|
119
|
+die "session error: $error" unless ($mail!=-1);
|
122
|
120
|
|
123
|
|
-foreach my $category (keys(%{$polls})) {
|
124
|
|
- next unless (keys%{$polls->{$category}});
|
125
|
|
- $data{admin} .= "<h1>$category</h1><br>";
|
126
|
|
- $data{normal} .= "<h1>$category</h1><br>";
|
127
|
|
- foreach my $poll_id (keys(%{$polls->{$category}})) {
|
128
|
|
- my $title = $polls->{$category}->{$poll_id}->{title};
|
129
|
|
- my $admin_id = $polls->{$category}->{$poll_id}->{admin_id};
|
130
|
|
- if (! $polls->{$category}->{$poll_id}->{restricted}) {
|
131
|
|
- $data{normal} .= "<a href=$cfg::config{url}/studs.php?poll=$poll_id>$title</a><br>";
|
|
121
|
+foreach my $dest (keys(%{$cfg::config{notification}->{to}})) {
|
|
122
|
+
|
|
123
|
+ my $data = $cfg::config{notification}->{to}->{$dest}->{intro};
|
|
124
|
+
|
|
125
|
+ foreach my $category (keys(%{$polls})) {
|
|
126
|
+ next unless (keys%{$polls->{$category}});
|
|
127
|
+ $data .= "<h1>$category</h1>";
|
|
128
|
+ foreach my $poll_id (keys(%{$polls->{$category}})) {
|
|
129
|
+ my $title = $polls->{$category}->{$poll_id}->{title};
|
|
130
|
+ if (exists $cfg::config{notification}->{to}->{$dest}->{admin}) {
|
|
131
|
+ my $admin_id = $polls->{$category}->{$poll_id}->{admin_id};
|
|
132
|
+ $data .= "<a href=$cfg::config{url}/adminstuds.php?poll=$admin_id>$title</a><br>";
|
|
133
|
+ }
|
|
134
|
+ else {
|
|
135
|
+ $data .= "<a href=$cfg::config{url}/studs.php?poll=$poll_id>$title</a><br>";
|
|
136
|
+ }
|
132
|
137
|
}
|
133
|
|
- $data{admin} .= "<a href=$cfg::config{url}/adminstuds.php?poll=$admin_id>$title</a><br>";
|
134
|
138
|
}
|
135
|
|
-}
|
136
|
139
|
|
137
|
|
-my ($mail,$error)=Email::Send::SMTP::Gmail->new(%{$cfg::config{notification}{from}});
|
138
|
|
-die "session error: $error" unless ($mail!=-1);
|
139
|
|
-foreach my $destination (keys(%{$cfg::config{notification}->{to}})) {
|
140
|
|
- utf8::decode($data{$destination});
|
|
140
|
+ $data .= $cfg::config{notification}->{to}->{$dest}->{outro};
|
|
141
|
+
|
|
142
|
+ utf8::decode($data);
|
|
143
|
+
|
141
|
144
|
$mail->send(
|
142
|
|
- -from=>'"PCF Paris 12ème" <pcf.12eme@gmail.com>',
|
143
|
|
- -replyto=>'secretariat@paris12.pcf.fr',
|
144
|
|
- -to=>$cfg::config{notification}->{to}->{$destination},
|
145
|
|
- -subject=>'les actions de la section',
|
|
145
|
+ -from=>$cfg::config{notification}{from_infos}{from},
|
|
146
|
+ -replyto=>$cfg::config{notification}{from_infos}{replyto},
|
|
147
|
+ -to=>$cfg::config{notification}->{to}->{$dest}->{adress},
|
|
148
|
+ -subject=>$cfg::config{notification}->{to}->{$dest}->{subject},
|
146
|
149
|
-contenttype=>'text/html',
|
147
|
|
- -body=>$data{$destination}
|
|
150
|
+ -body=>$data
|
148
|
151
|
);
|
149
|
|
- sleep(30);
|
150
|
152
|
}
|
151
|
153
|
$mail->bye();
|
152
|
|
-print "fin\n";
|