This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/_sakura/components/Users.php
2015-03-30 18:10:33 +02:00

78 lines
1.6 KiB
PHP

<?php
/*
* User Management
*/
namespace Sakura;
class Users {
// Check if a user is logged in
public static function loggedIn() {
// Just return false for now since we don't have a user system yet
return false;
}
// Get user data by id
public static function getUser($id) {
// Execute query
$user = Database::fetch('users', false, ['id' => [$id, '=']]);
// Return false if no user was found
if(empty($user))
return false;
// If user was found return user data
return $user;
}
// Get group data by id
public static function getGroup($id) {
// Execute query
$group = Database::fetch('groups', false, ['id' => [$id, '=']]);
// Return false if no group was found
if(empty($group))
return false;
// If group was found return group data
return $group;
}
// Get all users
public static function getAllUsers() {
// Execute query
$getUsers = Database::fetch('users', true);
// Reorder shit
foreach($getUsers as $user)
$users[$user['id']] = $user;
// and return an array with the users
return $users;
}
// Get all groups
public static function getAllGroups() {
// Execute query
$getGroups = Database::fetch('groups', true);
// Reorder shit
foreach($getGroups as $group)
$groups[$group['id']] = $group;
// and return an array with the users
return $groups;
}
}