mirror of
https://github.com/openvk/openvk
synced 2025-01-11 02:19:39 +03:00
Fix indentation in UserPresenter
This commit is contained in:
parent
fbfa15e4ed
commit
c3332ab625
1 changed files with 84 additions and 84 deletions
|
@ -128,99 +128,99 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
if(!$id)
|
if(!$id)
|
||||||
$this->notFound();
|
$this->notFound();
|
||||||
|
|
||||||
$user = $this->users->get($id);
|
$user = $this->users->get($id);
|
||||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||||
$this->willExecuteWriteAction();
|
$this->willExecuteWriteAction();
|
||||||
|
|
||||||
if($_GET['act'] === "main" || $_GET['act'] == NULL) {
|
if($_GET['act'] === "main" || $_GET['act'] == NULL) {
|
||||||
$user->setFirst_Name(empty($this->postParam("first_name")) ? $user->getFirstName() : $this->postParam("first_name"));
|
$user->setFirst_Name(empty($this->postParam("first_name")) ? $user->getFirstName() : $this->postParam("first_name"));
|
||||||
$user->setLast_Name(empty($this->postParam("last_name")) ? "" : $this->postParam("last_name"));
|
$user->setLast_Name(empty($this->postParam("last_name")) ? "" : $this->postParam("last_name"));
|
||||||
$user->setPseudo(empty($this->postParam("pseudo")) ? NULL : $this->postParam("pseudo"));
|
$user->setPseudo(empty($this->postParam("pseudo")) ? NULL : $this->postParam("pseudo"));
|
||||||
$user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status"));
|
$user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status"));
|
||||||
if (strtotime($this->postParam("birthday")) < time())
|
if (strtotime($this->postParam("birthday")) < time())
|
||||||
$user->setBirthday(strtotime($this->postParam("birthday")));
|
$user->setBirthday(strtotime($this->postParam("birthday")));
|
||||||
|
|
||||||
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
||||||
$user->setMarital_Status($this->postParam("marialstatus"));
|
$user->setMarital_Status($this->postParam("marialstatus"));
|
||||||
|
|
||||||
if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0)
|
if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0)
|
||||||
$user->setPolit_Views($this->postParam("politViews"));
|
$user->setPolit_Views($this->postParam("politViews"));
|
||||||
|
|
||||||
if ($this->postParam("gender") <= 1 && $this->postParam("gender") >= 0)
|
if ($this->postParam("gender") <= 1 && $this->postParam("gender") >= 0)
|
||||||
$user->setSex($this->postParam("gender"));
|
$user->setSex($this->postParam("gender"));
|
||||||
|
|
||||||
if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) {
|
if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) {
|
||||||
if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]["enable"])
|
if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]["enable"])
|
||||||
$this->flashFail("err", tr("error_segmentation"), "котлетки");
|
$this->flashFail("err", tr("error_segmentation"), "котлетки");
|
||||||
|
|
||||||
$code = $user->setPhoneWithVerification($this->postParam("phone"));
|
$code = $user->setPhoneWithVerification($this->postParam("phone"));
|
||||||
|
|
||||||
if(!Sms::send($this->postParam("phone"), "OPENVK - Your verification code is: $code"))
|
if(!Sms::send($this->postParam("phone"), "OPENVK - Your verification code is: $code"))
|
||||||
$this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!");
|
$this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!");
|
||||||
}
|
}
|
||||||
} elseif($_GET['act'] === "contacts") {
|
} elseif($_GET['act'] === "contacts") {
|
||||||
if(empty($this->postParam("email_contact")) || Validator::i()->emailValid($this->postParam("email_contact")))
|
if(empty($this->postParam("email_contact")) || Validator::i()->emailValid($this->postParam("email_contact")))
|
||||||
$user->setEmail_Contact(empty($this->postParam("email_contact")) ? NULL : $this->postParam("email_contact"));
|
$user->setEmail_Contact(empty($this->postParam("email_contact")) ? NULL : $this->postParam("email_contact"));
|
||||||
|
else
|
||||||
|
$this->flashFail("err", tr("invalid_email_address"), tr("invalid_email_address_comment"));
|
||||||
|
|
||||||
|
$telegram = $this->postParam("telegram");
|
||||||
|
if(empty($telegram) || Validator::i()->telegramValid($telegram))
|
||||||
|
if(strpos($telegram, "t.me/") === 0)
|
||||||
|
$user->setTelegram(empty($telegram) ? NULL : substr($telegram, 5));
|
||||||
else
|
else
|
||||||
$this->flashFail("err", tr("invalid_email_address"), tr("invalid_email_address_comment"));
|
$user->setTelegram(empty($telegram) ? NULL : ltrim($telegram, "@"));
|
||||||
|
else
|
||||||
|
$this->flashFail("err", tr("invalid_telegram_name"), tr("invalid_telegram_name_comment"));
|
||||||
|
|
||||||
$telegram = $this->postParam("telegram");
|
$user->setCity(empty($this->postParam("city")) ? NULL : $this->postParam("city"));
|
||||||
if(empty($telegram) || Validator::i()->telegramValid($telegram))
|
$user->setAddress(empty($this->postParam("address")) ? NULL : $this->postParam("address"));
|
||||||
if(strpos($telegram, "t.me/") === 0)
|
|
||||||
$user->setTelegram(empty($telegram) ? NULL : substr($telegram, 5));
|
|
||||||
else
|
|
||||||
$user->setTelegram(empty($telegram) ? NULL : ltrim($telegram, "@"));
|
|
||||||
else
|
|
||||||
$this->flashFail("err", tr("invalid_telegram_name"), tr("invalid_telegram_name_comment"));
|
|
||||||
|
|
||||||
$user->setCity(empty($this->postParam("city")) ? NULL : $this->postParam("city"));
|
$website = $this->postParam("website") ?? "";
|
||||||
$user->setAddress(empty($this->postParam("address")) ? NULL : $this->postParam("address"));
|
if(empty($website))
|
||||||
|
$user->setWebsite(NULL);
|
||||||
$website = $this->postParam("website") ?? "";
|
else
|
||||||
if(empty($website))
|
$user->setWebsite((!parse_url($website, PHP_URL_SCHEME) ? "https://" : "") . $website);
|
||||||
$user->setWebsite(NULL);
|
} elseif($_GET['act'] === "interests") {
|
||||||
else
|
$user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 300));
|
||||||
$user->setWebsite((!parse_url($website, PHP_URL_SCHEME) ? "https://" : "") . $website);
|
$user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 300));
|
||||||
} elseif($_GET['act'] === "interests") {
|
$user->setFav_Films(empty($this->postParam("fav_films")) ? NULL : ovk_proc_strtr($this->postParam("fav_films"), 300));
|
||||||
$user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 300));
|
$user->setFav_Shows(empty($this->postParam("fav_shows")) ? NULL : ovk_proc_strtr($this->postParam("fav_shows"), 300));
|
||||||
$user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 300));
|
$user->setFav_Books(empty($this->postParam("fav_books")) ? NULL : ovk_proc_strtr($this->postParam("fav_books"), 300));
|
||||||
$user->setFav_Films(empty($this->postParam("fav_films")) ? NULL : ovk_proc_strtr($this->postParam("fav_films"), 300));
|
$user->setFav_Quote(empty($this->postParam("fav_quote")) ? NULL : ovk_proc_strtr($this->postParam("fav_quote"), 300));
|
||||||
$user->setFav_Shows(empty($this->postParam("fav_shows")) ? NULL : ovk_proc_strtr($this->postParam("fav_shows"), 300));
|
$user->setAbout(empty($this->postParam("about")) ? NULL : ovk_proc_strtr($this->postParam("about"), 300));
|
||||||
$user->setFav_Books(empty($this->postParam("fav_books")) ? NULL : ovk_proc_strtr($this->postParam("fav_books"), 300));
|
} elseif($_GET['act'] === "status") {
|
||||||
$user->setFav_Quote(empty($this->postParam("fav_quote")) ? NULL : ovk_proc_strtr($this->postParam("fav_quote"), 300));
|
if(mb_strlen($this->postParam("status")) > 255) {
|
||||||
$user->setAbout(empty($this->postParam("about")) ? NULL : ovk_proc_strtr($this->postParam("about"), 300));
|
$statusLength = (string) mb_strlen($this->postParam("status"));
|
||||||
} elseif($_GET['act'] === "status") {
|
$this->flashFail("err", "Ошибка", "Статус слишком длинный ($statusLength символов вместо 255 символов)");
|
||||||
if(mb_strlen($this->postParam("status")) > 255) {
|
|
||||||
$statusLength = (string) mb_strlen($this->postParam("status"));
|
|
||||||
$this->flashFail("err", "Ошибка", "Статус слишком длинный ($statusLength символов вместо 255 символов)");
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status"));
|
|
||||||
$user->save();
|
|
||||||
|
|
||||||
header("HTTP/1.1 302 Found");
|
|
||||||
header("Location: /id" . $user->getId());
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
$user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status"));
|
||||||
$user->save();
|
$user->save();
|
||||||
} catch(\PDOException $ex) {
|
|
||||||
if($ex->getCode() == 23000)
|
|
||||||
$this->flashFail("err", tr("error"), tr("error_shorturl"));
|
|
||||||
else
|
|
||||||
throw $ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
|
header("HTTP/1.1 302 Found");
|
||||||
|
header("Location: /id" . $user->getId());
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->template->mode = in_array($this->queryParam("act"), [
|
try {
|
||||||
"main", "contacts", "interests", "avatar"
|
$user->save();
|
||||||
]) ? $this->queryParam("act")
|
} catch(\PDOException $ex) {
|
||||||
: "main";
|
if($ex->getCode() == 23000)
|
||||||
|
$this->flashFail("err", tr("error"), tr("error_shorturl"));
|
||||||
|
else
|
||||||
|
throw $ex;
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->user = $user;
|
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->template->mode = in_array($this->queryParam("act"), [
|
||||||
|
"main", "contacts", "interests", "avatar"
|
||||||
|
]) ? $this->queryParam("act")
|
||||||
|
: "main";
|
||||||
|
|
||||||
|
$this->template->user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderVerifyPhone(): void
|
function renderVerifyPhone(): void
|
||||||
|
|
Loading…
Reference in a new issue