Files
FreshRSS/lib/Minz/User.php
Luc SANCHEZ 5f898dcc5e Modernize Constants and use new constant for string 'currentUser' (#5089)
* Modernize Constants and use new constant 'currentUser'

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Add FreshRSS_Context::currentUser() function and use

* Update app/Controllers/userController.php

* Update app/Controllers/userController.php

* Update app/Controllers/userController.php

* Update app/Models/Auth.php

* Update p/api/greader.php

* Update p/api/greader.php

* Update p/api/greader.php

* Update app/Models/Context.php

* Update app/Models/LogDAO.php

* Update lib/Minz/Log.php

* Update p/api/greader.php

* Update app/layout/header.phtml

* Update app/views/helpers/export/articles.phtml

* Update cli/do-install.php

* Remarque's from Alkarex

* Remarque's from Alkarex

* Refactor using new Minz_User class

* Consistent naming of public constants

---------

Co-authored-by: Luc <sanchezluc+freshrss@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-03-26 14:17:22 +02:00

28 lines
693 B
PHP

<?php
/**
* The Minz_User class handles the user information.
*/
final class Minz_User {
public const INTERNAL_USER = '_';
public const CURRENT_USER = 'currentUser';
/**
* @return string the name of the current user, or null if there is none
*/
public static function name(): ?string {
$currentUser = trim(Minz_Session::param(Minz_User::CURRENT_USER, ''));
return $currentUser === '' ? null : $currentUser;
}
/**
* @param string $name the name of the new user. Set to empty string to clear the user.
*/
public static function change(string $name = ''): void {
$name = trim($name);
Minz_Session::_param(Minz_User::CURRENT_USER, $name === '' ? false : $name);
}
}