forked from phpbb-extensions/phpbb-ext-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.php.twig
More file actions
176 lines (160 loc) · 4.38 KB
/
sample.php.twig
File metadata and controls
176 lines (160 loc) · 4.38 KB
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
{% set is_phpbb_pre_32 = skeleton_version_compare(REQUIREMENTS.phpbb_version_max, "3.2", "<") %}
<?php
/**
*
* {{ EXTENSION.extension_display_name }}. An extension for the phpBB Forum Software package.
*
* @copyright (c) {{ "now"|date("Y") ~ (AUTHORS.0.author_name ? ', ' ~ AUTHORS.0.author_name) ~ (AUTHORS.0.author_homepage ? ', ' ~ AUTHORS.0.author_homepage) }}
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace {{ EXTENSION.vendor_name }}\{{ EXTENSION.extension_name }}\notification\type;
/**
* {{ EXTENSION.extension_display_name }} Notification class.
*/
class sample extends \phpbb\notification\type\base
{
/** @var \phpbb\controller\helper */
protected $helper;
/**
* Set the controller helper
*
* @param \phpbb\controller\helper $helper
*
* @return void
*/
public function set_controller_helper(\phpbb\controller\helper $helper)
{
$this->helper = $helper;
}
/**
* Get notification type name
*
* @return string
*/
public function get_type()
{
return '{{ EXTENSION.vendor_name }}.{{ EXTENSION.extension_name }}.notification.type.sample';
}
/**
* Notification option data (for outputting to the user)
*
* @var bool|array False if the service should use it's default data
* Array of data (including keys 'id', 'lang', and 'group')
*/
public static $notification_option = [
'lang' => 'NOTIFICATION_TYPE_{{ EXTENSION.extension_name|upper }}',
];
/**
* 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()
{
return false;
}
/**
* Get the id of the notification
*
* @param array $data The type specific data
*
* @return int Id of the notification
*/
public static function get_item_id($data)
{
return $data['notification_id'];
}
/**
* Get the id of the parent
*
* @param array $data The type specific data
*
* @return int Id of the parent
*/
public static function get_item_parent_id($data)
{
// No parent
return 0;
}
/**
* Find the users who want to receive notifications
*
* @param array $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.: [2 => [''], 3 => ['', 'email'], ...]
*
* @return array
*/
public function find_users_for_notification($data, $options = [])
{
// Return an array of users to be notified, storing the user_ids as the array keys
return [];
}
/**
* Users needed to query before this notification can be displayed
*
* @return array Array of user_ids
*/
public function users_to_query()
{
return [];
}
/**
* Get the HTML formatted title of this notification
*
* @return string
*/
public function get_title()
{
return $this->{{ LANGUAGE.object }}->lang('{{ EXTENSION.vendor_name|upper }}_{{ EXTENSION.extension_name|upper }}_NOTIFICATION');
}
/**
* Get the url to this item
*
* @return string URL
*/
public function get_url()
{
return $this->helper->route('{{ EXTENSION.vendor_name }}_{{ EXTENSION.extension_name }}_controller', $this->get_data('{{ EXTENSION.extension_name|lower }}_sample_name'));
}
/**
* Get email template
*
* @return string|bool
*/
public function get_email_template()
{
return false;
}
/**
* Get email template variables
*
* @return array
*/
public function get_email_template_variables()
{
return [];
}
/**
* Function for preparing the data for insertion in an SQL query
* (The service handles insertion)
*
* @param array $data The type specific data
* @param array $pre_create_data Data from pre_create_insert_array()
{% if is_phpbb_pre_32 %}{# for phpBB 3.1.x only #}
*
* @return array Array of data ready to be inserted into the database
{% endif %}{# for phpBB >= 3.2.x #}
*/
public function create_insert_array($data, $pre_create_data = [])
{
$this->set_data('{{ EXTENSION.extension_name|lower }}_sample_name', $data['{{ EXTENSION.extension_name|lower }}_sample_name']);
{% if is_phpbb_pre_32 %}{# for phpBB 3.1.x only #}
return parent::create_insert_array($data, $pre_create_data);
{% else %}{# for phpBB >= 3.2.x #}
parent::create_insert_array($data, $pre_create_data);
{% endif %}
}
}