]> git.agnieray.net Git - galette.git/commitdiff
Use default Galette language for cron
authorJohan Cwiklinski <johan@x-tnd.be>
Sat, 13 Jan 2024 11:55:43 +0000 (12:55 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 14 Jan 2024 19:45:19 +0000 (20:45 +0100)
closes #1769

galette/cron/reminder.php
galette/lib/Galette/Core/Authentication.php
tests/Galette/Core/tests/units/Login.php

index 9907a6f9eea38c557a04bd29dd4482b78a7be6cb..e47d1a4e933289670629e7a6227457ce8f15d282 100644 (file)
@@ -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 <johan@x-tnd.be>
- * @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);
 }
 
index cf6f85a121ab20d81645e3135e0f2441e4d1a3db..389450f54f1ed2b07c9910866c71cb33e343f464 100644 (file)
@@ -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 <johan@x-tnd.be>
- * @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 <johan@x-tnd.be>
- * @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;
     }
 
     /**
index 7cc0ce20e558adebdcec7629510755abd79c5844..61fbbb762704d52751a5708c987ec32287783c0a 100644 (file)
@@ -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 <johan@x-tnd.be>
- * @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 <johan@x-tnd.be>
- * @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);
     }
 }