gruffen commited on 2011-04-08 03:01:48
Showing 5 changed files, with 310 additions and 0 deletions.
... | ... |
@@ -350,6 +350,10 @@ $txt['shd_create_dept'] = 'Create New Department'; |
350 | 350 |
$txt['shd_edit_dept'] = 'Edit Department'; |
351 | 351 |
$txt['shd_no_roles_in_dept'] = 'There are no roles in this department.'; |
352 | 352 |
$txt['shd_new_dept_name'] = 'New Department Name'; |
353 |
+$txt['shd_dept_boardindex_cat'] = 'Display this department in the board index in category'; |
|
354 |
+$txt['shd_no_dept_name'] = 'No department name was specified.'; |
|
355 |
+$txt['shd_no_category'] = 'The specified category does not exist. Please go back and reload the page.'; |
|
356 |
+$txt['shd_could_not_create_dept'] = 'The department could not be created.'; |
|
353 | 357 |
//@} |
354 | 358 |
|
355 | 359 |
//! Plugins |
... | ... |
@@ -0,0 +1,150 @@ |
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-AdminDepartments.php / 1.0 Felidae # |
|
18 |
+############################################################### |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * This file handles the core of SimpleDesk's departmental administration. |
|
22 |
+ * |
|
23 |
+ * @package source |
|
24 |
+ * @since 1.1 |
|
25 |
+*/ |
|
26 |
+if (!defined('SMF')) |
|
27 |
+ die('Hacking attempt...'); |
|
28 |
+ |
|
29 |
+/** |
|
30 |
+ * The start point for all interaction with the SimpleDesk departments |
|
31 |
+ * |
|
32 |
+ * @since 1.1 |
|
33 |
+*/ |
|
34 |
+function shd_admin_departments() |
|
35 |
+{ |
|
36 |
+ global $context, $scripturl, $sourcedir, $settings, $txt, $modSettings; |
|
37 |
+ |
|
38 |
+ loadTemplate('sd_template/SimpleDesk-AdminDepartments'); |
|
39 |
+ |
|
40 |
+ $subactions = array( |
|
41 |
+ 'main' => 'shd_admin_dept_list', |
|
42 |
+ 'createdept' => 'shd_admin_create_dept', |
|
43 |
+ 'editdept' => 'shd_admin_edit_dept', |
|
44 |
+ 'savedept' => 'shd_admin_save_dept', |
|
45 |
+ ); |
|
46 |
+ |
|
47 |
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subactions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'main'; |
|
48 |
+ |
|
49 |
+ $subactions[$_REQUEST['sa']](); |
|
50 |
+} |
|
51 |
+ |
|
52 |
+/** |
|
53 |
+ * Display a list of all the departments currently in the system, with appropriate navigation to edit or create more. |
|
54 |
+ * |
|
55 |
+ * @since 1.1 |
|
56 |
+ */ |
|
57 |
+function shd_admin_dept_list() |
|
58 |
+{ |
|
59 |
+ global $context, $txt, $smcFunc; |
|
60 |
+ |
|
61 |
+ $context['page_title'] = $txt['shd_admin_departments_home']; |
|
62 |
+ $context['sub_template'] = 'shd_departments_home'; |
|
63 |
+ |
|
64 |
+ // 1. Get all the departments |
|
65 |
+ $query = $smcFunc['db_query']('', ' |
|
66 |
+ SELECT hdd.id_dept, hdd.dept_name, hdd.board_cat, c.name AS cat_name, hdd.before_after |
|
67 |
+ FROM {db_prefix}helpdesk_depts AS hdd |
|
68 |
+ LEFT JOIN {db_prefix}categories AS c ON (hdd.board_cat = c.id_cat) |
|
69 |
+ ORDER BY id_dept' |
|
70 |
+ ); |
|
71 |
+ while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
72 |
+ $context['shd_departments'][$row['id_dept']] = $row; |
|
73 |
+ $smcFunc['db_free_result']($query); |
|
74 |
+ |
|
75 |
+ // 2. Just for niceness, get all the helpdesk roles attached to each department. |
|
76 |
+ $query = $smcFunc['db_query']('', ' |
|
77 |
+ SELECT hddr.id_dept, hddr.id_role, hdr.template, hdr.role_name |
|
78 |
+ FROM {db_prefix}helpdesk_dept_roles AS hddr |
|
79 |
+ INNER JOIN {db_prefix}helpdesk_roles AS hdr ON (hddr.id_role = hdr.id_role) |
|
80 |
+ ORDER BY hddr.id_dept, hddr.id_role' |
|
81 |
+ ); |
|
82 |
+ while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
83 |
+ $context['shd_departments'][$row['id_dept']]['roles'][$row['id_role']] = $row; |
|
84 |
+ $smcFunc['db_free_result']($query); |
|
85 |
+} |
|
86 |
+ |
|
87 |
+function shd_admin_create_dept() |
|
88 |
+{ |
|
89 |
+ global $context, $txt, $smcFunc; |
|
90 |
+ |
|
91 |
+ $context['shd_cat_list'] = array( |
|
92 |
+ 0 => $txt['shd_boardindex_cat_none'], |
|
93 |
+ ); |
|
94 |
+ $request = $smcFunc['db_query']('', ' |
|
95 |
+ SELECT id_cat, name |
|
96 |
+ FROM {db_prefix}categories |
|
97 |
+ ORDER BY cat_order'); |
|
98 |
+ while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
99 |
+ $context['shd_cat_list'][$row['id_cat']] = $row['name']; |
|
100 |
+ $smcFunc['db_free_result']($request); |
|
101 |
+ |
|
102 |
+ if (empty($_REQUEST['part'])) |
|
103 |
+ { |
|
104 |
+ $context['page_title'] = $txt['shd_create_dept']; |
|
105 |
+ $context['sub_template'] = 'shd_create_dept'; |
|
106 |
+ checkSubmitOnce('register'); |
|
107 |
+ } |
|
108 |
+ else |
|
109 |
+ { |
|
110 |
+ checkSubmitOnce('check'); |
|
111 |
+ checkSession(); |
|
112 |
+ |
|
113 |
+ // Boring stuff like session checks done. Were you a naughty admin and didn't set it properly? |
|
114 |
+ if (!isset($_POST['dept_name']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['dept_name'])) === '') |
|
115 |
+ fatal_lang_error('shd_no_dept_name', false); |
|
116 |
+ else |
|
117 |
+ $_POST['dept_name'] = strtr($smcFunc['htmlspecialchars']($_POST['dept_name']), array("\r" => '', "\n" => '', "\t" => '')); |
|
118 |
+ |
|
119 |
+ // Now to check the category. |
|
120 |
+ if (!isset($_POST['dept_cat']) || !isset($context['shd_cat_list'][$_POST['dept_cat']])) |
|
121 |
+ fatal_lang_error('shd_invalid_category', false); |
|
122 |
+ else |
|
123 |
+ $_POST['dept_cat'] = (int) $_POST['dept_cat']; |
|
124 |
+ |
|
125 |
+ $_POST['dept_beforeafter'] = empty($_POST['dept_beforeafter']) ? 0 : 1; |
|
126 |
+ |
|
127 |
+ // Create the department |
|
128 |
+ $smcFunc['db_insert']('insert', |
|
129 |
+ '{db_prefix}helpdesk_depts', |
|
130 |
+ array( |
|
131 |
+ 'dept_name' => 'string', 'board_cat' => 'int', 'before_after' => 'int', |
|
132 |
+ ), |
|
133 |
+ array( |
|
134 |
+ $_POST['dept_name'], $_POST['dept_cat'], $_POST['dept_beforeafter'], |
|
135 |
+ ), |
|
136 |
+ array( |
|
137 |
+ 'id_dept', |
|
138 |
+ ) |
|
139 |
+ ); |
|
140 |
+ |
|
141 |
+ $newdept = $smcFunc['db_insert_id']('{db_prefix}helpdesk_depts', 'id_dept'); |
|
142 |
+ if (empty($newdept)) |
|
143 |
+ fatal_lang_error('shd_could_not_create_dept', false); |
|
144 |
+ |
|
145 |
+ // Take them to the main screen! |
|
146 |
+ redirectexit('action=admin;area=helpdesk_depts'); |
|
147 |
+ } |
|
148 |
+} |
|
149 |
+ |
|
150 |
+?> |
|
0 | 151 |
\ No newline at end of file |
... | ... |
@@ -0,0 +1,156 @@ |
1 |
+<?php |
|
2 |
+// Version: 1.0 Felidae; SimpleDesk's administration/departments area |
|
3 |
+ |
|
4 |
+/** |
|
5 |
+ * Displays SimpleDesk's administration for departments - front page, listing the departments, plus the create/edit dialogs. |
|
6 |
+ * |
|
7 |
+ * @package template |
|
8 |
+ * @since 1.1 |
|
9 |
+*/ |
|
10 |
+ |
|
11 |
+/** |
|
12 |
+ * Display the front page of the SimpleDesk departments. |
|
13 |
+ * |
|
14 |
+ * @since 1.1 |
|
15 |
+*/ |
|
16 |
+function template_shd_departments_home() |
|
17 |
+{ |
|
18 |
+ global $context, $settings, $txt, $modSettings, $scripturl; |
|
19 |
+ |
|
20 |
+ echo ' |
|
21 |
+ <div class="tborder"> |
|
22 |
+ <div class="cat_bar grid_header"> |
|
23 |
+ <h3 class="catbg"> |
|
24 |
+ <img src="', $settings['default_images_url'], '/simpledesk/departments.png" class="icon" alt="*"> |
|
25 |
+ ', $txt['shd_admin_departments_home'], ' |
|
26 |
+ </h3> |
|
27 |
+ </div> |
|
28 |
+ <p class="description shd_actionloginfo"> |
|
29 |
+ ', $txt['shd_admin_departments_homedesc'], ' |
|
30 |
+ </p> |
|
31 |
+ <table class="shd_ticketlist" cellspacing="0" width="100%"> |
|
32 |
+ <tbody><tr class="titlebg"> |
|
33 |
+ <td width="2%"></td> |
|
34 |
+ <td width="25%" class="shd_nowrap"> |
|
35 |
+ ', $txt['shd_department'], ' |
|
36 |
+ </td> |
|
37 |
+ <td>', $txt['shd_dept_boardindex'], '</td> |
|
38 |
+ <td width="40%" class="shd_nowrap"> |
|
39 |
+ ', $txt['shd_roles_in_dept'], ' |
|
40 |
+ </td> |
|
41 |
+ </tr>'; |
|
42 |
+ |
|
43 |
+ $use_bg2 = true; |
|
44 |
+ foreach ($context['shd_departments'] as $department) |
|
45 |
+ { |
|
46 |
+ echo ' |
|
47 |
+ <tr class="windowbg', $use_bg2 ? '2' : '', '"> |
|
48 |
+ <td></td> |
|
49 |
+ <td> |
|
50 |
+ ', $department['dept_name'], ' |
|
51 |
+ <div class="smalltext">[<a href="', $scripturl, '?action=admin;area=helpdesk_depts;sa=editdept;dept=', $role['id_dept'], '">', $txt['shd_edit_dept'], '</a>]</div></td> |
|
52 |
+ <td>'; |
|
53 |
+ |
|
54 |
+ if (!empty($department['cat_name'])) |
|
55 |
+ echo ' |
|
56 |
+ ', $txt['shd_dept_inside_category'], ': ', $department['cat_name'], ' |
|
57 |
+ <div class="smalltext">', empty($department['before_after']) ? $txt['shd_dept_cat_before_boards'] : $txt['shd_dept_cat_after_boards'], '</div>'; |
|
58 |
+ else |
|
59 |
+ echo ' |
|
60 |
+ ', $txt['shd_dept_no_boardindex']; |
|
61 |
+ |
|
62 |
+ echo ' |
|
63 |
+ </td> |
|
64 |
+ <td>'; |
|
65 |
+ |
|
66 |
+ if (!empty($department['roles'])) |
|
67 |
+ { |
|
68 |
+ $first = true; |
|
69 |
+ foreach ($department['roles'] as $role) |
|
70 |
+ { |
|
71 |
+ if (!$first) |
|
72 |
+ echo ', '; |
|
73 |
+ else |
|
74 |
+ $first = false; |
|
75 |
+ |
|
76 |
+ echo ' |
|
77 |
+ <span class="shd_nowrap"><img src="', $settings['default_images_url'], '/simpledesk/', $context['shd_permissions']['roles'][$role['template']]['icon'], '" class="icon" alt="*"> |
|
78 |
+ <a href="', $scripturl, '?action=admin;area=helpdesk_permissions;sa=editrole;role=', $role['id_role'], '">', $role['role_name'], '</a></span>'; |
|
79 |
+ } |
|
80 |
+ } |
|
81 |
+ else |
|
82 |
+ echo ' |
|
83 |
+ ', $txt['shd_no_roles_in_dept']; |
|
84 |
+ |
|
85 |
+ echo ' |
|
86 |
+ </td> |
|
87 |
+ </tr>'; |
|
88 |
+ $use_bg2 = !$use_bg2; |
|
89 |
+ } |
|
90 |
+ |
|
91 |
+ echo ' |
|
92 |
+ </table> |
|
93 |
+ <div class="flow_auto"> |
|
94 |
+ <div class="floatright"> |
|
95 |
+ <div class="additional_row">[<a href="', $scripturl, '?action=admin;area=helpdesk_depts;sa=createdept">', $txt['shd_create_dept'], '</a>]</div> |
|
96 |
+ </div> |
|
97 |
+ </div> |
|
98 |
+ </div>'; |
|
99 |
+} |
|
100 |
+ |
|
101 |
+function template_shd_create_dept() |
|
102 |
+{ |
|
103 |
+ global $context, $settings, $txt, $modSettings, $scripturl; |
|
104 |
+ |
|
105 |
+ echo ' |
|
106 |
+ <div class="tborder"> |
|
107 |
+ <div class="cat_bar"> |
|
108 |
+ <h3 class="catbg"> |
|
109 |
+ <img src="', $settings['default_images_url'], '/simpledesk/departments.png" class="icon" alt="*" /> |
|
110 |
+ ', $txt['shd_admin_departments_home'], ' |
|
111 |
+ </h3> |
|
112 |
+ </div> |
|
113 |
+ <p class="description"> |
|
114 |
+ ', $txt['shd_admin_departments_homedesc'], ' |
|
115 |
+ </p> |
|
116 |
+ </div> |
|
117 |
+ <div class="cat_bar grid_header"> |
|
118 |
+ <h3 class="catbg"> |
|
119 |
+ <img src="', $settings['default_images_url'], '/simpledesk/position.png" alt="*" /> |
|
120 |
+ ', $txt['shd_create_dept'], ' |
|
121 |
+ </h3> |
|
122 |
+ </div> |
|
123 |
+ <div class="roundframe"> |
|
124 |
+ <form action="', $scripturl, '?action=admin;area=helpdesk_depts;sa=createdept;part=2" method="post"> |
|
125 |
+ <div class="content"> |
|
126 |
+ <dl class="settings"> |
|
127 |
+ <dt><strong>', $txt['shd_new_dept_name'], '</strong></dt> |
|
128 |
+ <dd><input type="text" name="dept_name" id="dept_name" value="" class="input_text" size="30" /></dd> |
|
129 |
+ <dt><strong>', $txt['shd_dept_boardindex_cat'], '</strong></dt> |
|
130 |
+ <dd> |
|
131 |
+ <select name="dept_cat" id="dept_cat" onchange="document.getElementById(\'dept_beforeafter\').disabled = (this.value == 0);">'; |
|
132 |
+ foreach ($context['shd_cat_list'] as $id_cat => $cat_name) |
|
133 |
+ echo ' |
|
134 |
+ <option value="', $id_cat, '">', $cat_name, '</option>'; |
|
135 |
+ |
|
136 |
+ echo ' |
|
137 |
+ </select> |
|
138 |
+ </dd> |
|
139 |
+ <dt><strong>', $txt['shd_boardindex_cat_where'], '</strong></dt> |
|
140 |
+ <dd> |
|
141 |
+ <select name="dept_beforeafter" id="dept_beforeafter" disabled="disabled"> |
|
142 |
+ <option value="0">', $txt['shd_boardindex_cat_before'], '</option> |
|
143 |
+ <option value="1">', $txt['shd_boardindex_cat_after'], '</option> |
|
144 |
+ </select> |
|
145 |
+ </dd> |
|
146 |
+ </dl> |
|
147 |
+ </div> |
|
148 |
+ <input type="submit" value="', $txt['shd_create_dept'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" /> |
|
149 |
+ <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" /> |
|
150 |
+ <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" /> |
|
151 |
+ </form> |
|
152 |
+ </div> |
|
153 |
+ <span class="lowerframe"><span></span></span>'; |
|
154 |
+} |
|
155 |
+ |
|
156 |
+?> |
|
0 | 157 |
\ No newline at end of file |
1 | 158 |