gruffen commited on 2011-03-22 10:15:13
Showing 8 changed files, with 282 additions and 3 deletions.
... | ... |
@@ -389,6 +389,17 @@ $txt['shd_admin_plugins_lang_uzbek_latin'] = 'Uzbek (Latin)'; |
389 | 389 |
$txt['shd_admin_plugins_lang_vietnamese'] = 'Vietnamese'; |
390 | 390 |
//@} |
391 | 391 |
|
392 |
+//! Maintenance |
|
393 |
+//@{ |
|
394 |
+$txt['shd_admin_maint'] = 'Maintenance'; |
|
395 |
+$txt['shd_admin_maint_back'] = 'Back to Helpdesk Maintenance'; |
|
396 |
+$txt['shd_admin_maint_desc'] = 'This area allows you to perform some common maintenance tasks within SimpleDesk.'; |
|
397 |
+$txt['shd_admin_maint_findrepair'] = 'Find and Repair Errors'; |
|
398 |
+$txt['shd_admin_maint_findrepair_desc'] = 'Sometimes, however unlikely, things get a little out of step inside the database. This operation performs an integrity check on the database and attempts to repair any errors it encounters.'; |
|
399 |
+ |
|
400 |
+$txt['shd_maint_zero_tickets'] = '%1$d ticket(s) were found with invalid ids, they have all been given new ids, the next available id numbers.'; |
|
401 |
+//@} |
|
402 |
+ |
|
392 | 403 |
/** |
393 | 404 |
* @ignore |
394 | 405 |
* Warning: He may bite. |
... | ... |
@@ -68,6 +68,7 @@ function shd_admin_main() |
68 | 68 |
'helpdesk_customfield' => array('SimpleDesk-AdminCustomField.php', 'shd_admin_custom'), |
69 | 69 |
'helpdesk_permissions' => array('SimpleDesk-AdminPermissions.php', 'shd_admin_permissions'), |
70 | 70 |
'helpdesk_plugins' => array('SimpleDesk-AdminPlugins.php', 'shd_admin_plugins'), |
71 |
+ 'helpdesk_maint' => array('SimpleDesk-AdminMaint.php', 'shd_admin_maint'), |
|
71 | 72 |
); |
72 | 73 |
|
73 | 74 |
// Int hooks - after we basically set everything up (so it's manipulatable by the hook, but before we do the last bits of finalisation) |
... | ... |
@@ -127,9 +128,6 @@ function shd_admin_info() |
127 | 128 |
{ |
128 | 129 |
global $context, $settings, $scripturl, $txt, $sourcedir, $smcFunc; |
129 | 130 |
|
130 |
- // No little pixies allowed! |
|
131 |
- shd_is_allowed_to(array('admin_forum', 'admin_helpdesk')); |
|
132 |
- |
|
133 | 131 |
$subactions = array( |
134 | 132 |
'main' => array( |
135 | 133 |
'function' => false, |
... | ... |
@@ -0,0 +1,145 @@ |
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-AdminMaint.php / 1.0 Felidae # |
|
18 |
+############################################################### |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * This file handles the core of SimpleDesk's administrative maintenance. |
|
22 |
+ * |
|
23 |
+ * @package source |
|
24 |
+ * @since 1.1 |
|
25 |
+*/ |
|
26 |
+if (!defined('SMF')) |
|
27 |
+ die('Hacking attempt...'); |
|
28 |
+ |
|
29 |
+/** |
|
30 |
+ * The start point for maintenance. |
|
31 |
+ * |
|
32 |
+ * We're directed here from the main administration centre, after permission checks and a few dependencies loaded. |
|
33 |
+ * |
|
34 |
+ * @since 1.1 |
|
35 |
+*/ |
|
36 |
+function shd_admin_maint() |
|
37 |
+{ |
|
38 |
+ global $context, $txt, $db_show_debug; |
|
39 |
+ |
|
40 |
+ // Right, if we're here, we really, really need to turn this off. Because anything we do from this page onwards hurts the log badly. |
|
41 |
+ $db_show_debug = false; |
|
42 |
+ |
|
43 |
+ loadTemplate('sd_template/SimpleDesk-AdminMaint'); |
|
44 |
+ loadTemplate(false, array('admin', 'helpdesk_admin')); |
|
45 |
+ loadLanguage('ManageMaintenance'); |
|
46 |
+ |
|
47 |
+ $subactions = array( |
|
48 |
+ 'main' => 'shd_admin_maint_home', |
|
49 |
+ 'findrepair' => 'shd_admin_maint_findrepair', |
|
50 |
+ ); |
|
51 |
+ |
|
52 |
+ $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subactions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'main'; |
|
53 |
+ $subactions[$_REQUEST['sa']](); |
|
54 |
+} |
|
55 |
+ |
|
56 |
+function shd_admin_maint_home() |
|
57 |
+{ |
|
58 |
+ global $context, $txt; |
|
59 |
+ |
|
60 |
+ $context['sub_template'] = 'shd_admin_maint_home'; |
|
61 |
+ $context['page_title'] = $txt['shd_admin_maint']; |
|
62 |
+} |
|
63 |
+ |
|
64 |
+function shd_admin_maint_findrepair() |
|
65 |
+{ |
|
66 |
+ global $context, $txt; |
|
67 |
+ checkSession('request'); |
|
68 |
+ |
|
69 |
+ $context['page_title'] = $txt['shd_admin_maint_findrepair']; |
|
70 |
+ |
|
71 |
+ $context['maint_steps'] = array(); |
|
72 |
+ $context['maint_steps'] = array( |
|
73 |
+ array( |
|
74 |
+ 'name' => 'zero_tickets', |
|
75 |
+ 'pc' => 5, |
|
76 |
+ ), |
|
77 |
+ array( |
|
78 |
+ 'name' => 'clean_cache', |
|
79 |
+ 'pc' => 10, |
|
80 |
+ ), |
|
81 |
+ ); |
|
82 |
+ |
|
83 |
+ if (isset($_GET['done'])) |
|
84 |
+ { |
|
85 |
+ $context['sub_template'] = 'shd_admin_maint_findrepairdone'; |
|
86 |
+ $context['maintenance_result'] = array(); |
|
87 |
+ foreach ($context['steps'] as $step) |
|
88 |
+ if (!empty($_SESSION['shd_maint'][$step['name']])) |
|
89 |
+ $context['maintenance_result'][$step['name']] = $_SESSION['shd_maint'][$step['name']]; |
|
90 |
+ unset($_SESSION['shd_maint']); |
|
91 |
+ return; |
|
92 |
+ } |
|
93 |
+ |
|
94 |
+ $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
|
95 |
+ if (!isset($context['maint_steps'][$context['step']])) |
|
96 |
+ $context['step'] = 0; |
|
97 |
+ |
|
98 |
+ $context['continue_countdown'] = 3; |
|
99 |
+ $context['continue_get_data'] = '?action=admin;area=helpdesk_maint;sa=findrepair;' . $context['session_var'] . '=' . $context['session_id']; |
|
100 |
+ $context['continue_post_data'] = ''; |
|
101 |
+ $context['sub_template'] = 'not_done'; |
|
102 |
+ |
|
103 |
+ $context['continue_percent'] = 0; |
|
104 |
+ for ($i = 0; $i <= $context['step']; $i++) |
|
105 |
+ $context['continue_percent'] += $context['maint_steps'][$i]['pc']; |
|
106 |
+ |
|
107 |
+ $function = 'shd_maint_' . $context['maint_steps'][$context['step']]['name']; |
|
108 |
+ $function(); |
|
109 |
+} |
|
110 |
+ |
|
111 |
+function shd_maint_zero_tickets() |
|
112 |
+{ |
|
113 |
+ global $context, $smcFunc; |
|
114 |
+ |
|
115 |
+ // Check for tickets with id-ticket of 0. |
|
116 |
+ $query = $smcFunc['db_query']('', ' |
|
117 |
+ SELECT COUNT(*) |
|
118 |
+ FROM {db_prefix}helpdesk_tickets |
|
119 |
+ WHERE id_ticket = 0'); |
|
120 |
+ list($tickets) = $smcFunc['db_fetch_row']($query); |
|
121 |
+ if (!empty($tickets)) |
|
122 |
+ { |
|
123 |
+ $smcFunc['db_query']('', ' |
|
124 |
+ UPDATE {db_prefix}helpdesk_tickets |
|
125 |
+ SET id_ticket = NULL |
|
126 |
+ WHERE id_ticket = 0'); |
|
127 |
+ $_SESSION['shd_maint']['zero_tickets'] = $smcFunc['db_affected_rows'](); |
|
128 |
+ } |
|
129 |
+ |
|
130 |
+ // This is a short operation, no suboperation, so just tell it to go onto the next step. |
|
131 |
+ $context['continue_post_data'] .= '<input type="hidden" name="step" value="' . ($context['step'] + 1) . '" />'; |
|
132 |
+} |
|
133 |
+ |
|
134 |
+function shd_maint_clean_cache() |
|
135 |
+{ |
|
136 |
+ global $context; |
|
137 |
+ |
|
138 |
+ // Make sure all SimpleDesk cache items are forcibly flushed. |
|
139 |
+ clean_cache('shd'); |
|
140 |
+ |
|
141 |
+ // Normally, we'd update $context['continue_post_data'] to indicate our next port of call. But here, we don't have to. |
|
142 |
+ redirectexit('action=admin;area=helpdesk_maint;sa=findrepair;done;' . $context['session_var'] . '=' . $context['session_id']); |
|
143 |
+} |
|
144 |
+ |
|
145 |
+?> |
|
0 | 146 |
\ No newline at end of file |
... | ... |
@@ -282,6 +282,14 @@ function shd_admin_bootstrap(&$admin_areas) |
282 | 282 |
'subsections' => array( |
283 | 283 |
), |
284 | 284 |
), |
285 |
+ 'helpdesk_maint' => array( |
|
286 |
+ 'label' => $txt['shd_admin_maint'], |
|
287 |
+ 'file' => 'sd_source/SimpleDesk-Admin.php', |
|
288 |
+ 'icon' => 'shd/maintenance.png', |
|
289 |
+ 'function' => 'shd_admin_main', |
|
290 |
+ 'subsections' => array( |
|
291 |
+ ), |
|
292 |
+ ), |
|
285 | 293 |
), |
286 | 294 |
); |
287 | 295 |
|
... | ... |
@@ -0,0 +1,117 @@ |
1 |
+<?php |
|
2 |
+// Version: 1.0 Felidae; SimpleDesk's administration maintenance |
|
3 |
+ |
|
4 |
+/** |
|
5 |
+ * Displays SimpleDesk's administration maintenance |
|
6 |
+ * |
|
7 |
+ * @package template |
|
8 |
+ * @since 1.1 |
|
9 |
+*/ |
|
10 |
+ |
|
11 |
+/** |
|
12 |
+ * Display the front page of the SimpleDesk admin maintenance, including a list of all the tasks. |
|
13 |
+ * |
|
14 |
+ * @since 1.1 |
|
15 |
+*/ |
|
16 |
+function template_shd_admin_maint_home() |
|
17 |
+{ |
|
18 |
+ global $context, $settings, $txt, $modSettings, $scripturl; |
|
19 |
+ |
|
20 |
+ echo ' |
|
21 |
+ <div id="admincenter"> |
|
22 |
+ <div class="tborder"> |
|
23 |
+ <div class="cat_bar"> |
|
24 |
+ <h3 class="catbg"> |
|
25 |
+ <img src="', $settings['default_images_url'], '/simpledesk/maintenance.png" class="icon" alt="*" /> |
|
26 |
+ ', $txt['shd_admin_maint'], ' |
|
27 |
+ </h3> |
|
28 |
+ </div> |
|
29 |
+ <p class="description"> |
|
30 |
+ ', $txt['shd_admin_maint_desc'], ' |
|
31 |
+ </p> |
|
32 |
+ </div>'; |
|
33 |
+ |
|
34 |
+ // OK, recount all the important figures. |
|
35 |
+ echo ' |
|
36 |
+ <div class="cat_bar grid_header"> |
|
37 |
+ <h3 class="catbg"> |
|
38 |
+ <img src="', $settings['default_images_url'], '/simpledesk/find_repair.png" alt="*"> |
|
39 |
+ ', $txt['shd_admin_maint_findrepair'], ' |
|
40 |
+ </h3> |
|
41 |
+ </div> |
|
42 |
+ <div class="roundframe"> |
|
43 |
+ <div class="content"> |
|
44 |
+ <p>', $txt['shd_admin_maint_findrepair_desc'], '</p> |
|
45 |
+ <form action="', $scripturl, '?action=admin;area=helpdesk_maint;sa=findrepair" method="post"> |
|
46 |
+ <input type="submit" value="', $txt['maintain_run_now'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit"> |
|
47 |
+ <input type="hidden" name="template" value="1"> |
|
48 |
+ <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
|
49 |
+ </form> |
|
50 |
+ </div> |
|
51 |
+ </div> |
|
52 |
+ <span class="lowerframe"><span></span></span>'; |
|
53 |
+ |
|
54 |
+ // And we're done. |
|
55 |
+ echo ' |
|
56 |
+ </div>'; |
|
57 |
+} |
|
58 |
+ |
|
59 |
+function template_shd_admin_maint_findrepairdone() |
|
60 |
+{ |
|
61 |
+ global $context, $settings, $txt, $scripturl; |
|
62 |
+ |
|
63 |
+ echo ' |
|
64 |
+ <div id="admincenter"> |
|
65 |
+ <div class="tborder"> |
|
66 |
+ <div class="cat_bar"> |
|
67 |
+ <h3 class="catbg"> |
|
68 |
+ <img src="', $settings['default_images_url'], '/simpledesk/find_repair.png" class="icon" alt="*" /> |
|
69 |
+ ', $txt['shd_admin_maint_findrepair'], ' |
|
70 |
+ </h3> |
|
71 |
+ </div> |
|
72 |
+ <p class="description"> |
|
73 |
+ ', $txt['shd_admin_maint_findrepair_desc'], ' |
|
74 |
+ </p> |
|
75 |
+ </div>'; |
|
76 |
+ |
|
77 |
+ if (empty($context['maintenance_result'])) |
|
78 |
+ { |
|
79 |
+ // Yay everything was fine. |
|
80 |
+ echo ' |
|
81 |
+ <div class="windowbg"> |
|
82 |
+ <span class="topslice"><span></span></span> |
|
83 |
+ <div class="content"> |
|
84 |
+ <p>', $txt['maintain_no_errors'], '</p> |
|
85 |
+ <p class="padding"> |
|
86 |
+ <a href="', $scripturl, '?action=admin;area=helpdesk_maint;', $context['session_var'], '=', $context['session_id'], '">', $txt['shd_admin_maint_back'], '</a> |
|
87 |
+ </p> |
|
88 |
+ </div> |
|
89 |
+ <span class="botslice"><span></span></span> |
|
90 |
+ </div>'; |
|
91 |
+ } |
|
92 |
+ else |
|
93 |
+ { |
|
94 |
+ echo ' |
|
95 |
+ <div class="windowbg"> |
|
96 |
+ <span class="topslice"><span></span></span> |
|
97 |
+ <div class="content"> |
|
98 |
+ <p>', $txt['errors_found'], '</p>'; |
|
99 |
+ |
|
100 |
+ // Heh, super squeeky buns time! |
|
101 |
+ // Each test has potentially its own feedback to give. So we'll handle each one separately. |
|
102 |
+ if (!empty($context['maintenance_result']['zero_tickets'])) |
|
103 |
+ echo ' |
|
104 |
+ <p class="padding">', sprintf($txt['shd_maint_zero_tickets'], $context['maintenance_result']['zero_tickets']), '</p>'; |
|
105 |
+ |
|
106 |
+ echo ' |
|
107 |
+ </div> |
|
108 |
+ <span class="botslice"><span></span></span> |
|
109 |
+ </div>'; |
|
110 |
+ } |
|
111 |
+ |
|
112 |
+ // And we're done. |
|
113 |
+ echo ' |
|
114 |
+ </div>'; |
|
115 |
+} |
|
116 |
+ |
|
117 |
+?> |
|
0 | 118 |
\ No newline at end of file |
1 | 119 |