Documentation/Index/DocumentCommentsObserver: UCDocumentCommentsObserver.inc

Plik UCDocumentCommentsObserver.inc, 1.5 KB (dodany przez TS, 4 years temu)
xx
Line 
1<?php
2require_once './classes/Notifier/observers/AbsNotifierObserver.inc';
3
4/**
5 * UCDocumentCommentsObserver
6 *
7 * @author Tomasz Świenty
8 * @version 0.1
9 * @copyright Copyright (c) eDokumenty
10 */
11final class UCDocumentCommentsObserver extends AbsNotifierObserver {
12
13
14    /**
15     * @return array
16     */
17    public function preapreReceiversList() {
18
19        $receivers = [];
20
21        // przygotuj listę odbiorców jako lista identyfikatorów usr_id (tabela users.usr_id)
22        // możesz w tym celu użyć np this->data aby ograniczyć do kogo chcesz wysłać powiadomienie
23
24        return array_unique($receivers);
25
26    }
27
28
29    /**
30     * @return bool|void
31     */
32    public function update() {
33
34        $receivers = $this->preapreReceiversList();
35        if (!$receivers) {
36            return FALSE;
37        }
38
39        /* dane dodatarczone przez kontekst dokumentu
40        this->data = [
41            'type__' => 'DOCUMENT',
42            'doc_id' => $doc_id,
43            'comtid' => $comtid,
44            'msg___' => $comment,
45            'nttxt_' => $document->get('dscrpt')
46        ];
47
48        czyli należy zrobić $this->data['nttxt_'] aby otrzymać opis dokumentu
49        */
50
51        $notifier = new Notifier();
52        $notifier->setReceivers($receivers);
53        $notifier->setNotifiersType('Mail');
54        $notifier->setMessage('Dodano nowy komentarz do dokumentu');
55        $notifier->send();
56
57        return TRUE;
58
59    }
60}