Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
4.55% covered (danger)
4.55%
1 / 22
10.00% covered (danger)
10.00%
1 / 10
CRAP
0.00% covered (danger)
0.00%
0 / 1
disapprove_post
4.55% covered (danger)
4.55%
1 / 22
10.00% covered (danger)
10.00%
1 / 10
96.97
0.00% covered (danger)
0.00%
0 / 1
 get_type
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_style_class
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_title
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_reference
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 get_reason
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 get_url
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_email_template_variables
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 create_insert_array
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 get_insert_array
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 get_email_template
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
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
14namespace phpbb\notification\type;
15
16/**
17* Post disapproved notifications class
18* This class handles notifications for posts when they are disapproved (for authors)
19*/
20
21class disapprove_post extends \phpbb\notification\type\approve_post
22{
23    /**
24    * Get notification type name
25    *
26    * @return string
27    */
28    public function get_type()
29    {
30        return 'notification.type.disapprove_post';
31    }
32
33    /**
34    * Get the CSS style class of the notification
35    *
36    * @return string
37    */
38    public function get_style_class()
39    {
40        return 'notification-disapproved';
41    }
42
43    /**
44    * Language key used to output the text
45    *
46    * @var string
47    */
48    protected $language_key = 'NOTIFICATION_POST_DISAPPROVED';
49
50    /**
51    * Inherit notification read status from post.
52    *
53    * @var bool
54    */
55    protected $inherit_read_status = false;
56
57    /**
58    * Notification option data (for outputting to the user)
59    *
60    * @var bool|array False if the service should use it's default data
61    *                     Array of data (including keys 'id', 'lang', and 'group')
62    */
63    public static $notification_option = array(
64        'id'    => 'moderation_queue',
65        'lang'    => 'NOTIFICATION_TYPE_MODERATION_QUEUE',
66        'group'    => 'NOTIFICATION_GROUP_POSTING',
67    );
68
69    /**
70    * Get the HTML formatted title of this notification
71    *
72    * @return string
73    */
74    public function get_title()
75    {
76        return $this->language->lang($this->language_key);
77    }
78
79    /**
80    * Get the HTML formatted reference of the notification
81    *
82    * @return string
83    */
84    public function get_reference()
85    {
86        return $this->language->lang(
87            'NOTIFICATION_REFERENCE',
88            censor_text($this->get_data('topic_title'))
89        );
90    }
91
92    /**
93    * Get the reason for the disapproval notification
94    *
95    * @return string
96    */
97    public function get_reason()
98    {
99        return $this->language->lang(
100            'NOTIFICATION_REASON',
101            $this->get_data('disapprove_reason')
102        );
103    }
104
105    /**
106    * Get the url to this item
107    *
108    * @return string URL
109    */
110    public function get_url()
111    {
112        return '';
113    }
114
115    /**
116    * Get email template variables
117    *
118    * @return array
119    */
120    public function get_email_template_variables()
121    {
122        return array_merge(parent::get_email_template_variables(), array(
123            'REASON'    => html_entity_decode($this->get_data('disapprove_reason'), ENT_COMPAT),
124        ));
125    }
126
127    /**
128    * {@inheritdoc}
129    */
130    public function create_insert_array($type_data, $pre_create_data = array())
131    {
132        $this->set_data('disapprove_reason', $type_data['disapprove_reason']);
133
134        parent::create_insert_array($type_data, $pre_create_data);
135
136        $this->notification_time = time();
137    }
138
139    /**
140    * {@inheritdoc}
141    */
142    public function get_insert_array()
143    {
144        $data = parent::get_insert_array();
145        $data['notification_time'] = $this->notification_time;
146
147        return $data;
148    }
149
150    /**
151    * {@inheritdoc}
152    */
153    public function get_email_template()
154    {
155        return 'post_disapproved';
156    }
157}