Replaces 'id' with 'uid' when addressing SQL result maps in the
[platal.git] / bin / cron / registrations.php
CommitLineData
ee68ddc1 1#!/usr/bin/php5 -q
0337d704 2<?php
5ecaa68e 3
525bec1a 4require 'connect.db.inc.php';
0337d704 5
5ecaa68e 6$message = '';
0337d704 7
36d2dab7 8$res = XDB::iterRow("SELECT al.alias, pd.promo, e.email
525bec1a 9 FROM accounts AS a
36d2dab7
SJ
10 INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))
11 INNER JOIN profile_display AS pd ON (ap.pid = pd.pid)
12 LEFT JOIN aliases AS al ON (a.uid =a.uid AND al.type = 'a_vie')
13 LEFT JOIN emails AS e ON (a.uid = e.uid AND NOT FIND_IN_SET('filter', e.flags))
525bec1a
SJ
14 WHERE a.registration_date > {?}
15 GROUP BY al.alias
16 ORDER BY pd.promo",
17 date("Ymd000000", strtotime('last Monday')));
18if ($count = $res->total()) {
19 $message .= "$count INSCRIPTIONS CONFIRMÉES :\n";
20 while (list($forlife, $promo, $email) = $res->next()) {
21 $message .= "$promo, $forlife, $email\n";
0337d704 22 }
23}
24
525bec1a
SJ
25$res = XDB::iterRow("SELECT a.hruid, r.email, r.date
26 FROM register_pending AS r
27 INNER JOIN accounts AS a ON (a.uid = r.uid)
28 WHERE r.hash != 'INSCRIT'
29 ORDER BY r.date");
30if ($count = $res->total()) {
31 $message .= "\n$count INSCRIPTIONS NON CONFIRMÉES :\n";
32 while (list($forlife, $email, $date) = $res->next()) {
33 $message .= "$date, $forlife,\n $email\n";
0337d704 34 }
35}
36
525bec1a
SJ
37$res = XDB::query('SELECT COUNT(DISTINCT uid), COUNT(*)
38 FROM register_marketing');
0337d704 39list($a, $b) = $res->fetchOneRow();
525bec1a
SJ
40$message .= "\nINSCRIPTIONS SOLICITÉES :\n";
41$message .= " $a utilisateurs\n $b adresses email\n";
0337d704 42
525bec1a 43$message .= "\n\n";
0337d704 44
1e33266a 45$mailer = new PlMailer();
525bec1a 46$mailer->setSubject('Rapport des inscriptions de la semaine');
40bc7e89 47$mailer->setFrom($globals->register->notif);
48$mailer->addTo($globals->register->notif);
525bec1a 49$mailer->setTxtBody($message);
0337d704 50$mailer->send();
5ecaa68e 51
a7de4ef7 52// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 53?>