mirror of
https://github.com/openvk/openvk
synced 2025-03-14 21:45:22 +03:00
Remove repeated code, fix loaded buttons on chr...
...ome and fix getting suggested posts via API.Wall.getPost
This commit is contained in:
parent
222601383d
commit
ccf618a5ab
7 changed files with 28 additions and 51 deletions
|
@ -2,7 +2,7 @@
|
|||
namespace openvk\ServiceAPI;
|
||||
use openvk\Web\Models\Entities\Post;
|
||||
use openvk\Web\Models\Entities\User;
|
||||
use openvk\Web\Models\Entities\Notifications\{PostAcceptedNotification};
|
||||
use openvk\Web\Models\Entities\Notifications\PostAcceptedNotification;
|
||||
use openvk\Web\Models\Repositories\{Posts, Notes};
|
||||
|
||||
class Wall implements Handler
|
||||
|
@ -22,7 +22,10 @@ class Wall implements Handler
|
|||
{
|
||||
$post = $this->posts->get($id);
|
||||
if(!$post || $post->isDeleted())
|
||||
$reject("No post with id=$id");
|
||||
$reject(53, "No post with id=$id");
|
||||
|
||||
if($post->getSuggestionType() != 0)
|
||||
$reject(25, "Can't get suggested post");
|
||||
|
||||
$res = (object) [];
|
||||
$res->id = $post->getId();
|
||||
|
|
|
@ -410,7 +410,7 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
$this->flashFail("succ", tr("information_-1"), tr("group_owner_setted", $newOwner->getCanonicalName(), $club->getName()));
|
||||
}
|
||||
|
||||
function renderSuggestedThisUser(int $id)
|
||||
function renderSuggested(int $id): void
|
||||
{
|
||||
$this->assertUserLoggedIn();
|
||||
|
||||
|
@ -420,57 +420,26 @@ final class GroupPresenter extends OpenVKPresenter
|
|||
else
|
||||
$this->template->club = $club;
|
||||
|
||||
if($club->getWallType() == 1) {
|
||||
if($club->getWallType() == 0) {
|
||||
$this->flash("err", tr("error_suggestions"), tr("error_suggestions_closed"));
|
||||
$this->redirect("/club".$club->getId());
|
||||
}
|
||||
|
||||
if($club->getWallType() == 0) {
|
||||
$this->flash("err", tr("error_suggestions"), tr("error_suggestions_open"));
|
||||
$this->redirect("/club".$club->getId());
|
||||
}
|
||||
|
||||
if($club->canBeModifiedBy($this->user->identity)) {
|
||||
$this->flash("err", tr("error_suggestions"), "No sense");
|
||||
$this->redirect("/club".$club->getId());
|
||||
}
|
||||
|
||||
$this->template->posts = (new Posts)->getSuggestedPostsByUser($club->getId(), $this->user->id, (int) ($this->queryParam("p") ?? 1));
|
||||
$this->template->count = (new Posts)->getSuggestedPostsCountByUser($club->getId(), $this->user->id);
|
||||
$this->template->type = "my";
|
||||
$this->template->page = (int) ($this->queryParam("p") ?? 1);
|
||||
$this->template->_template = "Group/Suggested.xml";
|
||||
}
|
||||
|
||||
function renderSuggestedAll(int $id)
|
||||
{
|
||||
$this->assertUserLoggedIn();
|
||||
|
||||
$club = $this->clubs->get($id);
|
||||
if(!$club)
|
||||
$this->notFound();
|
||||
else
|
||||
$this->template->club = $club;
|
||||
|
||||
|
||||
if($club->getWallType() == 1) {
|
||||
$this->flash("err", tr("error_suggestions"), tr("error_suggestions_closed"));
|
||||
$this->redirect("/club".$club->getId());
|
||||
}
|
||||
|
||||
if($club->getWallType() == 0) {
|
||||
$this->flash("err", tr("error_suggestions"), tr("error_suggestions_open"));
|
||||
$this->redirect("/club".$club->getId());
|
||||
}
|
||||
|
||||
|
||||
if(!$club->canBeModifiedBy($this->user->identity)) {
|
||||
$this->flash("err", tr("error_suggestions"), tr("error_suggestions_access"));
|
||||
$this->redirect("/club".$club->getId());
|
||||
$this->template->posts = (new Posts)->getSuggestedPostsByUser($club->getId(), $this->user->id, (int) ($this->queryParam("p") ?? 1));
|
||||
$this->template->count = (new Posts)->getSuggestedPostsCountByUser($club->getId(), $this->user->id);
|
||||
$this->template->type = "my";
|
||||
} else {
|
||||
$this->template->posts = (new Posts)->getSuggestedPosts($club->getId(), (int) ($this->queryParam("p") ?? 1));
|
||||
$this->template->count = (new Posts)->getSuggestedPostsCount($club->getId());
|
||||
$this->template->type = "everyone";
|
||||
}
|
||||
|
||||
$this->template->posts = (new Posts)->getSuggestedPosts($club->getId(), (int) ($this->queryParam("p") ?? 1));
|
||||
$this->template->count = (new Posts)->getSuggestedPostsCount($club->getId());
|
||||
$this->template->type = "everyone";
|
||||
$this->template->page = (int) ($this->queryParam("p") ?? 1);
|
||||
$this->template->_template = "Group/Suggested.xml";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@
|
|||
{$club->getName()}
|
||||
|
||||
<object type="internal/link" style="white-space: normal;" id="sug{$club->getId()}" n:if="$club->getSuggestedPostsCount() > 0 && $club->getWallType() == 2">
|
||||
<a href="{$club->getURL()}/suggested/all">
|
||||
<a href="{$club->getURL()}/suggested">
|
||||
(<b>{$club->getSuggestedPostsCount()}</b>)
|
||||
</a>
|
||||
</object>
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
</div>
|
||||
|
||||
<div n:if="!is_null($suggestedPostsCountByEveryone) && $suggestedPostsCountByEveryone > 0" class="sugglist">
|
||||
<a href="/club{$club->getId()}/suggested/all">{tr("suggested_by_everyone", $suggestedPostsCountByEveryone)}</a>
|
||||
<a href="/club{$club->getId()}/suggested">{tr("suggested_by_everyone", $suggestedPostsCountByEveryone)}</a>
|
||||
</div>
|
||||
|
||||
{presenter "openvk!Wall->wallEmbedded", -$club->getId()}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{var $club = $notification->getModel(1)}
|
||||
|
||||
{_nt_in_club}
|
||||
<a href="{$club->getURL()}/suggested/all"><b>{$club->getName()}</b></a>
|
||||
<a href="{$club->getURL()}/suggested"><b>{$club->getName()}</b></a>
|
||||
{_nt_new_suggested_posts}
|
||||
|
|
|
@ -202,9 +202,7 @@ routes:
|
|||
- url: "/club{num}/setAdmin"
|
||||
handler: "Group->modifyAdmin"
|
||||
- url: "/club{num}/suggested"
|
||||
handler: "Group->suggestedThisUser"
|
||||
- url: "/club{num}/suggested/all"
|
||||
handler: "Group->suggestedAll"
|
||||
handler: "Group->suggested"
|
||||
- url: "/groups{num}"
|
||||
handler: "User->groups"
|
||||
- url: "/groups_pin"
|
||||
|
|
|
@ -2717,5 +2717,12 @@ body.article .floating_sidebar, body.article .page_content {
|
|||
|
||||
.button.loaded {
|
||||
background: #595959 url("/assets/packages/static/openvk/img/loading_mini.gif") no-repeat 50% 50%;
|
||||
padding: 16px 40px 6px 4px;
|
||||
padding: 2px 9px 7px 39px;
|
||||
margin-bottom: -6px;
|
||||
}
|
||||
|
||||
@-moz-document url-prefix() {
|
||||
.button.loaded {
|
||||
padding: 16px 40px 6px 4px !important;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue