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 <?php
class WidgetApi extends ApiController{ class UsersApi extends ApiController{
public function check($subDeviceId){ public function default(){
//$this->requireAuth(); //$this->requireAuth();
$response = null; $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); $this->response($response);
} }
} }

View File

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

View File

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