Only keep hashes of active acknowledged announcements in the announcements cookie

refs #11198
This commit is contained in:
Eric Lippmann 2016-12-13 11:03:09 +01:00
parent de94749502
commit 94071848ca
1 changed files with 13 additions and 1 deletions

View File

@ -3,7 +3,9 @@
namespace Icinga\Forms\Announcement;
use Icinga\Data\Filter\Filter;
use Icinga\Web\Announcement\AnnouncementCookie;
use Icinga\Web\Announcement\AnnouncementIniRepository;
use Icinga\Web\Form;
class AcknowledgeAnnouncementForm extends Form
@ -70,7 +72,17 @@ class AcknowledgeAnnouncementForm extends Form
public function onSuccess()
{
$cookie = new AnnouncementCookie();
$acknowledged = $cookie->getAcknowledged();
$repo = new AnnouncementIniRepository();
$query = $repo->findActive();
$filter = array();
foreach ($cookie->getAcknowledged() as $hash) {
$filter[] = Filter::expression('hash', '=', $hash);
}
$query->addFilter(Filter::matchAny($filter));
$acknowledged = array();
foreach ($query as $row) {
$acknowledged[] = $row->hash;
}
$acknowledged[] = $this->getElement('hash')->getValue();
$cookie->setAcknowledged($acknowledged);
$this->getResponse()->setCookie($cookie);