Make profile view working

This commit is contained in:
Léo Serre 2018-10-17 21:55:06 +02:00
parent 8e64350ed3
commit a35c82d2d9
2 changed files with 70 additions and 23 deletions

View File

@ -102,12 +102,67 @@ class User
public function get_id() {
return $this->id;
}
public function get_rank() {
if( $this->rank == 'blocked' ) {
return '<span class="userrole" style="color: #aaa;">Membre bloqué</span>';
}
else if( $this->rank == 'visitor' ) {
return '<span class="userrole" style="color: black;">Visiteur</span>';
}
else if( $this->rank == 'registered' ) {
return '<span class="userrole" style="color: green;">Membre</span>';
}
else if( $this->rank == 'premium' ) {
return '<span class="userrole" style="color: orange;">Membre premium</span>';
}
else if( $this->rank == 'moderator' ) {
return '<span class="userrole" style="color: orangered;">Modérateur</span>';
}
else {
return '<span class="userrole" style="color: red;">Administrateur</span>';
}
}
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 '<span class="userrole" style="color: '.$config['roles'][$this->role][2].';">'.$config['roles'][$this->role][1].'</span>';
}
/*****
** Sends an email to the user from an other user
*****/

View File

@ -11,7 +11,7 @@
<? if ($userProfile->get_id() != 0) { ?>
<h1><?=$userProfile->name?></h1>
<? if($user->rank_is_higher("moderator") || $user->get_id() == $userProfile->get_id()) { ?>
<a class="subtitle" id="editprofile" href="<?=$config['rel_root_folder']?>user/p/<?=$userProfile->get_id()?>/edit"><i class="fa fa-pencil-alt"></i> Éditer les paramètres du compte</a>
<a class="subtitle" id="editprofile" href="<?=$config['rel_root_folder']?>user/p/<?=$userProfile->get_id()?>/edit"><i class="fas fa-pencil-alt"></i> Éditer les paramètres du compte</a>
<? } ?>
<article>
<div id="profilepart">
@ -20,35 +20,35 @@
<? } ?>
<aside class="<?=$userProfile->get_avatar()!=NULL?'':'no'?>avatar">
<img alt="Avatar" id="profileavatar" src="<?=$config['rel_root_folder']?>medias/avatars/<?=$userProfile->get_id()?>_p.jpg" alt="Profile picture">
<i id="profilenoavatar" class="fa fa-user-secret"></i>
<i id="profilenoavatar" class="fas fa-user-secret"></i>
</aside>
<div id="description">
<p>Langue : <?=$config['locales'][$userProfile->locale][5]?></p>
<p>Inscrit le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($userProfile->registered)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
<p>Dernière connexion le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($userProfile->lastlogin)) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
<p><?=$userProfile->role()?></p>
<p>Langue : <?=$userProfile->get_locale()?></p>
<p>Inscrit le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($userProfile->get_register_date())) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
<p>Dernière connexion le <? echo strftime('%e %B %G, %kh%Mm%Ss',strtotime($userProfile->get_visit_date())) ?> <small><abbr title="Temps Universel Coordonné">UTC</abbr></small></p>
<p><?=$userProfile->get_rank()?></p>
<p>
<? if ($userProfile->website != "") { ?>
<a target="_blank" href="<?=$userProfile->website?>">Site internet <span class="external-link"><i class="fa fa-external-link"></i></span></a>
<a target="_blank" href="<?=$userProfile->website?>">Site internet <span class="external-link"><i class="fas fa-external-link-alt"></i></span></a>
<? }
if ($userProfile->website != "" AND $userProfile->id != $user->id) { ?>
if ($userProfile->website != "" AND $userProfile->get_id() != $user->get_id()) { ?>
&mdash;
<? }
if ($userProfile->id != $user->id) { ?>
if ($userProfile->get_id() != $user->get_id()) { ?>
<a href="#" onclick="$('#profilepart').hide(0, function(){$('#contact').show('fast');});">Contacter par mail</a>
<? }
if ($user->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())) { ?>
&mdash;
<? }
if ($user->role >= 600) { ?>
<a href="mailto:<?=$userProfile->mail?>"><?=$userProfile->mail?></a>
if ($user->rank_is_higher("premium")) { ?>
<a href="mailto:<?=$userProfile->email?>"><?=$userProfile->email?></a>
<? } ?>
</p>
</div>
<div style="clear:both;"></div>
</div>
<? if ($userProfile->id != $user->id) { ?>
<form style="display:none;" class="form" id="contact" action="<?=$config['rel_root_folder']?>user/p/<?=$userProfile->id?>" method="post" >
<? if ($userProfile->get_id() != $user->get_id()) { ?>
<form style="display:none;" class="form" id="contact" action="<?=$config['rel_root_folder']?>user/p/<?=$userProfile->get_id()?>" method="post" >
<textarea rows="12" name="message" id="message" placeholder="Votre message"></textarea>
<p><i>Votre adresse email sera transmise à votre destinataire.</i></p>
<input type="submit" name="submit" value="Envoyer">