/
alert.php
43 lines (36 loc) · 1.29 KB
/
alert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Concrete\Controller\Backend\Notification;
use Concrete\Core\Controller\AbstractController;
use Concrete\Core\Validation\CSRF\Token;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\JsonResponse;
class Alert extends AbstractController
{
protected $entityManager;
protected $token;
public function __construct(EntityManager $entityManager, Token $token)
{
parent::__construct();
$this->entityManager = $entityManager;
$this->token = $token;
}
public function archive()
{
$id = intval($this->request->request->get('naID'));
if ($this->token->validate() && $id > 0) {
$u = new \User();
if ($u->isRegistered()) {
$r = $this->entityManager->getRepository('Concrete\Core\Entity\Notification\NotificationAlert');
$alert = $r->findOneById($id);
if (is_object($alert) &&
is_object($alert->getUser()) &&
$alert->getUser()->getUserID() == $u->getUserID()) {
$alert->setNotificationIsArchived(true);
$this->entityManager->persist($alert);
$this->entityManager->flush();
}
}
}
$this->app->shutdown();
}
}