+ It is now possible to configure the number of leading zeroes in ticket ids, meaning you can have no leading zeroes if you like. Upon installing, the number will be set to 0, you can configure this in Admin / Helpdesk / Helpdesk Options / Display Options.
gruffen

gruffen commited on 2011-05-27 02:35:14
Showing 11 changed files, with 30 additions and 15 deletions.

... ...
@@ -83,6 +83,7 @@ if (empty($modSettings['shd_attachments_mode']))
83 83
 		'shd_thank_you_post' => 1,
84 84
 		'shd_theme' => 0,
85 85
 		'shd_hidemenuitem' => 0,
86
+		'shd_zerofill' => 5,
86 87
 	);
87 88
 }
88 89
 // shd_disable_tickettotopic, shd_maintenance_mode should not be added because it's empty by default!
... ...
@@ -145,6 +145,8 @@ $txt['shd_hidemenuitem'] = 'Hide the Helpdesk menu item?';
145 145
 $txt['shd_hidemenuitem_note'] = 'This is most useful if helpdesk departments are presented on the board index.';
146 146
 $txt['shd_disable_unread'] = 'Disable integration with Unread Posts/Unread Replies';
147 147
 $txt['shd_disable_unread_note'] = 'Normally, SimpleDesk adds a list of topics to the unread posts/unread replies page but sometimes (e.g. certain mobile themes) this does not always work so well.';
148
+$txt['shd_zerofill'] = 'Smallest number of digits to use';
149
+$txt['shd_zerofill_note'] = 'Ticket numbers are normally expressed like 00001, this would be 5 digits, and ticket 100000 would have no extra digits. You can use 0 to not have any leading zeroes if you like.';
148 150
 //@}
149 151
 
150 152
 //! @name Configuration items on the Posting Options page
... ...
@@ -333,6 +333,9 @@ function shd_admin_options($return_config)
333 333
  *			<li>smf: use an SMF style button-strip above the ticket menu</li>
334 334
  *		</ul>
335 335
  *	</li>
336
+ *	<li>'shd_theme' (dropdown) - selects the theme id to be used in the helpdesk, or 0 for the forum default</li>
337
+ *	<li>'shd_hidemenuitem' (checkbox) - whether to show or hide the menu item, typically used with multiple departments</li>
338
+ *	<li>'shd_disable_unread' (checkbox) - if checked, the integration of outstanding helpdesk tickets into the unread page is disabled</li>
336 339
  *
337 340
  *	@param bool $return_config Whether to return configuration items or not; this is provided solely for SMF ACP compatibility (it expects to pass bool true in to get a list of options)
338 341
  *
... ...
@@ -368,6 +371,7 @@ function shd_modify_display_options($return_config)
368 371
 		array('check', 'shd_display_avatar'),
369 372
 		array('select', 'shd_ticketnav_style', array('sd' => $txt['shd_ticketnav_style_sd'], 'sdcompact' => $txt['shd_ticketnav_style_sdcompact'], 'smf' => $txt['shd_ticketnav_style_smf']), 'subtext' => $txt['shd_ticketnav_style_note']),
370 373
 		array('select', 'shd_theme', $theme_list, 'subtext' => $txt['shd_theme_note']),
374
+		array('int', 'shd_zerofill', 'subtext' => $txt['shd_zerofill_note']),
371 375
 		'',
372 376
 		array('check', 'shd_hidemenuitem'),
373 377
 		'',
... ...
@@ -137,7 +137,7 @@ function shd_view_ticket()
137 137
 		'id' => $context['ticket_id'],
138 138
 		'dept' => $ticketinfo['dept'],
139 139
 		'dept_name' => $ticketinfo['dept_name'],
140
-		'display_id' => str_pad($context['ticket_id'], 5, '0', STR_PAD_LEFT),
140
+		'display_id' => str_pad($context['ticket_id'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
141 141
 		'subject' => $ticketinfo['subject'],
142 142
 		'first_msg' => $ticketinfo['id_first_msg'],
143 143
 		'body' => shd_format_text($ticketinfo['body'], $ticketinfo['smileys_enabled'], 'shd_reply_' . $ticketinfo['id_first_msg']),
... ...
@@ -1219,7 +1219,7 @@ function shd_attach_icon($filename)
1219 1219
 */
1220 1220
 function shd_load_relationships($ticket = 0)
1221 1221
 {
1222
-	global $context, $smcFunc, $txt;
1222
+	global $context, $smcFunc, $txt, $modSettings;
1223 1223
 
1224 1224
 	if ($ticket == 0)
1225 1225
 		$ticket = $context['ticket_id'];
... ...
@@ -1251,7 +1251,7 @@ function shd_load_relationships($ticket = 0)
1251 1251
 		$context['relationships_count']++;
1252 1252
 		$context['ticket_relationships'][$reltypes[$row['rel_type']]][] = array(
1253 1253
 			'id' => $row['id_ticket'],
1254
-			'display_id' => str_pad($row['id_ticket'], 5, '0', STR_PAD_LEFT),
1254
+			'display_id' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
1255 1255
 			'subject' => $row['subject'],
1256 1256
 			'status' => $row['status'],
1257 1257
 			'status_txt' => $txt['shd_status_' . $row['status']],
... ...
@@ -331,7 +331,7 @@ function shd_notify_users($notify_data)
331 331
 
332 332
 	// So, at this point, we have our list of language files to load so we can minimise the amount of actual work going on, and let's get ready
333 333
 	$replacements = array(
334
-		'{ticket_id}' => str_pad($notify_data['ticket'], 5, '0', STR_PAD_LEFT),
334
+		'{ticket_id}' => str_pad($notify_data['ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
335 335
 		'{subject}' => $notify_data['subject'],
336 336
 		'{ticketlink}' => $notify_data['ticketlink'],
337 337
 	);
... ...
@@ -518,7 +518,7 @@ function shd_notify_popup()
518 518
 
519 519
 	$replacements = array(
520 520
 		"\n" => '<br />',
521
-		'{ticket_id}' => str_pad($row['id_ticket'], 5, '0', STR_PAD_LEFT),
521
+		'{ticket_id}' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
522 522
 		'{subject}' => empty($row['extra']['subject']) ? $txt['no_subject'] : $row['extra']['subject'],
523 523
 		'{ticketlink}' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . (empty($row['id_msg']) ? '.0' : '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']),
524 524
 		'{body}' => empty($row['extra']['withbody']) || empty($row['body']) ? '' : strip_tags(shd_format_text($row['body'])),
... ...
@@ -34,7 +34,7 @@ if (!defined('SMF'))
34 34
 */
35 35
 function shd_post_ticket()
36 36
 {
37
-	global $context, $user_info, $sourcedir, $txt, $scripturl, $reply_request, $smcFunc, $options, $memberContext, $new_ticket;
37
+	global $context, $user_info, $sourcedir, $txt, $scripturl, $reply_request, $smcFunc, $options, $memberContext, $new_ticket, $modSettings;
38 38
 	$context['tabindex'] = 1;
39 39
 
40 40
 	$new_ticket = $_REQUEST['sa'] == 'newticket';
... ...
@@ -73,7 +73,7 @@ function shd_post_ticket()
73 73
 		'ticket' => $new_ticket ? 0 : $context['ticket_id'],
74 74
 		'link' => $new_ticket ? '' : '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id'] . '">' . $ticketinfo['subject'] . '</a>',
75 75
 		'msg' => $new_ticket ? 0 : $ticketinfo['id_first_msg'],
76
-		'display_id' => $new_ticket ? '' : str_pad($context['ticket_id'], 5, '0', STR_PAD_LEFT),
76
+		'display_id' => $new_ticket ? '' : str_pad($context['ticket_id'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
77 77
 		'status' => $new_ticket ? TICKET_STATUS_NEW : $ticketinfo['status'],
78 78
 		'urgency' => array(
79 79
 			'setting' => $new_ticket ? TICKET_URGENCY_LOW : $ticketinfo['urgency'],
... ...
@@ -353,7 +353,7 @@ function shd_save_ticket()
353 353
 		'ticket' => $context['ticket_id'],
354 354
 		'link' => $new_ticket ? '' : '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id'] . '">' . $ticketinfo['subject'] . '</a>',
355 355
 		'msg' => $msg,
356
-		'display_id' => empty($context['ticket_id']) ? '' : str_pad($context['ticket_id'], 5, '0', STR_PAD_LEFT),
356
+		'display_id' => empty($context['ticket_id']) ? '' : str_pad($context['ticket_id'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
357 357
 		'status' => $new_status,
358 358
 		'private' => array(
359 359
 			'setting' => $private,
... ...
@@ -756,7 +756,7 @@ function shd_post_reply()
756 756
 		'msg' => !empty($reply['id_msg']) ? $reply['id_msg'] : 0,
757 757
 		'ticket_link' => '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id'] . '">' . $ticketinfo['subject'] . '</a>',
758 758
 		'reply_link' => $new_reply ? 0 : '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id'] . '.msg' . $reply['id_msg'] . '#msg' . $reply['id_msg'] . '">' . $txt['response_prefix'] . ' ' . $ticketinfo['subject'] . '</a>',
759
-		'display_id' => str_pad($context['ticket_id'], 5, '0', STR_PAD_LEFT),
759
+		'display_id' => str_pad($context['ticket_id'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
760 760
 		'status' => $ticketinfo['status'],
761 761
 		'urgency' => array(
762 762
 			'setting' => $ticketinfo['urgency'],
... ...
@@ -982,7 +982,7 @@ function shd_save_reply()
982 982
 		'subject' => $ticketinfo['subject'],
983 983
 		'ticket' => $context['ticket_id'],
984 984
 		'msg' => $_REQUEST['msg'],
985
-		'display_id' => str_pad($context['ticket_id'], 5, '0', STR_PAD_LEFT),
985
+		'display_id' => str_pad($context['ticket_id'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
986 986
 		'urgency' => array(
987 987
 			'setting' => $ticketinfo['urgency'],
988 988
 		),
... ...
@@ -163,7 +163,7 @@ function ssi_staffTicketsUrgency($urgency, $limit = 10, $output_method = 'echo')
163 163
 */
164 164
 function ssi_getSDTickets($query_where, $query_where_params = array(), $query_limit = 0, $query_order = 'hdt.id_ticket ASC', $output_method = 'echo')
165 165
 {
166
-	global $smcFunc, $scripturl, $txt;
166
+	global $smcFunc, $scripturl, $txt, $modSettings;
167 167
 
168 168
 	$query_limit = (int) $query_limit;
169 169
 
... ...
@@ -193,7 +193,7 @@ function ssi_getSDTickets($query_where, $query_where_params = array(), $query_li
193 193
 
194 194
 		$tickets[] = array(
195 195
 			'id' => $row['id_ticket'],
196
-			'display_id' => str_pad($row['id_ticket'], 5, '0', STR_PAD_LEFT),
196
+			'display_id' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
197 197
 			'subject' => $row['subject'],
198 198
 			'short_subject' => shorten_subject($row['subject'], 25),
199 199
 			'href' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'],
... ...
@@ -93,7 +93,7 @@ function shd_unread_posts()
93 93
 			$members = array();
94 94
 			while ($row = $smcFunc['db_fetch_assoc']($request))
95 95
 			{
96
-				$row['id_ticket_display'] = str_pad($row['id_ticket'], 5, '0', STR_PAD_LEFT);
96
+				$row['id_ticket_display'] = str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT);
97 97
 				$row['updated'] = timeformat($row['last_updated']);
98 98
 				$context['shd_unread_info'][] = $row;
99 99
 				if ($row['id_member_started'] != 0)
... ...
@@ -934,7 +934,7 @@ function shd_helpdesk_listing()
934 934
 
935 935
 			$new_block = array(
936 936
 				'id' => $row['id_ticket'],
937
-				'display_id' => str_pad($row['id_ticket'], 5, '0', STR_PAD_LEFT),
937
+				'display_id' => str_pad($row['id_ticket'], $modSettings['shd_zerofill'], '0', STR_PAD_LEFT),
938 938
 				'dept_link' => empty($context['shd_department']) && $context['shd_multi_dept'] ? '[<a href="' . $scripturl . '?' . $context['shd_home'] . ';dept=' . $row['id_dept'] . '">' . $row['dept_name'] . '</a>] ' : '',
939 939
 				'link' => '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . ($_REQUEST['sa'] == 'recyclebin' ? ';recycle' : '') . '">' . $row['subject'] . '</a>',
940 940
 				'subject' => $row['subject'],
... ...
@@ -72,11 +72,13 @@ function shd_init()
72 72
 	define('MSG_STATUS_NORMAL', 0);
73 73
 	define('MSG_STATUS_DELETED', 1);
74 74
 
75
+	// Relationship types
75 76
 	define('RELATIONSHIP_LINKED', 0);
76 77
 	define('RELATIONSHIP_DUPLICATED', 1);
77 78
 	define('RELATIONSHIP_ISPARENT', 2);
78 79
 	define('RELATIONSHIP_ISCHILD', 3);
79 80
 
81
+	// Custom fields, their types, positions, content type
80 82
 	define('CFIELD_TICKET', 1);
81 83
 	define('CFIELD_REPLY', 2);
82 84
 
... ...
@@ -94,6 +96,7 @@ function shd_init()
94 96
 	define('CFIELD_TYPE_RADIO', 7);
95 97
 	define('CFIELD_TYPE_MULTI', 8);
96 98
 
99
+	// Roles and permissions
97 100
 	define('ROLE_USER', 1);
98 101
 	define('ROLE_STAFF', 2);
99 102
 	//define('ROLE_SUPERVISOR', 3);
... ...
@@ -103,6 +106,10 @@ function shd_init()
103 106
 	define('ROLEPERM_ALLOW', 1);
104 107
 	define('ROLEPERM_DENY', 2);
105 108
 
109
+	// How many digits should we show for ticket numbers? Normally we pad to 5 digits, e.g. 00001 - this is how we set that width.
110
+	if (empty($modSettings['shd_zerofill']) || $modSettings['shd_zerofill'] < 0)
111
+		$modSettings['shd_zerofill'] = 0;
112
+
106 113
 	// Load some stuff
107 114
 	shd_load_language('sd_language/SimpleDesk');
108 115
 	require($sourcedir . '/sd_source/Subs-SimpleDeskPermissions.php');
... ...
@@ -861,7 +868,7 @@ function shd_format_text($text, $smileys = true, $cache = '')
861 868
 		{
862 869
 			$id = (int) $matches[$i][1];
863 870
 			if (!empty($wikilinks[$id]))
864
-				$replacements[$matches[$i][0]] = '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $id . '.0">[' . str_pad($id, 5, '0', STR_PAD_LEFT) . '] ' . $wikilinks[$id] . '</a>';
871
+				$replacements[$matches[$i][0]] = '<a href="' . $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $id . '.0">[' . str_pad($id, $modSettings['shd_zerofill'], '0', STR_PAD_LEFT) . '] ' . $wikilinks[$id] . '</a>';
865 872
 		}
866 873
 
867 874
 		$text = str_replace(array_keys($replacements), array_values($replacements), $text);
... ...
@@ -87,6 +87,7 @@ $to_remove = array(
87 87
 	'shd_thank_you_nonstaff',
88 88
 	'shd_theme',
89 89
 	'shd_disable_unread',
90
+	'shd_zerofill',
90 91
 	// Board integration
91 92
 	'shd_hidemenuitem',
92 93
 	// Email notifications
93 94