userid = $userinfo['id'];
if (isset($_POST['joinclan']) && ClanInfo::isJoinable($_POST['joinclan'])) {
$this->join($_POST['joinclan']);
exit('');
}
$c = Db::getRow('select * from clan where id = ?', [$userinfo['clan']]);
if (!empty($c)) {
foreach ($c as $k => $v) {
$this->$k = $v;
}
}
}
private function join(string $clanname): void
{
Db::sql('update users set clan = (select id from clan where clan.name = ?) where id = ?', [$clanname, $this->userid]);
}
public function getId(): int
{
return $this->id;
}
public function getStatus(): ?int
{
return $this->status;
}
public function printClan(): void
{
echo '' . $this->printLogoImage() . $this->getName();
}
public function getAlign(): ?int
{
return $this->align;
}
public function printLogoImage(): string
{
return '';
}
public function getName(): ?string
{
return $this->name;
}
public function getLogo(): ?int
{
return $this->logo;
}
/**
* Клан зарегистрирован и подверждён.
* @return bool
*/
public function isRegistered(): bool
{
return !empty($this->id) && $this->status !== 0;
}
/**
* Клан зарегистрирован и ожидает подтверждения.
* @return bool
*/
public function isAwaitingConfirmation(): bool
{
return !empty($this->id) && $this->status === 0;
}
public static function addExp(int $value, int $clanid): void
{
Db::sql('update clan set exp = exp + ? where id = ?',[max($value,0), $clanid]);
}
}