From: Johan Cwiklinski Date: Sat, 13 Jan 2024 11:55:43 +0000 (+0100) Subject: Use default Galette language for cron X-Git-Tag: 1.0.1~4 X-Git-Url: https://git.agnieray.net/?a=commitdiff_plain;h=a3751f819fa256fe61b00c89345b0b260d38c39a;p=galette.git Use default Galette language for cron closes #1769 --- diff --git a/galette/cron/reminder.php b/galette/cron/reminder.php index 9907a6f9e..e47d1a4e9 100644 --- a/galette/cron/reminder.php +++ b/galette/cron/reminder.php @@ -7,7 +7,7 @@ * * PHP version 5 * - * Copyright © 2013-2023 The Galette Team + * Copyright © 2013-2024 The Galette Team * * This file is part of Galette (http://galette.tuxfamily.org). * @@ -28,7 +28,7 @@ * @package Galette * * @author Johan Cwiklinski - * @copyright 2013-2022 The Galette Team + * @copyright 2013-2024 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @link http://galette.tuxfamily.org * @since Available since 0.7.5dev - 2013-02-08 @@ -65,7 +65,10 @@ require_once GALETTE_ROOT . 'includes/routes/members.routes.php'; require_once GALETTE_ROOT . 'includes/routes/groups.routes.php'; require_once GALETTE_ROOT . 'includes/routes/contributions.routes.php'; if ($cron) { - $container->get('login')->logCron(basename($argv[0], '.php')); + $container->get('login')->logCron( + basename($argv[0], '.php'), + $container->get('preferences') + ); define('GALETTE_CRON', true); } diff --git a/galette/lib/Galette/Core/Authentication.php b/galette/lib/Galette/Core/Authentication.php index cf6f85a12..389450f54 100644 --- a/galette/lib/Galette/Core/Authentication.php +++ b/galette/lib/Galette/Core/Authentication.php @@ -7,7 +7,7 @@ * * PHP version 5 * - * Copyright © 2009-2023 The Galette Team + * Copyright © 2009-2024 The Galette Team * * This file is part of Galette (http://galette.tuxfamily.org). * @@ -28,7 +28,7 @@ * @package Galette * * @author Johan Cwiklinski - * @copyright 2009-2023 The Galette Team + * @copyright 2009-2024 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @link http://galette.tuxfamily.org * @since Available since 0.7dev - 2009-02-28 @@ -43,7 +43,7 @@ namespace Galette\Core; * @name Authentication * @package Galette * @author Johan Cwiklinski - * @copyright 2009-2023 The Galette Team + * @copyright 2009-2024 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @link http://galette.tuxfamily.org * @since Available since 0.7dev - 2009-02-28 @@ -126,11 +126,12 @@ abstract class Authentication /** * Authenticate from cron * - * @param string $name Service name + * @param string $name Service name + * @param Preferences $preferences Preferences instance * * @return void */ - public function logCron($name) + public function logCron($name, Preferences $preferences) { //known cronable files $ok = array('reminder'); @@ -139,6 +140,7 @@ abstract class Authentication $this->logged = true; $this->cron = true; $this->login = 'cron'; + $this->lang = $preferences->pref_lang; } else { trigger_error('Not authorized!', E_USER_ERROR); } @@ -160,6 +162,7 @@ abstract class Authentication $this->superadmin = false; $this->staff = false; $this->uptodate = false; + $this->lang = null; } /** diff --git a/tests/Galette/Core/tests/units/Login.php b/tests/Galette/Core/tests/units/Login.php index 7cc0ce20e..61fbbb762 100644 --- a/tests/Galette/Core/tests/units/Login.php +++ b/tests/Galette/Core/tests/units/Login.php @@ -7,7 +7,7 @@ * * PHP version 5 * - * Copyright © 2016-2023 The Galette Team + * Copyright © 2016-2024 The Galette Team * * This file is part of Galette (http://galette.tuxfamily.org). * @@ -28,7 +28,7 @@ * @package GaletteTests * * @author Johan Cwiklinski - * @copyright 2016-2023 The Galette Team + * @copyright 2016-2024 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @link http://galette.tuxfamily.org * @since 2016-12-05 @@ -45,7 +45,7 @@ use Galette\GaletteTestCase; * @name Login * @package GaletteTests * @author Johan Cwiklinski - * @copyright 2016-2023 The Galette Team + * @copyright 2016-2024 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @link http://galette.tuxfamily.org * @since 2016-12-05 @@ -86,6 +86,7 @@ class Login extends GaletteTestCase $this->assertFalse($this->login->isCron()); $this->assertFalse($this->login->isUp2Date()); $this->assertFalse($this->login->isImpersonated()); + $this->assertFalse($this->login->lang); } /** @@ -258,6 +259,7 @@ class Login extends GaletteTestCase $this->assertFalse($this->login->isCron()); $this->assertFalse($this->login->isUp2Date()); $this->assertFalse($this->login->isImpersonated()); + $this->assertSame($this->preferences->pref_lang, $this->login->lang); //test logout $this->login->logOut(); @@ -396,7 +398,7 @@ class Login extends GaletteTestCase */ public function testLogCron() { - $this->login->logCron('reminder'); + $this->login->logCron('reminder', $this->preferences); $this->assertTrue($this->login->isLogged()); $this->assertFalse($this->login->isStaff()); $this->assertFalse($this->login->isAdmin()); @@ -406,9 +408,10 @@ class Login extends GaletteTestCase $this->assertFalse($this->login->isUp2Date()); $this->assertFalse($this->login->isImpersonated()); $this->assertSame('cron', $this->login->login); + $this->assertSame($this->preferences->pref_lang, $this->login->lang); $this->expectException('Exception'); $this->expectExceptionMessage('Not authorized!'); - $this->login->logCron('filename'); + $this->login->logCron('filename', $this->preferences); } }