jdarwood007 commited on 2016-12-31 20:26:58
Showing 2 changed files, with 109 additions and 2 deletions.
Signed-off-by: jdarwood007 <unmonitored+github@sleepycode.com>
... | ... |
@@ -129,6 +129,23 @@ function shd_search2() |
129 | 129 |
$smcFunc['db_free_result']($query); |
130 | 130 |
} |
131 | 131 |
} |
132 |
+ else |
|
133 |
+ { |
|
134 |
+ $visible_depts = shd_allowed_to('access_helpdesk', false); |
|
135 |
+ $context['dept_list'] = array(); |
|
136 |
+ $query = $smcFunc['db_query']('', ' |
|
137 |
+ SELECT id_dept, dept_name |
|
138 |
+ FROM {db_prefix}helpdesk_depts |
|
139 |
+ WHERE id_dept IN ({array_int:depts}) |
|
140 |
+ ORDER BY dept_order', |
|
141 |
+ array( |
|
142 |
+ 'depts' => $visible_depts, |
|
143 |
+ ) |
|
144 |
+ ); |
|
145 |
+ while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
146 |
+ $context['dept_list'][$row['id_dept']] = $row['dept_name']; |
|
147 |
+ $smcFunc['db_free_result']($query); |
|
148 |
+ } |
|
132 | 149 |
|
133 | 150 |
// Ticket urgency |
134 | 151 |
$using_urgency = array(); |
... | ... |
@@ -161,11 +178,20 @@ function shd_search2() |
161 | 178 |
{ |
162 | 179 |
$status = array(); |
163 | 180 |
if (!empty($_POST['scope_open'])) |
181 |
+ { |
|
164 | 182 |
$status = array_merge($status, array(TICKET_STATUS_NEW, TICKET_STATUS_PENDING_STAFF, TICKET_STATUS_PENDING_USER, TICKET_STATUS_WITH_SUPERVISOR, TICKET_STATUS_ESCALATED)); |
183 |
+ $context['search_params']['scope_open'] = true; |
|
184 |
+ } |
|
165 | 185 |
if (!empty($_POST['scope_closed'])) |
186 |
+ { |
|
166 | 187 |
$status = array_merge($status, array(TICKET_STATUS_CLOSED)); |
188 |
+ $context['search_params']['scope_closed'] = true; |
|
189 |
+ } |
|
167 | 190 |
if (!empty($_POST['scope_recycle'])) |
191 |
+ { |
|
168 | 192 |
$status = array_merge($status, array(TICKET_STATUS_DELETED)); |
193 |
+ $context['search_params']['scope_recycle'] = true; |
|
194 |
+ } |
|
169 | 195 |
|
170 | 196 |
$context['search_clauses'][] = 'hdt.status IN ({array_int:status})'; |
171 | 197 |
$context['search_params']['status'] = $status; |
... | ... |
@@ -195,6 +221,10 @@ function shd_search2() |
195 | 221 |
if (empty($context['pagenum']) || $context['pagenum'] < 1) |
196 | 222 |
$context['pagenum'] = 1; |
197 | 223 |
|
224 |
+ // Pages. |
|
225 |
+ $context['next_page'] = $context['pagenum'] + 1; |
|
226 |
+ $context['prev_page'] = $context['pagenum'] < 2 ? 0 : $context['pagenum'] - 1; |
|
227 |
+ |
|
198 | 228 |
$number_per_page = 20; |
199 | 229 |
|
200 | 230 |
// OK, so are there any words? If not, execute this sucker the quick way and get out to the template quick. |
... | ... |
@@ -223,6 +253,9 @@ function shd_search2() |
223 | 253 |
} |
224 | 254 |
} |
225 | 255 |
|
256 |
+ // Search type. |
|
257 |
+ $context['search_params']['searchtype'] = in_array($_POST['searchtype'], array('any', 'all')) ? $_POST['searchtype'] : 'all'; |
|
258 |
+ |
|
226 | 259 |
// Spam me not! |
227 | 260 |
if (empty($_SESSION['lastsearch'])) |
228 | 261 |
spamProtection('search'); |
... | ... |
@@ -387,9 +420,8 @@ function shd_search2() |
387 | 420 |
unset($matches['messages'][$ticket]); |
388 | 421 |
|
389 | 422 |
// Now, we just have a list of tickets to play with. Let's put that together in a master list. |
390 |
- // !!! TODO: This doesn't make sense. |
|
391 | 423 |
foreach ($matches['messages'] as $msg => $ticket_words) |
392 |
- $matches['id_msg'][$ticket] = true; |
|
424 |
+ $matches['id_msg'][$msg] = true; |
|
393 | 425 |
unset($matches['messages']); |
394 | 426 |
} |
395 | 427 |
|
... | ... |
@@ -335,4 +335,79 @@ function template_search_results() |
335 | 335 |
</div> |
336 | 336 |
</div>'; |
337 | 337 |
} |
338 |
+ |
|
339 |
+ // Some buttons. |
|
340 |
+ echo ' |
|
341 |
+ <div class="search_results_posts"> |
|
342 |
+ <div class="windowbg">'; |
|
343 |
+ |
|
344 |
+ template_search_navigation('prev'); |
|
345 |
+ template_search_navigation('next'); |
|
346 |
+ |
|
347 |
+ echo ' |
|
348 |
+ </div> |
|
349 |
+ </div>'; |
|
350 |
+} |
|
351 |
+ |
|
352 |
+function template_search_navigation($direction = 'next') |
|
353 |
+{ |
|
354 |
+ global $scripturl, $context, $txt, $smcFunc; |
|
355 |
+ |
|
356 |
+ if ($direction == 'prev' && empty($context['prev_page'])) |
|
357 |
+ return; |
|
358 |
+ |
|
359 |
+ echo ' |
|
360 |
+ <form method="post" action="', $scripturl, '?action=helpdesk;sa=search2">'; |
|
361 |
+ |
|
362 |
+ // Departments. |
|
363 |
+ if (count($context['dept_list']) == 1) |
|
364 |
+ { |
|
365 |
+ $array = array_keys($context['dept_list']); |
|
366 |
+ echo ' |
|
367 |
+ <input type="hidden" name="search_dept[]" value="', $array[0], '" />'; |
|
368 |
+ } |
|
369 |
+ elseif (isset($context['search_params']['visible_depts'])) |
|
370 |
+ foreach ($context['search_params']['visible_depts'] as $dept) |
|
371 |
+ echo ' |
|
372 |
+ <input type="hidden" name="search_dept[]" value="', $dept, '">'; |
|
373 |
+ |
|
374 |
+ // Some search areas. |
|
375 |
+ if (isset($context['search_params']['areas'])) |
|
376 |
+ foreach ($context['search_params']['areas'] as $area => $dummy) |
|
377 |
+ echo ' |
|
378 |
+ <input type="hidden" name="search_', $area, '" value="1">'; |
|
379 |
+ |
|
380 |
+ // Standard search params arrays. |
|
381 |
+ foreach (array('urgency', 'starter_name_form', 'assigned_name_form') as $param) |
|
382 |
+ if (isset($context['search_params'][$param])) |
|
383 |
+ foreach ($context['search_params'][$param] as $value) |
|
384 |
+ echo ' |
|
385 |
+ <input type="hidden" name="', $param, '[]" value="', $value, '">'; |
|
386 |
+ |
|
387 |
+ // Standard search params bools. |
|
388 |
+ foreach (array('scope_open', 'scope_closed', 'scope_recycle') as $param) |
|
389 |
+ if (!empty($context['search_params'][$param])) |
|
390 |
+ echo ' |
|
391 |
+ <input type="hidden" name="', $param, '" value="1">'; |
|
392 |
+ |
|
393 |
+ // Standard search params strings. |
|
394 |
+ foreach (array('searchtype') as $param) |
|
395 |
+ if (!empty($context['search_params'][$param])) |
|
396 |
+ echo ' |
|
397 |
+ <input type="hidden" name="', $param, '" value="', $context['search_params'][$param], '">'; |
|
398 |
+ |
|
399 |
+ // Search terms. |
|
400 |
+ echo ' |
|
401 |
+ <input type="hidden" name="search" value="', $smcFunc['htmlspecialchars']($context['search_terms']), '">'; |
|
402 |
+ |
|
403 |
+ if ($direction == 'prev') |
|
404 |
+ echo ' |
|
405 |
+ <input type="hidden" name="page" value="', $context['prev_page'], '" /> |
|
406 |
+ <input type="submit" value="Previous" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit floatleft" />'; |
|
407 |
+ else |
|
408 |
+ echo ' |
|
409 |
+ <input type="hidden" name="page" value="', $context['next_page'], '" /> |
|
410 |
+ <input type="submit" value="Next" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" />'; |
|
411 |
+ |
|
412 |
+ echo '</form>'; |
|
338 | 413 |
} |
339 | 414 |
\ No newline at end of file |
340 | 415 |