From a35c82d2d94e7f816c4eb5fc8b1e2490972fc97b Mon Sep 17 00:00:00 2001 From: leosw Date: Wed, 17 Oct 2018 21:55:06 +0200 Subject: [PATCH] Make profile view working --- models/d.users.php | 65 +++++++++++++++++++++++++++++++++------ views/d.user.profile.html | 28 ++++++++--------- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/models/d.users.php b/models/d.users.php index 52e4147..e17eee6 100755 --- a/models/d.users.php +++ b/models/d.users.php @@ -102,12 +102,67 @@ class User public function get_id() { return $this->id; } + public function get_rank() { + if( $this->rank == 'blocked' ) { + return 'Membre bloqué'; + } + else if( $this->rank == 'visitor' ) { + return 'Visiteur'; + } + else if( $this->rank == 'registered' ) { + return 'Membre'; + } + else if( $this->rank == 'premium' ) { + return 'Membre premium'; + } + else if( $this->rank == 'moderator' ) { + return 'Modérateur'; + } + else { + return 'Administrateur'; + } + } public function get_avatar() { - if( $this->is_avatar_present ) + if( $this->is_avatar_present == 't') return $this->id; else return NULL; } + public function get_locale() { + if( isset($this->locale_loaded) ) { + return $this->locale_display_name; + } + else { + global $config; + + $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 * FROM locales WHERE name=$1"; + + pg_prepare($con, "prepare1", $query) + or die ("Cannot prepare statement\n"); + $result = pg_execute($con, "prepare1", array($this->locale)) + or die ("Cannot execute statement\n"); + + pg_close($con); + + if(pg_num_rows($result) == 1) { + $row = pg_fetch_assoc($result); + $this->locale_loaded = true; + $this->locale_display_name = $row['display_name']; + $this->locale_flag_name = $row['flag_name']; + return $this->locale_display_name; + } + return false; + } + } + public function get_visit_date() { + return $this->visit_date; + } + public function get_register_date() { + return $this->register_date; + } /***** ** Returns true if user permissions are higher than $rank @@ -337,14 +392,6 @@ class User pg_close($con); } - /***** - ** Outputs the role of the user - *****/ - public function role() { - global $config; - return ''.$config['roles'][$this->role][1].''; - } - /***** ** Sends an email to the user from an other user *****/ diff --git a/views/d.user.profile.html b/views/d.user.profile.html index 3485261..548dbdf 100755 --- a/views/d.user.profile.html +++ b/views/d.user.profile.html @@ -11,7 +11,7 @@ get_id() != 0) { ?>

name?>

rank_is_higher("moderator") || $user->get_id() == $userProfile->get_id()) { ?> - Éditer les paramètres du compte + Éditer les paramètres du compte
@@ -20,35 +20,35 @@
-

Langue : locale][5]?>

-

Inscrit le registered)) ?> UTC

-

Dernière connexion le lastlogin)) ?> UTC

-

role()?>

+

Langue : get_locale()?>

+

Inscrit le get_register_date())) ?> UTC

+

Dernière connexion le get_visit_date())) ?> UTC

+

get_rank()?>

website != "") { ?> - Site internet + Site internet website != "" AND $userProfile->id != $user->id) { ?> + if ($userProfile->website != "" AND $userProfile->get_id() != $user->get_id()) { ?> — id != $user->id) { ?> + if ($userProfile->get_id() != $user->get_id()) { ?> Contacter par mail role >= 600 AND ($userProfile->website != "" OR $userProfile->id != $user->id)) { ?> + if ($user->rank_is_higher("premium") AND ($userProfile->website != "" OR $userProfile->get_id() != $user->get_id())) { ?> — role >= 600) { ?> - mail?> + if ($user->rank_is_higher("premium")) { ?> + email?>

- id != $user->id) { ?> -