<?php
function getAvatar($userid = 0, $size = null) {
global $set;
if($size)
$size = "?s=$size";
if(!$userid) {
if($this->data->showavt) {
return "$set->url/img/private.png";
}
else if($this->data->gender) {
if(!$gender == 'Male'){
return "$set->url/img/male.png";
}
else {
return "$set->url/img/female.png";
}
}
}
$u = $this->db->getRow("SELECT `email`, `showavt`, `gender` FROM `".MLS_PREFIX."users` WHERE `userid` = ?i", $userid);
if(!$u->showavt){
return "$set->url/img/private.png";
}
else if($u->gender)
return "$set->url/img/male.png";
else
return "$set->url/img/female.png";
}
?>
如果用户是女性的男性,我无法显示头像。 如果用户隐藏他们的头像,我只设法显示私人头像。
答案 0 :(得分:0)
试试这个:
<?php
function getAvatar($userid = 0, $size = null) {
global $set;
if($size)
$size = "?s=$size";
if(!$userid) {
if($this->data->showavt) {
return "$set->url/img/private.png";
}
else if($gender = $this->data->gender) {
if($gender == 'Male'){
return "$set->url/img/male.png";
}
else {
return "$set->url/img/female.png";
}
}
}
$u = $this->db->getRow("SELECT `email`, `showavt`, `gender` FROM `".MLS_PREFIX."users` WHERE `userid` = ?i", $userid);
if(!$u->showavt){
return "$set->url/img/private.png";
}
else if($u->gender) // If gender field in DB is not boolean than try $u->gender == 'Male'
return "$set->url/img/male.png";
else
return "$set->url/img/female.png";
}
?>