. * * @category Main * @package Galette * * @author Johan Cwiklinski * @copyright 2013-2014 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @version SVN: $Id$ * @link http://galette.tuxfamily.org * @since Available since 0.7.5dev - 2013-02-08 */ use Galette\Entity\Texts; use Galette\Repository\Members; use Galette\Repository\Reminders; use Galette\Filters\MembersList; /** @ignore */ require_once __DIR__ . '/../includes/galette.inc.php'; $app = new \Slim\App( array( 'templates.path' => GALETTE_ROOT . 'templates/default/', 'mode' => 'CRON' ) ); session_start(); require_once __DIR__ . '/../includes/dependencies.php'; if (!$container->get('login')->isCron()) { die(); } $texts = new Texts( $container->get('texts_fields'), $container->get('preferences') ); $reminders = new Reminders(); $list_reminders = $reminders->getList($container->get('zdb'), false); if (count($list_reminders) > 0) { foreach ($list_reminders as $reminder) { //send reminders by mail $sent = $reminder->send($texts, $container->get('hist'), $container->get('zdb')); if ($sent === true) { $success_detected[] = $reminder->getMessage(); } else { $error_detected[] = $reminder->getMessage(); } } if (count($error_detected) > 0) { array_unshift( $error_detected, _T("Reminder has not been sent:") ); } if (count($success_detected) > 0) { array_unshift( $success_detected, _T("Sent reminders:") ); } } //called from a cron. warning and errors has been stored into history //and probably logged if (count($error_detected) > 0) { //if there are errors, we print them echo "\n"; $count = 0; foreach ($error_detected as $e) { if ($count > 0) { echo ' '; } echo $e . "\n"; $count++; } //we can also print additionnal informations. if (count($success_detected) > 0) { echo "\n"; echo str_replace( '%i', count($success_detected), _T("%i mails have been sent successfully.") ); } exit(1); } else { //if there were no errors, we just exit properly for cron to be quiet. exit(0); }