Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
13.33% |
2 / 15 |
|
28.57% |
2 / 7 |
CRAP | |
0.00% |
0 / 1 |
approve_topic | |
13.33% |
2 / 15 |
|
28.57% |
2 / 7 |
38.90 | |
0.00% |
0 / 1 |
get_type | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
is_available | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
find_users_for_notification | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
pre_create_insert_array | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
create_insert_array | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
get_insert_array | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
get_email_template | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * |
4 | * This file is part of the phpBB Forum Software package. |
5 | * |
6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
7 | * @license GNU General Public License, version 2 (GPL-2.0) |
8 | * |
9 | * For full copyright and license information, please see |
10 | * the docs/CREDITS.txt file. |
11 | * |
12 | */ |
13 | |
14 | namespace phpbb\notification\type; |
15 | |
16 | /** |
17 | * Topic approved notifications class |
18 | * This class handles notifications for topics when they are approved (for authors) |
19 | */ |
20 | |
21 | class approve_topic extends \phpbb\notification\type\topic |
22 | { |
23 | /** |
24 | * Get notification type name |
25 | * |
26 | * @return string |
27 | */ |
28 | public function get_type() |
29 | { |
30 | return 'notification.type.approve_topic'; |
31 | } |
32 | |
33 | /** |
34 | * Language key used to output the text |
35 | * |
36 | * @var string |
37 | */ |
38 | protected $language_key = 'NOTIFICATION_TOPIC_APPROVED'; |
39 | |
40 | /** |
41 | * Inherit notification read status from topic. |
42 | * |
43 | * @var bool |
44 | */ |
45 | protected $inherit_read_status = false; |
46 | |
47 | /** |
48 | * Notification option data (for outputting to the user) |
49 | * |
50 | * @var bool|array False if the service should use it's default data |
51 | * Array of data (including keys 'id', 'lang', and 'group') |
52 | */ |
53 | public static $notification_option = array( |
54 | 'id' => 'moderation_queue', |
55 | 'lang' => 'NOTIFICATION_TYPE_MODERATION_QUEUE', |
56 | 'group' => 'NOTIFICATION_GROUP_POSTING', |
57 | ); |
58 | |
59 | /** |
60 | * Is available |
61 | */ |
62 | public function is_available() |
63 | { |
64 | return !$this->auth->acl_get('m_approve'); |
65 | } |
66 | |
67 | /** |
68 | * Find the users who want to receive notifications |
69 | * |
70 | * @param array $type_data Data from submit_post |
71 | * @param array $options Options for finding users for notification |
72 | * |
73 | * @return array |
74 | */ |
75 | public function find_users_for_notification($type_data, $options = array()) |
76 | { |
77 | $options = array_merge(array( |
78 | 'ignore_users' => array(), |
79 | ), $options); |
80 | |
81 | return $this->get_authorised_recipients(array($type_data['poster_id']), $type_data['forum_id'], array_merge($options, array( |
82 | 'item_type' => static::$notification_option['id'], |
83 | ))); |
84 | } |
85 | |
86 | /** |
87 | * Pre create insert array function |
88 | * This allows you to perform certain actions, like run a query |
89 | * and load data, before create_insert_array() is run. The data |
90 | * returned from this function will be sent to create_insert_array(). |
91 | * |
92 | * @param array $type_data Post data from submit_post |
93 | * @param array $notify_users Notify users list |
94 | * Formatted from find_users_for_notification() |
95 | * |
96 | * @return array Whatever you want to send to create_insert_array(). |
97 | */ |
98 | public function pre_create_insert_array($type_data, $notify_users) |
99 | { |
100 | // In the parent class, this is used to check if the post is already |
101 | // read by a user and marks the notification read if it was marked read. |
102 | // Returning an empty array in effect, forces it to be marked as unread |
103 | // (and also saves a query) |
104 | return array(); |
105 | } |
106 | |
107 | /** |
108 | * {@inheritdoc} |
109 | */ |
110 | public function create_insert_array($type_data, $pre_create_data = array()) |
111 | { |
112 | |
113 | parent::create_insert_array($type_data, $pre_create_data); |
114 | |
115 | $this->notification_time = time(); |
116 | } |
117 | |
118 | /** |
119 | * {@inheritdoc} |
120 | */ |
121 | public function get_insert_array() |
122 | { |
123 | $data = parent::get_insert_array(); |
124 | $data['notification_time'] = $this->notification_time; |
125 | |
126 | return $data; |
127 | } |
128 | |
129 | /** |
130 | * {@inheritdoc} |
131 | */ |
132 | public function get_email_template() |
133 | { |
134 | return 'topic_approved'; |
135 | } |
136 | } |