gruffen commited on 2011-04-13 07:23:08
Showing 15 changed files, with 359 additions and 5 deletions.
... | ... |
@@ -67,14 +67,16 @@ if (empty($modSettings['shd_attachments_mode'])) |
67 | 67 |
'shd_allow_wikilinks' => 1, |
68 | 68 |
'shd_display_ticket_logs' => 1, |
69 | 69 |
'shd_logopt_resolve' => 1, |
70 |
+ 'shd_logopt_autoclose' => 1, |
|
70 | 71 |
'shd_logopt_assign' => 1, |
71 | 72 |
'shd_logopt_privacy' => 1, |
72 | 73 |
'shd_logopt_urgency' => 1, |
73 | 74 |
'shd_logopt_tickettopicmove' => 1, |
74 |
- 'shd_logopt_cfchange' => 1, |
|
75 |
+ 'shd_logopt_cfchanges' => 1, |
|
75 | 76 |
'shd_logopt_delete' => 1, |
76 | 77 |
'shd_logopt_restore' => 1, |
77 | 78 |
'shd_logopt_permadelete' => 1, |
79 |
+ 'shd_logopt_move_dept' => 1, |
|
78 | 80 |
'shd_logopt_relationships' => 1, |
79 | 81 |
'shd_logopt_newposts' => 1, |
80 | 82 |
'shd_logopt_editposts' => 1, |
... | ... |
@@ -153,6 +153,8 @@ $txt['shd_split_no_pm'] = 'You must enter a reason for splitting the ticket to s |
153 | 153 |
$txt['shd_relationships_are_disabled'] = 'Ticket relationships are currently disabled.'; |
154 | 154 |
$txt['error_invalid_fields'] = 'The following fields have values that cannot be used: %1$s'; |
155 | 155 |
$txt['error_missing_fields'] = 'The following fields were not completed and need to be: %1$s'; |
156 |
+$txt['shd_cannot_move_dept'] = 'You cannot move this ticket, there is nowhere to move it to.'; |
|
157 |
+$txt['shd_no_perm_move_dept'] = 'You are not permitted to move this ticket to another department.'; |
|
156 | 158 |
|
157 | 159 |
// The main Helpdesk. |
158 | 160 |
$txt['shd_home'] = 'Helpdesk'; // separate string in case someone wants to change it independently of the main/admin menu |
... | ... |
@@ -234,7 +236,7 @@ $txt['shd_ticket_quote'] = 'Reply with quote'; |
234 | 236 |
$txt['shd_go_advanced'] = 'Go advanced!'; |
235 | 237 |
$txt['shd_ticket_edit_reply'] = 'Edit reply'; |
236 | 238 |
$txt['shd_ticket_quote_short'] = 'Quote'; |
237 |
-$txt['shd_ticket_markunread'] = 'Mark as unread'; |
|
239 |
+$txt['shd_ticket_markunread'] = 'Mark unread'; |
|
238 | 240 |
$txt['shd_ticket_reply_short'] = 'Reply'; |
239 | 241 |
$txt['shd_ticket_edit'] = 'Edit'; |
240 | 242 |
$txt['shd_ticket_resolved'] = 'Mark resolved'; |
... | ... |
@@ -250,6 +252,7 @@ $txt['shd_ticket_restore'] = 'Restore'; |
250 | 252 |
$txt['shd_delete_permanently'] = 'Delete permanently'; |
251 | 253 |
$txt['shd_delete_permanently_confirm'] = 'Are you sure you want to permanently delete this ticket? This CAN NOT be undone!'; |
252 | 254 |
$txt['shd_ticket_move_to_topic'] = 'Move to topic'; |
255 |
+$txt['shd_move_dept'] = 'Move dept.'; |
|
253 | 256 |
$txt['shd_actions'] = 'Actions'; |
254 | 257 |
$txt['shd_back_to_ticket'] = 'Return to this ticket after posting'; |
255 | 258 |
$txt['shd_disable_smileys_post'] = 'Turn off smileys in this post'; |
... | ... |
@@ -258,6 +261,12 @@ $txt['shd_resolve_this_ticket'] = 'Mark this ticket as resolved'; |
258 | 261 |
$txt['shd_ticket_assign_ticket'] = 'Assign Ticket'; |
259 | 262 |
$txt['shd_ticket_assign_to'] = 'Assign ticket to'; |
260 | 263 |
|
264 |
+$txt['shd_ticket_move_dept'] = 'Move Ticket to another Department'; |
|
265 |
+$txt['shd_ticket_move_to'] = 'Move to'; |
|
266 |
+$txt['shd_current_dept'] = 'Currently in department'; |
|
267 |
+$txt['shd_ticket_move'] = 'Move Ticket'; |
|
268 |
+$txt['shd_unknown_dept'] = 'The specified department does not exist.'; |
|
269 |
+ |
|
261 | 270 |
// Ticket to topic and back |
262 | 271 |
$txt['shd_new_subject'] = 'New subject'; |
263 | 272 |
$txt['shd_move_ticket_to_topic'] = 'Move ticket to topic'; |
... | ... |
@@ -197,6 +197,7 @@ $txt['shd_logopt_permadelete'] = 'Log tickets and replies being permadeleted'; |
197 | 197 |
$txt['shd_logopt_relationships'] = 'Log any changes in ticket relationships'; |
198 | 198 |
$txt['shd_logopt_split'] = 'Log splitting of a ticket into two tickets'; |
199 | 199 |
$txt['shd_logopt_autoclose'] = 'Log tickets closed automatically by the helpdesk'; |
200 |
+$txt['shd_logopt_move_dept'] = 'Log tickets being moved between two departments'; |
|
200 | 201 |
|
201 | 202 |
$txt['shd_notify_send_to'] = 'Will be sent to'; |
202 | 203 |
$txt['shd_notify_ticket_starter'] = 'the user who started the ticket (if set in their preferences)'; |
... | ... |
@@ -352,7 +353,6 @@ $txt['shd_dept_boardindex_cat'] = 'Display this department in the board index in |
352 | 353 |
$txt['shd_no_dept_name'] = 'No department name was specified.'; |
353 | 354 |
$txt['shd_no_category'] = 'The specified category does not exist. Please go back and reload the page.'; |
354 | 355 |
$txt['shd_could_not_create_dept'] = 'The department could not be created.'; |
355 |
-$txt['shd_unknown_dept'] = 'The specified department does not exist.'; |
|
356 | 356 |
$txt['shd_must_have_dept'] = 'You cannot delete the only department; one must always exist.'; |
357 | 357 |
$txt['shd_dept_not_empty'] = 'You cannot delete this category, it contains at least one ticket.'; |
358 | 358 |
$txt['shd_roles_in_dept'] = 'Roles Within This Department'; |
... | ... |
@@ -122,6 +122,7 @@ $txt['shd_log_editticket'] = '"<a href="{scripturl}?action=helpdesk;sa=tick |
122 | 122 |
$txt['shd_log_newreply'] = '<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.msg{msg}#msg{msg}">New reply</a> to "<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.0">{subject}</a>".'; |
123 | 123 |
$txt['shd_log_editreply'] = 'A <a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.msg{msg}#msg{msg}">reply</a> was edited in "<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}.0">{subject}</a>".'; |
124 | 124 |
$txt['shd_log_newticketproxy'] = '"<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>" opened on behalf of {profile_link}.'; |
125 |
+$txt['shd_log_move_dept'] = '"<a href="{scripturl}?action=helpdesk;sa=ticket;ticket={ticket}">{subject}</a>" was moved from <a href="{scripturl}?action=helpdesk;sa=main;dept={old_dept_id}">{old_dept_name}</a> to <a href="{scripturl}?action=helpdesk;sa=main;dept={new_dept_id}">{new_dept_name}</a>.'; |
|
125 | 126 |
|
126 | 127 |
$txt['shd_logpart_att_added'] = 'Files added'; |
127 | 128 |
$txt['shd_logpart_att_removed'] = 'Files removed'; |
... | ... |
@@ -215,6 +215,14 @@ $txt['permissionname_shd_view_ticket_logs_own'] = 'For own tickets'; |
215 | 215 |
$txt['permissionname_shd_view_ticket_logs_any'] = 'For any ticket'; |
216 | 216 |
//@} |
217 | 217 |
|
218 |
+//! @name Moving between departments |
|
219 |
+//@{ |
|
220 |
+$txt['permissionname_shd_move_dept'] = 'Move tickets between departments'; |
|
221 |
+$txt['permissionhelp_shd_move_dept'] = 'This permission allows the user to move a ticket from the department it is in to any other department that they can see; if they can only see one department, no option is given.'; |
|
222 |
+$txt['permissionname_shd_move_dept_no'] = 'No tickets'; |
|
223 |
+$txt['permissionname_shd_move_dept_own'] = 'Their own tickets'; |
|
224 |
+$txt['permissionname_shd_move_dept_any'] = 'Any tickets'; |
|
225 |
+ |
|
218 | 226 |
//! @name Ticket merging |
219 | 227 |
//@{ |
220 | 228 |
$txt['permissionname_shd_merge_ticket'] = 'Merge two tickets together'; |
... | ... |
@@ -537,10 +537,12 @@ function shd_modify_standalone_options($return_config) |
537 | 537 |
* <li>'shd_logopt_privacy' (checkbox) - if checked, ticket privacy changes will be logged.</li> |
538 | 538 |
* <li>'shd_logopt_urgency' (checkbox) - if checked, ticket urgency changes will be logged.</li> |
539 | 539 |
* <li>'shd_logopt_tickettopicmove' (checkbox) - if checked, ticket to topic moves and back will be logged.</li> |
540 |
+ * <li>'shd_logopt_cfchanges' (checkbox) - if checked, changes to custom fields will be logged.</li> |
|
540 | 541 |
* <li>'shd_logopt_delete' (checkbox) - if checked, ticket/reply deletions (not permadelete) will be logged.</li> |
541 | 542 |
* <li>'shd_logopt_restore' (checkbox) - if checked, ticket/reply restores will be logged.</li> |
542 | 543 |
* <li>'shd_logopt_permadelete' (checkbox) - if checked, permadeletes will be logged.</li> |
543 | 544 |
* <li>'shd_logopt_relationships' (checkbox) - if checked, ticket relationship changes will be logged.</li> |
545 |
+ * <li>'shd_logopt_move_dept' (checkbox) - if checked, ticket moves between departments will be logged.</li> |
|
544 | 546 |
* <li>'shd_logopt_split' (checkbox) - if checked, splitting a topic will be logged.</li> |
545 | 547 |
* </ul> |
546 | 548 |
* |
... | ... |
@@ -554,6 +556,8 @@ function shd_modify_actionlog_options($return_config) |
554 | 556 |
{ |
555 | 557 |
global $context, $modSettings, $txt; |
556 | 558 |
|
559 |
+ $multi_dept = shd_allowed_to('access_helpdesk', false); |
|
560 |
+ |
|
557 | 561 |
$config_vars = array( |
558 | 562 |
array('check', 'shd_disable_action_log', 'javascript' => ' onchange="javascript:switchitems();"'), |
559 | 563 |
array('check', 'shd_display_ticket_logs', 'disabled' => !empty($modSettings['shd_disable_action_log'])), |
... | ... |
@@ -575,7 +579,8 @@ function shd_modify_actionlog_options($return_config) |
575 | 579 |
array('check', 'shd_logopt_restore', 'disabled' => !empty($modSettings['shd_disable_action_log'])), |
576 | 580 |
array('check', 'shd_logopt_permadelete', 'disabled' => !empty($modSettings['shd_disable_action_log'])), |
577 | 581 |
array('check', 'shd_logopt_relationships', 'disabled' => (!empty($modSettings['shd_disable_action_log']) || !empty($modSettings['shd_disable_relationships']))), |
578 |
- array('checkall', 'shd_logopt_3', array('shd_logopt_delete', 'shd_logopt_restore', 'shd_logopt_permadelete', 'shd_logopt_relationships')), |
|
582 |
+ array('check', 'shd_logopt_move_dept', 'disabled' => !empty($modSettings['shd_disable_action_log']) && !empty($multi_dept)), |
|
583 |
+ array('checkall', 'shd_logopt_3', array('shd_logopt_delete', 'shd_logopt_restore', 'shd_logopt_permadelete', 'shd_logopt_relationships', 'shd_logopt_move_dept')), |
|
579 | 584 |
//array('check', 'shd_logopt_split', 'disabled' => !empty($modSettings['shd_disable_action_log'])), |
580 | 585 |
); |
581 | 586 |
$context['settings_title'] = $txt['shd_admin_options_actionlog']; |
... | ... |
@@ -592,6 +597,7 @@ function shd_modify_actionlog_options($return_config) |
592 | 597 |
shd_switchable_item("shd_logopt_newposts", state); |
593 | 598 |
shd_switchable_item("shd_logopt_editposts", state); |
594 | 599 |
shd_switchable_item("shd_logopt_resolve", state); |
600 |
+ shd_switchable_item("shd_logopt_autoclose", state); |
|
595 | 601 |
shd_switchable_item("shd_logopt_assign", state); |
596 | 602 |
shd_switchable_item("shd_logopt_privacy", state); |
597 | 603 |
shd_switchable_item("shd_logopt_urgency", state); |
... | ... |
@@ -601,6 +607,7 @@ function shd_modify_actionlog_options($return_config) |
601 | 607 |
shd_switchable_item("shd_logopt_restore", state); |
602 | 608 |
shd_switchable_item("shd_logopt_permadelete", state); |
603 | 609 |
shd_switchable_item("shd_logopt_relationships", state); |
610 |
+ shd_switchable_item("shd_logopt_move_dept", state); |
|
604 | 611 |
/*shd_switchable_item("shd_logopt_split", state);*/ |
605 | 612 |
}'; |
606 | 613 |
|
... | ... |
@@ -494,6 +494,7 @@ function shd_view_ticket() |
494 | 494 |
$context['page_title'] = $txt['shd_helpdesk'] . ' [' . $context['ticket']['display_id'] . '] ' . $context['ticket']['subject']; |
495 | 495 |
|
496 | 496 |
// Ticket navigation / permission |
497 |
+ $context['can_move_dept'] = !empty($context['shd_multi_dept']) && (shd_allowed_to('shd_move_dept_any', $context['ticket']['dept']) || ($context['ticket']['ticket_opener'] && shd_allowed_to('shd_move_dept_own', $context['ticket']['dept']))); |
|
497 | 498 |
$context['can_reply'] = !$context['ticket']['closed'] && !$context['ticket']['deleted'] && (shd_allowed_to('shd_reply_ticket_any', $context['ticket']['dept']) || ($context['ticket']['ticket_opener'] && shd_allowed_to('shd_reply_ticket_own', $context['ticket']['dept']))); // needs perms - calc'd here because we use it in display template too |
498 | 499 |
$context['can_quote'] = $context['can_reply'] && !empty($modSettings['shd_allow_ticket_bbc']); |
499 | 500 |
$context['can_go_advanced'] = !empty($modSettings['shd_allow_ticket_bbc']) || !empty($modSettings['allow_ticket_smileys']) || shd_allowed_to('shd_post_attachment', $context['ticket']['dept']); |
... | ... |
@@ -580,6 +581,13 @@ function shd_view_ticket() |
580 | 581 |
'text' => 'shd_delete_permanently', |
581 | 582 |
'onclick' => 'return confirm(' . JavaScriptEscape($txt['shd_delete_permanently_confirm']) . ');', |
582 | 583 |
); |
584 |
+ $context['ticket_navigation'][] = array( |
|
585 |
+ 'url' => $scripturl . '?action=helpdesk;sa=movedept;ticket=' . $context['ticket']['id'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
|
586 |
+ 'icon' => 'movedept', |
|
587 |
+ 'alt' => '*', |
|
588 |
+ 'display' => $context['can_move_dept'], |
|
589 |
+ 'text' => 'shd_move_dept', |
|
590 |
+ ); |
|
583 | 591 |
$context['ticket_navigation'][] = array( |
584 | 592 |
'url' => $scripturl . '?action=helpdesk;sa=tickettotopic;ticket=' . $context['ticket']['id'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
585 | 593 |
'icon' => 'tickettotopic', |
... | ... |
@@ -0,0 +1,213 @@ |
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-Assign.php / 1.0 Felidae # |
|
18 |
+############################################################### |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * This file handles moving tickets between departments. |
|
22 |
+ * |
|
23 |
+ * @package source |
|
24 |
+ * @since 1.1 |
|
25 |
+*/ |
|
26 |
+ |
|
27 |
+if (!defined('SMF')) |
|
28 |
+ die('Hacking attempt...'); |
|
29 |
+ |
|
30 |
+/** |
|
31 |
+ * Sets up the ticket-moving UI and invokes the template. |
|
32 |
+ * |
|
33 |
+ * This validates that the user can see the ticket in question initially, and at least one other department. |
|
34 |
+ * |
|
35 |
+ * @see shd_movedept2() |
|
36 |
+ * @since 1.1 |
|
37 |
+*/ |
|
38 |
+function shd_movedept() |
|
39 |
+{ |
|
40 |
+ global $smcFunc, $context, $user_info, $sourcedir, $txt, $scripturl; |
|
41 |
+ |
|
42 |
+ checkSession('get'); |
|
43 |
+ |
|
44 |
+ if (empty($context['ticket_id'])) |
|
45 |
+ fatal_lang_error('shd_no_ticket', false); |
|
46 |
+ |
|
47 |
+ if (empty($context['shd_multi_dept'])) |
|
48 |
+ fatal_lang_error('shd_cannot_move_dept', false); |
|
49 |
+ |
|
50 |
+ $context['shd_return_to'] = isset($_REQUEST['home']) ? 'home' : 'ticket'; |
|
51 |
+ |
|
52 |
+ // Get ticket details - and kick it out if they shouldn't be able to see it. |
|
53 |
+ $query = shd_db_query('', ' |
|
54 |
+ SELECT id_member_started, subject, hdt.id_dept, dept_name |
|
55 |
+ FROM {db_prefix}helpdesk_tickets AS hdt |
|
56 |
+ INNER JOIN {db_prefix}helpdesk_depts AS hdd ON (hdt.id_dept = hdd.id_dept) |
|
57 |
+ WHERE {query_see_ticket} AND id_ticket = {int:ticket}', |
|
58 |
+ array( |
|
59 |
+ 'ticket' => $context['ticket_id'], |
|
60 |
+ ) |
|
61 |
+ ); |
|
62 |
+ |
|
63 |
+ $log_params = array(); |
|
64 |
+ if ($row = $smcFunc['db_fetch_row']($query)) |
|
65 |
+ list($ticket_starter, $subject, $context['current_dept'], $context['current_dept_name']) = $row; |
|
66 |
+ else |
|
67 |
+ { |
|
68 |
+ $smcFunc['db_free_result']($query); |
|
69 |
+ fatal_lang_error('shd_no_ticket'); |
|
70 |
+ } |
|
71 |
+ |
|
72 |
+ $smcFunc['db_free_result']($query); |
|
73 |
+ |
|
74 |
+ if (shd_allowed_to('shd_move_dept_any', $context['current_dept']) || (shd_allowed_to('shd_move_dept_own', $context['current_dept']) && $ticket_starter == $user_info['id'])) |
|
75 |
+ { |
|
76 |
+ $visible_depts = shd_allowed_to('access_helpdesk', false); |
|
77 |
+ $context['dept_list'] = array(); |
|
78 |
+ $query = $smcFunc['db_query']('', ' |
|
79 |
+ SELECT id_dept, dept_name |
|
80 |
+ FROM {db_prefix}helpdesk_depts |
|
81 |
+ WHERE id_dept IN ({array_int:depts}) |
|
82 |
+ ORDER BY dept_order', |
|
83 |
+ array( |
|
84 |
+ 'depts' => $visible_depts, |
|
85 |
+ ) |
|
86 |
+ ); |
|
87 |
+ while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
88 |
+ $context['dept_list'][$row['id_dept']] = $row['dept_name']; |
|
89 |
+ $smcFunc['db_free_result']($query); |
|
90 |
+ |
|
91 |
+ $context['linktree'][] = array( |
|
92 |
+ 'url' => $scripturl . '?action=helpdesk;sa=main', |
|
93 |
+ 'name' => $txt['shd_linktree_tickets'], |
|
94 |
+ ); |
|
95 |
+ $context['linktree'][] = array( |
|
96 |
+ 'url' => $scripturl . '?action=helpdesk;sa=main;dept=' . $context['current_dept'], |
|
97 |
+ 'name' => $context['current_dept_name'], |
|
98 |
+ ); |
|
99 |
+ $context['linktree'][] = array( |
|
100 |
+ 'url' => $scripturl . '?action=helpdesk;sa=ticket;ticket=' . $context['ticket_id'], |
|
101 |
+ 'name' => $subject, |
|
102 |
+ ); |
|
103 |
+ $context['linktree'][] = array( |
|
104 |
+ 'name' => $txt['shd_ticket_assign_ticket'], |
|
105 |
+ ); |
|
106 |
+ |
|
107 |
+ $context['page_title'] = $txt['shd_ticket_move']; |
|
108 |
+ |
|
109 |
+ loadTemplate('sd_template/SimpleDesk-MoveDept'); |
|
110 |
+ $context['sub_template'] = 'movedept'; |
|
111 |
+ } |
|
112 |
+ else |
|
113 |
+ fatal_lang_error('shd_no_perm_move_dept', false); |
|
114 |
+} |
|
115 |
+ |
|
116 |
+/** |
|
117 |
+ * Handles the actual assignment form, validates it and carries it out. |
|
118 |
+ * |
|
119 |
+ * Primarily this is just about receiving the form, making the same checks that {@link shd_movedept()} does and then |
|
120 |
+ * logging the action before updating the database. |
|
121 |
+ * |
|
122 |
+ * @see shd_movedept() |
|
123 |
+ * @since 1.1 |
|
124 |
+*/ |
|
125 |
+function shd_movedept2() |
|
126 |
+{ |
|
127 |
+ global $context, $smcFunc, $user_info, $sourcedir; |
|
128 |
+ |
|
129 |
+ checkSession(); |
|
130 |
+ checkSubmitOnce('check'); |
|
131 |
+ |
|
132 |
+ if (empty($context['ticket_id'])) |
|
133 |
+ fatal_lang_error('shd_no_ticket', false); |
|
134 |
+ |
|
135 |
+ // Just in case, are they cancelling? |
|
136 |
+ if (isset($_REQUEST['cancel'])) |
|
137 |
+ redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']); |
|
138 |
+ |
|
139 |
+ if (empty($context['shd_multi_dept'])) |
|
140 |
+ fatal_lang_error('shd_cannot_move_dept', false); |
|
141 |
+ |
|
142 |
+ $dest = isset($_REQUEST['to_dept']) ? (int) $_REQUEST['to_dept'] : 0; |
|
143 |
+ if (empty($dest) || !shd_allowed_to('access_helpdesk', $dest)) |
|
144 |
+ fatal_lang_error('shd_cannot_move_dept', false); |
|
145 |
+ |
|
146 |
+ $context['shd_return_to'] = isset($_REQUEST['home']) ? 'home' : 'ticket'; |
|
147 |
+ |
|
148 |
+ // Get ticket details - and kick it out if they shouldn't be able to see it. |
|
149 |
+ $query = shd_db_query('', ' |
|
150 |
+ SELECT id_member_started, subject, hdt.id_dept, dept_name |
|
151 |
+ FROM {db_prefix}helpdesk_tickets AS hdt |
|
152 |
+ INNER JOIN {db_prefix}helpdesk_depts AS hdd ON (hdt.id_dept = hdd.id_dept) |
|
153 |
+ WHERE {query_see_ticket} AND id_ticket = {int:ticket}', |
|
154 |
+ array( |
|
155 |
+ 'ticket' => $context['ticket_id'], |
|
156 |
+ ) |
|
157 |
+ ); |
|
158 |
+ |
|
159 |
+ $log_params = array(); |
|
160 |
+ if ($row = $smcFunc['db_fetch_row']($query)) |
|
161 |
+ list($ticket_starter, $subject, $context['current_dept'], $context['current_dept_name']) = $row; |
|
162 |
+ else |
|
163 |
+ { |
|
164 |
+ $smcFunc['db_free_result']($query); |
|
165 |
+ fatal_lang_error('shd_no_ticket'); |
|
166 |
+ } |
|
167 |
+ |
|
168 |
+ $smcFunc['db_free_result']($query); |
|
169 |
+ |
|
170 |
+ if (shd_allowed_to('shd_move_dept_any', $context['current_dept']) || (shd_allowed_to('shd_move_dept_own', $context['current_dept']) && $ticket_starter == $user_info['id'])) |
|
171 |
+ { |
|
172 |
+ // Find the new department. We've already established the user can see it, but we need its name. |
|
173 |
+ $query = $smcFunc['db_query']('', ' |
|
174 |
+ SELECT id_dept, dept_name |
|
175 |
+ FROM {db_prefix}helpdesk_depts |
|
176 |
+ WHERE id_dept IN ({int:dest})', |
|
177 |
+ array( |
|
178 |
+ 'dest' => $dest, |
|
179 |
+ ) |
|
180 |
+ ); |
|
181 |
+ list($new_dept, $dept_name) = $smcFunc['db_fetch_row']($query); |
|
182 |
+ $smcFunc['db_free_result']($query); |
|
183 |
+ |
|
184 |
+ $log_params = array( |
|
185 |
+ 'subject' => $subject, |
|
186 |
+ 'ticket' => $context['ticket_id'], |
|
187 |
+ 'old_dept_id' => $context['current_dept'], |
|
188 |
+ 'old_dept_name' => $context['current_dept_name'], |
|
189 |
+ 'new_dept_id' => $new_dept, |
|
190 |
+ 'new_dept_name' => $dept_name, |
|
191 |
+ ); |
|
192 |
+ shd_log_action('move_dept', $log_params); |
|
193 |
+ |
|
194 |
+ $smcFunc['db_query']('', ' |
|
195 |
+ UPDATE {db_prefix}helpdesk_tickets |
|
196 |
+ SET id_dept = {int:new_dept} |
|
197 |
+ WHERE id_ticket = {int:ticket}', |
|
198 |
+ array( |
|
199 |
+ 'new_dept' => $new_dept, |
|
200 |
+ 'ticket' => $context['ticket_id'], |
|
201 |
+ ) |
|
202 |
+ ); |
|
203 |
+ |
|
204 |
+ if (!empty($context['shd_return_to']) && $context['shd_return_to'] == 'home') |
|
205 |
+ redirectexit($context['shd_home'] . ';dept=' . $new_dept); |
|
206 |
+ else |
|
207 |
+ redirectexit('action=helpdesk;sa=ticket;ticket=' . $context['ticket_id']); |
|
208 |
+ } |
|
209 |
+ else |
|
210 |
+ fatal_lang_error('shd_no_perm_move_dept', false); |
|
211 |
+} |
|
212 |
+ |
|
213 |
+?> |
|
0 | 214 |
\ No newline at end of file |
... | ... |
@@ -84,6 +84,8 @@ function shd_main() |
84 | 84 |
'markunread' => array('SimpleDesk-MiscActions.php', 'shd_ticket_unread'), |
85 | 85 |
'assign' => array('SimpleDesk-Assign.php', 'shd_assign'), |
86 | 86 |
'assign2' => array('SimpleDesk-Assign.php', 'shd_assign2'), |
87 |
+ 'movedept' => array('SimpleDesk-MoveDept.php', 'shd_movedept'), |
|
88 |
+ 'movedept2' => array('SimpleDesk-MoveDept.php', 'shd_movedept2'), |
|
87 | 89 |
'resolveticket' => array('SimpleDesk-MiscActions.php', 'shd_ticket_resolve'), |
88 | 90 |
'relation' => array('SimpleDesk-MiscActions.php', 'shd_ticket_relation'), |
89 | 91 |
'ajax' => array('SimpleDesk-AjaxHandler.php', 'shd_ajax'), |
... | ... |
@@ -856,7 +858,9 @@ function shd_helpdesk_listing() |
856 | 858 |
'is_unread' => ($row['id_last_msg'] > $row['log_read']), |
857 | 859 |
'new_href' => ($row['id_last_msg'] <= $row['log_read']) ? '' : ($scripturl . '?action=helpdesk;sa=ticket;ticket=' . $row['id_ticket'] . '.new' . ($_REQUEST['sa'] == 'recyclebin' ? ';recycle' : '') . '#new'), |
858 | 860 |
'private' => $row['private'], |
859 |
- 'actions' => array(), |
|
861 |
+ 'actions' => array( |
|
862 |
+ 'movedept' => !empty($context['shd_multi_dept']) && (shd_allowed_to('shd_move_dept_any', $context['shd_department']) || ($is_own && shd_allowed_to('shd_move_dept_own', $context['shd_department']))) ? '<a href="' . $scripturl . '?action=helpdesk;sa=movedept;ticket=' . $row['id_ticket'] . ';home;' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . $txt['shd_move_dept'] . '"><img src="' . $settings['default_images_url'] . '/simpledesk/movedept.png" alt="' . $txt['shd_move_dept'] . '" /></a>' : '', |
|
863 |
+ ), |
|
860 | 864 |
'num_replies' => $row['num_replies'], |
861 | 865 |
'all_replies' => (int) $row['num_replies'] + (int) $row['deleted_replies'], |
862 | 866 |
); |
... | ... |
@@ -354,6 +354,7 @@ function shd_log_action($action, $params) |
354 | 354 |
'cf_rplchgdef_staffadmin' => 'shd_logopt_cfchanges', |
355 | 355 |
'cf_rplchgdef_useradmin' => 'shd_logopt_cfchanges', |
356 | 356 |
'cf_rplchgdef_userstaffadmin' => 'shd_logopt_cfchanges', |
357 |
+ 'move_dept' => 'shd_logopt_move_dept', |
|
357 | 358 |
//'split_origin' => 'shd_logopt_split', |
358 | 359 |
//'split_new' => 'shd_logopt_split', |
359 | 360 |
); |
... | ... |
@@ -97,6 +97,11 @@ function shd_load_action_log_entries($start = 0, $items_per_page = 10, $sort = ' |
97 | 97 |
$exclude[] = 'cf_tktchgdef_useradmin'; |
98 | 98 |
$exclude[] = 'cf_rplchgdef_useradmin'; |
99 | 99 |
} |
100 |
+ |
|
101 |
+ // Can they see multiple departments? If not, exclude dept move notices too. |
|
102 |
+ $dept = shd_allowed_to('access_helpdesk', false); |
|
103 |
+ if (count($dept) == 1) |
|
104 |
+ $exclude[] = 'move_dept'; |
|
100 | 105 |
} |
101 | 106 |
|
102 | 107 |
if (!empty($exclude)) |
... | ... |
@@ -275,6 +279,17 @@ function shd_load_action_log_entries($start = 0, $items_per_page = 10, $sort = ' |
275 | 279 |
$actions[$k]['action_text'] = str_replace('{otherticket}', $actions[$k]['extra']['otherticket'], $actions[$k]['action_text']); |
276 | 280 |
} |
277 | 281 |
|
282 |
+ if (isset($action['extra']['old_dept_id'])) |
|
283 |
+ { |
|
284 |
+ $replace = array( |
|
285 |
+ '{old_dept_id}' => $action['extra']['old_dept_id'], |
|
286 |
+ '{old_dept_name}' => $action['extra']['old_dept_name'], |
|
287 |
+ '{new_dept_id}' => $action['extra']['new_dept_id'], |
|
288 |
+ '{new_dept_name}' => $action['extra']['new_dept_name'], |
|
289 |
+ ); |
|
290 |
+ $actions[$k]['action_text'] = str_replace(array_keys($replace), array_values($replace), $actions[$k]['action_text']); |
|
291 |
+ } |
|
292 |
+ |
|
278 | 293 |
// Custom fields? |
279 | 294 |
if (isset($action['extra']['fieldname'])) |
280 | 295 |
{ |
... | ... |
@@ -93,6 +93,7 @@ function shd_load_all_permission_sets() |
93 | 93 |
|
94 | 94 |
'shd_ticket_to_topic' => array(false, 'moderation', 'log_tickettotopic.png'), |
95 | 95 |
'shd_topic_to_ticket' => array(false, 'moderation', 'log_topictoticket.png'), |
96 |
+ 'shd_move_dept' => array(true, 'moderation', 'log_movedept.png'), |
|
96 | 97 |
//'shd_merge_ticket' => array(true, 'moderation', 'log_merge.png'), |
97 | 98 |
//'shd_split_ticket' => array(true, 'moderation', 'log_split_origin.png'), |
98 | 99 |
); |
... | ... |
@@ -178,6 +179,7 @@ function shd_load_role_templates() |
178 | 179 |
'shd_restore_reply_any' => ROLEPERM_ALLOW, |
179 | 180 |
'shd_ticket_to_topic' => ROLEPERM_ALLOW, |
180 | 181 |
'shd_topic_to_ticket' => ROLEPERM_ALLOW, |
182 |
+ 'shd_move_dept_own' => ROLEPERM_ALLOW, |
|
181 | 183 |
//'shd_merge_ticket_any' => ROLEPERM_ALLOW, |
182 | 184 |
//'shd_split_ticket_any' => ROLEPERM_ALLOW, |
183 | 185 |
), |
... | ... |
@@ -219,6 +221,7 @@ function shd_load_role_templates() |
219 | 221 |
'shd_restore_reply_any' => ROLEPERM_ALLOW, |
220 | 222 |
'shd_ticket_to_topic' => ROLEPERM_ALLOW, |
221 | 223 |
'shd_topic_to_ticket' => ROLEPERM_ALLOW, |
224 |
+ 'shd_move_dept_any' => ROLEPERM_ALLOW, |
|
222 | 225 |
//'shd_merge_ticket_any' => ROLEPERM_ALLOW, |
223 | 226 |
//'shd_split_ticket_any' => ROLEPERM_ALLOW, |
224 | 227 |
), |
... | ... |
@@ -0,0 +1,82 @@ |
1 |
+<?php |
|
2 |
+// Version: 1.0 Felidae; SimpleDesk department moving. |
|
3 |
+ |
|
4 |
+/** |
|
5 |
+ * Handles moving a ticket between departments. |
|
6 |
+ * |
|
7 |
+ * @package template |
|
8 |
+ * @since 1.0 |
|
9 |
+*/ |
|
10 |
+ |
|
11 |
+/** |
|
12 |
+ * Displays the list of possible users a ticket can have assigned. |
|
13 |
+ * |
|
14 |
+ * Will have been populated by shd_movedept() in SimpleDesk-MoveDept.php, adding into $context['dept_list']. |
|
15 |
+ * |
|
16 |
+ * @see shd_movedept() |
|
17 |
+ * @since 1.1 |
|
18 |
+*/ |
|
19 |
+function template_movedept() |
|
20 |
+{ |
|
21 |
+ global $context, $txt, $scripturl, $settings; |
|
22 |
+ |
|
23 |
+ if (empty($context['shd_return_to'])) |
|
24 |
+ $context['shd_return_to'] = 'ticket'; |
|
25 |
+ |
|
26 |
+ // Back to the helpdesk. |
|
27 |
+ echo ' |
|
28 |
+ <div class="floatleft"> |
|
29 |
+ ', template_button_strip(array($context['navigation']['back']), 'bottom'), ' |
|
30 |
+ </div><br class="clear" /><br />'; |
|
31 |
+ |
|
32 |
+ echo ' |
|
33 |
+ <div class="cat_bar grid_header"> |
|
34 |
+ <h3 class="catbg"> |
|
35 |
+ <img src="', $settings['default_images_url'], '/simpledesk/movedept.png" alt="*" /> |
|
36 |
+ ', $txt['shd_ticket_move_dept'], ' |
|
37 |
+ </h3> |
|
38 |
+ </div> |
|
39 |
+ <div class="roundframe"> |
|
40 |
+ <form action="', $scripturl, '?action=helpdesk;sa=movedept2;ticket=', $context['ticket_id'], '" method="post" onsubmit="submitonce(this);"> |
|
41 |
+ <div class="content"> |
|
42 |
+ <dl class="settings"> |
|
43 |
+ <dt> |
|
44 |
+ <strong>', $txt['shd_current_dept'], ':</strong> |
|
45 |
+ </dt> |
|
46 |
+ <dd> |
|
47 |
+ <a href="', $scripturl, '?action=helpdesk;sa=main;dept=', $context['current_dept'], '">', $context['current_dept_name'], '</a> |
|
48 |
+ </dd> |
|
49 |
+ <dt> |
|
50 |
+ <strong>', $txt['shd_ticket_move_to'], ':</strong> |
|
51 |
+ </dt> |
|
52 |
+ <dd> |
|
53 |
+ <select name="to_dept">'; |
|
54 |
+ |
|
55 |
+ foreach ($context['dept_list'] as $id => $name) |
|
56 |
+ echo ' |
|
57 |
+ <option value="', $id, '"', ($id == $context['current_dept'] ? ' selected="selected"' : ''), '>', $name, '</option>'; |
|
58 |
+ |
|
59 |
+ echo ' |
|
60 |
+ </select> |
|
61 |
+ </dd> |
|
62 |
+ <dt> |
|
63 |
+ <input type="submit" name="cancel" value="', ($context['shd_return_to'] == 'home' ? $txt['shd_cancel_home'] : $txt['shd_cancel_ticket']), '" accesskey="c" class="button_submit" /> |
|
64 |
+ </dt> |
|
65 |
+ <dd> |
|
66 |
+ <input type="submit" value="', $txt['shd_ticket_move'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" /> |
|
67 |
+ </dd> |
|
68 |
+ </dl> |
|
69 |
+ <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />'; |
|
70 |
+ |
|
71 |
+ if ($context['shd_return_to'] == 'home') |
|
72 |
+ echo ' |
|
73 |
+ <input type="hidden" name="home" value="1" />'; |
|
74 |
+ |
|
75 |
+ echo ' |
|
76 |
+ </div> |
|
77 |
+ </form> |
|
78 |
+ </div> |
|
79 |
+ <span class="lowerframe"><span></span></span>'; |
|
80 |
+} |
|
81 |
+ |
|
82 |
+?> |
|
0 | 83 |
\ No newline at end of file |
1 | 84 |