User Gavatar Support

This commit is contained in:
JonatanRek 2020-01-21 11:24:50 +01:00
parent 84f130faf3
commit c499a83a0c
4 changed files with 28 additions and 2 deletions

4
.todo
View File

@ -7,3 +7,7 @@
//TODO: Check and fix time based automation //TODO: Check and fix time based automation
//TODO: 404 same like in ENergo COunter Project //TODO: 404 same like in ENergo COunter Project
//TODO: @FILIP Fix Editation of all Automations //TODO: @FILIP Fix Editation of all Automations
//TODO: @FILIP test if registration work without an isuu even with notification
//TODO: Fix Default Room selection
//TODO: Fix User Delete button
//TODO: Fix new add email form

View File

@ -21,6 +21,11 @@ class UserManager
} }
} }
public function getAvatarUrl(){
$email = self::getUserData('email');
return 'https://secure.gravatar.com/avatar/' . md5( strtolower( trim( $email ) ) );
}
public function login ($username, $password, $rememberMe) { public function login ($username, $password, $rememberMe) {
try { try {
if ($user = Db::loadOne ('SELECT * FROM users WHERE LOWER(username)=LOWER(?)', array ($username))) { if ($user = Db::loadOne ('SELECT * FROM users WHERE LOWER(username)=LOWER(?)', array ($username))) {
@ -104,7 +109,6 @@ class UserManager
public static function getUserData ($type, $userId = '') { public static function getUserData ($type, $userId = '') {
if ($userId == '') { if ($userId == '') {
$userId = $_SESSION['user']['id']; $userId = $_SESSION['user']['id'];
echo 'no user id';
} }
$user = Db::loadOne ('SELECT ' . $type . ' FROM users WHERE user_id=?', array ($userId)); $user = Db::loadOne ('SELECT ' . $type . ' FROM users WHERE user_id=?', array ($userId));
return $user[$type]; return $user[$type];

View File

@ -23,6 +23,7 @@
<div class="col-md-9 main-body"> <div class="col-md-9 main-body">
<div class="col-12 col-sm-9 mx-auto mt-4"> <div class="col-12 col-sm-9 mx-auto mt-4">
<h4 class="mb-4"> <h4 class="mb-4">
<?php $LANGMNG->echo('t_pageAfterLogIn') ?> <?php $LANGMNG->echo('t_pageAfterLogIn') ?>
</h4> </h4>
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
@ -39,6 +40,19 @@
</form> </form>
<div class="col-12 col-sm-9 mx-auto mt-4"> <div class="col-12 col-sm-9 mx-auto mt-4">
<h4 class="mb-4"><?php $LANGMNG->echo('t_profile') ?></h4> <h4 class="mb-4"><?php $LANGMNG->echo('t_profile') ?></h4>
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_userAvatar') ?>:</div>
<img src="<?php echo $USERAVATARURL; ?>" />
<div class="label">* providet by Gavatar</div>
</div>
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_userName') ?>:</div>
<input class="input" value="<?php echo $USERNAME; ?>" disabled>
</div>
<div class="field">
<div class="label"><?php $LANGMNG->echo('l_userEmail') ?>:</div>
<input class="input" value="<?php echo $USEREMAIL; ?>" disabled>
</div>
<div class="field"> <div class="field">
<a href="logout" class="button is-primary"><?php $LANGMNG->echo('b_logOut') ?></a> <a href="logout" class="button is-primary"><?php $LANGMNG->echo('b_logOut') ?></a>
</div> </div>

View File

@ -24,7 +24,7 @@ class Setting extends Template
$template = new Template('setting'); $template = new Template('setting');
$template->prepare('baseDir', BASEDIR); $template->prepare('baseDir', BASEDIR);
$template->prepare('debugMod', DEBUGMOD); $template->prepare('debugMod', DEBUGMOD);
$template->prepare('title', 'Automation'); $template->prepare('title', 'Automation');
$template->prepare('langMng', $langMng); $template->prepare('langMng', $langMng);
$template->prepare('automations', $automations); $template->prepare('automations', $automations);
@ -32,6 +32,10 @@ class Setting extends Template
$users = $userManager->getUsers(); $users = $userManager->getUsers();
$template->prepare('users', $users); $template->prepare('users', $users);
$template->prepare('userName', $userManager->getUserData('username'));
$template->prepare('userEmail', $userManager->getUserData('email'));
$template->prepare('userAvatarUrl', $userManager->getAvatarUrl());
if ($userManager->getUserData('ota') == ''){ if ($userManager->getUserData('ota') == ''){
$ga = new PHPGangsta_GoogleAuthenticator(); $ga = new PHPGangsta_GoogleAuthenticator();
$otaSecret = $ga->createSecret(); $otaSecret = $ga->createSecret();