diff --git a/Web/Presenters/AdminPresenter.php b/Web/Presenters/AdminPresenter.php index ceda6f6b8..270f4d981 100644 --- a/Web/Presenters/AdminPresenter.php +++ b/Web/Presenters/AdminPresenter.php @@ -379,6 +379,30 @@ function renderQuickWarn(int $id): void exit(json_encode([ "message" => $this->queryParam("message") ])); } + function renderQuickDeactivate(int $id): void + { + $this->assertNoCSRF(); + + $user = $this->users->get($id); + if(!$user) + exit(json_encode([ "error" => "User does not exist" ])); + + $user->deactivate($this->queryParam("reason") ?? NULL); + exit(json_encode([ "success" => true ])); + } + + function renderQuickRestore(int $id): void + { + $this->assertNoCSRF(); + + $user = $this->users->get($id); + if(!$user) + exit(json_encode([ "error" => "User does not exist" ])); + + $user->reactivate(); + exit(json_encode([ "success" => true ])); + } + function renderBannedLinks(): void { $this->template->links = $this->bannedLinks->getList((int) $this->queryParam("p") ?: 1); diff --git a/Web/Presenters/UserPresenter.php b/Web/Presenters/UserPresenter.php index 48ebb660f..58bf0e9da 100644 --- a/Web/Presenters/UserPresenter.php +++ b/Web/Presenters/UserPresenter.php @@ -28,24 +28,34 @@ function __construct(Users $users) function renderView(int $id): void { $user = $this->users->get($id); - if(!$user || $user->isDeleted()) { - if($user->isDeactivated()) { + $canViewDeleted = $this->user->identity->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL) && OPENVK_ROOT_CONF["openvk"]["preferences"]["security"]["adminsCanViewDeletedUsers"]; + + if ($user === NULL) { + $this->template->_template = "User/deleted.xml"; + + return; + } + + if ($user->isDeleted() AND !$canViewDeleted) { + if ($user->isDeactivated()) { $this->template->_template = "User/deactivated.xml"; - $this->template->user = $user; - } else { - $this->template->_template = "User/deleted.xml"; + + return; } - } else { - $this->template->albums = (new Albums)->getUserAlbums($user); - $this->template->albumsCount = (new Albums)->getUserAlbumsCount($user); - $this->template->videos = (new Videos)->getByUser($user, 1, 2); - $this->template->videosCount = (new Videos)->getUserVideosCount($user); - $this->template->notes = (new Notes)->getUserNotes($user, 1, 4); - $this->template->notesCount = (new Notes)->getUserNotesCount($user); - - $this->template->user = $user; + + $this->template->_template = "User/deleted.xml"; + + return; } + + $this->template->albums = (new Albums)->getUserAlbums($user); + $this->template->albumsCount = (new Albums)->getUserAlbumsCount($user); + $this->template->videos = (new Videos)->getByUser($user, 1, 2); + $this->template->videosCount = (new Videos)->getUserVideosCount($user); + $this->template->notes = (new Notes)->getUserNotes($user, 1, 4); + $this->template->notesCount = (new Notes)->getUserNotesCount($user); + $this->template->user = $user; } function renderFriends(int $id): void diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index fb38133d9..bad6e7c50 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -35,7 +35,10 @@ src="/assets/packages/static/openvk/img/checkmark.png" /> ({_this_is_you}) - + + [DELETED] + +