diff --git a/protected/models/User.php b/protected/models/User.php index 38963a7..72006f5 100644 --- a/protected/models/User.php +++ b/protected/models/User.php @@ -305,27 +305,27 @@ public function getUpicDir() { } public function getUpicPath() { - if($this->upic[0] == 0) return ""; + if($this->hasDefaultPicture()) return ""; return $this->upicDir . "/{$this->upicName}.jpg"; } public function getUpicPathBig() { - if($this->upic[0] == 0) return ""; + if($this->hasDefaultPicture()) return ""; return $this->upicDir . "/{$this->upicName}_big.jpg"; } public function getUpicUrl() { - if($this->upic[0] == 0) return "/i/avatar_placeholder.png"; + if($this->hasDefaultPicture()) return "/i/avatar_placeholder.png"; return "/i/upic/" . floor($this->id / 1000) . "/" . $this->upicName . ".jpg"; } public function getUpicUrlBig() { - if($this->upic[0] == 0) return ""; + if($this->hasDefaultPicture()) return ""; return "/i/upic/" . floor($this->id / 1000) . "/" . $this->upicName . "_big.jpg"; } public function upicUnlink() { - if($this->upic[0] == 0) return false; + if($this->hasDefaultPicture()) return false; @unlink($this->upicPath); @unlink($this->upicPathBig); $this->upic = array(0, 0, 0); @@ -406,4 +406,8 @@ public function Notify($typ, $param1, $param2 = null, $param3 = null) { return true; } + + protected function hasDefaultPicture(): bool { + return $this->upic === null || $this->upic[0] == 0; + } }