modifs.mineures sans commentaires
This commit is contained in:
parent
efda96cae5
commit
92ad052682
|
@ -78,7 +78,7 @@ class AuthzManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Vérifier la session que la session est valide.
|
||||
* Vérifier que la session est valide.
|
||||
*
|
||||
* comme raccourci, si la session est valide, initialiser $username avec le
|
||||
* nom d'utilisateur *du cookie*
|
||||
|
@ -120,7 +120,11 @@ class AuthzManager {
|
|||
|
||||
/** tester si l'utilisateur est connecté */
|
||||
function _isAuth(): bool {
|
||||
if (!$this->checkSession()) return false;
|
||||
if (!session::started() && session::started_once()) {
|
||||
# la session a déjà été démarrée, pas besoin de la démarrer de nouveau
|
||||
} else if (!$this->checkSession()) {
|
||||
return false;
|
||||
}
|
||||
return session::get(self::SESSION_KEY_USERNAME) !== null;
|
||||
}
|
||||
|
||||
|
@ -130,7 +134,11 @@ class AuthzManager {
|
|||
* @throws ValueException si aucun utilisateur n'est connecté
|
||||
*/
|
||||
function _getAuth(): string {
|
||||
if ($this->checkSession()) {
|
||||
if (!session::started() && session::started_once()) {
|
||||
# la session a déjà été démarrée, pas besoin de la démarrer de nouveau
|
||||
$username = session::get(self::SESSION_KEY_USERNAME);
|
||||
if ($username !== null) return $username;
|
||||
} elseif ($this->checkSession()) {
|
||||
$username = session::get(self::SESSION_KEY_USERNAME);
|
||||
if ($username !== null) return $username;
|
||||
}
|
||||
|
|
|
@ -10,14 +10,21 @@ class autorefreshPlugin extends BasePlugin {
|
|||
|
||||
const TEXT = "Rafraîchir cette page automatiquement";
|
||||
|
||||
/** @var int délai en secondes avant le rafraichissement */
|
||||
const DELAY = 15;
|
||||
|
||||
function __construct(?array $params=null) {
|
||||
$this->checked = $params["checked"] ?? static::CHECKED;
|
||||
$this->text = $params["text"] ?? static::TEXT;
|
||||
$this->delay = intval($params["delay"] ?? static::DELAY) * 1000;
|
||||
}
|
||||
|
||||
protected bool $checked;
|
||||
|
||||
protected string $text;
|
||||
|
||||
protected int $delay;
|
||||
|
||||
function printJquery(): void {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
@ -25,7 +32,7 @@ jQuery.noConflict()(function($) {
|
|||
var autorefreshTimeout = null;
|
||||
function autorefreshUpdate(enabled) {
|
||||
if (enabled && autorefreshTimeout == null) {
|
||||
autorefreshTimeout = setTimeout(function() { location.reload(); }, 15000);
|
||||
autorefreshTimeout = setTimeout(function() { location.reload(); }, <?=$this->delay?>);
|
||||
} else if (!enabled && autorefreshTimeout != null) {
|
||||
clearTimeout(autorefreshTimeout);
|
||||
autorefreshTimeout = null;
|
||||
|
|
|
@ -52,4 +52,34 @@ class DateTest extends TestCase {
|
|||
self::assertSame("05/04/2024", strval(new Date("5/4/2024 09:15")));
|
||||
self::assertSame("05/04/2024", strval(new Date("5/4/2024 09h15")));
|
||||
}
|
||||
|
||||
function testCompare() {
|
||||
$a = new Date("10/02/2024");
|
||||
$b = new Date("15/02/2024");
|
||||
$c = new Date("20/02/2024");
|
||||
$a2 = new Date("10/02/2024");
|
||||
$b2 = new Date("15/02/2024");
|
||||
$c2 = new Date("20/02/2024");
|
||||
|
||||
self::assertTrue($a == $a2);
|
||||
self::assertFalse($a === $a2);
|
||||
self::assertTrue($b == $b2);
|
||||
self::assertTrue($c == $c2);
|
||||
|
||||
self::assertFalse($a < $a);
|
||||
self::assertTrue($a < $b);
|
||||
self::assertTrue($a < $c);
|
||||
|
||||
self::assertTrue($a <= $a);
|
||||
self::assertTrue($a <= $b);
|
||||
self::assertTrue($a <= $c);
|
||||
|
||||
self::assertFalse($c > $c);
|
||||
self::assertTrue($c > $b);
|
||||
self::assertTrue($c > $a);
|
||||
|
||||
self::assertTrue($c >= $c);
|
||||
self::assertTrue($c >= $b);
|
||||
self::assertTrue($c >= $a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,4 +61,49 @@ class DateTimeTest extends TestCase {
|
|||
self::assertSame("05/04/2024 09:15:00", strval(new DateTime("5/4/2024 09:15")));
|
||||
self::assertSame("05/04/2024 09:15:00", strval(new DateTime("5/4/2024 09h15")));
|
||||
}
|
||||
|
||||
function testCompare() {
|
||||
$a = new DateTime("10/02/2024");
|
||||
$a2 = new DateTime("10/02/2024 8:30");
|
||||
$a3 = new DateTime("10/02/2024 15:45");
|
||||
$b = new DateTime("15/02/2024");
|
||||
$b2 = new DateTime("15/02/2024 8:30");
|
||||
$b3 = new DateTime("15/02/2024 15:45");
|
||||
$x = new DateTime("10/02/2024");
|
||||
$x2 = new DateTime("10/02/2024 8:30");
|
||||
$x3 = new DateTime("10/02/2024 15:45");
|
||||
|
||||
self::assertTrue($a == $x);
|
||||
self::assertFalse($a === $x);
|
||||
self::assertTrue($a2 == $x2);
|
||||
self::assertTrue($a3 == $x3);
|
||||
|
||||
self::assertFalse($a < $a);
|
||||
self::assertTrue($a < $a2);
|
||||
self::assertTrue($a < $a3);
|
||||
self::assertTrue($a < $b);
|
||||
self::assertTrue($a < $b2);
|
||||
self::assertTrue($a < $b3);
|
||||
|
||||
self::assertTrue($a <= $a);
|
||||
self::assertTrue($a <= $a2);
|
||||
self::assertTrue($a <= $a3);
|
||||
self::assertTrue($a <= $b);
|
||||
self::assertTrue($a <= $b2);
|
||||
self::assertTrue($a <= $b3);
|
||||
|
||||
self::assertTrue($b > $a);
|
||||
self::assertTrue($b > $a2);
|
||||
self::assertTrue($b > $a3);
|
||||
self::assertFalse($b > $b);
|
||||
self::assertFalse($b > $b2);
|
||||
self::assertFalse($b > $b3);
|
||||
|
||||
self::assertTrue($b >= $a);
|
||||
self::assertTrue($b >= $a2);
|
||||
self::assertTrue($b >= $a3);
|
||||
self::assertTrue($b >= $b);
|
||||
self::assertFalse($b >= $b2);
|
||||
self::assertFalse($b >= $b3);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue