2015-03-29 15:54:27 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* User Management
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Sakura;
|
|
|
|
|
|
|
|
class Users {
|
|
|
|
|
2015-03-29 17:33:06 +00:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
}
|
2015-03-29 15:54:27 +00:00
|
|
|
|
2015-03-29 20:36:54 +00:00
|
|
|
// Get user data by id
|
2015-03-29 19:59:35 +00:00
|
|
|
public static function getUser($id) {
|
|
|
|
|
|
|
|
// Execute query
|
|
|
|
$user = Database::fetch('users', false, ['id' => [$id, '=']]);
|
2015-03-30 16:10:33 +00:00
|
|
|
|
2015-03-29 19:59:35 +00:00
|
|
|
// Return false if no user was found
|
|
|
|
if(empty($user))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// If user was found return user data
|
|
|
|
return $user;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-29 20:36:54 +00:00
|
|
|
// Get group data by id
|
|
|
|
public static function getGroup($id) {
|
|
|
|
|
|
|
|
// Execute query
|
|
|
|
$group = Database::fetch('groups', false, ['id' => [$id, '=']]);
|
2015-03-30 16:10:33 +00:00
|
|
|
|
2015-03-29 20:36:54 +00:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-29 20:54:30 +00:00
|
|
|
// Get all groups
|
2015-03-29 20:36:54 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-29 15:54:27 +00:00
|
|
|
}
|