ArchiveNotification.php 2.3 KB
Newer Older
Prosper De Laure's avatar
Prosper De Laure committed
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
<?php

/*
 * Copyright (C) 2015 Maarch
 *
 * This file is part of bundle medona
 *
 * Bundle medona is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Bundle medona is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with bundle medona.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace ext\thirdPartyArchiving\bundle\medona\Controller;

/**
 * Class for ArchiveNotification
 *
 * @author Prosper DE LAURE <prosper.delaure@maarch.org>
 */
class ArchiveNotification extends abstractMessage
{
     /**
     * Get received notification messages
     *
     * @return array Array of medona/message object
     */
    public function listReception()
    {
        $registrationNumber = $this->getCurrentRegistrationNumber();

        $queryParts = [];
41
        $queryParts[] = "recipientOrgRegNumber=$registrationNumber OR senderOrgRegNumber=$registrationNumber";
42
        $queryParts[] = "type='ArchiveModificationNotification' OR type='ArchiveDestructionNotification' OR type='ArchivalProfileModificationNotification'";
Prosper De Laure's avatar
Prosper De Laure committed
43
44
        $queryParts[] = "active=true";

45
        return $this->sdoFactory->find('medona/message', '('.implode(') and (', $queryParts).')', null, false, false, 300);
Prosper De Laure's avatar
Prosper De Laure committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    }

    /**
     * Count notification message
     *
     * @return array Number of notification messages
     */
    public function count()
    {
        $registrationNumber = $this->getCurrentRegistrationNumber();

        $res = array();
        $queryParts = array();
        $queryParts[] = "(type='ArchiveModificationNotification' OR type='ArchiveDestructionNotification' OR type='ArchivalProfileModificationNotification')";
60
        $queryParts[] = "recipientOrgRegNumber=$registrationNumber OR senderOrgRegNumber=$registrationNumber";
Prosper De Laure's avatar
Prosper De Laure committed
61
62
63
64
65
66
        $queryParts[] = "active=true";
        $res['received'] = $this->sdoFactory->count('medona/message', implode(' and ', $queryParts));

        return $res;
    }
}