aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/notification/type/type_interface.php
blob: ed77335ce561d68a98e56b418a3c0c0113f46a90 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

namespace phpbb\notification\type;

/**
* Base notifications interface
*/
interface type_interface
{
	/**
	* Get notification type name
	*
	* @return string
	*/
	public function get_type();

	/**
	* Set initial data from the database
	*
	* @param array $data Row directly from the database
	*/
	public function set_initial_data($data);

	/**
	* Get the id of the item
	*
	* @param array $type_data The type specific data
	*/
	static public function get_item_id($type_data);

	/**
	* Get the id of the parent
	*
	* @param array $type_data The type specific data
	*/
	static public function get_item_parent_id($type_data);

	/**
	* Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options)
	*
	* @return bool True/False whether or not this is available to the user
	*/
	public function is_available();

	/**
	* Find the users who want to receive notifications
	*
	* @param array $type_data The type specific data
	* @param array $options Options for finding users for notification
	* 		ignore_users => array of users and user types that should not receive notifications from this type because they've already been notified
	* 						e.g.: array(2 => array(''), 3 => array('', 'email'), ...)
	*
	* @return array
	*/
	public function find_users_for_notification($type_data, $options);

	/**
	* Users needed to query before this notification can be displayed
	*
	* @return array Array of user_ids
	*/
	public function users_to_query();

	/**
	* Get the special items to load
	*
	* @return array Data will be combined sent to load_special() so you can run a single query and get data required for this notification type
	*/
	public function get_load_special();

	/**
	* Load the special items
	*
	* @param array $data Data from get_load_special()
	* @param array $notifications Array of notifications (key is notification_id, value is the notification objects)
	*/
	public function load_special($data, $notifications);

	/**
	* Get the CSS style class of the notification
	*
	* @return string
	*/
	public function get_style_class();

	/**
	* Get the HTML formatted title of this notification
	*
	* @return string
	*/
	public function get_title();

	/**
	* Get the HTML formatted reference of the notification
	*
	* @return string
	*/
	public function get_reference();

	/**
	* Get the forum of the notification reference
	*
	* @return string
	*/
	public function get_forum();

	/**
	* Get the url to this item
	*
	* @return string URL
	*/
	public function get_url();

	/**
	* Get the url to redirect after the item has been marked as read
	*
	* @return string URL
	*/
	public function get_redirect_url();

	/**
	* URL to unsubscribe to this notification
	*
	* @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item
	*/
	public function get_unsubscribe_url($method);

	/**
	* Get the user's avatar (the user who caused the notification typically)
	*
	* @return string
	*/
	public function get_avatar();

	/**
	* Prepare to output the notification to the template
	*/
	public function prepare_for_display();

	/**
	* Get email template
	*
	* @return string|bool
	*/
	public function get_email_template();

	/**
	* Get email template variables
	*
	* @return array
	*/
	public function get_email_template_variables();

	/**
	* Pre create insert array function
	* This allows you to perform certain actions, like run a query
	* and load data, before create_insert_array() is run. The data
	* returned from this function will be sent to create_insert_array().
	*
	* @param array $type_data The type specific data
	* @param array $notify_users Notify users list
	* 		Formatted from find_users_for_notification()
	* @return array Whatever you want to send to create_insert_array().
	*/
	public function pre_create_insert_array($type_data, $notify_users);

	/**
	* Function for preparing the data for insertion in an SQL query
	*
	* @param array $type_data The type specific data
	* @param array $pre_create_data Data from pre_create_insert_array()
	*/
	public function create_insert_array($type_data, $pre_create_data);

	/**
	* Function for getting the data for insertion in an SQL query
	*
	* @return array Array of data ready to be inserted into the database
	*/
	public function get_insert_array();

	/**
	* Function for preparing the data for update in an SQL query
	* (The service handles insertion)
	*
	* @param array $type_data Data unique to this notification type
	*
	* @return array Array of data ready to be updated in the database
	*/
	public function create_update_array($type_data);

	/**
	* Mark this item read
	*
	* @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False)
	* @return string
	*/
	public function mark_read($return = false);

	/**
	* Mark this item unread
	*
	* @param bool $return True to return a string containing the SQL code to update this item, False to execute it (Default: False)
	* @return string
	*/
	public function mark_unread($return = false);
}