mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +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)
|
||||
$this->notFound();
|
||||
|
||||
$user = $this->users->get($id);
|
||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$this->willExecuteWriteAction();
|
||||
$user = $this->users->get($id);
|
||||
if($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$this->willExecuteWriteAction();
|
||||
|
||||
if($_GET['act'] === "main" || $_GET['act'] == NULL) {
|
||||
$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->setPseudo(empty($this->postParam("pseudo")) ? NULL : $this->postParam("pseudo"));
|
||||
$user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status"));
|
||||
if (strtotime($this->postParam("birthday")) < time())
|
||||
$user->setBirthday(strtotime($this->postParam("birthday")));
|
||||
|
||||
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
||||
$user->setMarital_Status($this->postParam("marialstatus"));
|
||||
|
||||
if($_GET['act'] === "main" || $_GET['act'] == NULL) {
|
||||
$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->setPseudo(empty($this->postParam("pseudo")) ? NULL : $this->postParam("pseudo"));
|
||||
$user->setStatus(empty($this->postParam("status")) ? NULL : $this->postParam("status"));
|
||||
if (strtotime($this->postParam("birthday")) < time())
|
||||
$user->setBirthday(strtotime($this->postParam("birthday")));
|
||||
|
||||
if ($this->postParam("marialstatus") <= 8 && $this->postParam("marialstatus") >= 0)
|
||||
$user->setMarital_Status($this->postParam("marialstatus"));
|
||||
if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0)
|
||||
$user->setPolit_Views($this->postParam("politViews"));
|
||||
|
||||
if ($this->postParam("gender") <= 1 && $this->postParam("gender") >= 0)
|
||||
$user->setSex($this->postParam("gender"));
|
||||
|
||||
if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) {
|
||||
if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]["enable"])
|
||||
$this->flashFail("err", tr("error_segmentation"), "котлетки");
|
||||
|
||||
if ($this->postParam("politViews") <= 9 && $this->postParam("politViews") >= 0)
|
||||
$user->setPolit_Views($this->postParam("politViews"));
|
||||
$code = $user->setPhoneWithVerification($this->postParam("phone"));
|
||||
|
||||
if ($this->postParam("gender") <= 1 && $this->postParam("gender") >= 0)
|
||||
$user->setSex($this->postParam("gender"));
|
||||
|
||||
if(!empty($this->postParam("phone")) && $this->postParam("phone") !== $user->getPhone()) {
|
||||
if(!OPENVK_ROOT_CONF["openvk"]["credentials"]["smsc"]["enable"])
|
||||
$this->flashFail("err", tr("error_segmentation"), "котлетки");
|
||||
|
||||
$code = $user->setPhoneWithVerification($this->postParam("phone"));
|
||||
|
||||
if(!Sms::send($this->postParam("phone"), "OPENVK - Your verification code is: $code"))
|
||||
$this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!");
|
||||
}
|
||||
} elseif($_GET['act'] === "contacts") {
|
||||
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"));
|
||||
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
|
||||
$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"));
|
||||
$user->setAddress(empty($this->postParam("address")) ? NULL : $this->postParam("address"));
|
||||
|
||||
$website = $this->postParam("website") ?? "";
|
||||
if(empty($website))
|
||||
$user->setWebsite(NULL);
|
||||
else
|
||||
$user->setWebsite((!parse_url($website, PHP_URL_SCHEME) ? "https://" : "") . $website);
|
||||
} elseif($_GET['act'] === "interests") {
|
||||
$user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 300));
|
||||
$user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 300));
|
||||
$user->setFav_Films(empty($this->postParam("fav_films")) ? NULL : ovk_proc_strtr($this->postParam("fav_films"), 300));
|
||||
$user->setFav_Shows(empty($this->postParam("fav_shows")) ? NULL : ovk_proc_strtr($this->postParam("fav_shows"), 300));
|
||||
$user->setFav_Books(empty($this->postParam("fav_books")) ? NULL : ovk_proc_strtr($this->postParam("fav_books"), 300));
|
||||
$user->setFav_Quote(empty($this->postParam("fav_quote")) ? NULL : ovk_proc_strtr($this->postParam("fav_quote"), 300));
|
||||
$user->setAbout(empty($this->postParam("about")) ? NULL : ovk_proc_strtr($this->postParam("about"), 300));
|
||||
} elseif($_GET['act'] === "status") {
|
||||
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;
|
||||
if(!Sms::send($this->postParam("phone"), "OPENVK - Your verification code is: $code"))
|
||||
$this->flashFail("err", tr("error_segmentation"), "котлетки: Remote err!");
|
||||
}
|
||||
|
||||
try {
|
||||
$user->save();
|
||||
} catch(\PDOException $ex) {
|
||||
if($ex->getCode() == 23000)
|
||||
$this->flashFail("err", tr("error"), tr("error_shorturl"));
|
||||
} elseif($_GET['act'] === "contacts") {
|
||||
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"));
|
||||
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
|
||||
throw $ex;
|
||||
}
|
||||
$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"));
|
||||
$user->setAddress(empty($this->postParam("address")) ? NULL : $this->postParam("address"));
|
||||
|
||||
$this->flash("succ", tr("changes_saved"), tr("changes_saved_comment"));
|
||||
$website = $this->postParam("website") ?? "";
|
||||
if(empty($website))
|
||||
$user->setWebsite(NULL);
|
||||
else
|
||||
$user->setWebsite((!parse_url($website, PHP_URL_SCHEME) ? "https://" : "") . $website);
|
||||
} elseif($_GET['act'] === "interests") {
|
||||
$user->setInterests(empty($this->postParam("interests")) ? NULL : ovk_proc_strtr($this->postParam("interests"), 300));
|
||||
$user->setFav_Music(empty($this->postParam("fav_music")) ? NULL : ovk_proc_strtr($this->postParam("fav_music"), 300));
|
||||
$user->setFav_Films(empty($this->postParam("fav_films")) ? NULL : ovk_proc_strtr($this->postParam("fav_films"), 300));
|
||||
$user->setFav_Shows(empty($this->postParam("fav_shows")) ? NULL : ovk_proc_strtr($this->postParam("fav_shows"), 300));
|
||||
$user->setFav_Books(empty($this->postParam("fav_books")) ? NULL : ovk_proc_strtr($this->postParam("fav_books"), 300));
|
||||
$user->setFav_Quote(empty($this->postParam("fav_quote")) ? NULL : ovk_proc_strtr($this->postParam("fav_quote"), 300));
|
||||
$user->setAbout(empty($this->postParam("about")) ? NULL : ovk_proc_strtr($this->postParam("about"), 300));
|
||||
} elseif($_GET['act'] === "status") {
|
||||
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;
|
||||
}
|
||||
|
||||
$this->template->mode = in_array($this->queryParam("act"), [
|
||||
"main", "contacts", "interests", "avatar"
|
||||
]) ? $this->queryParam("act")
|
||||
: "main";
|
||||
try {
|
||||
$user->save();
|
||||
} catch(\PDOException $ex) {
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue