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
34 * @link http://galette.tuxfamily.org
35 * @since Available since 0.7.5dev - 2013-02-08
38 use Galette\Entity\Texts
;
39 use Galette\Repository\Members
;
40 use Galette\Repository\Reminders
;
41 use Galette\Filters\MembersList
;
44 require_once __DIR__
. '/../includes/galette.inc.php';
46 if (!$login->isCron()) {
51 $container->get('texts_fields'),
52 $container->get('preferences')
54 $reminders = new Reminders();
57 $list_reminders = $reminders->getList($container->get('zdb'), false);
58 if (count($list_reminders) > 0) {
59 foreach ($list_reminders as $reminder) {
60 //send reminders by mail
61 $sent = $reminder->send($texts, $container->get('hist'), $container->get('zdb'));
64 $success_detected[] = $reminder->getMessage();
66 $error_detected[] = $reminder->getMessage();
70 if (count($error_detected) > 0) {
73 _T("Reminder has not been sent:")
77 if (count($success_detected) > 0) {
85 //called from a cron. warning and errors has been stored into history
87 if (count($error_detected) > 0) {
88 //if there are errors, we print them
91 foreach ($error_detected as $e) {
98 //we can also print additionnal informations.
99 if (count($success_detected) > 0) {
103 count($success_detected),
104 _T("%i mails have been sent successfully.")
109 //if there were no errors, we just exit properly for cron to be quiet.