1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
23:
24: include_once dirname(dirname(__DIR__)) . '/include/common.php';
25:
26: class PublisherNotificationsPlugin extends Xoops\Module\Plugin\PluginAbstract implements NotificationsPluginInterface
27: {
28: 29: 30: 31: 32: 33:
34: public function item($category, $item_id)
35: {
36: $xoops = Xoops::getInstance();
37: $item = array();
38: $item_id = (int) $item_id;
39:
40: if ($category === 'global') {
41: $item['name'] = '';
42: $item['url'] = '';
43: return $item;
44: }
45:
46: if ($category === 'category') {
47:
48: $sql = 'SELECT name, short_url FROM ' . $xoopsDB->prefix('publisher_categories') . ' WHERE categoryid = ' . $item_id;
49: $result = $xoopsDB->query($sql);
50: $result_array = $xoopsDB->fetchArray($result);
51: $item['name'] = $result_array['name'];
52: $item['url'] = PublisherUtils::seoGenUrl('category', $item_id, $result_array['short_url']);
53: return $item;
54: }
55:
56: if ($category === 'item') {
57:
58: $sql = 'SELECT title, short_url FROM ' . $xoopsDB->prefix('publisher_items') . ' WHERE itemid = ' . $item_id;
59: $result = $xoopsDB->query($sql);
60: $result_array = $xoopsDB->fetchArray($result);
61: $item['name'] = $result_array['title'];
62: $item['url'] = PublisherUtils::seoGenUrl('item', $item_id, $result_array['short_url']);
63: return $item;
64: }
65:
66: return $item;
67: }
68:
69: 70: 71:
72: public function categories()
73: {
74: $ret = array();
75: $ret[1]['name'] = 'global';
76: $ret[1]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_NOTIFY;
77: $ret[1]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_NOTIFY_DSC;
78: $ret[1]['subscribe_from'] = array('index.php', 'category.php', 'item.php');
79:
80: $ret[2]['name'] = 'category';
81: $ret[2]['title'] = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY;
82: $ret[2]['description'] = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY_DSC;
83: $ret[2]['subscribe_from'] = array('index.php', 'category.php', 'item.php');
84: $ret[2]['item_name'] = 'categoryid';
85: $ret[2]['allow_bookmark'] = 1;
86:
87: $ret[3]['name'] = 'item';
88: $ret[3]['title'] = _MI_PUBLISHER_ITEM_NOTIFY;
89: $ret[3]['description'] = _MI_PUBLISHER_ITEM_NOTIFY_DSC;
90: $ret[3]['subscribe_from'] = array('item.php');
91: $ret[3]['item_name'] = 'itemid';
92: $ret[3]['allow_bookmark'] = 1;
93: return $ret;
94: }
95:
96: 97: 98:
99: public function events()
100: {
101: $ret = array();
102: $ret[1]['name'] = 'category_created';
103: $ret[1]['category'] = 'global';
104: $ret[1]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY;
105: $ret[1]['caption'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY_CAP;
106: $ret[1]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY_DSC;
107: $ret[1]['mail_template'] = 'global_item_category_created';
108: $ret[1]['mail_subject'] = _MI_PUBLISHER_GLOBAL_ITEM_CATEGORY_CREATED_NOTIFY_SBJ;
109:
110: $ret[2]['name'] = 'submitted';
111: $ret[2]['category'] = 'global';
112: $ret[2]['admin_only'] = 1;
113: $ret[2]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY;
114: $ret[2]['caption'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY_CAP;
115: $ret[2]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY_DSC;
116: $ret[2]['mail_template'] = 'global_item_submitted';
117: $ret[2]['mail_subject'] = _MI_PUBLISHER_GLOBAL_ITEM_SUBMITTED_NOTIFY_SBJ;
118:
119: $ret[3]['name'] = 'published';
120: $ret[3]['category'] = 'global';
121: $ret[3]['title'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY;
122: $ret[3]['caption'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY_CAP;
123: $ret[3]['description'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY_DSC;
124: $ret[3]['mail_template'] = 'global_item_published';
125: $ret[3]['mail_subject'] = _MI_PUBLISHER_GLOBAL_ITEM_PUBLISHED_NOTIFY_SBJ;
126:
127: $ret[4]['name'] = 'submitted';
128: $ret[4]['category'] = 'category';
129: $ret[4]['admin_only'] = 1;
130: $ret[4]['title'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY;
131: $ret[4]['caption'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY_CAP;
132: $ret[4]['description'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY_DSC;
133: $ret[4]['mail_template'] = 'category_item_submitted';
134: $ret[4]['mail_subject'] = _MI_PUBLISHER_CATEGORY_ITEM_SUBMITTED_NOTIFY_SBJ;
135:
136: $ret[5]['name'] = 'published';
137: $ret[5]['category'] = 'category';
138: $ret[5]['title'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY;
139: $ret[5]['caption'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY_CAP;
140: $ret[5]['description'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY_DSC;
141: $ret[5]['mail_template'] = 'category_item_published';
142: $ret[5]['mail_subject'] = _MI_PUBLISHER_CATEGORY_ITEM_PUBLISHED_NOTIFY_SBJ;
143:
144: $ret[6]['name'] = 'rejected';
145: $ret[6]['category'] = 'item';
146: $ret[6]['invisible'] = 1;
147: $ret[6]['title'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY;
148: $ret[6]['caption'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY_CAP;
149: $ret[6]['description'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY_DSC;
150: $ret[6]['mail_template'] = 'item_rejected';
151: $ret[6]['mail_subject'] = _MI_PUBLISHER_ITEM_REJECTED_NOTIFY_SBJ;
152:
153: $ret[7]['name'] = 'approved';
154: $ret[7]['category'] = 'item';
155: $ret[7]['invisible'] = 1;
156: $ret[7]['title'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY;
157: $ret[7]['caption'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY_CAP;
158: $ret[7]['description'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY_DSC;
159: $ret[7]['mail_template'] = 'item_approved';
160: $ret[7]['mail_subject'] = _MI_PUBLISHER_ITEM_APPROVED_NOTIFY_SBJ;
161: return $ret;
162: }
163:
164: 165: 166: 167: 168: 169: 170:
171: public function tags($category, $item_id, $event)
172: {
173: return array();
174: }
175: }
176: