openvk/Web/Presenters/NotificationPresenter.php

31 lines
991 B
PHP
Raw Permalink Normal View History

2020-06-07 19:04:43 +03:00
<?php declare(strict_types=1);
namespace openvk\Web\Presenters;
final class NotificationPresenter extends OpenVKPresenter
{
2022-09-17 00:19:46 +03:00
protected $presenterName = "notification";
2020-06-07 19:04:43 +03:00
function renderFeed(): void
{
$this->assertUserLoggedIn();
2020-06-07 19:04:43 +03:00
$archive = $this->queryParam("act") === "archived";
$count = $this->user->identity->getNotificationsCount($archive);
if($count == 0 && $this->queryParam("act") == NULL) {
$mode = "archived";
$archive = true;
} else {
$mode = $archive ? "archived" : "new";
}
$this->template->mode = $mode;
2020-06-07 19:04:43 +03:00
$this->template->page = (int) ($this->queryParam("p") ?? 1);
$this->template->iterator = iterator_to_array($this->user->identity->getNotifications($this->template->page, $archive));
$this->template->count = $count;
2020-06-07 19:04:43 +03:00
$this->user->identity->updateNotificationOffset();
$this->user->identity->save();
}
}