1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//namespace XoopsModules\Publisher\Plugin; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Publisher class |
17
|
|
|
* |
18
|
|
|
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
19
|
|
|
* @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
20
|
|
|
* @package Class |
21
|
|
|
* @subpackage Utils |
22
|
|
|
* @since 1.0 |
23
|
|
|
* @author trabis <[email protected]> |
24
|
|
|
* @version $Id$ |
25
|
|
|
*/ |
26
|
|
|
use NotificationsPluginInterface; |
27
|
|
|
use Xoops; |
28
|
|
|
use Xoops\Module\Plugin\PluginAbstract; |
29
|
|
|
use XoopsModules\Publisher; |
30
|
|
|
|
31
|
|
|
require_once \dirname(\dirname(__DIR__)) . '/include/common.php'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class NotificationsPlugin |
35
|
|
|
* @package XoopsModules\Publisher\Plugin |
36
|
|
|
*/ |
37
|
|
|
class PublisherNotificationsPlugin extends PluginAbstract implements NotificationsPluginInterface |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* @param string $category |
41
|
|
|
* @param int $item_id |
42
|
|
|
* |
43
|
|
|
* @return array |
44
|
|
|
*/ |
45
|
|
|
public function item($category, $item_id) |
46
|
|
|
{ |
47
|
|
|
$xoops = Xoops::getInstance(); |
|
|
|
|
48
|
|
|
$item = []; |
49
|
|
|
$item_id = (int)$item_id; |
50
|
|
|
|
51
|
|
|
if ('global' === $category) { |
52
|
|
|
$item['name'] = ''; |
53
|
|
|
$item['url'] = ''; |
54
|
|
|
|
55
|
|
|
return $item; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
if ('category' === $category) { |
59
|
|
|
// Assume we have a valid category id |
60
|
|
|
$sql = 'SELECT name, short_url FROM ' . $xoopsDB->prefix('publisher_categories') . ' WHERE categoryid = ' . $item_id; |
|
|
|
|
61
|
|
|
$result = $xoopsDB->query($sql); // TODO: error check |
62
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
63
|
|
|
$item['name'] = $result_array['name']; |
64
|
|
|
$item['url'] = Publisher\Utils::seoGenUrl('category', $item_id, $result_array['short_url']); |
65
|
|
|
|
66
|
|
|
return $item; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if ('item' === $category) { |
70
|
|
|
// Assume we have a valid story id |
71
|
|
|
$sql = 'SELECT title, short_url FROM ' . $xoopsDB->prefix('publisher_items') . ' WHERE itemid = ' . $item_id; |
72
|
|
|
$result = $xoopsDB->query($sql); // TODO: error check |
73
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
74
|
|
|
$item['name'] = $result_array['title']; |
75
|
|
|
$item['url'] = Publisher\Utils::seoGenUrl('item', $item_id, $result_array['short_url']); |
76
|
|
|
|
77
|
|
|
return $item; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $item; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return array |
85
|
|
|
*/ |
86
|
|
|
public function categories() |
87
|
|
|
{ |
88
|
|
|
$ret = []; |
89
|
|
|
$ret[1]['name'] = 'global'; |
90
|
|
|
$ret[1]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_NOTIFY; |
91
|
|
|
$ret[1]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_NOTIFY_DSC; |
92
|
|
|
$ret[1]['subscribe_from'] = ['index.php', 'category.php', 'item.php']; |
93
|
|
|
|
94
|
|
|
$ret[2]['name'] = 'category'; |
95
|
|
|
$ret[2]['title'] = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY; |
96
|
|
|
$ret[2]['description'] = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY_DSC; |
97
|
|
|
$ret[2]['subscribe_from'] = ['index.php', 'category.php', 'item.php']; |
98
|
|
|
$ret[2]['item_name'] = 'categoryid'; |
99
|
|
|
$ret[2]['allow_bookmark'] = 1; |
100
|
|
|
|
101
|
|
|
$ret[3]['name'] = 'item'; |
102
|
|
|
$ret[3]['title'] = _MI_PUBLISHER_ITEM_NOTIFY; |
103
|
|
|
$ret[3]['description'] = _MI_PUBLISHER_ITEM_NOTIFY_DSC; |
104
|
|
|
$ret[3]['subscribe_from'] = ['item.php']; |
105
|
|
|
$ret[3]['item_name'] = 'itemid'; |
106
|
|
|
$ret[3]['allow_bookmark'] = 1; |
107
|
|
|
|
108
|
|
|
return $ret; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return array |
113
|
|
|
*/ |
114
|
|
|
public function events() |
115
|
|
|
{ |
116
|
|
|
$ret = []; |
117
|
|
|
$ret[1]['name'] = 'category_created'; |
118
|
|
|
$ret[1]['category'] = 'global'; |
119
|
|
|
$ret[1]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY; |
120
|
|
|
$ret[1]['caption'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY_CAP; |
121
|
|
|
$ret[1]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY_DSC; |
122
|
|
|
$ret[1]['mail_template'] = 'global_item_category_created'; |
123
|
|
|
$ret[1]['mail_subject'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY_SBJ; |
124
|
|
|
|
125
|
|
|
$ret[2]['name'] = 'submitted'; |
126
|
|
|
$ret[2]['category'] = 'global'; |
127
|
|
|
$ret[2]['admin_only'] = 1; |
128
|
|
|
$ret[2]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY; |
129
|
|
|
$ret[2]['caption'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY_CAP; |
130
|
|
|
$ret[2]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY_DSC; |
131
|
|
|
$ret[2]['mail_template'] = 'global_item_submitted'; |
132
|
|
|
$ret[2]['mail_subject'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY_SBJ; |
133
|
|
|
|
134
|
|
|
$ret[3]['name'] = 'published'; |
135
|
|
|
$ret[3]['category'] = 'global'; |
136
|
|
|
$ret[3]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY; |
137
|
|
|
$ret[3]['caption'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY_CAP; |
138
|
|
|
$ret[3]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY_DSC; |
139
|
|
|
$ret[3]['mail_template'] = 'global_item_published'; |
140
|
|
|
$ret[3]['mail_subject'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY_SBJ; |
141
|
|
|
|
142
|
|
|
$ret[4]['name'] = 'submitted'; |
143
|
|
|
$ret[4]['category'] = 'category'; |
144
|
|
|
$ret[4]['admin_only'] = 1; |
145
|
|
|
$ret[4]['title'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY; |
146
|
|
|
$ret[4]['caption'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY_CAP; |
147
|
|
|
$ret[4]['description'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY_DSC; |
148
|
|
|
$ret[4]['mail_template'] = 'category_item_submitted'; |
149
|
|
|
$ret[4]['mail_subject'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY_SBJ; |
150
|
|
|
|
151
|
|
|
$ret[5]['name'] = 'published'; |
152
|
|
|
$ret[5]['category'] = 'category'; |
153
|
|
|
$ret[5]['title'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY; |
154
|
|
|
$ret[5]['caption'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY_CAP; |
155
|
|
|
$ret[5]['description'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY_DSC; |
156
|
|
|
$ret[5]['mail_template'] = 'category_item_published'; |
157
|
|
|
$ret[5]['mail_subject'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY_SBJ; |
158
|
|
|
|
159
|
|
|
$ret[6]['name'] = 'rejected'; |
160
|
|
|
$ret[6]['category'] = 'item'; |
161
|
|
|
$ret[6]['invisible'] = 1; |
162
|
|
|
$ret[6]['title'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY; |
163
|
|
|
$ret[6]['caption'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY_CAP; |
164
|
|
|
$ret[6]['description'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY_DSC; |
165
|
|
|
$ret[6]['mail_template'] = 'item_rejected'; |
166
|
|
|
$ret[6]['mail_subject'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY_SBJ; |
167
|
|
|
|
168
|
|
|
$ret[7]['name'] = 'approved'; |
169
|
|
|
$ret[7]['category'] = 'item'; |
170
|
|
|
$ret[7]['invisible'] = 1; |
171
|
|
|
$ret[7]['title'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY; |
172
|
|
|
$ret[7]['caption'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY_CAP; |
173
|
|
|
$ret[7]['description'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY_DSC; |
174
|
|
|
$ret[7]['mail_template'] = 'item_approved'; |
175
|
|
|
$ret[7]['mail_subject'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY_SBJ; |
176
|
|
|
|
177
|
|
|
return $ret; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* @param string $category |
182
|
|
|
* @param int $item_id |
183
|
|
|
* @param string $event |
184
|
|
|
* |
185
|
|
|
* @return array |
186
|
|
|
*/ |
187
|
|
|
public function tags($category, $item_id, $event) |
188
|
|
|
{ |
189
|
|
|
return []; |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|