1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* You may not change or alter any portion of this comment or credits |
5
|
|
|
* of supporting developers from this source code or any supporting source code |
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
* |
8
|
|
|
* This program is distributed in the hope that it will be useful, |
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
16
|
|
|
* @author Brian Wahoff <[email protected]> |
17
|
|
|
* @author Eric Juden <[email protected]> |
18
|
|
|
* @author XOOPS Development Team |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use Xmf\Request; |
22
|
|
|
use XoopsModules\News; |
|
|
|
|
23
|
|
|
use XoopsModules\Xhelp\{ |
24
|
|
|
Helper, |
25
|
|
|
Utility, |
26
|
|
|
WebLib |
27
|
|
|
}; |
28
|
|
|
|
29
|
|
|
/** @var Helper $helper */ |
30
|
|
|
require_once __DIR__ . '/header.php'; |
31
|
|
|
require_once XHELP_INCLUDE_PATH . '/events.php'; |
32
|
|
|
xoops_load('XoopsPagenav'); |
33
|
|
|
|
34
|
|
|
// Setup event handlers for page |
35
|
|
|
|
36
|
|
|
$helper = Helper::getInstance(); |
37
|
|
|
|
38
|
|
|
//Initialise Necessary Data Handler Classes |
39
|
|
|
/** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
40
|
|
|
$staffHandler = $helper->getHandler('Staff'); |
41
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
42
|
|
|
$memberHandler = xoops_getHandler('member'); |
43
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
44
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
45
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
46
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
47
|
|
|
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
48
|
|
|
$ticketHandler = $helper->getHandler('Ticket'); |
49
|
|
|
/** @var \XoopsModules\Xhelp\TicketListHandler $ticketListHandler */ |
50
|
|
|
$ticketListHandler = $helper->getHandler('TicketList'); |
51
|
|
|
/** @var \XoopsModules\Xhelp\SavedSearchHandler $savedSearchHandler */ |
52
|
|
|
$savedSearchHandler = $helper->getHandler('SavedSearch'); |
53
|
|
|
|
54
|
|
|
//Determine default 'op' (if none is specified) |
55
|
|
|
$uid = 0; |
56
|
|
|
if ($xoopsUser) { |
57
|
|
|
$uid = $xoopsUser->getVar('uid'); |
58
|
|
|
if ($xhelp_isStaff) { |
59
|
|
|
$op = 'staffMain'; |
60
|
|
|
} else { |
61
|
|
|
$op = 'userMain'; |
62
|
|
|
} |
63
|
|
|
} else { |
64
|
|
|
$op = 'anonMain'; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
// Page Global Variables |
68
|
|
|
$status_opt = [_XHELP_TEXT_SELECT_ALL => -1, _XHELP_STATUS0 => 0, _XHELP_STATUS1 => 1, _XHELP_STATUS2 => 2]; |
69
|
|
|
$state_opt = [_XHELP_TEXT_SELECT_ALL => -1, _XHELP_STATE1 => 1, _XHELP_STATE2 => 2]; |
70
|
|
|
$sort_columns = []; |
71
|
|
|
$sort_order = ['ASC', 'DESC']; |
72
|
|
|
$vars = ['op', 'limit', 'start', 'sort', 'order', 'refresh']; |
73
|
|
|
$all_users = []; |
74
|
|
|
$refresh = $start = $limit = 0; |
75
|
|
|
$sort = ''; |
76
|
|
|
$order = ''; |
77
|
|
|
|
78
|
|
|
//Initialize Variables |
79
|
|
|
foreach ($vars as $var) { |
80
|
|
|
if (isset($_REQUEST[$var])) { |
81
|
|
|
$$var = $_REQUEST[$var]; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
//Ensure Criteria Fields hold valid values |
86
|
|
|
$limit = $limit; |
87
|
|
|
$start = $start; |
88
|
|
|
$sort = \mb_strtolower($sort); |
89
|
|
|
$order = (in_array(mb_strtoupper($order), $sort_order) ? $order : 'ASC'); |
90
|
|
|
|
91
|
|
|
$displayName = $helper->getConfig('xhelp_displayName'); // Determines if username or real name is displayed |
92
|
|
|
|
93
|
|
|
switch ($op) { |
94
|
|
|
case 'staffMain': |
95
|
|
|
staffmain_display(); |
96
|
|
|
break; |
97
|
|
|
case 'staffViewAll': |
98
|
|
|
staffviewall_display(); |
99
|
|
|
break; |
100
|
|
|
case 'userMain': |
101
|
|
|
usermain_display(); |
102
|
|
|
break; |
103
|
|
|
case 'userViewAll': |
104
|
|
|
userviewall_display(); |
105
|
|
|
break; |
106
|
|
|
case 'setdept': |
107
|
|
|
if (!$xhelp_isStaff) { |
108
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/* |
112
|
|
|
if (!$hasRights = $staff->checkRoleRights(XHELP_SEC_TICKET_EDIT)) { |
113
|
|
|
$message = _XHELP_MESSAGE_NO_EDIT_TICKET; |
114
|
|
|
redirect_header(XHELP_BASE_URL."/".basename(__FILE__), 3, $message); |
115
|
|
|
} |
116
|
|
|
*/ |
117
|
|
|
if (Request::hasVar('setdept', 'POST')) { |
118
|
|
|
setdept_action(); |
119
|
|
|
} else { |
120
|
|
|
setdept_display(); |
121
|
|
|
} |
122
|
|
|
break; |
123
|
|
|
case 'setpriority': |
124
|
|
|
if (!$xhelp_isStaff) { |
125
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
126
|
|
|
} |
127
|
|
|
/* |
128
|
|
|
if (!$hasRights = $staff->checkRoleRights(XHELP_SEC_TICKET_PRIORITY)) { |
129
|
|
|
$message = _XHELP_MESSAGE_NO_CHANGE_PRIORITY; |
130
|
|
|
redirect_header(XHELP_BASE_URL."/".basename(__FILE__), 3, $message); |
131
|
|
|
} |
132
|
|
|
*/ |
133
|
|
|
if (Request::hasVar('setpriority', 'POST')) { |
134
|
|
|
setpriority_action(); |
135
|
|
|
} else { |
136
|
|
|
setpriority_display(); |
137
|
|
|
} |
138
|
|
|
break; |
139
|
|
|
case 'setstatus': |
140
|
|
|
if (!$xhelp_isStaff) { |
141
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
142
|
|
|
} |
143
|
|
|
/* |
144
|
|
|
if (!$hasRights = $staff->checkRoleRights(XHELP_SEC_TICKET_STATUS)) { |
145
|
|
|
$message = _XHELP_MESSAGE_NO_CHANGE_STATUS; |
146
|
|
|
redirect_header(XHELP_BASE_URL."/".basename(__FILE__), 3, $message); |
147
|
|
|
} |
148
|
|
|
*/ |
149
|
|
|
if (Request::hasVar('setstatus', 'POST')) { |
150
|
|
|
setstatus_action(); |
151
|
|
|
} else { |
152
|
|
|
setstatus_display(); |
153
|
|
|
} |
154
|
|
|
break; |
155
|
|
|
case 'setowner': |
156
|
|
|
if (!$xhelp_isStaff) { |
157
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
158
|
|
|
} |
159
|
|
|
/* |
160
|
|
|
if (!$hasRights = $staff->checkRoleRights(XHELP_SEC_TICKET_OWNERSHIP)) { |
161
|
|
|
$message = _XHELP_MESSAGE_NO_CHANGE_OWNER; |
162
|
|
|
redirect_header(XHELP_BASE_URL."/".basename(__FILE__), 3, $message); |
163
|
|
|
} |
164
|
|
|
*/ |
165
|
|
|
if (Request::hasVar('setowner', 'POST')) { |
166
|
|
|
setowner_action(); |
167
|
|
|
} else { |
168
|
|
|
setowner_display(); |
169
|
|
|
} |
170
|
|
|
break; |
171
|
|
|
case 'addresponse': |
172
|
|
|
if (!$xhelp_isStaff) { |
173
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
174
|
|
|
} |
175
|
|
|
/* |
176
|
|
|
if (!$hasRights = $staff->checkRoleRights(XHELP_SEC_RESPONSE_ADD)) { |
177
|
|
|
$message = _XHELP_MESSAGE_NO_ADD_RESPONSE; |
178
|
|
|
redirect_header(XHELP_BASE_URL."/".basename(__FILE__), 3, $message); |
179
|
|
|
} |
180
|
|
|
*/ |
181
|
|
|
if (Request::hasVar('addresponse', 'POST')) { |
182
|
|
|
addresponse_action(); |
183
|
|
|
} else { |
184
|
|
|
addresponse_display(); |
185
|
|
|
} |
186
|
|
|
break; |
187
|
|
|
case 'delete': |
188
|
|
|
if (!$xhelp_isStaff) { |
189
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
190
|
|
|
} |
191
|
|
|
/* |
192
|
|
|
if (!$hasRights = $staff->checkRoleRights(XHELP_SEC_TICKET_DELETE)) { |
193
|
|
|
$message = _XHELP_MESSAGE_NO_DELETE_TICKET; |
194
|
|
|
redirect_header(XHELP_BASE_URL."/".basename(__FILE__), 3, $message); |
195
|
|
|
} |
196
|
|
|
*/ |
197
|
|
|
if (Request::hasVar('delete', 'POST')) { |
198
|
|
|
delete_action(); |
199
|
|
|
} else { |
200
|
|
|
delete_display(); |
201
|
|
|
} |
202
|
|
|
break; |
203
|
|
|
case 'anonMain': |
204
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
205
|
|
|
$configHandler = xoops_getHandler('config'); |
206
|
|
|
$xoopsConfigUser = []; |
207
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('conf_name', 'allow_register'), 'OR'); |
208
|
|
|
$criteria->add(new \Criteria('conf_name', 'activation_type'), 'OR'); |
209
|
|
|
$myConfigs = $configHandler->getConfigs($criteria); |
210
|
|
|
|
211
|
|
|
foreach ($myConfigs as $myConf) { |
212
|
|
|
$xoopsConfigUser[$myConf->getVar('conf_name')] = $myConf->getVar('conf_value'); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
if (0 == $xoopsConfigUser['allow_register']) { |
216
|
|
|
$helper->redirect('error.php'); |
217
|
|
|
} else { |
218
|
|
|
$helper->redirect('addTicket.php'); |
219
|
|
|
} |
220
|
|
|
exit(); |
221
|
|
|
default: |
222
|
|
|
$helper->redirect(basename(__FILE__), 3); |
223
|
|
|
break; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Assign the selected tickets to the specified department |
228
|
|
|
*/ |
229
|
|
|
function setdept_action() |
230
|
|
|
{ |
231
|
|
|
global $eventService, $staff; |
232
|
|
|
$helper = Helper::getInstance(); |
233
|
|
|
|
234
|
|
|
//Sanity Check: tickets and department are supplied |
235
|
|
|
if (!isset($_POST['tickets'])) { |
236
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
if (!isset($_POST['department'])) { |
240
|
|
|
$helper->redirect(basename(__FILE__), 3, _AM_XHELP_MESSAGE_NO_DEPARTMENT); |
241
|
|
|
} |
242
|
|
|
$tickets = implode(',', $_POST['tickets']); |
243
|
|
|
$tickets = cleanTickets($tickets); |
244
|
|
|
$oTickets = Utility::getTickets($tickets); |
245
|
|
|
|
246
|
|
|
$depts = []; |
247
|
|
|
foreach ($oTickets as $ticket) { |
248
|
|
|
$depts[$ticket->getVar('department')] = $ticket->getVar('department'); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
// Check staff permissions |
252
|
|
|
if (!$staff->checkRoleRights(XHELP_SEC_TICKET_EDIT, $depts)) { |
253
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_EDIT_TICKET); |
254
|
|
|
} |
255
|
|
|
$department = Request::getInt('department', 0, 'POST'); |
256
|
|
|
$ret = Utility::setDept($tickets, $department); |
257
|
|
|
if ($ret) { |
258
|
|
|
$eventService->trigger('batch_dept', [@$oTickets, $department]); |
259
|
|
|
if (count($oTickets) > 0) { |
260
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_UPDATE_DEPARTMENT); |
261
|
|
|
} else { |
262
|
|
|
$helper->redirect('ticket.php?id=' . $oTickets[0]->getVar('id'), 3, _XHELP_MESSAGE_UPDATE_DEPARTMENT); |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_UPDATE_DEPARTMENT_ERROR); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Display form for the Batch Action: Set Department |
270
|
|
|
*/ |
271
|
|
|
function setdept_display() |
272
|
|
|
{ |
273
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $displayName; |
274
|
|
|
$helper = Helper::getInstance(); |
275
|
|
|
|
276
|
|
|
if (!isset($_POST['tickets'])) { |
277
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
281
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
282
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
283
|
|
|
$oTickets = Utility::getTickets($_POST['tickets']); |
284
|
|
|
$all_users = []; |
285
|
|
|
$j = 0; |
286
|
|
|
|
287
|
|
|
$sortedTickets = makeBatchTicketArray($oTickets, $depts, $all_users, $j, XHELP_SEC_TICKET_EDIT); |
288
|
|
|
unset($oTickets); |
289
|
|
|
|
290
|
|
|
$tplDepts = []; |
291
|
|
|
foreach ($depts as $dept) { |
292
|
|
|
$tplDepts[$dept->getVar('id')] = $dept->getVar('department'); |
293
|
|
|
} |
294
|
|
|
unset($depts); |
295
|
|
|
|
296
|
|
|
//Retrieve all member information for the current page |
297
|
|
|
if (count($all_users)) { |
298
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
299
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
300
|
|
|
} else { |
301
|
|
|
$users = []; |
302
|
|
|
} |
303
|
|
|
$sortedTickets = updateBatchTicketInfo($sortedTickets, $users, $j); |
304
|
|
|
|
305
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_setdept.tpl'; // Set template |
306
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; // Include the page header |
307
|
|
|
$xoopsTpl->assign('xhelp_department_options', $tplDepts); |
308
|
|
|
$xoopsTpl->assign('xhelp_tickets', implode(',', $_POST['tickets'])); |
309
|
|
|
$xoopsTpl->assign('xhelp_goodTickets', $sortedTickets['good']); |
310
|
|
|
$xoopsTpl->assign('xhelp_badTickets', $sortedTickets['bad']); |
311
|
|
|
$xoopsTpl->assign('xhelp_hasGoodTickets', count($sortedTickets['good']) > 0); |
312
|
|
|
$xoopsTpl->assign('xhelp_hasBadTickets', count($sortedTickets['bad']) > 0); |
313
|
|
|
$xoopsTpl->assign('xhelp_batchErrorMsg', _XHELP_MESSAGE_NO_EDIT_TICKET); |
314
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
function setpriority_action() |
318
|
|
|
{ |
319
|
|
|
$helper = Helper::getInstance(); |
320
|
|
|
global $eventService, $staff; |
321
|
|
|
if (!isset($_POST['tickets'])) { |
322
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
if (!isset($_POST['priority'])) { |
326
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_PRIORITY); |
327
|
|
|
} |
328
|
|
|
$tickets = implode(',', $_POST['tickets']); |
329
|
|
|
$tickets = cleanTickets($tickets); |
330
|
|
|
$oTickets = Utility::getTickets($tickets); |
331
|
|
|
|
332
|
|
|
$depts = []; |
333
|
|
|
foreach ($oTickets as $ticket) { |
334
|
|
|
$depts[$ticket->getVar('department')] = $ticket->getVar('department'); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
// Check staff permissions |
338
|
|
|
if (!$staff->checkRoleRights(XHELP_SEC_TICKET_PRIORITY, $depts)) { |
339
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_CHANGE_PRIORITY); |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
$ret = Utility::setPriority($tickets, $_POST['priority']); |
343
|
|
|
if ($ret) { |
344
|
|
|
$eventService->trigger('batch_priority', [@$oTickets, $_POST['priority']]); |
345
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_UPDATE_PRIORITY); |
346
|
|
|
} |
347
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_UPDATE_PRIORITY_ERROR); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
function setpriority_display() |
351
|
|
|
{ |
352
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin, $displayName; |
353
|
|
|
$helper = Helper::getInstance(); |
354
|
|
|
//Make sure that some tickets were selected |
355
|
|
|
if (!isset($_POST['tickets'])) { |
356
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
360
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
361
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
362
|
|
|
$oTickets = Utility::getTickets($_POST['tickets']); |
363
|
|
|
$all_users = []; |
364
|
|
|
$j = 0; |
365
|
|
|
|
366
|
|
|
$sortedTickets = makeBatchTicketArray($oTickets, $depts, $all_users, $j, XHELP_SEC_TICKET_PRIORITY); |
367
|
|
|
unset($oTickets); |
368
|
|
|
|
369
|
|
|
//Retrieve all member information for the current page |
370
|
|
|
if (count($all_users)) { |
371
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
372
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
373
|
|
|
} else { |
374
|
|
|
$users = []; |
375
|
|
|
} |
376
|
|
|
$sortedTickets = updateBatchTicketInfo($sortedTickets, $users, $j); |
377
|
|
|
|
378
|
|
|
//Get Array of priorities/descriptions |
379
|
|
|
$aPriority = [ |
380
|
|
|
1 => _XHELP_PRIORITY1, |
381
|
|
|
2 => _XHELP_PRIORITY2, |
382
|
|
|
3 => _XHELP_PRIORITY3, |
383
|
|
|
4 => _XHELP_PRIORITY4, |
384
|
|
|
5 => _XHELP_PRIORITY5, |
385
|
|
|
]; |
386
|
|
|
|
387
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_setpriority.tpl'; // Set template |
388
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
389
|
|
|
$xoopsTpl->assign('xhelp_priorities_desc', $aPriority); |
390
|
|
|
$xoopsTpl->assign('xhelp_priorities', array_keys($aPriority)); |
391
|
|
|
$xoopsTpl->assign('xhelp_priority', 4); |
392
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
393
|
|
|
$xoopsTpl->assign('xhelp_tickets', implode(',', $_POST['tickets'])); |
394
|
|
|
$xoopsTpl->assign('xhelp_goodTickets', $sortedTickets['good']); |
395
|
|
|
$xoopsTpl->assign('xhelp_badTickets', $sortedTickets['bad']); |
396
|
|
|
$xoopsTpl->assign('xhelp_hasGoodTickets', count($sortedTickets['good']) > 0); |
397
|
|
|
$xoopsTpl->assign('xhelp_hasBadTickets', count($sortedTickets['bad']) > 0); |
398
|
|
|
$xoopsTpl->assign('xhelp_batchErrorMsg', _XHELP_MESSAGE_NO_CHANGE_PRIORITY); |
399
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
400
|
|
|
} |
401
|
|
|
|
402
|
|
|
function setstatus_action() |
403
|
|
|
{ |
404
|
|
|
global $eventService, $staff; |
405
|
|
|
$helper = Helper::getInstance(); |
406
|
|
|
if (!isset($_POST['tickets'])) { |
407
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
if (!isset($_POST['status'])) { |
411
|
|
|
$helper->redirect(basename(__FILE__), 3, _AM_XHELP_MESSAGE_NO_STATUS); |
412
|
|
|
} |
413
|
|
|
$tickets = implode(',', $_POST['tickets']); |
414
|
|
|
$tickets = cleanTickets($tickets); |
415
|
|
|
$oTickets = Utility::getTickets($tickets); |
416
|
|
|
|
417
|
|
|
$depts = []; |
418
|
|
|
foreach ($oTickets as $ticket) { |
419
|
|
|
$depts[$ticket->getVar('department')] = $ticket->getVar('department'); |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
// Check staff permissions |
423
|
|
|
if (!$staff->checkRoleRights(XHELP_SEC_TICKET_STATUS, $depts)) { |
424
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_CHANGE_STATUS); |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** @var \XoopsModules\Xhelp\StatusHandler $statusHandler */ |
428
|
|
|
$statusHandler = $helper->getHandler('Status'); |
429
|
|
|
$status = $statusHandler->get($_POST['status']); |
430
|
|
|
$ret = Utility::setStatus($tickets, $_POST['status']); |
431
|
|
|
if ($ret) { |
432
|
|
|
$eventService->trigger('batch_status', [&$oTickets, &$status]); |
433
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_UPDATE_STATUS); |
434
|
|
|
} |
435
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_UPDATE_STATUS_ERROR); |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
function setstatus_display() |
439
|
|
|
{ |
440
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin, $displayName; |
441
|
|
|
$helper = Helper::getInstance(); |
442
|
|
|
/** @var \XoopsModules\Xhelp\StatusHandler $statusHandler */ |
443
|
|
|
$statusHandler = $helper->getHandler('Status'); |
444
|
|
|
$criteria = new \Criteria('', ''); |
445
|
|
|
$criteria->setOrder('ASC'); |
446
|
|
|
$criteria->setSort('description'); |
447
|
|
|
$statuses = $statusHandler->getObjects($criteria); |
448
|
|
|
|
449
|
|
|
//Make sure that some tickets were selected |
450
|
|
|
if (!isset($_POST['tickets'])) { |
451
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
455
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
456
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
457
|
|
|
$oTickets = Utility::getTickets($_POST['tickets']); |
458
|
|
|
$all_users = []; |
459
|
|
|
$j = 0; |
460
|
|
|
|
461
|
|
|
$sortedTickets = makeBatchTicketArray($oTickets, $depts, $all_users, $j, XHELP_SEC_TICKET_STATUS); |
462
|
|
|
unset($oTickets); |
463
|
|
|
|
464
|
|
|
//Retrieve all member information for the current page |
465
|
|
|
if (count($all_users)) { |
466
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
467
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
468
|
|
|
} else { |
469
|
|
|
$users = []; |
470
|
|
|
} |
471
|
|
|
$sortedTickets = updateBatchTicketInfo($sortedTickets, $users, $j); |
472
|
|
|
|
473
|
|
|
//Get Array of Status/Descriptions |
474
|
|
|
$aStatus = []; |
475
|
|
|
foreach ($statuses as $status) { |
476
|
|
|
$aStatus[$status->getVar('id')] = $status->getVar('description'); |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_setstatus.tpl'; // Set template |
480
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
481
|
|
|
$xoopsTpl->assign('xhelp_status_options', $aStatus); |
482
|
|
|
$xoopsTpl->assign('xhelp_tickets', implode(',', $_POST['tickets'])); |
483
|
|
|
$xoopsTpl->assign('xhelp_goodTickets', $sortedTickets['good']); |
484
|
|
|
$xoopsTpl->assign('xhelp_badTickets', $sortedTickets['bad']); |
485
|
|
|
$xoopsTpl->assign('xhelp_hasGoodTickets', count($sortedTickets['good']) > 0); |
486
|
|
|
$xoopsTpl->assign('xhelp_hasBadTickets', count($sortedTickets['bad']) > 0); |
487
|
|
|
$xoopsTpl->assign('xhelp_batchErrorMsg', _XHELP_MESSAGE_NO_CHANGE_STATUS); |
488
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
function setowner_action() |
492
|
|
|
{ |
493
|
|
|
global $eventService, $staff; |
494
|
|
|
$helper = Helper::getInstance(); |
495
|
|
|
if (!isset($_POST['tickets'])) { |
496
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
if (!isset($_POST['owner'])) { |
500
|
|
|
$helper->redirect(basename(__FILE__), 3, _AM_XHELP_MESSAGE_NO_OWNER); |
501
|
|
|
} |
502
|
|
|
$tickets = implode(',', $_POST['tickets']); |
503
|
|
|
$tickets = cleanTickets($tickets); |
504
|
|
|
$oTickets = Utility::getTickets($tickets); |
505
|
|
|
|
506
|
|
|
$depts = []; |
507
|
|
|
foreach ($oTickets as $ticket) { |
508
|
|
|
$depts[$ticket->getVar('department')] = $ticket->getVar('department'); |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
// Check staff permissions |
512
|
|
|
if (!$staff->checkRoleRights(XHELP_SEC_TICKET_OWNERSHIP, $depts)) { |
513
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_CHANGE_OWNER); |
514
|
|
|
} |
515
|
|
|
$ret = Utility::setOwner($tickets, $_POST['owner']); |
516
|
|
|
|
517
|
|
|
if ($ret) { |
518
|
|
|
$eventService->trigger('batch_owner', [&$oTickets, $_POST['owner']]); |
519
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_ASSIGN_OWNER); |
520
|
|
|
} |
521
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_ASSIGN_OWNER_ERROR); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
function setowner_display() |
525
|
|
|
{ |
526
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $displayName; |
527
|
|
|
$helper = Helper::getInstance(); |
528
|
|
|
|
529
|
|
|
//Make sure that some tickets were selected |
530
|
|
|
if (!isset($_POST['tickets'])) { |
531
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
535
|
|
|
$ticketHandler = $helper->getHandler('Ticket'); |
|
|
|
|
536
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
537
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
|
|
|
|
538
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
539
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
|
|
|
540
|
|
|
|
541
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
542
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
543
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
544
|
|
|
$oTickets = Utility::getTickets($_POST['tickets']); |
545
|
|
|
$all_users = []; |
546
|
|
|
$j = 0; |
547
|
|
|
|
548
|
|
|
$sortedTickets = makeBatchTicketArray($oTickets, $depts, $all_users, $j, XHELP_SEC_TICKET_OWNERSHIP); |
549
|
|
|
unset($oTickets); |
550
|
|
|
|
551
|
|
|
//Retrieve all member information for the current page |
552
|
|
|
if (count($all_users)) { |
553
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
554
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
555
|
|
|
} else { |
556
|
|
|
$users = []; |
557
|
|
|
} |
558
|
|
|
$sortedTickets = updateBatchTicketInfo($sortedTickets, $users, $j); |
559
|
|
|
|
560
|
|
|
$aOwners = []; |
561
|
|
|
foreach ($users as $uid => $user) { |
562
|
|
|
$aOwners[$uid] = $uid; |
563
|
|
|
} |
564
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($aOwners)) . ')', 'IN'); |
565
|
|
|
$owners = Utility::getUsers($criteria, $helper->getConfig('xhelp_displayName')); |
|
|
|
|
566
|
|
|
|
567
|
|
|
$a_users = []; |
568
|
|
|
$a_users[0] = _XHELP_NO_OWNER; |
569
|
|
|
foreach ($owners as $owner_id => $owner_name) { |
570
|
|
|
$a_users[$owner_id] = $owner_name; |
571
|
|
|
} |
572
|
|
|
unset($users, $owners, $aOwners); |
573
|
|
|
|
574
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_setowner.tpl'; // Set template |
575
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
576
|
|
|
$xoopsTpl->assign('xhelp_staff_ids', $a_users); |
577
|
|
|
$xoopsTpl->assign('xhelp_tickets', implode(',', $_POST['tickets'])); |
578
|
|
|
$xoopsTpl->assign('xhelp_goodTickets', $sortedTickets['good']); |
579
|
|
|
$xoopsTpl->assign('xhelp_badTickets', $sortedTickets['bad']); |
580
|
|
|
$xoopsTpl->assign('xhelp_hasGoodTickets', count($sortedTickets['good']) > 0); |
581
|
|
|
$xoopsTpl->assign('xhelp_hasBadTickets', count($sortedTickets['bad']) > 0); |
582
|
|
|
$xoopsTpl->assign('xhelp_batchErrorMsg', _XHELP_MESSAGE_NO_CHANGE_OWNER); |
583
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
function addresponse_action() |
587
|
|
|
{ |
588
|
|
|
global $eventService, $session, $staff; |
589
|
|
|
$helper = Helper::getInstance(); |
590
|
|
|
if (!isset($_POST['tickets'])) { |
591
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
592
|
|
|
} |
593
|
|
|
|
594
|
|
|
if (!isset($_POST['response'])) { |
595
|
|
|
$helper->redirect(basename(__FILE__), 3, _AM_XHELP_MESSAGE_NO_RESPONSE); |
596
|
|
|
} |
597
|
|
|
$private = isset($_POST['private']); |
598
|
|
|
|
599
|
|
|
$tickets = implode(',', $_POST['tickets']); |
600
|
|
|
$tickets = cleanTickets($tickets); |
601
|
|
|
$oTickets = Utility::getTickets($tickets); |
602
|
|
|
|
603
|
|
|
$depts = []; |
604
|
|
|
foreach ($oTickets as $ticket) { |
605
|
|
|
$depts[$ticket->getVar('department')] = $ticket->getVar('department'); |
606
|
|
|
} |
607
|
|
|
|
608
|
|
|
// Check staff permissions |
609
|
|
|
if (!$staff->checkRoleRights(XHELP_SEC_RESPONSE_ADD, $depts)) { |
610
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_ADD_RESPONSE); |
611
|
|
|
} |
612
|
|
|
$ret = Utility::addResponse($tickets, $_POST['response'], $_POST['timespent'], $private); |
613
|
|
|
if ($ret) { |
|
|
|
|
614
|
|
|
$session->del('xhelp_batch_addresponse'); |
615
|
|
|
$session->del('xhelp_batch_response'); |
616
|
|
|
$session->del('xhelp_batch_timespent'); |
617
|
|
|
$session->del('xhelp_batch_private'); |
618
|
|
|
|
619
|
|
|
$eventService->trigger('batch_response', [&$oTickets, &$ret]); |
620
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_ADDRESPONSE); |
621
|
|
|
} |
622
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_ADDRESPONSE_ERROR); |
623
|
|
|
} |
624
|
|
|
|
625
|
|
|
function addresponse_display() |
626
|
|
|
{ |
627
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin, $session, $displayName; |
628
|
|
|
$helper = Helper::getInstance(); |
629
|
|
|
/** @var \XoopsModules\Xhelp\ResponseTemplatesHandler $responseTemplatesHandler */ |
630
|
|
|
$responseTemplatesHandler = $helper->getHandler('ResponseTemplates'); |
631
|
|
|
$ticketVar = 'xhelp_batch_addresponse'; |
632
|
|
|
$tpl = 0; |
633
|
|
|
$uid = $xoopsUser->getVar('uid'); |
634
|
|
|
|
635
|
|
|
//Make sure that some tickets were selected |
636
|
|
|
if (isset($_POST['tickets'])) { |
637
|
|
|
$tickets = $_POST['tickets']; |
638
|
|
|
} else { |
639
|
|
|
if (!$tickets = $session->get($ticketVar)) { |
640
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
641
|
|
|
} |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
645
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
646
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
647
|
|
|
$oTickets = Utility::getTickets($_POST['tickets']); |
648
|
|
|
$all_users = []; |
649
|
|
|
$j = 0; |
650
|
|
|
|
651
|
|
|
$sortedTickets = makeBatchTicketArray($oTickets, $depts, $all_users, $j, XHELP_SEC_RESPONSE_ADD); |
652
|
|
|
unset($oTickets); |
653
|
|
|
|
654
|
|
|
//Retrieve all member information for the current page |
655
|
|
|
if (count($all_users)) { |
656
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
657
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
658
|
|
|
} else { |
659
|
|
|
$users = []; |
660
|
|
|
} |
661
|
|
|
$sortedTickets = updateBatchTicketInfo($sortedTickets, $users, $j); |
662
|
|
|
|
663
|
|
|
//Store tickets in session so they won't be in URL |
664
|
|
|
$session->set($ticketVar, $tickets); |
665
|
|
|
|
666
|
|
|
//Check if a predefined response was selected |
667
|
|
|
if (Request::hasVar('tpl', 'REQUEST')) { |
668
|
|
|
$tpl = $_REQUEST['tpl']; |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_batch_response.tpl'; |
672
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
673
|
|
|
$xoopsTpl->assign('xhelp_tickets', implode(',', $tickets)); |
674
|
|
|
$xoopsTpl->assign('xhelp_formaction', basename(__FILE__)); |
675
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
676
|
|
|
$xoopsTpl->assign('xhelp_timespent', ($timespent = $session->get('xhelp_batch_timespent')) ? $timespent : ''); |
677
|
|
|
$xoopsTpl->assign('xhelp_goodTickets', $sortedTickets['good']); |
678
|
|
|
$xoopsTpl->assign('xhelp_badTickets', $sortedTickets['bad']); |
679
|
|
|
$xoopsTpl->assign('xhelp_hasGoodTickets', count($sortedTickets['good']) > 0); |
680
|
|
|
$xoopsTpl->assign('xhelp_hasBadTickets', count($sortedTickets['bad']) > 0); |
681
|
|
|
$xoopsTpl->assign('xhelp_batchErrorMsg', _XHELP_MESSAGE_NO_ADD_RESPONSE); |
682
|
|
|
$xoopsTpl->assign('xhelp_responseTpl', $tpl); |
683
|
|
|
|
684
|
|
|
//Get all staff defined templates |
685
|
|
|
$criteria = new \Criteria('uid', $uid); |
686
|
|
|
$criteria->setSort('name'); |
687
|
|
|
$responseTpl = $responseTemplatesHandler->getObjects($criteria, true); |
688
|
|
|
|
689
|
|
|
//Fill Response Template Array |
690
|
|
|
$tpls = []; |
691
|
|
|
$tpls[0] = '------------------'; |
692
|
|
|
|
693
|
|
|
foreach ($responseTpl as $key => $obj) { |
694
|
|
|
$tpls[$key] = $obj->getVar('name'); |
695
|
|
|
} |
696
|
|
|
$xoopsTpl->assign('xhelp_responseTpl_options', $tpls); |
697
|
|
|
//Get response message to display |
698
|
|
|
if (isset($responseTpl[$tpl])) { // Display Template Text |
699
|
|
|
$xoopsTpl->assign('xhelp_response_message', $responseTpl[$tpl]->getVar('response', 'e')); |
700
|
|
|
} else { |
701
|
|
|
$response = $session->get('xhelp_batch_response'); |
702
|
|
|
if ($response) { //Display Saved Text |
703
|
|
|
$xoopsTpl->assign('xhelp_response_message', $response); |
704
|
|
|
} |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
//Private Message? |
708
|
|
|
$xoopsTpl->assign('xhelp_private', ($private = $session->get('xhelp_batch_private')) ? $private : false); |
709
|
|
|
|
710
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
711
|
|
|
} |
712
|
|
|
|
713
|
|
|
function delete_action() |
714
|
|
|
{ |
715
|
|
|
global $eventService, $staff; |
716
|
|
|
$helper = Helper::getInstance(); |
717
|
|
|
if (!isset($_POST['tickets'])) { |
718
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_TICKETS); |
719
|
|
|
} |
720
|
|
|
|
721
|
|
|
$tickets = implode(',', $_POST['tickets']); |
722
|
|
|
$tickets = cleanTickets($tickets); |
723
|
|
|
$oTickets = Utility::getTickets($tickets); |
724
|
|
|
|
725
|
|
|
$depts = []; |
726
|
|
|
foreach ($oTickets as $ticket) { |
727
|
|
|
$depts[$ticket->getVar('department')] = $ticket->getVar('department'); |
728
|
|
|
} |
729
|
|
|
|
730
|
|
|
// Check staff permissions |
731
|
|
|
if (!$staff->checkRoleRights(XHELP_SEC_TICKET_DELETE, $depts)) { |
732
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_NO_DELETE_TICKET); |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
$ret = Utility::deleteTickets($tickets); |
736
|
|
|
if ($ret) { |
737
|
|
|
$eventService->trigger('batch_delete_ticket', [@$oTickets]); |
738
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_DELETE_TICKETS); |
739
|
|
|
} |
740
|
|
|
$helper->redirect(basename(__FILE__), 3, _XHELP_MESSAGE_DELETE_TICKETS_ERROR); |
741
|
|
|
} |
742
|
|
|
|
743
|
|
|
function delete_display() |
744
|
|
|
{ |
745
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin, $displayName; |
746
|
|
|
$helper = Helper::getInstance(); |
747
|
|
|
//Make sure that some tickets were selected |
748
|
|
|
if (!isset($_POST['tickets'])) { |
749
|
|
|
$helper->redirect('index.php', 3, _XHELP_MESSAGE_NO_TICKETS); |
750
|
|
|
} |
751
|
|
|
|
752
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
753
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
754
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
755
|
|
|
$oTickets = Utility::getTickets($_POST['tickets']); |
756
|
|
|
$all_users = []; |
757
|
|
|
$j = 0; |
758
|
|
|
|
759
|
|
|
$sortedTickets = makeBatchTicketArray($oTickets, $depts, $all_users, $j, XHELP_SEC_TICKET_DELETE); |
760
|
|
|
unset($oTickets); |
761
|
|
|
|
762
|
|
|
//Retrieve all member information for the current page |
763
|
|
|
if (count($all_users)) { |
764
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
765
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
766
|
|
|
} else { |
767
|
|
|
$users = []; |
768
|
|
|
} |
769
|
|
|
$sortedTickets = updateBatchTicketInfo($sortedTickets, $users, $j); |
770
|
|
|
|
771
|
|
|
$hiddenvars = [ |
|
|
|
|
772
|
|
|
'delete' => _XHELP_BUTTON_SET, //'tickets' => implode($_POST['tickets'], ','), |
773
|
|
|
'op' => 'delete', |
774
|
|
|
]; |
775
|
|
|
$aHiddens[] = [ |
|
|
|
|
776
|
|
|
'name' => 'delete', |
777
|
|
|
'value' => _XHELP_BUTTON_SET, |
778
|
|
|
]; |
779
|
|
|
$aHiddens[] = [ |
780
|
|
|
'name' => 'op', |
781
|
|
|
'value' => 'delete', |
782
|
|
|
]; |
783
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_deletetickets.tpl'; |
784
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
785
|
|
|
$xoopsTpl->assign('xhelp_message', _XHELP_MESSAGE_TICKET_DELETE_CNFRM); |
786
|
|
|
$xoopsTpl->assign('xhelp_hiddens', $aHiddens); |
787
|
|
|
$xoopsTpl->assign('xhelp_goodTickets', $sortedTickets['good']); |
788
|
|
|
$xoopsTpl->assign('xhelp_badTickets', $sortedTickets['bad']); |
789
|
|
|
$xoopsTpl->assign('xhelp_hasGoodTickets', count($sortedTickets['good']) > 0); |
790
|
|
|
$xoopsTpl->assign('xhelp_hasBadTickets', count($sortedTickets['bad']) > 0); |
791
|
|
|
$xoopsTpl->assign('xhelp_batchErrorMsg', _XHELP_MESSAGE_NO_DELETE_TICKET); |
792
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
793
|
|
|
} |
794
|
|
|
|
795
|
|
|
/** |
796
|
|
|
* @param int $topicid |
797
|
|
|
* @param int $limit |
798
|
|
|
* @param int $start |
799
|
|
|
* @return bool |
800
|
|
|
* @todo make SmartyNewsRenderer class |
801
|
|
|
*/ |
802
|
|
|
function getAnnouncements(int $topicid, int $limit = 5, int $start = 0): bool |
803
|
|
|
{ |
804
|
|
|
global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsTpl; |
805
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
806
|
|
|
$moduleHandler = xoops_getHandler('module'); |
807
|
|
|
|
808
|
|
|
if (0 == $topicid || (!$count = $moduleHandler->getByDirname('news'))) { |
|
|
|
|
809
|
|
|
$xoopsTpl->assign('xhelp_useAnnouncements', false); |
810
|
|
|
|
811
|
|
|
return false; |
812
|
|
|
} |
813
|
|
|
// $news_version = round($count->getVar('version') / 100, 2); |
814
|
|
|
// |
815
|
|
|
// switch ($news_version) { |
816
|
|
|
// case '1.1': |
817
|
|
|
// $sarray = NewsStory::getAllPublished($limit, $start, $topicid); |
818
|
|
|
// break; |
819
|
|
|
// |
820
|
|
|
// case '1.21': |
821
|
|
|
// default: |
822
|
|
|
|
823
|
|
|
if (!class_exists(News\NewsStory::class)) { |
|
|
|
|
824
|
|
|
return false; |
825
|
|
|
} |
826
|
|
|
|
827
|
|
|
$sarray = News\NewsStory::getAllPublished($limit, $start, false, $topicid); |
828
|
|
|
// } |
829
|
|
|
|
830
|
|
|
$scount = count($sarray); |
|
|
|
|
831
|
|
|
foreach ($sarray as $iValue) { |
832
|
|
|
$story = []; |
833
|
|
|
$story['id'] = $iValue->storyid(); |
834
|
|
|
$story['poster'] = $iValue->uname(); |
835
|
|
|
if (false !== $story['poster']) { |
836
|
|
|
$story['poster'] = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $iValue->uid() . "'>" . $story['poster'] . '</a>'; |
837
|
|
|
} else { |
838
|
|
|
$story['poster'] = $xoopsConfig['anonymous']; |
839
|
|
|
} |
840
|
|
|
$story['posttime'] = formatTimestamp($iValue->published()); |
841
|
|
|
$story['text'] = $iValue->hometext(); |
842
|
|
|
$introcount = mb_strlen($story['text']); |
843
|
|
|
$fullcount = (int)mb_strlen($iValue->bodytext()); |
844
|
|
|
$totalcount = $introcount + $fullcount; |
|
|
|
|
845
|
|
|
$morelink = ''; |
846
|
|
|
if ($fullcount > 1) { |
847
|
|
|
$morelink .= '<a href="' . XOOPS_URL . '/modules/news/article.php?storyid=' . $iValue->storyid() . ''; |
848
|
|
|
$morelink .= '">' . _XHELP_ANNOUNCE_READMORE . '</a> | '; |
849
|
|
|
//$morelink .= sprintf(_NW_BYTESMORE,$totalcount); |
850
|
|
|
//$morelink .= ' | '; |
851
|
|
|
} |
852
|
|
|
$ccount = $iValue->comments(); |
853
|
|
|
$morelink .= '<a href="' . XOOPS_URL . '/modules/news/article.php?storyid=' . $iValue->storyid() . ''; |
854
|
|
|
$morelink2 = '<a href="' . XOOPS_URL . '/modules/news/article.php?storyid=' . $iValue->storyid() . ''; |
855
|
|
|
if (0 == $ccount) { |
856
|
|
|
$morelink .= '">' . _XHELP_COMMMENTS . '</a>'; |
857
|
|
|
} else { |
858
|
|
|
if ($fullcount < 1) { |
859
|
|
|
if (1 == $ccount) { |
860
|
|
|
$morelink .= '">' . _XHELP_ANNOUNCE_READMORE . '</a> | ' . $morelink2 . '">' . _XHELP_ANNOUNCE_ONECOMMENT . '</a>'; |
861
|
|
|
} else { |
862
|
|
|
$morelink .= '">' . _XHELP_ANNOUNCE_READMORE . '</a> | ' . $morelink2 . '">'; |
863
|
|
|
$morelink .= sprintf(_XHELP_ANNOUNCE_NUMCOMMENTS, $ccount); |
864
|
|
|
$morelink .= '</a>'; |
865
|
|
|
} |
866
|
|
|
} else { |
867
|
|
|
if (1 == $ccount) { |
868
|
|
|
$morelink .= '">' . _XHELP_ANNOUNCE_ONECOMMENT . '</a>'; |
869
|
|
|
} else { |
870
|
|
|
$morelink .= '">'; |
871
|
|
|
$morelink .= sprintf(_XHELP_ANNOUNCE_NUMCOMMENTS, $ccount); |
872
|
|
|
$morelink .= '</a>'; |
873
|
|
|
} |
874
|
|
|
} |
875
|
|
|
} |
876
|
|
|
$story['morelink'] = $morelink; |
877
|
|
|
$story['adminlink'] = ''; |
878
|
|
|
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) { |
879
|
|
|
$story['adminlink'] = $iValue->adminlink(); |
880
|
|
|
} |
881
|
|
|
//$story['mail_link'] = 'mailto:?subject='.sprintf(_NW_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).': '.XOOPS_URL.'/modules/news/article.php?storyid='.$sarray[$i]->storyid(); |
882
|
|
|
$story['imglink'] = ''; |
883
|
|
|
$story['align'] = ''; |
884
|
|
|
if ($iValue->topicdisplay()) { |
885
|
|
|
$story['imglink'] = $iValue->imglink(); |
886
|
|
|
$story['align'] = $iValue->topicalign(); |
887
|
|
|
} |
888
|
|
|
$story['title'] = $iValue->textlink() . ' : ' . "<a href='" . XOOPS_URL . '/modules/news/article.php?storyid=' . $iValue->storyid() . "'>" . $iValue->title() . '</a>'; |
889
|
|
|
$story['hits'] = $iValue->counter(); |
890
|
|
|
// The line below can be used to display a Permanent Link image |
891
|
|
|
// $story['title'] .= " <a href='".XOOPS_URL."/modules/news/article.php?storyid=".$sarray[$i]->storyid()."'><img src='".XOOPS_URL."/modules/news/assets/images/x.gif' alt='Permanent Link'></a>"; |
892
|
|
|
|
893
|
|
|
$xoopsTpl->append('xhelp_announcements', $story); |
894
|
|
|
$xoopsTpl->assign('xhelp_useAnnouncements', true); |
895
|
|
|
unset($story); |
896
|
|
|
} |
897
|
|
|
return true; |
898
|
|
|
//=========================================== |
899
|
|
|
} |
900
|
|
|
|
901
|
|
|
/** |
902
|
|
|
* @param string $dept |
903
|
|
|
* @return string |
904
|
|
|
*/ |
905
|
|
|
function getDepartmentName(string $dept): string |
906
|
|
|
{ |
907
|
|
|
//BTW - I don't like that we rely on the global $depts variable to exist. |
908
|
|
|
// What if we moved this into the DepartmentsHandler class? |
909
|
|
|
global $depts; |
910
|
|
|
if (isset($depts[$dept])) { // Make sure that ticket has a department |
911
|
|
|
$department = $depts[$dept]->getVar('department'); |
912
|
|
|
} else { // Else, fill it with 0 |
913
|
|
|
$department = _XHELP_TEXT_NO_DEPT; |
914
|
|
|
} |
915
|
|
|
|
916
|
|
|
return $department; |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* @param string $tickets |
921
|
|
|
* @return array |
922
|
|
|
*/ |
923
|
|
|
function cleanTickets(string $tickets): array |
924
|
|
|
{ |
925
|
|
|
$t_tickets = explode(',', $tickets); |
926
|
|
|
$ret = []; |
927
|
|
|
foreach ($t_tickets as $ticket) { |
928
|
|
|
$ticket = (int)$ticket; |
929
|
|
|
if ($ticket) { |
930
|
|
|
$ret[] = $ticket; |
931
|
|
|
} |
932
|
|
|
} |
933
|
|
|
unset($t_tickets); |
934
|
|
|
|
935
|
|
|
return $ret; |
936
|
|
|
} |
937
|
|
|
|
938
|
|
|
function staffmain_display() |
939
|
|
|
{ |
940
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin; |
941
|
|
|
global $limit, $start, $refresh, $displayName, $xhelp_isStaff, $session, $eventService, $xhelp_module_header, $aSavedSearches; |
942
|
|
|
$helper = Helper::getInstance(); |
943
|
|
|
if (!$xhelp_isStaff) { |
944
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
945
|
|
|
} |
946
|
|
|
|
947
|
|
|
$xhelpConfig = Utility::getModuleConfig(); |
948
|
|
|
//Get Saved Searches for Current User + Searches for every user |
949
|
|
|
$allSavedSearches = Utility::getSavedSearches([$xoopsUser->getVar('uid'), XHELP_GLOBAL_UID]); |
950
|
|
|
|
951
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
952
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
953
|
|
|
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
954
|
|
|
$ticketHandler = $helper->getHandler('Ticket'); |
955
|
|
|
/** @var \XoopsModules\Xhelp\TicketListHandler $ticketListHandler */ |
956
|
|
|
$ticketListHandler = $helper->getHandler('TicketList'); |
957
|
|
|
|
958
|
|
|
//Set Number of items in each section |
959
|
|
|
if (0 == $limit) { |
960
|
|
|
$limit = $xhelpConfig['xhelp_staffTicketCount']; |
961
|
|
|
} elseif (-1 == $limit) { |
962
|
|
|
$limit = 0; |
963
|
|
|
} |
964
|
|
|
$uid = $xoopsUser->getVar('uid'); |
965
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
966
|
|
|
$priority = $ticketHandler->getStaffTickets($uid, XHELP_QRY_STAFF_HIGHPRIORITY, $start, $limit); |
|
|
|
|
967
|
|
|
$ticketLists = $ticketListHandler->getListsByUser($uid); |
968
|
|
|
$all_users = []; |
969
|
|
|
|
970
|
|
|
$tickets = []; |
971
|
|
|
$i = 0; |
972
|
|
|
foreach ($ticketLists as $ticketList) { |
973
|
|
|
$searchid = $ticketList->getVar('searchid'); |
974
|
|
|
$criteria = $allSavedSearches[$searchid]['search']; |
975
|
|
|
$searchname = $allSavedSearches[$searchid]['name']; |
976
|
|
|
$searchOnCustFields = $allSavedSearches[$searchid]['hasCustFields']; |
977
|
|
|
$criteria->setLimit($limit); |
978
|
|
|
$newTickets = $ticketHandler->getObjectsByStaff($criteria, false, $searchOnCustFields); |
979
|
|
|
$tickets[$i] = []; |
980
|
|
|
$tickets[$i]['tickets'] = []; |
981
|
|
|
$tickets[$i]['searchid'] = $searchid; |
982
|
|
|
$tickets[$i]['searchname'] = $searchname; |
983
|
|
|
$tickets[$i]['tableid'] = safeHTMLId($searchname); |
984
|
|
|
$tickets[$i]['hasTickets'] = count($newTickets) > 0; |
985
|
|
|
$j = 0; |
986
|
|
|
foreach ($newTickets as $ticket) { |
987
|
|
|
$dept = @$depts[$ticket->getVar('department')]; |
988
|
|
|
$tickets[$i]['tickets'][$j] = [ |
989
|
|
|
'id' => $ticket->getVar('id'), |
990
|
|
|
'uid' => $ticket->getVar('uid'), |
991
|
|
|
'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), |
992
|
|
|
'full_subject' => $ticket->getVar('subject'), |
993
|
|
|
'description' => $ticket->getVar('description'), |
994
|
|
|
'department' => safeDepartmentName($dept), |
995
|
|
|
'departmentid' => $ticket->getVar('department'), |
996
|
|
|
'departmenturl' => Utility::createURI('index.php', [ |
997
|
|
|
'op' => 'staffViewAll', |
998
|
|
|
'dept' => $ticket->getVar('department'), |
999
|
|
|
]), |
1000
|
|
|
'priority' => $ticket->getVar('priority'), |
1001
|
|
|
'status' => Utility::getStatus($ticket->getVar('status')), |
1002
|
|
|
'posted' => $ticket->posted(), |
1003
|
|
|
'ownership' => _XHELP_MESSAGE_NOOWNER, |
1004
|
|
|
'ownerid' => $ticket->getVar('ownership'), |
1005
|
|
|
'closedBy' => $ticket->getVar('closedBy'), |
1006
|
|
|
'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), |
1007
|
|
|
'uname' => '', |
1008
|
|
|
'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), |
1009
|
|
|
'ownerinfo' => '', |
1010
|
|
|
'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), |
1011
|
|
|
'overdue' => $ticket->isOverdue(), |
1012
|
|
|
]; |
1013
|
|
|
$all_users[$ticket->getVar('uid')] = ''; |
1014
|
|
|
$all_users[$ticket->getVar('ownership')] = ''; |
1015
|
|
|
$all_users[$ticket->getVar('closedBy')] = ''; |
1016
|
|
|
++$j; |
1017
|
|
|
} |
1018
|
|
|
++$i; |
1019
|
|
|
unset($newTickets); |
1020
|
|
|
} |
1021
|
|
|
|
1022
|
|
|
//Retrieve all member information for the current page |
1023
|
|
|
if (count($all_users)) { |
1024
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($all_users)) . ')', 'IN'); |
1025
|
|
|
$users = Utility::getUsers($criteria, $displayName); |
1026
|
|
|
} else { |
1027
|
|
|
$users = []; |
1028
|
|
|
} |
1029
|
|
|
|
1030
|
|
|
//Update tickets with user information |
1031
|
|
|
foreach ($tickets as $i => $iValue) { |
1032
|
|
|
foreach ($iValue['tickets'] as $j => $jValue) { |
1033
|
|
|
if (isset($users[$tickets[$i]['tickets'][$j]['uid']])) { |
1034
|
|
|
$tickets[$i]['tickets'][$j]['uname'] = $users[$tickets[$i]['tickets'][$j]['uid']]; |
1035
|
|
|
} else { |
1036
|
|
|
$tickets[$i]['tickets'][$j]['uname'] = $xoopsConfig['anonymous']; |
1037
|
|
|
} |
1038
|
|
|
if ($tickets[$i]['tickets'][$j]['ownerid']) { |
1039
|
|
|
if (isset($users[$tickets[$i]['tickets'][$j]['ownerid']])) { |
1040
|
|
|
$tickets[$i]['tickets'][$j]['ownership'] = $users[$tickets[$i]['tickets'][$j]['ownerid']]; |
1041
|
|
|
$tickets[$i]['tickets'][$j]['ownerinfo'] = XOOPS_URL . '/userinfo.php?uid=' . $tickets[$i]['tickets'][$j]['ownerid']; |
1042
|
|
|
} |
1043
|
|
|
} |
1044
|
|
|
} |
1045
|
|
|
} |
1046
|
|
|
|
1047
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_staff_index.tpl'; // Set template |
1048
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; // Include the page header |
1049
|
|
|
if ($refresh > 0) { |
1050
|
|
|
$xhelp_module_header .= "<meta http-equiv=\"Refresh\" content=\"$refresh;url=" . XOOPS_URL . "/modules/xhelp/index.php?refresh=$refresh\">"; |
1051
|
|
|
} |
1052
|
|
|
$xoopsTpl->assign('xhelp_baseURL', XHELP_BASE_URL); |
1053
|
|
|
$xoopsTpl->assign('xhelp_ticketLists', $tickets); |
1054
|
|
|
$xoopsTpl->assign('xhelp_hasTicketLists', count($tickets) > 0); |
1055
|
|
|
$xoopsTpl->assign('xhelp_refresh', $refresh); |
1056
|
|
|
$xoopsTpl->assign('xoops_module_header', $xhelp_module_header); |
1057
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
1058
|
|
|
$xoopsTpl->assign('xhelp_uid', $xoopsUser->getVar('uid')); |
1059
|
|
|
$xoopsTpl->assign('xhelp_current_file', basename(__FILE__)); |
1060
|
|
|
$xoopsTpl->assign('xhelp_savedSearches', $aSavedSearches); |
1061
|
|
|
$xoopsTpl->assign('xhelp_allSavedSearches', $allSavedSearches); |
1062
|
|
|
|
1063
|
|
|
getAnnouncements((int)$xhelpConfig['xhelp_announcements']); |
1064
|
|
|
|
1065
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
1066
|
|
|
} |
1067
|
|
|
|
1068
|
|
|
/** |
1069
|
|
|
* @param string $orig_text |
1070
|
|
|
* @return array|string|string[]|null |
1071
|
|
|
*/ |
1072
|
|
|
function safeHTMLId(string $orig_text) |
1073
|
|
|
{ |
1074
|
|
|
//Only allow alphanumeric characters |
1075
|
|
|
$match = ['/[^a-zA-Z0-9]]/', '/\s/']; |
1076
|
|
|
$replace = ['', '']; |
1077
|
|
|
|
1078
|
|
|
$htmlID = preg_replace($match, $replace, $orig_text); |
1079
|
|
|
|
1080
|
|
|
return $htmlID; |
1081
|
|
|
} |
1082
|
|
|
|
1083
|
|
|
/** |
1084
|
|
|
* @param \XoopsModules\Xhelp\Department $deptObj |
1085
|
|
|
* @return string |
1086
|
|
|
*/ |
1087
|
|
|
function safeDepartmentName(\XoopsModules\Xhelp\Department $deptObj): string |
1088
|
|
|
{ |
1089
|
|
|
if (is_object($deptObj)) { |
1090
|
|
|
$department = $deptObj->getVar('department'); |
1091
|
|
|
} else { // Else, fill it with 0 |
1092
|
|
|
$department = _XHELP_TEXT_NO_DEPT; |
1093
|
|
|
} |
1094
|
|
|
|
1095
|
|
|
return $department; |
1096
|
|
|
} |
1097
|
|
|
|
1098
|
|
|
function staffviewall_display() |
1099
|
|
|
{ |
1100
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin; |
1101
|
|
|
global $xhelp_isStaff, $sort_order, $start, $limit, $xhelp_module_header, $state_opt, $aSavedSearches; |
1102
|
|
|
$helper = Helper::getInstance(); |
1103
|
|
|
if (!$xhelp_isStaff) { |
1104
|
|
|
$helper->redirect(basename(__FILE__), 3, _NOPERM); |
1105
|
|
|
} |
1106
|
|
|
|
1107
|
|
|
//Sanity Check: sort / order column valid |
1108
|
|
|
$sort = @$_REQUEST['sort']; |
1109
|
|
|
$order = @$_REQUEST['order']; |
1110
|
|
|
|
1111
|
|
|
$sort_columns = [ |
1112
|
|
|
'id' => 'DESC', |
1113
|
|
|
'priority' => 'DESC', |
1114
|
|
|
'elapsed' => 'ASC', |
1115
|
|
|
'lastupdate' => 'ASC', |
1116
|
|
|
'status' => 'ASC', |
1117
|
|
|
'subject' => 'ASC', |
1118
|
|
|
'department' => 'ASC', |
1119
|
|
|
'ownership' => 'ASC', |
1120
|
|
|
'uid' => 'ASC', |
1121
|
|
|
]; |
1122
|
|
|
$sort = array_key_exists(mb_strtolower((string)$sort), $sort_columns) ? $sort : 'id'; |
1123
|
|
|
$order = (in_array(mb_strtoupper((string)$order), $sort_order) ? $order : $sort_columns[$sort]); |
1124
|
|
|
|
1125
|
|
|
$uid = $xoopsUser->getVar('uid'); |
1126
|
|
|
$dept = Request::getInt('dept', 0); |
1127
|
|
|
$status = Request::getInt('status', -1); |
1128
|
|
|
$ownership = Request::getInt('ownership', -1); |
1129
|
|
|
$state = Request::getInt('state', -1); |
1130
|
|
|
|
1131
|
|
|
$xhelpConfig = Utility::getModuleConfig(); |
1132
|
|
|
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
1133
|
|
|
$ticketHandler = $helper->getHandler('Ticket'); |
1134
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
1135
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
1136
|
|
|
|
1137
|
|
|
if (0 == $limit) { |
1138
|
|
|
$limit = $xhelpConfig['xhelp_staffTicketCount']; |
1139
|
|
|
} elseif (-1 == $limit) { |
1140
|
|
|
$limit = 0; |
1141
|
|
|
} |
1142
|
|
|
|
1143
|
|
|
//Prepare Database Query and Querystring |
1144
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('uid', $uid, '=', 'j')); |
1145
|
|
|
$qs = [ |
1146
|
|
|
'op' => 'staffViewAll', //Common Query String Values |
1147
|
|
|
'start' => $start, |
1148
|
|
|
'limit' => $limit, |
1149
|
|
|
]; |
1150
|
|
|
|
1151
|
|
|
if ($dept) { |
1152
|
|
|
$qs['dept'] = $dept; |
1153
|
|
|
$criteria->add(new \Criteria('department', $dept, '=', 't')); |
1154
|
|
|
} |
1155
|
|
|
if (-1 != $status) { |
1156
|
|
|
$qs['status'] = $status; |
1157
|
|
|
$criteria->add(new \Criteria('status', $status, '=', 't')); |
1158
|
|
|
} |
1159
|
|
|
if (-1 != $ownership) { |
1160
|
|
|
$qs['ownership'] = $ownership; |
1161
|
|
|
$criteria->add(new \Criteria('ownership', $ownership, '=', 't')); |
1162
|
|
|
} |
1163
|
|
|
|
1164
|
|
|
if (-1 != $state) { |
1165
|
|
|
$qs['state'] = $state; |
1166
|
|
|
$criteria->add(new \Criteria('state', $state, '=', 's')); |
1167
|
|
|
} |
1168
|
|
|
|
1169
|
|
|
$criteria->setLimit($limit); |
1170
|
|
|
$criteria->setStart($start); |
1171
|
|
|
$criteria->setSort($sort); |
1172
|
|
|
$criteria->setOrder($order); |
1173
|
|
|
|
1174
|
|
|
//Setup Column Sorting Vars |
1175
|
|
|
$tpl_cols = []; |
1176
|
|
|
foreach ($sort_columns as $col => $initsort) { |
1177
|
|
|
$col_qs = ['sort' => $col]; |
1178
|
|
|
//Check if we need to sort by current column |
1179
|
|
|
if ($sort == $col) { |
1180
|
|
|
$col_qs['order'] = ($order == $sort_order[0] ? $sort_order[1] : $sort_order[0]); |
1181
|
|
|
$col_sortby = true; |
1182
|
|
|
} else { |
1183
|
|
|
$col_qs['order'] = $initsort; |
1184
|
|
|
$col_sortby = false; |
1185
|
|
|
} |
1186
|
|
|
$tpl_cols[$col] = [ |
1187
|
|
|
'url' => Utility::createURI(basename(__FILE__), array_merge($qs, $col_qs)), |
1188
|
|
|
'urltitle' => _XHELP_TEXT_SORT_TICKETS, |
1189
|
|
|
'sortby' => $col_sortby, |
1190
|
|
|
'sortdir' => \mb_strtolower($col_qs['order']), |
1191
|
|
|
]; |
1192
|
|
|
} |
1193
|
|
|
|
1194
|
|
|
$allTickets = $ticketHandler->getObjectsByStaff($criteria, true); |
1195
|
|
|
$count = $ticketHandler->getCountByStaff($criteria); |
1196
|
|
|
$nav = new \XoopsPageNav($count, $limit, $start, 'start', "op=staffViewAll&limit=$limit&sort=$sort&order=$order&dept=$dept&status=$status&ownership=$ownership"); |
1197
|
|
|
$tickets = []; |
1198
|
|
|
$allUsers = []; |
1199
|
|
|
$depts = &$membershipHandler->membershipByStaff($xoopsUser->getVar('uid'), true); //All Departments for Staff Member |
1200
|
|
|
|
1201
|
|
|
foreach ($allTickets as $ticket) { |
1202
|
|
|
$deptid = $ticket->getVar('department'); |
1203
|
|
|
$tickets[] = [ |
1204
|
|
|
'id' => $ticket->getVar('id'), |
1205
|
|
|
'uid' => $ticket->getVar('uid'), |
1206
|
|
|
'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), |
1207
|
|
|
'full_subject' => $ticket->getVar('subject'), |
1208
|
|
|
'description' => $ticket->getVar('description'), |
1209
|
|
|
'department' => safeDepartmentName($depts[$deptid]), |
1210
|
|
|
'departmentid' => $deptid, |
1211
|
|
|
'departmenturl' => Utility::createURI('index.php', ['op' => 'staffViewAll', 'dept' => $deptid]), |
1212
|
|
|
'priority' => $ticket->getVar('priority'), |
1213
|
|
|
'status' => Utility::getStatus($ticket->getVar('status')), |
1214
|
|
|
'posted' => $ticket->posted(), |
1215
|
|
|
'ownership' => _XHELP_MESSAGE_NOOWNER, |
1216
|
|
|
'ownerid' => $ticket->getVar('ownership'), |
1217
|
|
|
'closedBy' => $ticket->getVar('closedBy'), |
1218
|
|
|
'closedByUname' => '', |
1219
|
|
|
'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), |
1220
|
|
|
'uname' => '', |
1221
|
|
|
'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), |
1222
|
|
|
'ownerinfo' => '', |
1223
|
|
|
'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), |
1224
|
|
|
'elapsed' => $ticket->elapsed(), |
1225
|
|
|
'lastUpdate' => $ticket->lastUpdate(), |
1226
|
|
|
'overdue' => $ticket->isOverdue(), |
1227
|
|
|
]; |
1228
|
|
|
$allUsers[$ticket->getVar('uid')] = ''; |
1229
|
|
|
$allUsers[$ticket->getVar('ownership')] = ''; |
1230
|
|
|
$allUsers[$ticket->getVar('closedBy')] = ''; |
1231
|
|
|
} |
1232
|
|
|
$has_allTickets = count($allTickets) > 0; |
1233
|
|
|
unset($allTickets); |
1234
|
|
|
|
1235
|
|
|
//Get all member information needed on this page |
1236
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', array_keys($allUsers)) . ')', 'IN'); |
1237
|
|
|
$users = Utility::getUsers($criteria, $xhelpConfig['xhelp_displayName']); |
1238
|
|
|
unset($allUsers); |
1239
|
|
|
|
1240
|
|
|
$staff_opt = Utility::getStaff($xhelpConfig['xhelp_displayName']); |
1241
|
|
|
|
1242
|
|
|
foreach ($tickets as $i => $iValue) { |
1243
|
|
|
if (isset($users[$iValue['uid']])) { |
1244
|
|
|
$tickets[$i]['uname'] = $users[$iValue['uid']]; |
1245
|
|
|
} else { |
1246
|
|
|
$tickets[$i]['uname'] = $xoopsConfig['anonymous']; |
1247
|
|
|
} |
1248
|
|
|
if ($tickets[$i]['ownerid']) { |
1249
|
|
|
if (isset($users[$tickets[$i]['ownerid']])) { |
1250
|
|
|
$tickets[$i]['ownership'] = $users[$tickets[$i]['ownerid']]; |
1251
|
|
|
$tickets[$i]['ownerinfo'] = XHELP_SITE_URL . '/userinfo.php?uid=' . $tickets[$i]['ownerid']; |
1252
|
|
|
} |
1253
|
|
|
} |
1254
|
|
|
if ($tickets[$i]['closedBy']) { |
1255
|
|
|
if (isset($users[$tickets[$i]['closedBy']])) { |
1256
|
|
|
$tickets[$i]['closedByUname'] = $users[$tickets[$i]['closedBy']]; |
1257
|
|
|
} |
1258
|
|
|
} |
1259
|
|
|
} |
1260
|
|
|
|
1261
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_staff_viewall.tpl'; // Set template |
1262
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; // Include the page header |
1263
|
|
|
|
1264
|
|
|
$javascript = '<script type="text/javascript" src="' . XHELP_BASE_URL . "/include/functions.js\"></script> |
1265
|
|
|
//<script type=\"text/javascript\" src='" . XHELP_SCRIPT_URL . "/ChangeSelectedState.php?client'></script> |
1266
|
|
|
<script type=\"text/javascript\"> |
1267
|
|
|
<!-- |
1268
|
|
|
function states_onchange() |
1269
|
|
|
{ |
1270
|
|
|
state = xoopsGetElementById('state'); |
1271
|
|
|
var sH = new Xhelp\ChangeSelectedState(); |
1272
|
|
|
sH.statusesByState(state.value); |
1273
|
|
|
} |
1274
|
|
|
|
1275
|
|
|
var stateHandler = { |
1276
|
|
|
statusesByState: function(result){ |
1277
|
|
|
var statuses = gE('status'); |
1278
|
|
|
xhelpFillSelect(statuses, result); |
1279
|
|
|
} |
1280
|
|
|
} |
1281
|
|
|
|
1282
|
|
|
function window_onload() |
1283
|
|
|
{ |
1284
|
|
|
xhelpDOMAddEvent(xoopsGetElementById('state'), 'change', states_onchange, true); |
1285
|
|
|
} |
1286
|
|
|
|
1287
|
|
|
window.setTimeout('window_onload()', 1500); |
1288
|
|
|
//--> |
1289
|
|
|
</script>"; |
1290
|
|
|
|
1291
|
|
|
$xoopsTpl->assign('xhelp_baseURL', XHELP_BASE_URL); |
1292
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
1293
|
|
|
$xoopsTpl->assign('xhelp_cols', $tpl_cols); |
1294
|
|
|
$xoopsTpl->assign('xhelp_allTickets', $tickets); |
1295
|
|
|
$xoopsTpl->assign('xhelp_has_tickets', $has_allTickets); |
1296
|
|
|
$xoopsTpl->assign('xhelp_priorities', [5, 4, 3, 2, 1]); |
1297
|
|
|
$xoopsTpl->assign('xoops_module_header', $javascript . $xhelp_module_header); |
1298
|
|
|
$xoopsTpl->assign('xhelp_priorities_desc', [ |
1299
|
|
|
5 => _XHELP_PRIORITY5, |
1300
|
|
|
4 => _XHELP_PRIORITY4, |
1301
|
|
|
3 => _XHELP_PRIORITY3, |
1302
|
|
|
2 => _XHELP_PRIORITY2, |
1303
|
|
|
1 => _XHELP_PRIORITY1, |
1304
|
|
|
]); |
1305
|
|
|
if (0 != $limit) { |
1306
|
|
|
$xoopsTpl->assign('xhelp_pagenav', $nav->renderNav()); |
1307
|
|
|
} |
1308
|
|
|
$xoopsTpl->assign('xhelp_limit_options', [-1 => _XHELP_TEXT_SELECT_ALL, 10 => '10', 15 => '15', 20 => '20', 30 => '30']); |
1309
|
|
|
$xoopsTpl->assign('xhelp_filter', [ |
1310
|
|
|
'department' => $dept, |
1311
|
|
|
'status' => $status, |
1312
|
|
|
'state' => $state, |
1313
|
|
|
'ownership' => $ownership, |
1314
|
|
|
'limit' => $limit, |
1315
|
|
|
'start' => $start, |
1316
|
|
|
'sort' => $sort, |
1317
|
|
|
'order' => $order, |
1318
|
|
|
]); |
1319
|
|
|
|
1320
|
|
|
$xoopsTpl->append('xhelp_department_values', 0); |
1321
|
|
|
$xoopsTpl->append('xhelp_department_options', _XHELP_TEXT_SELECT_ALL); |
1322
|
|
|
|
1323
|
|
|
if (1 == $xhelpConfig['xhelp_deptVisibility']) { // Apply dept visibility to staff members? |
1324
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
1325
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
1326
|
|
|
$depts = $membershipHandler->getVisibleDepartments($xoopsUser->getVar('uid')); |
1327
|
|
|
} |
1328
|
|
|
|
1329
|
|
|
foreach ($depts as $xhelp_id => $obj) { |
1330
|
|
|
$xoopsTpl->append('xhelp_department_values', $xhelp_id); |
1331
|
|
|
$xoopsTpl->append('xhelp_department_options', $obj->getVar('department')); |
1332
|
|
|
} |
1333
|
|
|
|
1334
|
|
|
$xoopsTpl->assign('xhelp_ownership_options', array_values($staff_opt)); |
1335
|
|
|
$xoopsTpl->assign('xhelp_ownership_values', array_keys($staff_opt)); |
1336
|
|
|
$xoopsTpl->assign('xhelp_state_options', array_keys($state_opt)); |
1337
|
|
|
$xoopsTpl->assign('xhelp_state_values', array_values($state_opt)); |
1338
|
|
|
$xoopsTpl->assign('xhelp_savedSearches', $aSavedSearches); |
1339
|
|
|
|
1340
|
|
|
/** @var \XoopsModules\Xhelp\StatusHandler $statusHandler */ |
1341
|
|
|
$statusHandler = $helper->getHandler('Status'); |
1342
|
|
|
$criteria = new \Criteria('', ''); |
1343
|
|
|
$criteria->setSort('description'); |
1344
|
|
|
$criteria->setOrder('ASC'); |
1345
|
|
|
$statuses = $statusHandler->getObjects($criteria); |
1346
|
|
|
|
1347
|
|
|
$xoopsTpl->append('xhelp_status_options', _XHELP_TEXT_SELECT_ALL); |
1348
|
|
|
$xoopsTpl->append('xhelp_status_values', -1); |
1349
|
|
|
foreach ($statuses as $status) { |
1350
|
|
|
$xoopsTpl->append('xhelp_status_options', $status->getVar('description')); |
1351
|
|
|
$xoopsTpl->append('xhelp_status_values', $status->getVar('id')); |
1352
|
|
|
} |
1353
|
|
|
|
1354
|
|
|
$xoopsTpl->assign('xhelp_department_current', $dept); |
1355
|
|
|
$xoopsTpl->assign('xhelp_status_current', $status); |
1356
|
|
|
$xoopsTpl->assign('xhelp_current_file', basename(__FILE__)); |
1357
|
|
|
$xoopsTpl->assign('xhelp_text_allTickets', _XHELP_TEXT_ALL_TICKETS); |
1358
|
|
|
|
1359
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
1360
|
|
|
} |
1361
|
|
|
|
1362
|
|
|
function usermain_display() |
1363
|
|
|
{ |
1364
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin; |
1365
|
|
|
global $xhelp_module_header; |
1366
|
|
|
$helper = Helper::getInstance(); |
1367
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_user_index.tpl'; // Set template |
1368
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; // Include the page header |
1369
|
|
|
|
1370
|
|
|
$xhelpConfig = Utility::getModuleConfig(); |
1371
|
|
|
/** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
1372
|
|
|
$staffHandler = $helper->getHandler('Staff'); |
1373
|
|
|
|
1374
|
|
|
$staffCount = $staffHandler->getObjects(); |
1375
|
|
|
if (0 == count($staffCount)) { |
1376
|
|
|
$xoopsTpl->assign('xhelp_noStaff', true); |
1377
|
|
|
} |
1378
|
|
|
/** |
1379
|
|
|
* @todo remove calls to these three classes and use the ones in beginning |
1380
|
|
|
*/ |
1381
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
1382
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
|
|
|
1383
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
1384
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
|
|
|
|
1385
|
|
|
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
1386
|
|
|
$ticketHandler = $helper->getHandler('Ticket'); |
1387
|
|
|
|
1388
|
|
|
$userTickets = $ticketHandler->getMyUnresolvedTickets($xoopsUser->getVar('uid'), true); |
1389
|
|
|
|
1390
|
|
|
foreach ($userTickets as $ticket) { |
1391
|
|
|
$aUserTickets[] = [ |
1392
|
|
|
'id' => $ticket->getVar('id'), |
1393
|
|
|
'uid' => $ticket->getVar('uid'), |
1394
|
|
|
'subject' => $ticket->getVar('subject'), |
1395
|
|
|
'status' => Utility::getStatus($ticket->getVar('status')), |
1396
|
|
|
'priority' => $ticket->getVar('priority'), |
1397
|
|
|
'posted' => $ticket->posted(), |
1398
|
|
|
]; |
1399
|
|
|
} |
1400
|
|
|
$has_userTickets = count($userTickets) > 0; |
1401
|
|
|
if ($has_userTickets) { |
1402
|
|
|
$xoopsTpl->assign('xhelp_userTickets', $aUserTickets); |
|
|
|
|
1403
|
|
|
} else { |
1404
|
|
|
$xoopsTpl->assign('xhelp_userTickets', 0); |
1405
|
|
|
} |
1406
|
|
|
$xoopsTpl->assign('xhelp_baseURL', XHELP_BASE_URL); |
1407
|
|
|
$xoopsTpl->assign('xhelp_has_userTickets', $has_userTickets); |
1408
|
|
|
$xoopsTpl->assign('xhelp_priorities', [5, 4, 3, 2, 1]); |
1409
|
|
|
$xoopsTpl->assign('xhelp_priorities_desc', [ |
1410
|
|
|
5 => _XHELP_PRIORITY5, |
1411
|
|
|
4 => _XHELP_PRIORITY4, |
1412
|
|
|
3 => _XHELP_PRIORITY3, |
1413
|
|
|
2 => _XHELP_PRIORITY2, |
1414
|
|
|
1 => _XHELP_PRIORITY1, |
1415
|
|
|
]); |
1416
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
1417
|
|
|
$xoopsTpl->assign('xoops_module_header', $xhelp_module_header); |
1418
|
|
|
|
1419
|
|
|
getAnnouncements((int)$xhelpConfig['xhelp_announcements']); |
1420
|
|
|
|
1421
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; //Include the page footer |
1422
|
|
|
} |
1423
|
|
|
|
1424
|
|
|
function userviewall_display() |
1425
|
|
|
{ |
1426
|
|
|
global $xoopsOption, $xoopsTpl, $xoopsConfig, $xoopsUser, $xoopsLogger, $xoopsUserIsAdmin; |
1427
|
|
|
global $xhelp_module_header, $sort, $order, $sort_order, $limit, $start, $state_opt, $state; |
1428
|
|
|
|
1429
|
|
|
$helper = Helper::getInstance(); |
1430
|
|
|
|
1431
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhelp_user_viewall.tpl'; // Set template |
1432
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; // Include the page header |
1433
|
|
|
|
1434
|
|
|
//Sanity Check: sort column valid |
1435
|
|
|
$sort_columns = [ |
1436
|
|
|
'id' => 'DESC', |
1437
|
|
|
'priority' => 'DESC', |
1438
|
|
|
'elapsed' => 'ASC', |
1439
|
|
|
'lastupdate' => 'ASC', |
1440
|
|
|
'status' => 'ASC', |
1441
|
|
|
'subject' => 'ASC', |
1442
|
|
|
'department' => 'ASC', |
1443
|
|
|
'ownership' => 'ASC', |
1444
|
|
|
'uid' => 'ASC', |
1445
|
|
|
]; |
1446
|
|
|
$sort = array_key_exists($sort, $sort_columns) ? $sort : 'id'; |
1447
|
|
|
$order = @$_REQUEST['order']; |
1448
|
|
|
$order = (in_array(mb_strtoupper($order ?? ''), $sort_order) ? $order : $sort_columns[$sort]); |
1449
|
|
|
$uid = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
1450
|
|
|
|
1451
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
1452
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
1453
|
|
|
/** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */ |
1454
|
|
|
$ticketHandler = $helper->getHandler('Ticket'); |
1455
|
|
|
/** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
1456
|
|
|
$staffHandler = $helper->getHandler('Staff'); |
1457
|
|
|
|
1458
|
|
|
$dept = Request::getInt('dept', 0); |
1459
|
|
|
$status = Request::getInt('status', -1); |
1460
|
|
|
$state = Request::getInt('state', -1); |
1461
|
|
|
|
1462
|
|
|
$depts = $departmentHandler->getObjects(null, true); |
1463
|
|
|
|
1464
|
|
|
if (0 == $limit) { |
1465
|
|
|
$limit = 10; |
1466
|
|
|
} elseif (-1 == $limit) { |
1467
|
|
|
$limit = 0; |
1468
|
|
|
} |
1469
|
|
|
|
1470
|
|
|
//Prepare Database Query and Querystring |
1471
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('uid', $uid)); |
1472
|
|
|
$qs = [ |
1473
|
|
|
'op' => 'userViewAll', //Common Query String Values |
1474
|
|
|
'start' => $start, |
1475
|
|
|
'limit' => $limit, |
1476
|
|
|
]; |
1477
|
|
|
|
1478
|
|
|
if ($dept) { |
1479
|
|
|
$qs['dept'] = $dept; |
1480
|
|
|
$criteria->add(new \Criteria('department', $dept, '=', 't')); |
1481
|
|
|
} |
1482
|
|
|
if (-1 != $status) { |
1483
|
|
|
$qs['status'] = $status; |
1484
|
|
|
$criteria->add(new \Criteria('status', $status, '=', 't')); |
1485
|
|
|
} |
1486
|
|
|
|
1487
|
|
|
if (-1 != $state) { |
1488
|
|
|
$qs['state'] = $state; |
1489
|
|
|
$criteria->add(new \Criteria('state', $state, '=', 's')); |
1490
|
|
|
} |
1491
|
|
|
|
1492
|
|
|
$criteria->setLimit($limit); |
1493
|
|
|
$criteria->setStart($start); |
1494
|
|
|
$criteria->setSort($sort); |
1495
|
|
|
$criteria->setOrder($order); |
1496
|
|
|
|
1497
|
|
|
//Setup Column Sorting Vars |
1498
|
|
|
$tpl_cols = []; |
1499
|
|
|
foreach ($sort_columns as $col => $initsort) { |
1500
|
|
|
$col_qs = ['sort' => $col]; |
1501
|
|
|
//Check if we need to sort by current column |
1502
|
|
|
if ($sort == $col) { |
1503
|
|
|
$col_qs['order'] = ($order == $sort_order[0] ? $sort_order[1] : $sort_order[0]); |
1504
|
|
|
$col_sortby = true; |
1505
|
|
|
} else { |
1506
|
|
|
$col_qs['order'] = $initsort; |
1507
|
|
|
$col_sortby = false; |
1508
|
|
|
} |
1509
|
|
|
$tpl_cols[$col] = [ |
1510
|
|
|
'url' => Utility::createURI(basename(__FILE__), array_merge($qs, $col_qs)), |
1511
|
|
|
'urltitle' => _XHELP_TEXT_SORT_TICKETS, |
1512
|
|
|
'sortby' => $col_sortby, |
1513
|
|
|
'sortdir' => \mb_strtolower($col_qs['order']), |
1514
|
|
|
]; |
1515
|
|
|
} |
1516
|
|
|
|
1517
|
|
|
$xoopsTpl->assign('xhelp_cols', $tpl_cols); |
1518
|
|
|
$staffCount = $staffHandler->getObjects(); |
1519
|
|
|
if (0 == count($staffCount)) { |
1520
|
|
|
$xoopsTpl->assign('xhelp_noStaff', true); |
1521
|
|
|
} |
1522
|
|
|
|
1523
|
|
|
$userTickets = $ticketHandler->getObjects($criteria); |
1524
|
|
|
foreach ($userTickets as $ticket) { |
1525
|
|
|
$aUserTickets[] = [ |
1526
|
|
|
'id' => $ticket->getVar('id'), |
1527
|
|
|
'uid' => $ticket->getVar('uid'), |
1528
|
|
|
'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), |
1529
|
|
|
'full_subject' => $ticket->getVar('subject'), |
1530
|
|
|
'status' => Utility::getStatus($ticket->getVar('status')), |
1531
|
|
|
'department' => safeDepartmentName($depts[$ticket->getVar('department')]), |
1532
|
|
|
'departmentid' => $ticket->getVar('department'), |
1533
|
|
|
'departmenturl' => Utility::createURI(basename(__FILE__), ['op' => 'userViewAll', 'dept' => $ticket->getVar('department')]), |
1534
|
|
|
'priority' => $ticket->getVar('priority'), |
1535
|
|
|
'posted' => $ticket->posted(), |
1536
|
|
|
'elapsed' => $ticket->elapsed(), |
1537
|
|
|
]; |
1538
|
|
|
} |
1539
|
|
|
$has_userTickets = count($userTickets) > 0; |
1540
|
|
|
if ($has_userTickets) { |
1541
|
|
|
$xoopsTpl->assign('xhelp_userTickets', $aUserTickets); |
|
|
|
|
1542
|
|
|
} else { |
1543
|
|
|
$xoopsTpl->assign('xhelp_userTickets', 0); |
1544
|
|
|
} |
1545
|
|
|
|
1546
|
|
|
$javascript = '<script type="text/javascript" src="' . XHELP_BASE_URL . "/include/functions.js\"></script> |
1547
|
|
|
<script type=\"text/javascript\" src='" . XHELP_SCRIPT_URL . "/ChangeSelectedState.php?client'></script> |
1548
|
|
|
<script type=\"text/javascript\"> |
1549
|
|
|
<!-- |
1550
|
|
|
function states_onchange() |
1551
|
|
|
{ |
1552
|
|
|
state = xoopsGetElementById('state'); |
1553
|
|
|
var sH = new Xhelp\WebLib(stateHandler); |
1554
|
|
|
sH.statusesByState(state.value); |
1555
|
|
|
} |
1556
|
|
|
|
1557
|
|
|
var stateHandler = { |
1558
|
|
|
statusesByState: function(result){ |
1559
|
|
|
var statuses = gE('status'); |
1560
|
|
|
xhelpFillSelect(statuses, result); |
1561
|
|
|
} |
1562
|
|
|
} |
1563
|
|
|
|
1564
|
|
|
function window_onload() |
1565
|
|
|
{ |
1566
|
|
|
xhelpDOMAddEvent(xoopsGetElementById('state'), 'change', states_onchange, true); |
1567
|
|
|
} |
1568
|
|
|
|
1569
|
|
|
window.setTimeout('window_onload()', 1500); |
1570
|
|
|
//--> |
1571
|
|
|
</script>"; |
1572
|
|
|
|
1573
|
|
|
$xoopsTpl->assign('xhelp_baseURL', XHELP_BASE_URL); |
1574
|
|
|
$xoopsTpl->assign('xhelp_has_userTickets', $has_userTickets); |
1575
|
|
|
$xoopsTpl->assign('xhelp_viewAll', true); |
1576
|
|
|
$xoopsTpl->assign('xhelp_priorities', [5, 4, 3, 2, 1]); |
1577
|
|
|
$xoopsTpl->assign('xhelp_priorities_desc', [ |
1578
|
|
|
5 => _XHELP_PRIORITY5, |
1579
|
|
|
4 => _XHELP_PRIORITY4, |
1580
|
|
|
3 => _XHELP_PRIORITY3, |
1581
|
|
|
2 => _XHELP_PRIORITY2, |
1582
|
|
|
1 => _XHELP_PRIORITY1, |
1583
|
|
|
]); |
1584
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XHELP_IMAGE_URL . '/'); |
1585
|
|
|
$xoopsTpl->assign('xoops_module_header', $javascript . $xhelp_module_header); |
1586
|
|
|
$xoopsTpl->assign('xhelp_limit_options', [-1 => _XHELP_TEXT_SELECT_ALL, 10 => '10', 15 => '15', 20 => '20', 30 => '30']); |
1587
|
|
|
$xoopsTpl->assign('xhelp_filter', [ |
1588
|
|
|
'department' => $dept, |
1589
|
|
|
'status' => $status, |
1590
|
|
|
'limit' => $limit, |
1591
|
|
|
'start' => $start, |
1592
|
|
|
'sort' => $sort, |
1593
|
|
|
'order' => $order, |
1594
|
|
|
'state' => $state, |
1595
|
|
|
]); |
1596
|
|
|
$xoopsTpl->append('xhelp_department_values', 0); |
1597
|
|
|
$xoopsTpl->append('xhelp_department_options', _XHELP_TEXT_SELECT_ALL); |
1598
|
|
|
|
1599
|
|
|
//$depts = getVisibleDepartments($depts); |
1600
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
1601
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
1602
|
|
|
$depts = $membershipHandler->getVisibleDepartments($xoopsUser->getVar('uid')); |
1603
|
|
|
foreach ($depts as $xhelp_id => $obj) { |
1604
|
|
|
$xoopsTpl->append('xhelp_department_values', $xhelp_id); |
1605
|
|
|
$xoopsTpl->append('xhelp_department_options', $obj->getVar('department')); |
1606
|
|
|
} |
1607
|
|
|
|
1608
|
|
|
/** @var \XoopsModules\Xhelp\StatusHandler $statusHandler */ |
1609
|
|
|
$statusHandler = $helper->getHandler('Status'); |
1610
|
|
|
$criteria = new \Criteria('', ''); |
1611
|
|
|
$criteria->setSort('description'); |
1612
|
|
|
$criteria->setOrder('ASC'); |
1613
|
|
|
$statuses = $statusHandler->getObjects($criteria); |
1614
|
|
|
|
1615
|
|
|
$xoopsTpl->append('xhelp_status_options', _XHELP_TEXT_SELECT_ALL); |
1616
|
|
|
$xoopsTpl->append('xhelp_status_values', -1); |
1617
|
|
|
foreach ($statuses as $status) { |
1618
|
|
|
$xoopsTpl->append('xhelp_status_options', $status->getVar('description')); |
1619
|
|
|
$xoopsTpl->append('xhelp_status_values', $status->getVar('id')); |
1620
|
|
|
} |
1621
|
|
|
|
1622
|
|
|
$xoopsTpl->assign('xhelp_department_current', $dept); |
1623
|
|
|
$xoopsTpl->assign('xhelp_status_current', $status); |
1624
|
|
|
$xoopsTpl->assign('xhelp_state_options', array_keys($state_opt)); |
1625
|
|
|
$xoopsTpl->assign('xhelp_state_values', array_values($state_opt)); |
1626
|
|
|
|
1627
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
1628
|
|
|
} |
1629
|
|
|
|
1630
|
|
|
/** |
1631
|
|
|
* @param array $oTickets |
1632
|
|
|
* @param array $depts |
1633
|
|
|
* @param array $all_users |
1634
|
|
|
* @param int $j |
1635
|
|
|
* @param int $task |
1636
|
|
|
* @return array |
1637
|
|
|
*/ |
1638
|
|
|
function makeBatchTicketArray(array $oTickets, array $depts, array &$all_users, int &$j, int $task): array |
1639
|
|
|
{ |
1640
|
|
|
global $staff; |
1641
|
|
|
|
1642
|
|
|
$sortedTickets['good'] = []; |
|
|
|
|
1643
|
|
|
$sortedTickets['bad'] = []; |
1644
|
|
|
foreach ($oTickets as $ticket) { |
1645
|
|
|
$dept = @$depts[$ticket->getVar('department')]; |
1646
|
|
|
if ($hasRights = $staff->checkRoleRights($task, $ticket->getVar('department'))) { |
|
|
|
|
1647
|
|
|
$sortedTickets['good'][] = [ |
1648
|
|
|
'id' => $ticket->getVar('id'), |
1649
|
|
|
'uid' => $ticket->getVar('uid'), |
1650
|
|
|
'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), |
1651
|
|
|
'full_subject' => $ticket->getVar('subject'), |
1652
|
|
|
'description' => $ticket->getVar('description'), |
1653
|
|
|
'department' => safeDepartmentName($dept), |
1654
|
|
|
'departmentid' => $ticket->getVar('department'), |
1655
|
|
|
'departmenturl' => Utility::createURI('index.php', [ |
1656
|
|
|
'op' => 'staffViewAll', |
1657
|
|
|
'dept' => $ticket->getVar('department'), |
1658
|
|
|
]), |
1659
|
|
|
'priority' => $ticket->getVar('priority'), |
1660
|
|
|
'status' => Utility::getStatus($ticket->getVar('status')), |
1661
|
|
|
'posted' => $ticket->posted(), |
1662
|
|
|
'ownership' => _XHELP_MESSAGE_NOOWNER, |
1663
|
|
|
'ownerid' => $ticket->getVar('ownership'), |
1664
|
|
|
'closedBy' => $ticket->getVar('closedBy'), |
1665
|
|
|
'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), |
1666
|
|
|
'uname' => '', |
1667
|
|
|
'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), |
1668
|
|
|
'ownerinfo' => '', |
1669
|
|
|
'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), |
1670
|
|
|
'overdue' => $ticket->isOverdue(), |
1671
|
|
|
]; |
1672
|
|
|
} else { |
1673
|
|
|
$sortedTickets['bad'][] = [ |
1674
|
|
|
'id' => $ticket->getVar('id'), |
1675
|
|
|
'uid' => $ticket->getVar('uid'), |
1676
|
|
|
'subject' => xoops_substr($ticket->getVar('subject'), 0, 35), |
1677
|
|
|
'full_subject' => $ticket->getVar('subject'), |
1678
|
|
|
'description' => $ticket->getVar('description'), |
1679
|
|
|
'department' => safeDepartmentName($dept), |
1680
|
|
|
'departmentid' => $ticket->getVar('department'), |
1681
|
|
|
'departmenturl' => Utility::createURI('index.php', [ |
1682
|
|
|
'op' => 'staffViewAll', |
1683
|
|
|
'dept' => $ticket->getVar('department'), |
1684
|
|
|
]), |
1685
|
|
|
'priority' => $ticket->getVar('priority'), |
1686
|
|
|
'status' => Utility::getStatus($ticket->getVar('status')), |
1687
|
|
|
'posted' => $ticket->posted(), |
1688
|
|
|
'ownership' => _XHELP_MESSAGE_NOOWNER, |
1689
|
|
|
'ownerid' => $ticket->getVar('ownership'), |
1690
|
|
|
'closedBy' => $ticket->getVar('closedBy'), |
1691
|
|
|
'totalTimeSpent' => $ticket->getVar('totalTimeSpent'), |
1692
|
|
|
'uname' => '', |
1693
|
|
|
'userinfo' => XHELP_SITE_URL . '/userinfo.php?uid=' . $ticket->getVar('uid'), |
1694
|
|
|
'ownerinfo' => '', |
1695
|
|
|
'url' => XHELP_BASE_URL . '/ticket.php?id=' . $ticket->getVar('id'), |
1696
|
|
|
'overdue' => $ticket->isOverdue(), |
1697
|
|
|
]; |
1698
|
|
|
} |
1699
|
|
|
$all_users[$ticket->getVar('uid')] = ''; |
1700
|
|
|
$all_users[$ticket->getVar('ownership')] = ''; |
1701
|
|
|
$all_users[$ticket->getVar('closedBy')] = ''; |
1702
|
|
|
++$j; |
1703
|
|
|
} |
1704
|
|
|
|
1705
|
|
|
return $sortedTickets; |
1706
|
|
|
} |
1707
|
|
|
|
1708
|
|
|
/** |
1709
|
|
|
* @param array $sortedTickets |
1710
|
|
|
* @param array $users |
1711
|
|
|
* @param int $j |
1712
|
|
|
* @return array |
1713
|
|
|
*/ |
1714
|
|
|
function updateBatchTicketInfo(array &$sortedTickets, array $users, int &$j): array |
|
|
|
|
1715
|
|
|
{ |
1716
|
|
|
global $xoopsConfig; |
1717
|
|
|
|
1718
|
|
|
//Update tickets with user information |
1719
|
|
|
$aTicketTypes = ['good', 'bad']; |
1720
|
|
|
foreach ($aTicketTypes as $ticketType) { |
1721
|
|
|
foreach ($sortedTickets[$ticketType] as $j => $jValue) { |
1722
|
|
|
if (isset($users[$sortedTickets[$ticketType][$j]['uid']])) { |
1723
|
|
|
$sortedTickets[$ticketType][$j]['uname'] = $users[$sortedTickets[$ticketType][$j]['uid']]; |
1724
|
|
|
} else { |
1725
|
|
|
$sortedTickets[$ticketType][$j]['uname'] = $xoopsConfig['anonymous']; |
1726
|
|
|
} |
1727
|
|
|
if ($sortedTickets[$ticketType][$j]['ownerid']) { |
1728
|
|
|
if (isset($users[$sortedTickets[$ticketType][$j]['ownerid']])) { |
1729
|
|
|
$sortedTickets[$ticketType][$j]['ownership'] = $users[$sortedTickets[$ticketType][$j]['ownerid']]; |
1730
|
|
|
$sortedTickets[$ticketType][$j]['ownerinfo'] = XOOPS_URL . '/userinfo.php?uid=' . $sortedTickets[$ticketType][$j]['ownerid']; |
1731
|
|
|
} |
1732
|
|
|
} |
1733
|
|
|
} |
1734
|
|
|
} |
1735
|
|
|
|
1736
|
|
|
return $sortedTickets; |
1737
|
|
|
} |
1738
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths