1<?php
2/**
3 * DokuWiki Plugin structtasks
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Chris MacMackin <cmacmackin@gmail.com>
7 *
8 */
9
10namespace dokuwiki\plugin\structtasks\meta;
11
12/**
13 * Notifies a user when they are assigned to a task.
14 *
15 * @package dokuwiki\plugin\structtasks\meta
16 */
17class OpenStatusNotifier extends AbstractNotifier
18{
19    const lang_key_prefix = 'openstatus';
20    public function getNotifiableUsers($page, $editor_email, $new_data, $old_data) {
21        // Don't send emails for newly-created pages
22        if ($old_data['content'] === '' and $new_data['content'] !== '') return [];
23        $new_closed = $this->isCompleted($new_data['status']);
24        $old_closed = $this->isCompleted($old_data['status']);
25        if ($new_closed or !$old_closed) return [];
26        return array_filter(
27            $new_data['assignees'],
28            function ($val) use ($editor_email) {return $val !== $editor_email;}
29        );
30    }
31}
32