gruffen commited on 2011-04-01 17:26:48
Showing 5 changed files, with 400 additions and 0 deletions.
... | ... |
@@ -0,0 +1,30 @@ |
1 |
+<?php |
|
2 |
+############################################################### |
|
3 |
+# Simple Desk Project - www.simpledesk.net # |
|
4 |
+############################################################### |
|
5 |
+# An advanced help desk modifcation built on SMF # |
|
6 |
+############################################################### |
|
7 |
+# # |
|
8 |
+# * Copyright 2010 - SimpleDesk.net # |
|
9 |
+# # |
|
10 |
+# This file and its contents are subject to the license # |
|
11 |
+# included with this distribution, license.txt, which # |
|
12 |
+# states that this software is New BSD Licensed. # |
|
13 |
+# Any questions, please contact SimpleDesk.net # |
|
14 |
+# # |
|
15 |
+############################################################### |
|
16 |
+# SimpleDesk Version: 1.0 Felidae # |
|
17 |
+# File Info: SimpleDesk.english.php / 1.0 Felidae # |
|
18 |
+############################################################### |
|
19 |
+// Version: 1.0 Felidae; SimpleDesk staff list plugin |
|
20 |
+ |
|
21 |
+// Important! Before editing these language files please read the text at the top of index.english.php. |
|
22 |
+ |
|
23 |
+$txt['shdp_report_to_helpdesk'] = 'Report to Helpdesk'; |
|
24 |
+$txt['shdp_report_to_helpdesk_desc'] = 'This plugin redirects reported posts to the helpdesk to be dealt with.'; |
|
25 |
+ |
|
26 |
+$txt['reported_post'] = 'Reported post'; |
|
27 |
+$txt['reported_body'] = 'The following post, "{subject}" by {author}, was reported by {reporter}' . "\n" . '---------------------------------------' . "\n" . '{body}' . "\n" . '---------------------------------------' . "\n\n" . 'The reason given was: ' . "\n" . '{comment}'; |
|
28 |
+ |
|
29 |
+$txt['report_to_mod_func'] = 'Use this function to inform the moderators and administrators of an abusive or wrongly posted message.'; |
|
30 |
+?> |
|
0 | 31 |
\ No newline at end of file |
... | ... |
@@ -0,0 +1,19 @@ |
1 |
+<?xml version="1.0"?> |
|
2 |
+<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info"> |
|
3 |
+<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/"> |
|
4 |
+ <id>SimpleDeskTeam:reporthelpdesk</id> |
|
5 |
+ <name>SimpleDesk: Report to Helpdesk</name> |
|
6 |
+ <version>1.0</version> |
|
7 |
+ <type>modification</type> |
|
8 |
+ <install for="2.0 RC5"> |
|
9 |
+ <require-file name="SDPluginReportToHelpdesk.english.php" destination="$languagedir" /> |
|
10 |
+ <require-dir name="report_to_helpdesk" destination="$sourcedir/sd_plugins_source" /> |
|
11 |
+ |
|
12 |
+ <redirect url="?action=admin;area=helpdesk_plugins#js_feature_report_to_helpdesk" /> |
|
13 |
+ </install> |
|
14 |
+ |
|
15 |
+ <uninstall for="2.0 RC5"> |
|
16 |
+ <remove-file name="$languagedir/SDPluginReportToHelpdesk.english.php" /> |
|
17 |
+ <remove-dir name="$sourcedir/sd_plugins_source/report_to_helpdesk" /> |
|
18 |
+ </uninstall> |
|
19 |
+</package-info> |
|
0 | 20 |
\ No newline at end of file |
... | ... |
@@ -0,0 +1,41 @@ |
1 |
+<?php |
|
2 |
+############################################################### |
|
3 |
+# Simple Desk Project - www.simpledesk.net # |
|
4 |
+############################################################### |
|
5 |
+# An advanced help desk modifcation built on SMF # |
|
6 |
+############################################################### |
|
7 |
+# # |
|
8 |
+# * Copyright 2010 - SimpleDesk.net # |
|
9 |
+# # |
|
10 |
+# This file and its contents are subject to the license # |
|
11 |
+# included with this distribution, license.txt, which # |
|
12 |
+# states that this software is New BSD Licensed. # |
|
13 |
+# Any questions, please contact SimpleDesk.net # |
|
14 |
+# # |
|
15 |
+############################################################### |
|
16 |
+# SimpleDesk Version: 1.0 Felidae # |
|
17 |
+# File Info: SDPluginReportToHelpdesk.php / 1.0 Felidae # |
|
18 |
+############################################################### |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * This file handles sending notifications to users when things happen in the helpdesk. |
|
22 |
+ * |
|
23 |
+ * @package source |
|
24 |
+ * @since 1.1 |
|
25 |
+ */ |
|
26 |
+ |
|
27 |
+if (!defined('SMF')) |
|
28 |
+ die('Hacking attempt...'); |
|
29 |
+ |
|
30 |
+// Deal with the action |
|
31 |
+function shd_report_to_helpdesk_actions(&$actionArray) |
|
32 |
+{ |
|
33 |
+ global $context; |
|
34 |
+ |
|
35 |
+ if (!in_array('report_to_helpdesk', $context['shd_plugins'])) |
|
36 |
+ return; |
|
37 |
+ |
|
38 |
+ $actionArray['reporttm'] = array('sd_plugins_source/report_to_helpdesk/SDPluginReportToHelpdeskMain.php', 'shd_report_to_helpdesk'); |
|
39 |
+} |
|
40 |
+ |
|
41 |
+?> |
|
0 | 42 |
\ No newline at end of file |
... | ... |
@@ -0,0 +1,234 @@ |
1 |
+<?php |
|
2 |
+############################################################### |
|
3 |
+# Simple Desk Project - www.simpledesk.net # |
|
4 |
+############################################################### |
|
5 |
+# An advanced help desk modifcation built on SMF # |
|
6 |
+############################################################### |
|
7 |
+# # |
|
8 |
+# * Copyright 2010 - SimpleDesk.net # |
|
9 |
+# # |
|
10 |
+# This file and its contents are subject to the license # |
|
11 |
+# included with this distribution, license.txt, which # |
|
12 |
+# states that this software is New BSD Licensed. # |
|
13 |
+# Any questions, please contact SimpleDesk.net # |
|
14 |
+# # |
|
15 |
+############################################################### |
|
16 |
+# SimpleDesk Version: 1.0 Felidae # |
|
17 |
+# File Info: SimpleDesk-Notifications.php / 1.0 Felidae # |
|
18 |
+############################################################### |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * This file handles sending notifications to users when things happen in the helpdesk. |
|
22 |
+ * |
|
23 |
+ * @package source |
|
24 |
+ * @since 1.1 |
|
25 |
+ */ |
|
26 |
+ |
|
27 |
+if (!defined('SMF')) |
|
28 |
+ die('Hacking attempt...'); |
|
29 |
+ |
|
30 |
+function shd_report_to_helpdesk() |
|
31 |
+{ |
|
32 |
+ global $txt, $topic, $sourcedir, $modSettings, $user_info, $context, $smcFunc; |
|
33 |
+ |
|
34 |
+ $context['robot_no_index'] = true; |
|
35 |
+ |
|
36 |
+ // You can't use this if it's off or you are not allowed to do it. |
|
37 |
+ isAllowedTo('report_any'); |
|
38 |
+ |
|
39 |
+ // If they're posting, it should be processed by ReportToModerator2. |
|
40 |
+ if ((isset($_POST[$context['session_var']]) || isset($_POST['submit'])) && empty($context['post_errors'])) |
|
41 |
+ shd_report_to_helpdesk2(); |
|
42 |
+ |
|
43 |
+ // We need a message ID to check! |
|
44 |
+ if (empty($_REQUEST['msg']) && empty($_REQUEST['mid'])) |
|
45 |
+ fatal_lang_error('no_access', false); |
|
46 |
+ |
|
47 |
+ // For compatibility, accept mid, but we should be using msg. (not the flavor kind!) |
|
48 |
+ $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
49 |
+ |
|
50 |
+ // Check the message's ID - don't want anyone reporting a post they can't even see! |
|
51 |
+ $result = $smcFunc['db_query']('', ' |
|
52 |
+ SELECT m.id_msg, m.id_member, t.id_member_started |
|
53 |
+ FROM {db_prefix}messages AS m |
|
54 |
+ INNER JOIN {db_prefix}topics AS t ON (t.id_topic = {int:current_topic}) |
|
55 |
+ WHERE m.id_msg = {int:id_msg} |
|
56 |
+ AND m.id_topic = {int:current_topic} |
|
57 |
+ LIMIT 1', |
|
58 |
+ array( |
|
59 |
+ 'current_topic' => $topic, |
|
60 |
+ 'id_msg' => $_REQUEST['msg'], |
|
61 |
+ ) |
|
62 |
+ ); |
|
63 |
+ if ($smcFunc['db_num_rows']($result) == 0) |
|
64 |
+ fatal_lang_error('no_board', false); |
|
65 |
+ list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result); |
|
66 |
+ $smcFunc['db_free_result']($result); |
|
67 |
+ |
|
68 |
+ // Do we need to show the visual verification image? |
|
69 |
+ $context['require_verification'] = $user_info['is_guest'] && !empty($modSettings['guests_report_require_captcha']); |
|
70 |
+ if ($context['require_verification']) |
|
71 |
+ { |
|
72 |
+ require_once($sourcedir . '/Subs-Editor.php'); |
|
73 |
+ $verificationOptions = array( |
|
74 |
+ 'id' => 'report', |
|
75 |
+ ); |
|
76 |
+ $context['require_verification'] = create_control_verification($verificationOptions); |
|
77 |
+ $context['visual_verification_id'] = $verificationOptions['id']; |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ // Show the inputs for the comment, etc. |
|
81 |
+ loadLanguage('Post'); |
|
82 |
+ shd_load_language('SDPluginReportToHelpdesk'); |
|
83 |
+ loadTemplate('SendTopic'); |
|
84 |
+ |
|
85 |
+ $context['comment_body'] = !isset($_POST['comment']) ? '' : trim($_POST['comment']); |
|
86 |
+ $context['email_address'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
|
87 |
+ |
|
88 |
+ // This is here so that the user could, in theory, be redirected back to the topic. |
|
89 |
+ $context['start'] = $_REQUEST['start']; |
|
90 |
+ $context['message_id'] = $_REQUEST['msg']; |
|
91 |
+ |
|
92 |
+ $context['page_title'] = $txt['report_to_mod']; |
|
93 |
+ $context['sub_template'] = 'report'; |
|
94 |
+} |
|
95 |
+ |
|
96 |
+function shd_report_to_helpdesk2() |
|
97 |
+{ |
|
98 |
+ global $txt, $scripturl, $topic, $board, $user_info, $modSettings, $sourcedir, $language, $context, $smcFunc; |
|
99 |
+ |
|
100 |
+ // You must have the proper permissions! |
|
101 |
+ isAllowedTo('report_any'); |
|
102 |
+ |
|
103 |
+ // Make sure they aren't spamming. |
|
104 |
+ spamProtection('reporttm'); |
|
105 |
+ |
|
106 |
+ require_once($sourcedir . '/Subs-Post.php'); |
|
107 |
+ |
|
108 |
+ // No errors, yet. |
|
109 |
+ $post_errors = array(); |
|
110 |
+ |
|
111 |
+ // Check their session. |
|
112 |
+ if (checkSession('post', '', false) != '') |
|
113 |
+ $post_errors[] = 'session_timeout'; |
|
114 |
+ |
|
115 |
+ // Make sure we have a comment and it's clean. |
|
116 |
+ if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') |
|
117 |
+ $post_errors[] = 'no_comment'; |
|
118 |
+ |
|
119 |
+ $poster_comment = $smcFunc['htmlspecialchars'](!empty($_POST['comment']) ? $_POST['comment'] : '', ENT_QUOTES); |
|
120 |
+ |
|
121 |
+ // Guests need to provide their address! |
|
122 |
+ if ($user_info['is_guest']) |
|
123 |
+ { |
|
124 |
+ $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
|
125 |
+ if ($_POST['email'] === '') |
|
126 |
+ $post_errors[] = 'no_email'; |
|
127 |
+ elseif (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_POST['email']) == 0) |
|
128 |
+ $post_errors[] = 'bad_email'; |
|
129 |
+ |
|
130 |
+ isBannedEmail($_POST['email'], 'cannot_post', sprintf($txt['you_are_post_banned'], $txt['guest_title'])); |
|
131 |
+ |
|
132 |
+ $user_info['email'] = htmlspecialchars($_POST['email']); |
|
133 |
+ } |
|
134 |
+ |
|
135 |
+ // Could they get the right verification code? |
|
136 |
+ if ($user_info['is_guest'] && !empty($modSettings['guests_report_require_captcha'])) |
|
137 |
+ { |
|
138 |
+ require_once($sourcedir . '/Subs-Editor.php'); |
|
139 |
+ $verificationOptions = array( |
|
140 |
+ 'id' => 'report', |
|
141 |
+ ); |
|
142 |
+ $context['require_verification'] = create_control_verification($verificationOptions, true); |
|
143 |
+ if (is_array($context['require_verification'])) |
|
144 |
+ $post_errors = array_merge($post_errors, $context['require_verification']); |
|
145 |
+ } |
|
146 |
+ |
|
147 |
+ // Any errors? |
|
148 |
+ if (!empty($post_errors)) |
|
149 |
+ { |
|
150 |
+ loadLanguage('Errors'); |
|
151 |
+ |
|
152 |
+ $context['post_errors'] = array(); |
|
153 |
+ foreach ($post_errors as $post_error) |
|
154 |
+ $context['post_errors'][] = $txt['error_' . $post_error]; |
|
155 |
+ |
|
156 |
+ return shd_report_to_helpdesk(); |
|
157 |
+ } |
|
158 |
+ |
|
159 |
+ // Get the basic topic information, and make sure they can see it. |
|
160 |
+ $_POST['msg'] = (int) $_POST['msg']; |
|
161 |
+ |
|
162 |
+ $request = $smcFunc['db_query']('', ' |
|
163 |
+ SELECT m.id_topic, m.id_board, m.subject, m.body, m.id_member AS id_poster, m.poster_name, IFNULL(mem.real_name, {string:guest}) AS real_name |
|
164 |
+ FROM {db_prefix}messages AS m |
|
165 |
+ LEFT JOIN {db_prefix}members AS mem ON (m.id_member = mem.id_member) |
|
166 |
+ WHERE m.id_msg = {int:id_msg} |
|
167 |
+ AND m.id_topic = {int:current_topic} |
|
168 |
+ LIMIT 1', |
|
169 |
+ array( |
|
170 |
+ 'current_topic' => $topic, |
|
171 |
+ 'id_msg' => $_POST['msg'], |
|
172 |
+ 'guest' => $txt['guest_title'], |
|
173 |
+ ) |
|
174 |
+ ); |
|
175 |
+ if ($smcFunc['db_num_rows']($request) == 0) |
|
176 |
+ fatal_lang_error('no_board', false); |
|
177 |
+ $message = $smcFunc['db_fetch_assoc']($request); |
|
178 |
+ $smcFunc['db_free_result']($request); |
|
179 |
+ |
|
180 |
+ $poster_name = un_htmlspecialchars($message['real_name']) . ($message['real_name'] != $message['poster_name'] ? ' (' . $message['poster_name'] . ')' : ''); |
|
181 |
+ $reporterName = un_htmlspecialchars($user_info['name']) . ($user_info['name'] != $user_info['username'] && $user_info['username'] != '' ? ' (' . $user_info['username'] . ')' : ''); |
|
182 |
+ $subject = un_htmlspecialchars($message['subject']); |
|
183 |
+ |
|
184 |
+ // OK, so we're about to make this one. Get everything we need, including forum's default language version of our nice strings. |
|
185 |
+ shd_load_language('SDPluginReportToHelpdesk', $language); |
|
186 |
+ require_once($sourcedir . '/sd_source/Subs-SimpleDeskPost.php'); |
|
187 |
+ |
|
188 |
+ $replacements = array( |
|
189 |
+ '{subject}' => $subject, |
|
190 |
+ '{author}' => $poster_name, |
|
191 |
+ '{reporter}' => $reporterName, |
|
192 |
+ '{comment}' => $poster_comment, |
|
193 |
+ ); |
|
194 |
+ $body = str_replace(array_keys($replacements), array_values($replacements), $txt['reported_body']); |
|
195 |
+ preparsecode($body); |
|
196 |
+ $body = str_replace('{body}', $message['body'], $body); |
|
197 |
+ |
|
198 |
+ $msgOptions = array( |
|
199 |
+ 'id' => 0, |
|
200 |
+ 'body' => $body, |
|
201 |
+ 'smileys_enabled' => false, |
|
202 |
+ ); |
|
203 |
+ $ticketOptions = array( |
|
204 |
+ 'id' => 0, |
|
205 |
+ 'mark_as_read' => true, |
|
206 |
+ 'subject' => $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($txt['reported_post'] . ': ' . $subject)), |
|
207 |
+ 'private' => false, |
|
208 |
+ 'status' => TICKET_STATUS_NEW, |
|
209 |
+ 'urgency' => TICKET_URGENCY_LOW, |
|
210 |
+ 'assigned' => 0, |
|
211 |
+ ); |
|
212 |
+ $posterOptions = array( |
|
213 |
+ 'id' => $user_info['id'], |
|
214 |
+ 'name' => $user_info['name'], |
|
215 |
+ 'email' => $user_info['email'], |
|
216 |
+ 'ip' => $user_info['ip'], |
|
217 |
+ ); |
|
218 |
+ |
|
219 |
+ shd_create_ticket_post($msgOptions, $ticketOptions, $posterOptions); |
|
220 |
+ shd_clear_active_tickets(); |
|
221 |
+ |
|
222 |
+ // Update our nice ticket store with the ticket id |
|
223 |
+ $context['ticket_id'] = $ticketOptions['id']; |
|
224 |
+ $context['ticket_form']['ticket'] = $ticketOptions['id']; |
|
225 |
+ |
|
226 |
+ // Handle notifications |
|
227 |
+ require_once($sourcedir . '/sd_source/SimpleDesk-Notifications.php'); |
|
228 |
+ shd_notifications_notify_newticket($msgOptions, $ticketOptions, $posterOptions); |
|
229 |
+ |
|
230 |
+ // Back to the post we reported! |
|
231 |
+ redirectexit('reportsent;topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
232 |
+} |
|
233 |
+ |
|
234 |
+?> |
|
0 | 235 |
\ No newline at end of file |
... | ... |
@@ -0,0 +1,76 @@ |
1 |
+<?php |
|
2 |
+########################################################### |
|
3 |
+# Simple Desk Project - www.simpledesk.net # |
|
4 |
+########################################################### |
|
5 |
+# An advanced help desk modifcation built on SMF # |
|
6 |
+########################################################### |
|
7 |
+# # |
|
8 |
+# * Copyright 2010 - SimpleDesk.net # |
|
9 |
+# # |
|
10 |
+# This file and its contents are subject to the license # |
|
11 |
+# included with this distribution, license.txt, which # |
|
12 |
+# states that this software is New BSD Licensed. # |
|
13 |
+# Any questions, please contact SimpleDesk.net # |
|
14 |
+# # |
|
15 |
+########################################################### |
|
16 |
+# SimpleDesk Version: 1.0 Felidae # |
|
17 |
+# File Info: index.php / 1.0 Felidae # |
|
18 |
+########################################################### |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * @package plugin-emailnotifications |
|
22 |
+ * @since 1.1 |
|
23 |
+*/ |
|
24 |
+ |
|
25 |
+if (!defined('SHD_VERSION')) |
|
26 |
+ die('Hacking attempt...'); |
|
27 |
+ |
|
28 |
+/* |
|
29 |
+ * Return information about this plugin. |
|
30 |
+ * |
|
31 |
+ * details |
|
32 |
+ * - name: a $txt reference for the plugin's name (so it can be translated), if not present as a $txt will be used as a literal. (Note, see includes - language below) |
|
33 |
+ * - description: a $txt reference one line description of the mod (translatable) - if not present, it will be used as a literal. |
|
34 |
+ * - author: Author's name, literal |
|
35 |
+ * - website: Website to link back to the author |
|
36 |
+ * - version: Plugin version |
|
37 |
+ * - compatibility: Array of supported SD version-strings |
|
38 |
+ * |
|
39 |
+ * includes |
|
40 |
+ * - source: a key-value pair array of file names to include at strategic points, key name is the point to include it on, value is a filename or array of filenames to include within the plugin's dir |
|
41 |
+ * - language: a key-value pair of array of language files to include, much like source. |
|
42 |
+ * |
|
43 |
+ * hooks |
|
44 |
+ * - key-value pair of hook name to function name or array of function names to be called at the hook point |
|
45 |
+ * |
|
46 |
+ * @since 1.1 |
|
47 |
+*/ |
|
48 |
+function shdplugin_report_to_helpdesk() |
|
49 |
+{ |
|
50 |
+ return array( |
|
51 |
+ 'details' => array( // general plugin details |
|
52 |
+ 'title' => 'shdp_report_to_helpdesk', |
|
53 |
+ 'description' => 'shdp_report_to_helpdesk_desc', |
|
54 |
+ 'author' => 'SimpleDesk Team', |
|
55 |
+ 'website' => 'http://www.simpledesk.net/', |
|
56 |
+ 'version' => '1.0', |
|
57 |
+ 'compatibility' => array( |
|
58 |
+ 'SimpleDesk 1.0 Felidae', // should tie up with the SHD_VERSION constants |
|
59 |
+ ), |
|
60 |
+ ), |
|
61 |
+ 'includes' => array( |
|
62 |
+ 'source' => array( |
|
63 |
+ 'init' => 'SDPluginReportToHelpdesk.php', |
|
64 |
+ ), |
|
65 |
+ 'language' => array( |
|
66 |
+ 'hdadmin' => 'SDPluginReportToHelpdesk', |
|
67 |
+ ), |
|
68 |
+ ), |
|
69 |
+ 'hooks' => array( // what functions to call when |
|
70 |
+ 'actions' => 'shd_report_to_helpdesk_actions', |
|
71 |
+ ), |
|
72 |
+ ); |
|
73 |
+} |
|
74 |
+ |
|
75 |
+ |
|
76 |
+?> |
|
0 | 77 |
\ No newline at end of file |
1 | 78 |