diff --git a/web/inc/classes/Model.class.php b/web/inc/classes/Model.class.php index 41041b8..b435223 100644 --- a/web/inc/classes/Model.class.php +++ b/web/inc/classes/Model.class.php @@ -95,8 +95,10 @@ class Model { * @param $value The value to search for * @param string $field The field to search in. HAS to be marked as unique otherwise will throw error */ - public function load($value,$field='id') + public function load($value=false,$field='id') { + if(!$value) + $value = $this->id; if($field!='id') { //sanity check. Check if $field is marked as unique diff --git a/web/models/User.model.php b/web/models/User.model.php index 528db72..8676ffa 100644 --- a/web/models/User.model.php +++ b/web/models/User.model.php @@ -24,6 +24,7 @@ class User extends Model { function login() { if(!$this->id) return false; + $this->load(); $this->last_login = $this->getDateTime(); $this->save(); diff --git a/web/pages/profile/controller.php b/web/pages/profile/controller.php index 1adea7e..931f281 100644 --- a/web/pages/profile/controller.php +++ b/web/pages/profile/controller.php @@ -14,15 +14,14 @@ class Profile extends Page { { $error = false; - $user = $_SESSION['user']; - $user->data['firstname'] = trim($_REQUEST['firstname']); - $user->data['lastname'] = trim($_REQUEST['lastname']); - //$user->data['email'] = $_REQUEST['email']; - $user->data['birthday'] = $_REQUEST['birthday']; - $user->data['club'] = trim($_REQUEST['club']); - //$user->data['timezone'] = $_REQUEST['timezone']; + $_SESSION['user']->data['firstname'] = trim($_REQUEST['firstname']); + $_SESSION['user']->data['lastname'] = trim($_REQUEST['lastname']); + //$_SESSION['user']->data['email'] = $_REQUEST['email']; + $_SESSION['user']->data['birthday'] = $_REQUEST['birthday']; + $_SESSION['user']->data['club'] = trim($_REQUEST['club']); + //$_SESSION['user']->data['timezone'] = $_REQUEST['timezone']; - if(!strtotime($user->data['birthday'])) + if(!strtotime($_SESSION['user']->data['birthday'])) $error = 'Das Geburstdatum ist ungültig. Bitte die Eingabe prüfen'; $newphoto = false; @@ -61,9 +60,9 @@ class Profile extends Page { } if($newphoto) - $user->data['photo'] = $newphoto; + $_SESSION['user']->data['photo'] = $newphoto; - $user->save(); + $_SESSION['user']->save(); $this->redirect('/profile'); }