diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index bff4de2f..4115d178 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -173,6 +173,18 @@ final class UserPresenter extends OpenVKPresenter $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; } try { diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index 2687c42b..9d40d5c9 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -353,14 +353,24 @@
{$alert}
+ {var thatIsThisUser = isset($thisUser) && $user->getId() == $thisUser->getId()} +

{$user->getFullName()}

{if !is_null($user->getStatus())} -
{$user->getStatus()}
- {elseif isset($thisUser) && $user->getId() == $thisUser->getId()} +
{$user->getStatus()}
+ {elseif $thatIsThisUser}
- [ {_"change_status"} ] +
[ {_"change_status"} ]
{/if}
@@ -542,6 +552,19 @@ Function.noop ]); } + + {if isset($thisUser) && $user->getId() == $thisUser->getId()} + function setStatusEditorShown(shown) { + document.getElementById("status_editor").style.display = shown ? "block" : "none"; + } + + document.addEventListener("click", event => { + if(!event.target.closest("#status_editor") && !event.target.closest("#page_status_text")) + setStatusEditorShown(false); + }); + + document.getElementById("page_status_text").onclick = setStatusEditorShown.bind(this, true); + {/if}
diff --git a/Web/static/css/style.css b/Web/static/css/style.css index 3f9cfa1c..443b8cc4 100644 --- a/Web/static/css/style.css +++ b/Web/static/css/style.css @@ -340,6 +340,29 @@ table { overflow: hidden; } +.page_status_edit_button { + cursor: pointer; +} + +.page_status_edit_button:hover { + text-decoration: underline; +} + +.page_status_popup { + position: absolute; + border: 1px solid #CCC; + background-color: #f7f7f7; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);; + padding: 10px; + float: right; + margin-top: 6px; + margin-left: -6px; +} + +.page_status_popup form { + margin: 0; +} + .button { border-radius: 2px; border: #595959;