diff --git a/controllers/d.users.php b/controllers/d.users.php index f178c53..4b9b055 100755 --- a/controllers/d.users.php +++ b/controllers/d.users.php @@ -76,7 +76,7 @@ if(isset($controller->splitted_url[1])) { if (isset($_POST['submit'])) { // PROCESS DATA FROM FORM $user = new User(); - $user->mail = strtolower($_POST['mail']); + $user->email = strtolower($_POST['mail']); if($user->availableMail()) { header('Location: '.$config['rel_root_folder'].'user/password_lost?error=1'); @@ -102,8 +102,7 @@ if(isset($controller->splitted_url[1])) { $userProfile->checkID(intval($controller->splitted_url[2])); } $head['title'] = "Profil inexistant"; - if($userProfile->id != 0) { - $userProfile->populate(); + if($userProfile->get_id() != 0) { $head['title'] = "Profil de ".$userProfile->name; } diff --git a/models/d.users.php b/models/d.users.php index ead7c37..52e4147 100755 --- a/models/d.users.php +++ b/models/d.users.php @@ -97,11 +97,17 @@ class User } /***** - ** Populate the object using raw data from SQL + ** Simple return only functions *****/ public function get_id() { return $this->id; } + public function get_avatar() { + if( $this->is_avatar_present ) + return $this->id; + else + return NULL; + } /***** ** Returns true if user permissions are higher than $rank @@ -151,7 +157,7 @@ class User $con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass']) or die ("Could not connect to server\n"); - $query = "SELECT id FROM users WHERE lower(name)=$1"; + $query = "SELECT * FROM users WHERE lower(name)=$1"; pg_prepare($con, "prepare1", $query) or die ("Cannot prepare statement\n"); @@ -165,8 +171,8 @@ class User } else { if(pg_num_rows($result)==1) { - $user = pg_fetch_assoc($result); - $this->id = $user['id']; + $row = pg_fetch_assoc($result); + $this->populate($row); } return 0; } @@ -181,7 +187,7 @@ class User $con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass']) or die ("Could not connect to server\n"); - $query = "SELECT id FROM users WHERE lower(email)=$1"; + $query = "SELECT * FROM users WHERE lower(email)=$1"; pg_prepare($con, "prepare1", $query) or die ("Cannot prepare statement\n"); @@ -195,8 +201,8 @@ class User } else { if(pg_num_rows($result)==1) { - $user = pg_fetch_assoc($result); - $this->id = $user['id']; + $row = pg_fetch_assoc($result); + $this->populate($row); } return 0; } @@ -279,17 +285,16 @@ class User $con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass']) or die ("Could not connect to server\n"); - $query = "UPDATE users SET password = $1 WHERE mail = $2"; + $query = "UPDATE users SET password = $1 WHERE email = $2"; pg_prepare($con, "prepare1", $query) or die ("Cannot prepare statement\n"); - pg_execute($con, "prepare1", array($this->password, $this->mail)) + pg_execute($con, "prepare1", array($this->password, $this->email)) or die ("Cannot execute statement\n"); pg_close($con); - $this->availableMail(); - $this->populate(); + $this->availableMail(); // Retreive user data from email $url = "http://".$_SERVER['SERVER_NAME'].$config['rel_root_folder']; @@ -308,7 +313,7 @@ class User 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n"; - mail($this->mail, 'Kabano - Nouveau mot de passe', $message, $headers); + mail($this->email, 'Kabano - Nouveau mot de passe', $message, $headers); } /***** diff --git a/views/blocks/d.head.html b/views/blocks/d.head.html index 6c923b9..fad594e 100755 --- a/views/blocks/d.head.html +++ b/views/blocks/d.head.html @@ -10,9 +10,9 @@ else { ?> - + - + diff --git a/views/d.user.profile.html b/views/d.user.profile.html index 87936c5..3485261 100755 --- a/views/d.user.profile.html +++ b/views/d.user.profile.html @@ -8,18 +8,18 @@
- id != 0) { ?> + get_id() != 0) { ?>

name?>

- role >= 800 || $user->id == $userProfile->id) { ?> - Éditer les paramètres du compte + rank_is_higher("moderator") || $user->get_id() == $userProfile->get_id()) { ?> + Éditer les paramètres du compte

Le message a bien été envoyé.

-