This commit is contained in:
JonatanRek 2020-06-23 20:25:42 +02:00
parent 41916a90bd
commit cb6ab3bdda
3 changed files with 19 additions and 7 deletions

View File

@ -1,9 +1,19 @@
<?php
class WidgetApi extends ApiController{
public function check($subDeviceId){
class UsersApi extends ApiController{
public function default(){
//$this->requireAuth();
$response = null;
$users = UserManager::getUsers(["user_id", "username", "at_home"]);
foreach ($users as $key => $user) {
$response[] = [
"userName" => $users['username'],
"homeStatus" => ($users['at_home']) ? true : false,
"avatarUrl" => getAvatarUrl($value['user_id']),
];
}
$this->response($response);
}
}

View File

@ -2,7 +2,7 @@
/**
* Notification Manager
*/
//TODO: Working timestamp to body or $title
//TODO: Working timestamp to $title
class NotificationManager
{
function addSubscriber($userID = '', $token = ''){

View File

@ -1,9 +1,9 @@
<?php
class UserManager
{
public static function getUsers () {
public static function getUsers ($filtr = ['*']) {
try {
$allUsers = Db::loadAll ("SELECT user_id, username, at_home, ota FROM users");
$allUsers = Db::loadAll ("SELECT " . implode($filtr, ",") . " FROM users");
return $allUsers;
} catch(PDOException $error) {
echo $error->getMessage();
@ -32,8 +32,10 @@ class UserManager
}
public static function getAvatarUrl($userId = null){
$email = self::getUserData('email');
if ($userId != null){
if ($userId == null) {
$email = self::getUserData('email');
}
else if ($userId != null){
$email = self::getUserData('email',$userId);
}
return 'https://secure.gravatar.com/avatar/' . md5( strtolower( trim( $email ) ) );