Newsletter KW 30 and the weeks before
This commit is contained in:
@@ -10,7 +10,39 @@ class participo
|
||||
{
|
||||
private static $db = null;
|
||||
private static $message = ['error' => null, 'success' => null, 'notice' => null];
|
||||
|
||||
/** id of session user
|
||||
*
|
||||
* Session user describes the currently logged in user
|
||||
*
|
||||
* @var int>0
|
||||
*/
|
||||
private static $userId = null;
|
||||
private static $sessionUser = null;
|
||||
|
||||
/** get session users id
|
||||
*
|
||||
* if not set so far it is loaded from the session cookies
|
||||
*
|
||||
* @return int id of session user
|
||||
*/
|
||||
public static function getSessionUserId()
|
||||
{
|
||||
if (!isset(self::$userId)) {
|
||||
self::$userId = $_SESSION['user']['userId'] ?? null;
|
||||
}
|
||||
self::$userId = filterId(self::$userId);
|
||||
return self::$userId;
|
||||
}
|
||||
|
||||
/** lazy loading of the session user */
|
||||
public static function sessionUser(bool $forceLoading = true)
|
||||
{
|
||||
if (is_null($sessionUser) || $forceLoading) {
|
||||
self::$sessionUser = User::loadFromDb(self::getSessionUserId());
|
||||
}
|
||||
return self::$sessionUser;
|
||||
}
|
||||
|
||||
/** Returns the current login status
|
||||
*
|
||||
@@ -23,15 +55,6 @@ class participo
|
||||
return (isset($_SESSION) && array_key_exists('login', $_SESSION) && $_SESSION['login'] == true);
|
||||
}
|
||||
|
||||
public static function getSessionUserId()
|
||||
{
|
||||
$userId = null;
|
||||
if (isset($_SESSION) && array_key_exists('user', $_SESSION) && array_key_exists('userId', $_SESSION['user'])) {
|
||||
$userId = $_SESSION['user']['userId'];
|
||||
}
|
||||
return $userId;
|
||||
}
|
||||
|
||||
/** Remove all login data from the session data
|
||||
*
|
||||
* @return void
|
||||
@@ -175,6 +198,11 @@ class participo
|
||||
return self::hasUserAttribute($userId, 'isAdmin');
|
||||
}
|
||||
|
||||
public static function getUserId()
|
||||
{
|
||||
}
|
||||
|
||||
/** get current logged in users kids */
|
||||
public static function getKids($userId = null)
|
||||
{
|
||||
$userId = $userId ?? $_SESSION['user']['userId'] ?? null;
|
||||
@@ -412,10 +440,10 @@ function lastLoginTable($jsonFileName = 'lastLogins.json')
|
||||
'<tbody>';
|
||||
foreach ($lastLoginRows as $userName => $lastLogin) {
|
||||
$lastLoginsTable .=
|
||||
'<tr><td>' . $userName . '</td><td>' . $lastLogin . '</td></tr>';
|
||||
'<tr><td>' . $userName . '</td><td>' . $lastLogin . '</td></tr>';
|
||||
}
|
||||
$lastLoginsTable .=
|
||||
'</tbody>'.
|
||||
'</tbody>' .
|
||||
'</table>';
|
||||
return $lastLoginsTable;
|
||||
}
|
||||
@@ -568,6 +596,19 @@ function getHtmlSquareDate($date = null)
|
||||
. '</div>';
|
||||
}
|
||||
|
||||
/** filter_var for a pos int
|
||||
*
|
||||
* check for int; null is default; only values > 0 are excepted
|
||||
*
|
||||
* @param [type] $id
|
||||
* @retval int>0 filtered id
|
||||
* @retval null sth. went wrong
|
||||
* */
|
||||
function filterPosInt($id)
|
||||
{
|
||||
return filter_var($id, FILTER_VALIDATE_INT, ['options' => ['default' => null, 'min_range' => 1]]);
|
||||
}
|
||||
|
||||
/** filter_var for a (db)id
|
||||
*
|
||||
* check for valid id; null is default; only values > 0 are excepted
|
||||
@@ -578,11 +619,11 @@ function getHtmlSquareDate($date = null)
|
||||
*/
|
||||
function filterId($id)
|
||||
{
|
||||
return filter_var($id, FILTER_VALIDATE_INT, ['options' => ['default' => null, 'min_range' => 1]]);
|
||||
return filterPosInt($id);
|
||||
}
|
||||
|
||||
/** filter a variable as count
|
||||
*
|
||||
*
|
||||
* - count means a non negative integer
|
||||
* - helper function to stay DRY
|
||||
*
|
||||
@@ -590,7 +631,7 @@ function filterId($id)
|
||||
* @param integer $min
|
||||
* @return integer the input variable as integer >= 0
|
||||
*/
|
||||
function filterCount($variable, int $min = 0){
|
||||
function filterCount($variable, int $min = 0)
|
||||
{
|
||||
return filter_var($variable, FILTER_VALIDATE_INT, ['options' => ['default' => null, 'min_range' => 1]]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user