3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Galette cron reminders
10 * Copyright © 2013-2016 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since Available since 0.7.5dev - 2013-02-08
37 use Galette\Entity\Texts
;
38 use Galette\Repository\Members
;
39 use Galette\Repository\Reminders
;
40 use Galette\Filters\MembersList
;
43 require_once __DIR__
. '/../includes/galette.inc.php';
47 'templates.path' => GALETTE_ROOT
. 'templates/default/',
52 require_once __DIR__
. '/../includes/dependencies.php';
54 if (isset($needs_update) && $needs_update === true) {
55 echo _T("Your Galette database is not present, or not up to date.");
59 /** TODO: login is now handled in dependencies.php; the cron case should be aswell */
61 $container->get('login')->logCron(basename($argv[0], '.php'));
64 if (!$container->get('login')->isCron()) {
69 $container->get('preferences')
71 $reminders = new Reminders();
74 $list_reminders = $reminders->getList($container->get('zdb'), false);
75 if (count($list_reminders) > 0) {
76 foreach ($list_reminders as $reminder) {
77 //send reminders by email
78 $sent = $reminder->send($texts, $container->get('history'), $container->get('zdb'));
81 $success_detected[] = $reminder->getMessage();
83 $error_detected[] = $reminder->getMessage();
87 if (count($error_detected) > 0) {
90 _T("Reminder has not been sent:")
94 if (count($success_detected) > 0) {
102 //called from a cron. warning and errors has been stored into history
103 //and probably logged
104 if (count($error_detected) > 0) {
105 //if there are errors, we print them
108 foreach ($error_detected as $e) {
115 //we can also print additionnal information.
116 if (count($success_detected) > 0) {
120 count($success_detected),
121 _T("%i emails have been sent successfully.")
126 //if there were no errors, we just exit properly for cron to be quiet.