[Report to Helpdesk] Add department support for posting reports. [Feature 571]
gruffen

gruffen commited on 2011-05-24 10:48:08
Showing 4 changed files, with 61 additions and 1 deletions.

... ...
@@ -27,4 +27,8 @@ $txt['reported_post'] = 'Reported post';
27 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 28
 
29 29
 $txt['report_to_mod_func'] = 'Use this function to inform the moderators and administrators of an abusive or wrongly posted message.';
30
+
31
+$txt['report_normally'] = 'Do not direct reports to the helpdesk';
32
+$txt['report_posts_dept'] = 'Where should reported posts end up?';
33
+$txt['report_pms_dept'] = 'Where should reported private messages end up?';
30 34
 ?>
31 35
\ No newline at end of file
... ...
@@ -30,11 +30,12 @@ if (!defined('SMF'))
30 30
 // Deal with the action
31 31
 function shd_report_to_helpdesk_actions(&$actionArray)
32 32
 {
33
-	global $context;
33
+	global $context, $modSettings;
34 34
 
35 35
 	if (!in_array('report_to_helpdesk', $context['shd_plugins']))
36 36
 		return;
37 37
 
38
+	if (!empty($modSettings['report_posts_dept']))
38 39
 		$actionArray['reporttm'] = array('sd_plugins_source/report_to_helpdesk/SDPluginReportToHelpdeskMain.php', 'shd_report_to_helpdesk');
39 40
 }
40 41
 
... ...
@@ -208,6 +208,7 @@ function shd_report_to_helpdesk2()
208 208
 		'status' => TICKET_STATUS_NEW,
209 209
 		'urgency' => TICKET_URGENCY_LOW,
210 210
 		'assigned' => 0,
211
+		'dept' => $modSettings['report_posts_dept'],
211 212
 	);
212 213
 	$posterOptions = array(
213 214
 		'id' => $user_info['id'],
... ...
@@ -231,4 +232,55 @@ function shd_report_to_helpdesk2()
231 232
 	redirectexit('reportsent;topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']);
232 233
 }
233 234
 
235
+function shd_report_to_helpdesk_options($return_config)
236
+{
237
+	global $context, $modSettings, $txt, $sourcedir, $smcFunc;
238
+
239
+	$dept_list = array(
240
+		0 => $txt['report_normally'],
241
+	);
242
+	$query = $smcFunc['db_query']('', '
243
+		SELECT id_dept, dept_name
244
+		FROM {db_prefix}helpdesk_depts
245
+		ORDER BY dept_order');
246
+	while ($row = $smcFunc['db_fetch_assoc']($query))
247
+		$dept_list[$row['id_dept']] = $row['dept_name'];
248
+	$smcFunc['db_free_result']($query);
249
+
250
+	$config_vars = array(
251
+		array('select', 'report_posts_dept', $dept_list),
252
+		'',
253
+		//array('select', 'report_pms_dept', $dept_list),
254
+	);
255
+	$context['settings_title'] = $txt['shdp_report_to_helpdesk'];
256
+	$context['settings_icon'] = 'warning.png';
257
+
258
+	return $config_vars;
259
+}
260
+
261
+function shd_report_to_helpdesk_adminmenu(&$admin_areas)
262
+{
263
+	global $context, $modSettings, $txt;
264
+
265
+	// Enabled?
266
+	if (!in_array('report_to_helpdesk', $context['shd_plugins']))
267
+		return;
268
+
269
+	$admin_areas['helpdesk_info']['areas']['helpdesk_options']['subsections']['report_to_helpdesk'] = array($txt['shdp_report_to_helpdesk']);
270
+}
271
+
272
+function shd_report_to_helpdesk_hdadminopts()
273
+{
274
+	global $context, $modSettings, $txt;
275
+
276
+	// Enabled?
277
+	if (!in_array('report_to_helpdesk', $context['shd_plugins']))
278
+		return;
279
+
280
+	$context[$context['admin_menu_name']]['tab_data']['tabs']['report_to_helpdesk'] = array(
281
+		'description' => $txt['shdp_report_to_helpdesk_desc'],
282
+		'function' => 'shd_report_to_helpdesk_options',
283
+	);
284
+}
285
+
234 286
 ?>
235 287
\ No newline at end of file
... ...
@@ -61,6 +61,7 @@ function shdplugin_report_to_helpdesk()
61 61
 		'includes' => array(
62 62
 			'source' => array(
63 63
 				'init' => 'SDPluginReportToHelpdesk.php',
64
+				'hdadmin' => 'SDPluginReportToHelpdeskMain.php',
64 65
 			),
65 66
 			'language' => array(
66 67
 				'hdadmin' => 'SDPluginReportToHelpdesk',
... ...
@@ -68,6 +69,8 @@ function shdplugin_report_to_helpdesk()
68 69
 		),
69 70
 		'hooks' => array( // what functions to call when
70 71
 			'actions' => 'shd_report_to_helpdesk_actions',
72
+			'hdadminopts' => 'shd_report_to_helpdesk_hdadminopts',
73
+			'adminmenu' => 'shd_report_to_helpdesk_adminmenu',
71 74
 		),
72 75
 	);
73 76
 }
74 77