|
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\Module\Admin; |
|
22
|
|
|
use Xmf\Request; |
|
23
|
|
|
use XoopsModules\Xhelp; |
|
24
|
|
|
use XoopsModules\Xhelp\Constants; |
|
25
|
|
|
|
|
26
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
27
|
|
|
xoops_load('XoopsPagenav'); |
|
28
|
|
|
// require_once XHELP_CLASS_PATH . '/Form.php'; |
|
29
|
|
|
// require_once XHELP_CLASS_PATH . '/FormRadio.php'; |
|
30
|
|
|
// require_once XHELP_CLASS_PATH . '/FormCheckbox.php'; |
|
31
|
|
|
|
|
32
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
33
|
|
|
global $xoopsModule; |
|
34
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
35
|
|
|
|
|
36
|
|
|
$limit = Request::getInt('limit', 15, 'REQUEST'); |
|
37
|
|
|
$start = Request::getInt('start', 0, 'REQUEST'); |
|
38
|
|
|
|
|
39
|
|
|
if (Request::hasVar('order', 'REQUEST')) { |
|
40
|
|
|
$order = $_REQUEST['order']; |
|
41
|
|
|
} else { |
|
42
|
|
|
$order = 'ASC'; |
|
43
|
|
|
} |
|
44
|
|
|
if (Request::hasVar('sort', 'REQUEST')) { |
|
45
|
|
|
$sort = $_REQUEST['sort']; |
|
46
|
|
|
} else { |
|
47
|
|
|
$sort = 'department'; |
|
48
|
|
|
} |
|
49
|
|
|
$dept_search = false; |
|
50
|
|
|
if (Request::hasVar('dept_search', 'REQUEST')) { |
|
51
|
|
|
$dept_search = $_REQUEST['dept_search']; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$aSortBy = ['id' => _AM_XHELP_TEXT_ID, 'department' => _AM_XHELP_TEXT_DEPARTMENT]; |
|
55
|
|
|
$aOrderBy = ['ASC' => _AM_XHELP_TEXT_ASCENDING, 'DESC' => _AM_XHELP_TEXT_DESCENDING]; |
|
56
|
|
|
$aLimitBy = ['10' => 10, '15' => 15, '20' => 20, '25' => 25, '50' => 50, '100' => 100]; |
|
57
|
|
|
|
|
58
|
|
|
$op = 'default'; |
|
59
|
|
|
|
|
60
|
|
|
if (Request::hasVar('op', 'REQUEST')) { |
|
61
|
|
|
$op = $_REQUEST['op']; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
switch ($op) { |
|
65
|
|
|
case 'activateMailbox': |
|
66
|
|
|
activateMailbox(); |
|
67
|
|
|
break; |
|
68
|
|
|
case 'AddDepartmentServer': |
|
69
|
|
|
addDepartmentServer(); |
|
70
|
|
|
break; |
|
71
|
|
|
case 'DeleteDepartmentServer': |
|
72
|
|
|
deleteDepartmentServer(); |
|
73
|
|
|
break; |
|
74
|
|
|
case 'deleteStaffDept': |
|
75
|
|
|
deleteStaffDept(); |
|
76
|
|
|
break; |
|
77
|
|
|
case 'editDepartment': |
|
78
|
|
|
editDepartment(); |
|
79
|
|
|
break; |
|
80
|
|
|
case 'EditDepartmentServer': |
|
81
|
|
|
editDepartmentServer(); |
|
82
|
|
|
break; |
|
83
|
|
|
case 'manageDepartments': |
|
84
|
|
|
manageDepartments(); |
|
85
|
|
|
break; |
|
86
|
|
|
case 'testMailbox': |
|
87
|
|
|
testMailbox(); |
|
88
|
|
|
break; |
|
89
|
|
|
case 'clearAddSession': |
|
90
|
|
|
clearAddSession(); |
|
91
|
|
|
break; |
|
92
|
|
|
case 'clearEditSession': |
|
93
|
|
|
clearEditSession(); |
|
94
|
|
|
break; |
|
95
|
|
|
case 'updateDefault': |
|
96
|
|
|
updateDefault(); |
|
97
|
|
|
break; |
|
98
|
|
|
default: |
|
99
|
|
|
$helper->redirect('admin/index.php'); |
|
100
|
|
|
break; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* |
|
105
|
|
|
*/ |
|
106
|
|
|
function activateMailbox() |
|
107
|
|
|
{ |
|
108
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
109
|
|
|
$id = Request::getInt('id', 0, 'GET'); |
|
110
|
|
|
$setstate = Request::getInt('setstate', 0, 'GET'); |
|
111
|
|
|
|
|
112
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */ |
|
113
|
|
|
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox'); |
|
114
|
|
|
$mailbox = $departmentMailBoxHandler->get($id); |
|
115
|
|
|
if ($mailbox) { |
|
|
|
|
|
|
116
|
|
|
$url = XHELP_BASE_URL . '/admin/department.php?op=editDepartment&id=' . $mailbox->getVar('departmentid'); |
|
117
|
|
|
$mailbox->setVar('active', $setstate); |
|
118
|
|
|
if ($departmentMailBoxHandler->insert($mailbox, true)) { |
|
119
|
|
|
$helper->redirect($url); |
|
120
|
|
|
} else { |
|
121
|
|
|
redirect_header($url, 3, _AM_XHELP_DEPARTMENT_SERVER_ERROR); |
|
122
|
|
|
} |
|
123
|
|
|
} else { |
|
124
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _XHELP_NO_MAILBOX_ERROR); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* |
|
130
|
|
|
*/ |
|
131
|
|
|
function addDepartmentServer() |
|
132
|
|
|
{ |
|
133
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
134
|
|
|
$deptID = 0; |
|
135
|
|
|
|
|
136
|
|
|
if (Request::hasVar('id', 'GET')) { |
|
137
|
|
|
$deptID = Request::getInt('id', 0, 'GET'); |
|
138
|
|
|
} else { |
|
139
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_DEPARTMENT_NO_ID); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */ |
|
143
|
|
|
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox'); |
|
144
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBox $server */ |
|
145
|
|
|
$server = $departmentMailBoxHandler->create(); |
|
146
|
|
|
$server->setVar('departmentid', $deptID); |
|
147
|
|
|
$server->setVar('emailaddress', \Xmf\Request::getString('emailaddress', '', 'POST')); |
|
148
|
|
|
$server->setVar('server', \Xmf\Request::getString('server', '', 'POST')); |
|
149
|
|
|
$server->setVar('serverport', \Xmf\Request::getString('port', '', 'POST')); |
|
150
|
|
|
$server->setVar('username', \Xmf\Request::getString('username', '', 'POST')); |
|
151
|
|
|
$server->setVar('password', \Xmf\Request::getString('password', '', 'POST')); |
|
152
|
|
|
$server->setVar('priority', $_POST['priority']); |
|
153
|
|
|
|
|
154
|
|
|
if ($departmentMailBoxHandler->insert($server)) { |
|
155
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments'); |
|
156
|
|
|
} else { |
|
157
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_DEPARTMENT_SERVER_ERROR); |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* |
|
163
|
|
|
*/ |
|
164
|
|
|
function deleteDepartmentServer() |
|
165
|
|
|
{ |
|
166
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
167
|
|
|
if (Request::hasVar('id', 'REQUEST')) { |
|
168
|
|
|
$emailID = Request::getInt('id', 0, 'REQUEST'); |
|
169
|
|
|
} else { |
|
170
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_DEPARTMENT_SERVER_NO_ID); |
|
171
|
|
|
} |
|
172
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */ |
|
173
|
|
|
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox'); |
|
174
|
|
|
$server = $departmentMailBoxHandler->get($emailID); |
|
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
if (!isset($_POST['ok'])) { |
|
177
|
|
|
xoops_cp_header(); |
|
178
|
|
|
//echo $oAdminButton->renderButtons('manDept'); |
|
179
|
|
|
$adminObject = Admin::getInstance(); |
|
180
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
181
|
|
|
|
|
182
|
|
|
xoops_confirm(['op' => 'DeleteDepartmentServer', 'id' => $emailID, 'ok' => 1], XHELP_BASE_URL . '/admin/department.php', sprintf(_AM_XHELP_MSG_DEPT_MBOX_DEL_CFRM, $server->getVar('emailaddress'))); |
|
|
|
|
|
|
183
|
|
|
xoops_cp_footer(); |
|
184
|
|
|
} elseif ($departmentMailBoxHandler->delete($server, true)) { |
|
185
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments'); |
|
186
|
|
|
} else { |
|
187
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_DEPARTMENT_SERVER_DELETE_ERROR); |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* |
|
193
|
|
|
*/ |
|
194
|
|
|
function deleteStaffDept() |
|
195
|
|
|
{ |
|
196
|
|
|
$deptID = 0; |
|
197
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
198
|
|
|
if (Request::hasVar('deptid', 'GET')) { |
|
199
|
|
|
$deptID = Request::getInt('deptid', 0, 'GET'); |
|
200
|
|
|
} else { |
|
201
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_MSG_NO_DEPTID); |
|
202
|
|
|
} |
|
203
|
|
|
if (Request::hasVar('uid', 'GET')) { |
|
204
|
|
|
$staffID = Request::getInt('uid', 0, 'GET'); |
|
205
|
|
|
} elseif (Request::hasVar('staff', 'POST')) { |
|
206
|
|
|
$staffID = $_POST['staff']; |
|
207
|
|
|
} else { |
|
208
|
|
|
$helper->redirect("department.php?op=editDepartment&deptid=$deptID", 3, _AM_XHELP_MSG_NO_UID); |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
|
212
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
|
213
|
|
|
if (is_array($staffID)) { |
|
|
|
|
|
|
214
|
|
|
foreach ($staffID as $sid) { |
|
215
|
|
|
$ret = $membershipHandler->removeDeptFromStaff($deptID, $sid); |
|
216
|
|
|
} |
|
217
|
|
|
} else { |
|
218
|
|
|
$ret = $membershipHandler->removeDeptFromStaff($deptID, $staffID); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
if ($ret) { |
|
|
|
|
|
|
222
|
|
|
$helper->redirect("department.php?op=editDepartment&deptid=$deptID"); |
|
223
|
|
|
} else { |
|
224
|
|
|
$helper->redirect("department.php??op=editDepartment&deptid=$deptID", 3, _AM_XHELP_MSG_REMOVE_STAFF_DEPT_ERR); |
|
225
|
|
|
} |
|
226
|
|
|
} |
|
227
|
|
|
|
|
228
|
|
|
/** |
|
229
|
|
|
* |
|
230
|
|
|
*/ |
|
231
|
|
|
function editDepartment() |
|
232
|
|
|
{ |
|
233
|
|
|
$deptID = 0; |
|
234
|
|
|
$session = Xhelp\Session::getInstance(); |
|
235
|
|
|
global $icons, $xoopsModule, $limit, $start; |
|
236
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
237
|
|
|
$errors = []; |
|
238
|
|
|
|
|
239
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
240
|
|
|
$displayName = $helper->getConfig('xhelp_displayName'); // Determines if username or real name is displayed |
|
241
|
|
|
|
|
242
|
|
|
$session->set('xhelp_return_page', mb_substr(mb_strstr($_SERVER['REQUEST_URI'], 'admin/'), 6)); |
|
243
|
|
|
|
|
244
|
|
|
if (Request::hasVar('deptid', 'REQUEST')) { |
|
245
|
|
|
$deptID = Request::getInt('deptid', 0); |
|
246
|
|
|
} else { |
|
247
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_MSG_NO_DEPTID); |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
|
251
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
|
252
|
|
|
/** @var \XoopsGroupHandler $groupHandler */ |
|
253
|
|
|
$groupHandler = xoops_getHandler('group'); |
|
254
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
255
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
256
|
|
|
|
|
257
|
|
|
if (Request::hasVar('updateDept', 'POST')) { |
|
258
|
|
|
$groups = ($_POST['groups'] ?? []); |
|
259
|
|
|
|
|
260
|
|
|
$hasErrors = false; |
|
261
|
|
|
//Department Name supplied? |
|
262
|
|
|
if ('' === trim(\Xmf\Request::getString('newDept', '', 'POST'))) { |
|
263
|
|
|
$hasErrors = true; |
|
264
|
|
|
$errors['newDept'][] = _AM_XHELP_MESSAGE_NO_DEPT; |
|
265
|
|
|
} else { |
|
266
|
|
|
//Department Name unique? |
|
267
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('department', \Xmf\Request::getString('newDept', '', 'POST'))); |
|
268
|
|
|
$criteria->add(new \Criteria('id', (string)$deptID, '!=')); |
|
269
|
|
|
$existingDepts = $departmentHandler->getCount($criteria); |
|
270
|
|
|
if ($existingDepts) { |
|
271
|
|
|
$hasErrors = true; |
|
272
|
|
|
$errors['newDept'][] = _XHELP_MESSAGE_DEPT_EXISTS; |
|
273
|
|
|
} |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
if ($hasErrors) { |
|
277
|
|
|
$session = Xhelp\Session::getInstance(); |
|
278
|
|
|
//Store existing dept info in session, reload addition page |
|
279
|
|
|
$aDept = []; |
|
280
|
|
|
$aDept['newDept'] = \Xmf\Request::getString('newDept', '', 'POST'); |
|
281
|
|
|
$aDept['groups'] = $groups; |
|
282
|
|
|
$session->set("xhelp_editDepartment_$deptID", $aDept); |
|
283
|
|
|
$session->set("xhelp_editDepartmentErrors_$deptID", $errors); |
|
284
|
|
|
redirect_header(Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'editDepartment', 'deptid' => $deptID], false)); |
|
|
|
|
|
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
$dept = $departmentHandler->get($deptID); |
|
288
|
|
|
|
|
289
|
|
|
$oldDept = $dept; |
|
290
|
|
|
$groups = $_POST['groups']; |
|
291
|
|
|
|
|
292
|
|
|
// Need to remove old group permissions first |
|
293
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $module_id)); |
|
294
|
|
|
$criteria->add(new \Criteria('gperm_itemid', (string)$deptID)); |
|
295
|
|
|
$criteria->add(new \Criteria('gperm_name', _XHELP_GROUP_PERM_DEPT)); |
|
296
|
|
|
$grouppermHandler->deleteAll($criteria); |
|
297
|
|
|
|
|
298
|
|
|
foreach ($groups as $group) { // Add new group permissions |
|
299
|
|
|
$grouppermHandler->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id); |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
$dept->setVar('department', \Xmf\Request::getString('newDept', '', 'POST')); |
|
303
|
|
|
|
|
304
|
|
|
if ($departmentHandler->insert($dept)) { |
|
305
|
|
|
$message = _XHELP_MESSAGE_UPDATE_DEPT; |
|
|
|
|
|
|
306
|
|
|
|
|
307
|
|
|
// Update default dept |
|
308
|
|
|
if (Request::hasVar('defaultDept', 'POST') && (1 == $_POST['defaultDept'])) { |
|
309
|
|
|
Xhelp\Utility::setMeta('default_department', $dept->getVar('id')); |
|
310
|
|
|
} else { |
|
311
|
|
|
$depts = $departmentHandler->getObjects(); |
|
312
|
|
|
$aDepts = []; |
|
313
|
|
|
foreach ($depts as $dpt) { |
|
314
|
|
|
$aDepts[] = $dpt->getVar('id'); |
|
315
|
|
|
} |
|
316
|
|
|
Xhelp\Utility::setMeta('default_department', $aDepts[0]); |
|
317
|
|
|
} |
|
318
|
|
|
|
|
319
|
|
|
// Edit configoption for department |
|
320
|
|
|
/** @var \XoopsModules\Xhelp\ConfigOptionHandler $configOptionHandler */ |
|
321
|
|
|
$configOptionHandler = $helper->getHandler('ConfigOption'); |
|
322
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('confop_name', $oldDept->getVar('department'))); |
|
|
|
|
|
|
323
|
|
|
$criteria->add(new \Criteria('confop_value', $oldDept->getVar('id'))); |
|
324
|
|
|
$confOption = $configOptionHandler->getObjects($criteria); |
|
325
|
|
|
|
|
326
|
|
|
if (count($confOption) > 0) { |
|
327
|
|
|
$confOption[0]->setVar('confop_name', $dept->getVar('department')); |
|
328
|
|
|
|
|
329
|
|
|
if (!$configOptionHandler->insert($confOption[0])) { |
|
330
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_MSG_UPDATE_CONFIG_ERR); |
|
331
|
|
|
} |
|
332
|
|
|
} |
|
333
|
|
|
clearEditSessionVars($deptID); |
|
334
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments'); |
|
335
|
|
|
} else { |
|
336
|
|
|
$message = _XHELP_MESSAGE_UPDATE_DEPT_ERROR . $dept->getHtmlErrors(); |
|
337
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, $message); |
|
338
|
|
|
} |
|
339
|
|
|
} else { |
|
340
|
|
|
xoops_cp_header(); |
|
341
|
|
|
//echo $oAdminButton->renderButtons('manDept'); |
|
342
|
|
|
|
|
343
|
|
|
$dept = $departmentHandler->get($deptID); |
|
344
|
|
|
|
|
345
|
|
|
$session = Xhelp\Session::getInstance(); |
|
346
|
|
|
$sess_dept = $session->get("xhelp_editDepartment_$deptID"); |
|
347
|
|
|
$sess_errors = $session->get("xhelp_editDepartmentErrors_$deptID"); |
|
348
|
|
|
|
|
349
|
|
|
//Display any form errors |
|
350
|
|
|
if (false === !$sess_errors) { |
|
351
|
|
|
xhelpRenderErrors($sess_errors, Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'clearEditSession', 'deptid' => $deptID])); |
|
|
|
|
|
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
|
$adminObject = Admin::getInstance(); |
|
355
|
|
|
$adminObject->displayNavigation('department.php?op=editDepartment'); |
|
356
|
|
|
|
|
357
|
|
|
// Get list of groups with permission |
|
358
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('gperm_modid', $module_id)); |
|
359
|
|
|
$criteria->add(new \Criteria('gperm_itemid', (string)$deptID)); |
|
360
|
|
|
$criteria->add(new \Criteria('gperm_name', _XHELP_GROUP_PERM_DEPT)); |
|
361
|
|
|
$group_perms = $grouppermHandler->getObjects($criteria); |
|
362
|
|
|
|
|
363
|
|
|
$aPerms = []; // Put group_perms in usable format |
|
364
|
|
|
foreach ($group_perms as $perm) { |
|
365
|
|
|
$aPerms[$perm->getVar('gperm_groupid')] = $perm->getVar('gperm_groupid'); |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
if (false !== !$sess_dept) { |
|
369
|
|
|
$fld_newDept = $dept->getVar('department'); |
|
370
|
|
|
$fld_groups = $aPerms; |
|
371
|
|
|
} else { |
|
372
|
|
|
$fld_newDept = $sess_dept['newDept']; |
|
373
|
|
|
$fld_groups = $sess_dept['groups']; |
|
374
|
|
|
} |
|
375
|
|
|
|
|
376
|
|
|
// Get list of all groups |
|
377
|
|
|
$criteria = new \Criteria('', ''); |
|
378
|
|
|
$criteria->setSort('name'); |
|
379
|
|
|
$criteria->setOrder('ASC'); |
|
380
|
|
|
$groups = $groupHandler->getObjects($criteria, true); |
|
381
|
|
|
|
|
382
|
|
|
$aGroups = []; |
|
383
|
|
|
foreach ($groups as $group_id => $group) { |
|
384
|
|
|
$aGroups[$group_id] = $group->getVar('name'); |
|
385
|
|
|
} |
|
386
|
|
|
asort($aGroups); // Set groups in alphabetical order |
|
387
|
|
|
|
|
388
|
|
|
echo '<script type="text/javascript" src="' . XOOPS_URL . '/modules/xhelp/include/functions.js"></script>'; |
|
389
|
|
|
$form = new Xhelp\Form( |
|
390
|
|
|
_AM_XHELP_EDIT_DEPARTMENT, 'edit_dept', Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', [ |
|
391
|
|
|
'op' => 'editDepartment', |
|
392
|
|
|
'deptid' => $deptID, |
|
393
|
|
|
]) |
|
394
|
|
|
); |
|
395
|
|
|
$dept_name = new \XoopsFormText(_AM_XHELP_TEXT_EDIT_DEPT, 'newDept', 20, 35, $fld_newDept); |
|
396
|
|
|
$group_select = new \XoopsFormSelect(_AM_XHELP_TEXT_EDIT_DEPT_PERMS, 'groups', $fld_groups, 6, true); |
|
397
|
|
|
$group_select->addOptionArray($aGroups); |
|
398
|
|
|
$defaultDeptID = Xhelp\Utility::getMeta('default_department'); |
|
399
|
|
|
$defaultDept = new Xhelp\FormCheckbox(_AM_XHELP_TEXT_DEFAULT_DEPT, 'defaultDept', (($defaultDeptID == $deptID) ? 1 : 0), 'defaultDept'); |
|
400
|
|
|
$defaultDept->addOption('1', ''); |
|
401
|
|
|
$btn_tray = new \XoopsFormElementTray(''); |
|
402
|
|
|
$btn_tray->addElement(new \XoopsFormButton('', 'updateDept', _SUBMIT, 'submit')); |
|
403
|
|
|
$form->addElement($dept_name); |
|
404
|
|
|
$form->addElement($group_select); |
|
405
|
|
|
$form->addElement($defaultDept); |
|
406
|
|
|
$form->addElement($btn_tray); |
|
407
|
|
|
$form->setLabelWidth('20%'); |
|
408
|
|
|
echo $form->render(); |
|
409
|
|
|
|
|
410
|
|
|
// Get dept staff members |
|
411
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
|
412
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
|
413
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
|
414
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
415
|
|
|
/** @var \XoopsModules\Xhelp\StaffRoleHandler $staffRoleHandler */ |
|
416
|
|
|
$staffRoleHandler = $helper->getHandler('StaffRole'); |
|
417
|
|
|
/** @var \XoopsModules\Xhelp\RoleHandler $roleHandler */ |
|
418
|
|
|
$roleHandler = $helper->getHandler('Role'); |
|
419
|
|
|
|
|
420
|
|
|
$staff = $membershipHandler->membershipByDept($deptID, $limit, $start); |
|
421
|
|
|
$criteria = new \Criteria('j.department', (string)$deptID); |
|
422
|
|
|
$staffCount = $membershipHandler->getCount($criteria); |
|
423
|
|
|
$roles = $roleHandler->getObjects(null, true); |
|
424
|
|
|
|
|
425
|
|
|
echo "<form action='" . XHELP_ADMIN_URL . '/department.php?op=deleteStaffDept&deptid=' . $deptID . "' method='post'>"; |
|
426
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
|
427
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'> |
|
428
|
|
|
<tr><th colspan='" . (3 + count($roles)) . "'><label>" . _AM_XHELP_MANAGE_STAFF . '</label></th></tr>'; |
|
429
|
|
|
|
|
430
|
|
|
if ($staffCount > 0) { |
|
431
|
|
|
$aStaff = []; |
|
432
|
|
|
foreach ($staff as $stf) { |
|
433
|
|
|
$aStaff[$stf->getVar('uid')] = $stf->getVar('uid'); // Get array of staff uid |
|
434
|
|
|
} |
|
435
|
|
|
|
|
436
|
|
|
// Get user list |
|
437
|
|
|
$criteria = new \Criteria('uid', '(' . implode(',', $aStaff) . ')', 'IN'); |
|
438
|
|
|
//$members = $memberHandler->getUserList($criteria); |
|
439
|
|
|
$members = Xhelp\Utility::getUsers($criteria, $displayName); |
|
|
|
|
|
|
440
|
|
|
|
|
441
|
|
|
// Get staff roles |
|
442
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('uid', '(' . implode(',', $aStaff) . ')', 'IN')); |
|
443
|
|
|
$criteria->add(new \Criteria('deptid', (string)$deptID)); |
|
444
|
|
|
$staffRoles = $staffRoleHandler->getObjects($criteria); |
|
445
|
|
|
unset($aStaff); |
|
446
|
|
|
|
|
447
|
|
|
$staffInfo = []; |
|
448
|
|
|
foreach ($staff as $stf) { |
|
449
|
|
|
$staff_uid = $stf->getVar('uid'); |
|
450
|
|
|
$staffInfo[$staff_uid]['uname'] = $members[$staff_uid]; |
|
451
|
|
|
$aRoles = []; |
|
452
|
|
|
foreach ($staffRoles as $role) { |
|
453
|
|
|
$role_id = $role->getVar('roleid'); |
|
454
|
|
|
if ($role->getVar('uid') == $staff_uid) { |
|
455
|
|
|
$aRoles[$role_id] = $roles[$role_id]->getVar('name'); |
|
456
|
|
|
} |
|
457
|
|
|
$staffInfo[$staff_uid]['roles'] = implode(', ', $aRoles); |
|
458
|
|
|
} |
|
459
|
|
|
} |
|
460
|
|
|
$nav = new \XoopsPageNav($staffCount, $limit, $start, 'start', "op=editDepartment&deptid=$deptID&limit=$limit"); |
|
461
|
|
|
|
|
462
|
|
|
echo "<tr class='head'><td rowspan='2'>" . _AM_XHELP_TEXT_ID . "</td><td rowspan='2'>" . _AM_XHELP_TEXT_USER . "</td><td colspan='" . count($roles) . "'>" . _AM_XHELP_TEXT_ROLES . "</td><td rowspan='2'>" . _AM_XHELP_TEXT_ACTIONS . '</td></tr>'; |
|
463
|
|
|
echo "<tr class='head'>"; |
|
464
|
|
|
foreach ($roles as $thisrole) { |
|
465
|
|
|
echo '<td>' . $thisrole->getVar('name') . '</td>'; |
|
466
|
|
|
} |
|
467
|
|
|
echo '</tr>'; |
|
468
|
|
|
foreach ($staffInfo as $uid => $staff) { |
|
469
|
|
|
echo "<tr class='even'> |
|
470
|
|
|
<td><input type='checkbox' name='staff[]' value='" . $uid . "'>" . $uid . '</td> |
|
471
|
|
|
<td>' . $staff['uname'] . '</td>'; |
|
472
|
|
|
foreach ($roles as $thisrole) { |
|
473
|
|
|
echo "<td><img src='" . XHELP_BASE_URL . '/assets/images/'; |
|
474
|
|
|
echo in_array($thisrole->getVar('name'), explode(', ', $staff['roles'])) ? 'on.png' : 'off.png'; |
|
475
|
|
|
echo "'></td>"; |
|
476
|
|
|
} |
|
477
|
|
|
echo " <td> |
|
478
|
|
|
<a href='" . XHELP_ADMIN_URL . '/staff.php?op=editStaff&uid=' . $uid . "'><img src='" . XOOPS_URL . "/modules/xhelp/assets/images/button_edit.png' title='" . _AM_XHELP_TEXT_EDIT . "' name='editStaff'></a> |
|
479
|
|
|
<a href='" . XHELP_ADMIN_URL . '/department.php?op=deleteStaffDept&uid=' . $uid . '&deptid=' . $deptID . "'><img src='" . XOOPS_URL . "/modules/xhelp/assets/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE_STAFF_DEPT . "' name='deleteStaffDept'></a> |
|
480
|
|
|
</td> |
|
481
|
|
|
</tr>"; |
|
482
|
|
|
} |
|
483
|
|
|
echo "<tr> |
|
484
|
|
|
<td class='foot' colspan='" . (3 + count($roles)) . "'> |
|
485
|
|
|
<input type='checkbox' name='checkallRoles' value='0' onclick='selectAll(this.form,\"staff[]\",this.checked);'> |
|
486
|
|
|
<input type='submit' name='deleteStaff' id='deleteStaff' value='" . _AM_XHELP_BUTTON_DELETE . "'> |
|
487
|
|
|
</td> |
|
488
|
|
|
</tr>"; |
|
489
|
|
|
echo '</table></form>'; |
|
490
|
|
|
echo "<div id='staff_nav'>" . $nav->renderNav() . '</div>'; |
|
491
|
|
|
} else { |
|
492
|
|
|
echo '</table></form>'; |
|
493
|
|
|
} |
|
494
|
|
|
|
|
495
|
|
|
//now do the list of servers |
|
496
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */ |
|
497
|
|
|
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox'); |
|
498
|
|
|
$deptServers = $departmentMailBoxHandler->getByDepartment($deptID); |
|
499
|
|
|
//iterate |
|
500
|
|
|
if (count($deptServers) > 0) { |
|
501
|
|
|
echo "<br><table width='100%' cellspacing='1' class='outer'> |
|
502
|
|
|
<tr> |
|
503
|
|
|
<th colspan='5'><label>" . _AM_XHELP_DEPARTMENT_SERVERS . "</label></th> |
|
504
|
|
|
</tr> |
|
505
|
|
|
<tr> |
|
506
|
|
|
<td class='head' width='20%'><label>" . _AM_XHELP_DEPARTMENT_SERVERS_EMAIL . "</label></td> |
|
507
|
|
|
<td class='head'><label>" . _AM_XHELP_DEPARTMENT_SERVERS_TYPE . "</label></td> |
|
508
|
|
|
<td class='head'><label>" . _AM_XHELP_DEPARTMENT_SERVERS_SERVERNAME . "</label></td> |
|
509
|
|
|
<td class='head'><label>" . _AM_XHELP_DEPARTMENT_SERVERS_PORT . "</label></td> |
|
510
|
|
|
<td class='head'><label>" . _AM_XHELP_DEPARTMENT_SERVERS_ACTION . '</label></td> |
|
511
|
|
|
</tr>'; |
|
512
|
|
|
$i = 0; |
|
513
|
|
|
foreach ($deptServers as $server) { |
|
514
|
|
|
if ($server->getVar('active')) { |
|
515
|
|
|
$activ_link = '".XHELP_ADMIN_URL."/department.php?op=activateMailbox&setstate=0&id=' . $server->getVar('id'); |
|
516
|
|
|
$activ_img = $icons['online']; |
|
517
|
|
|
$activ_title = _AM_XHELP_MESSAGE_DEACTIVATE; |
|
518
|
|
|
} else { |
|
519
|
|
|
$activ_link = '".XHELP_ADMIN_URL."/department.php?op=activateMailbox&setstate=1&id=' . $server->getVar('id'); |
|
520
|
|
|
$activ_img = $icons['offline']; |
|
521
|
|
|
$activ_title = _AM_XHELP_MESSAGE_ACTIVATE; |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
echo '<tr class="even"> |
|
525
|
|
|
<td>' . $server->getVar('emailaddress') . '</td> |
|
526
|
|
|
<td>' . Xhelp\Utility::getMBoxType($server->getVar('mboxtype')) . '</td> |
|
527
|
|
|
<td>' . $server->getVar('server') . '</td> |
|
528
|
|
|
<td>' . $server->getVar('serverport') . '</td> |
|
529
|
|
|
<td> <a href="' . $activ_link . '" title="' . $activ_title . '">' . $activ_img . '</a> |
|
530
|
|
|
<a href="' . XHELP_ADMIN_URL . '/department.php?op=EditDepartmentServer&id=' . $server->GetVar('id') . '">' . $icons['edit'] . '</a> |
|
531
|
|
|
<a href="' . XHELP_ADMIN_URL . '/department.php?op=DeleteDepartmentServer&id=' . $server->GetVar('id') . '">' . $icons['delete'] . '</a> |
|
532
|
|
|
|
|
533
|
|
|
</td> |
|
534
|
|
|
</tr>'; |
|
535
|
|
|
} |
|
536
|
|
|
echo '</table>'; |
|
537
|
|
|
} |
|
538
|
|
|
//finally add Mailbox form |
|
539
|
|
|
echo '<br><br>'; |
|
540
|
|
|
|
|
541
|
|
|
$formElements = [ |
|
542
|
|
|
'type_select', |
|
543
|
|
|
'server_text', |
|
544
|
|
|
'port_text', |
|
545
|
|
|
'username_text', |
|
546
|
|
|
'pass_text', |
|
547
|
|
|
'priority_radio', |
|
548
|
|
|
'email_text', |
|
549
|
|
|
'btn_tray', |
|
550
|
|
|
]; |
|
551
|
|
|
$form = new Xhelp\Form(_AM_XHELP_DEPARTMENT_ADD_SERVER, 'add_server', Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'AddDepartmentServer', 'id' => $deptID])); |
|
552
|
|
|
|
|
553
|
|
|
$type_select = new \XoopsFormSelect(_AM_XHELP_DEPARTMENT_SERVERS_TYPE, 'mboxtype'); |
|
554
|
|
|
$type_select->setExtra("id='mboxtype'"); |
|
555
|
|
|
$type_select->addOption((string)Constants::XHELP_MAILBOXTYPE_POP3, _AM_XHELP_MBOX_POP3); |
|
556
|
|
|
|
|
557
|
|
|
$server_text = new \XoopsFormText(_AM_XHELP_DEPARTMENT_SERVERS_SERVERNAME, 'server', 40, 50); |
|
558
|
|
|
$server_text->setExtra("id='txtServer'"); |
|
559
|
|
|
|
|
560
|
|
|
$port_text = new \XoopsFormText(_AM_XHELP_DEPARTMENT_SERVERS_PORT, 'port', 5, 5, '110'); |
|
561
|
|
|
$port_text->setExtra("id='txtPort'"); |
|
562
|
|
|
|
|
563
|
|
|
$username_text = new \XoopsFormText(_AM_XHELP_DEPARTMENT_SERVER_USERNAME, 'username', 25, 50); |
|
564
|
|
|
$username_text->setExtra("id='txtUsername'"); |
|
565
|
|
|
|
|
566
|
|
|
$pass_text = new \XoopsFormText(_AM_XHELP_DEPARTMENT_SERVER_PASSWORD, 'password', 25, 50); |
|
567
|
|
|
$pass_text->setExtra("id='txtPassword'"); |
|
568
|
|
|
|
|
569
|
|
|
$priority_radio = new Xhelp\FormRadio(_AM_XHELP_DEPARTMENT_SERVERS_PRIORITY, 'priority', (string)XHELP_DEFAULT_PRIORITY); |
|
570
|
|
|
$priority_array = [ |
|
571
|
|
|
1 => "<label for='priority1'><img src='" . XHELP_IMAGE_URL . "/priority1.png' title='" . Xhelp\Utility::getPriority(1) . "' alt='priority1'></label>", |
|
572
|
|
|
2 => "<label for='priority2'><img src='" . XHELP_IMAGE_URL . "/priority2.png' title='" . Xhelp\Utility::getPriority(2) . "' alt='priority2'></label>", |
|
573
|
|
|
3 => "<label for='priority3'><img src='" . XHELP_IMAGE_URL . "/priority3.png' title='" . Xhelp\Utility::getPriority(3) . "' alt='priority3'></label>", |
|
574
|
|
|
4 => "<label for='priority4'><img src='" . XHELP_IMAGE_URL . "/priority4.png' title='" . Xhelp\Utility::getPriority(4) . "' alt='priority4'></label>", |
|
575
|
|
|
5 => "<label for='priority5'><img src='" . XHELP_IMAGE_URL . "/priority5.png' title='" . Xhelp\Utility::getPriority(5) . "' alt='priority5'></label>", |
|
576
|
|
|
]; |
|
577
|
|
|
$priority_radio->addOptionArray($priority_array); |
|
578
|
|
|
|
|
579
|
|
|
$email_text = new \XoopsFormText(_AM_XHELP_DEPARTMENT_SERVER_EMAILADDRESS, 'emailaddress', 50, 255); |
|
580
|
|
|
$email_text->setExtra("id='txtEmailaddress'"); |
|
581
|
|
|
|
|
582
|
|
|
$btn_tray = new \XoopsFormElementTray(''); |
|
583
|
|
|
$test_button = new \XoopsFormButton('', 'email_test', _AM_XHELP_BUTTON_TEST, 'button'); |
|
584
|
|
|
$test_button->setExtra("id='test'"); |
|
585
|
|
|
$submit_button = new \XoopsFormButton('', 'updateDept2', _SUBMIT, 'submit'); |
|
586
|
|
|
$cancel2_button = new \XoopsFormButton('', 'cancel2', _AM_XHELP_BUTTON_CANCEL, 'button'); |
|
587
|
|
|
$cancel2_button->setExtra("onclick='history.go(-1)'"); |
|
588
|
|
|
$btn_tray->addElement($test_button); |
|
589
|
|
|
$btn_tray->addElement($submit_button); |
|
590
|
|
|
$btn_tray->addElement($cancel2_button); |
|
591
|
|
|
|
|
592
|
|
|
$form->setLabelWidth('20%'); |
|
593
|
|
|
foreach ($formElements as $element) { |
|
594
|
|
|
$form->addElement($$element); |
|
595
|
|
|
} |
|
596
|
|
|
echo $form->render(); |
|
597
|
|
|
|
|
598
|
|
|
echo '<script type="text/javascript" language="javascript"> |
|
599
|
|
|
<!-- |
|
600
|
|
|
function xhelpEmailTest() |
|
601
|
|
|
{ |
|
602
|
|
|
pop = openWithSelfMain("", "email_test", 250, 150); |
|
603
|
|
|
frm = xoopsGetElementById("add_server"); |
|
604
|
|
|
newaction = "department.php?op=testMailbox"; |
|
605
|
|
|
oldaction = frm.action; |
|
606
|
|
|
frm.action = newaction; |
|
607
|
|
|
frm.target = "email_test"; |
|
608
|
|
|
frm.submit(); |
|
609
|
|
|
frm.action = oldaction; |
|
610
|
|
|
frm.target = "main"; |
|
611
|
|
|
|
|
612
|
|
|
} |
|
613
|
|
|
|
|
614
|
|
|
xhelpDOMAddEvent(xoopsGetElementById("email_test"), "click", xhelpEmailTest, false); |
|
615
|
|
|
|
|
616
|
|
|
//--> |
|
617
|
|
|
</script>'; |
|
618
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
619
|
|
|
} |
|
620
|
|
|
} |
|
621
|
|
|
|
|
622
|
|
|
/** |
|
623
|
|
|
* |
|
624
|
|
|
*/ |
|
625
|
|
|
function editDepartmentServer() |
|
626
|
|
|
{ |
|
627
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
628
|
|
|
if (Request::hasVar('id', 'GET')) { |
|
629
|
|
|
$id = Request::getInt('id', 0, 'GET'); |
|
630
|
|
|
} else { |
|
631
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3); // TODO: Make message for no mbox_id |
|
632
|
|
|
} |
|
633
|
|
|
|
|
634
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */ |
|
635
|
|
|
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox'); |
|
636
|
|
|
$deptServer = $departmentMailBoxHandler->get($id); |
|
|
|
|
|
|
637
|
|
|
|
|
638
|
|
|
if (Request::hasVar('updateMailbox', 'POST')) { |
|
639
|
|
|
$deptServer->setVar('emailaddress', \Xmf\Request::getString('emailaddress', '', 'POST')); |
|
640
|
|
|
$deptServer->setVar('server', \Xmf\Request::getString('server', '', 'POST')); |
|
641
|
|
|
$deptServer->setVar('serverport', \Xmf\Request::getString('port', '', 'POST')); |
|
642
|
|
|
$deptServer->setVar('username', \Xmf\Request::getString('username', '', 'POST')); |
|
643
|
|
|
$deptServer->setVar('password', \Xmf\Request::getString('password', '', 'POST')); |
|
644
|
|
|
$deptServer->setVar('priority', $_POST['priority']); |
|
645
|
|
|
$deptServer->setVar('active', $_POST['activity']); |
|
646
|
|
|
|
|
647
|
|
|
if ($departmentMailBoxHandler->insert($deptServer)) { |
|
648
|
|
|
$helper->redirect('admin/department.php?op=editDepartment&deptid=' . $deptServer->getVar('departmentid')); |
|
649
|
|
|
} else { |
|
650
|
|
|
$helper->redirect('admin/department.php?op=editDepartment&deptid=' . $deptServer->getVar('departmentid'), 3); |
|
651
|
|
|
} |
|
652
|
|
|
} else { |
|
653
|
|
|
xoops_cp_header(); |
|
654
|
|
|
//echo $oAdminButton->renderButtons('manDept'); |
|
655
|
|
|
$adminObject = Admin::getInstance(); |
|
656
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
657
|
|
|
echo '<script type="text/javascript" src="' . XOOPS_URL . '/modules/xhelp/include/functions.js"></script>'; |
|
658
|
|
|
echo "<form method='post' id='edit_server' action='department.php?op=EditDepartmentServer&id=" . $id . "'> |
|
659
|
|
|
<table width='100%' cellspacing='1' class='outer'> |
|
660
|
|
|
<tr> |
|
661
|
|
|
<th colspan='2'><label>" . _AM_XHELP_DEPARTMENT_EDIT_SERVER . "</label></th> |
|
662
|
|
|
</tr> |
|
663
|
|
|
<tr> |
|
664
|
|
|
<td class='head' width='20%'><label for='mboxtype'>" . _AM_XHELP_DEPARTMENT_SERVERS_TYPE . "</label></td> |
|
665
|
|
|
<td class='even'> |
|
666
|
|
|
<select name='mboxtype' id='mboxtype' onchange='xhelpPortOnChange(this.options[this.selectedIndex].text, \"txtPort\")'> |
|
667
|
|
|
<option value='" . Constants::XHELP_MAILBOXTYPE_POP3 . "'>" . _AM_XHELP_MBOX_POP3 . "</option> |
|
668
|
|
|
<!--<option value='" . _XHELP_MAILBOXTYPE_IMAP . "'>" . _AM_XHELP_MBOX_IMAP . "</option>--> |
|
669
|
|
|
</select> |
|
670
|
|
|
</td> |
|
671
|
|
|
</tr> |
|
672
|
|
|
<tr> |
|
673
|
|
|
<td class='head'><label for='txtServer'>" . _AM_XHELP_DEPARTMENT_SERVERS_SERVERNAME . "</label></td> |
|
674
|
|
|
<td class='even'><input type='text' id='txtServer' name='server' value='" . $deptServer->getVar('server') . "' size='40' maxlength='50'> |
|
675
|
|
|
</tr> |
|
676
|
|
|
<tr> |
|
677
|
|
|
<td class='head'><label for='txtPort'>" . _AM_XHELP_DEPARTMENT_SERVERS_PORT . "</label></td> |
|
678
|
|
|
<td class='even'><input type='text' id='txtPort' name='port' maxlength='5' size='5' value='" . $deptServer->getVar('serverport') . "'> |
|
679
|
|
|
</tr> |
|
680
|
|
|
<tr> |
|
681
|
|
|
<td class='head'><label for='txtUsername'>" . _AM_XHELP_DEPARTMENT_SERVER_USERNAME . "</label></td> |
|
682
|
|
|
<td class='even'><input type='text' id='txtUsername' name='username' value='" . $deptServer->getVar('username') . "' size='25' maxlength='50'> |
|
683
|
|
|
</tr> |
|
684
|
|
|
<tr> |
|
685
|
|
|
<td class='head'><label for='txtPassword'>" . _AM_XHELP_DEPARTMENT_SERVER_PASSWORD . "</label></td> |
|
686
|
|
|
<td class='even'><input type='text' id='txtPassword' name='password' value='" . $deptServer->getVar('password') . "' size='25' maxlength='50'> |
|
687
|
|
|
</tr> |
|
688
|
|
|
<tr> |
|
689
|
|
|
<td width='38%' class='head'><label for='txtPriority'>" . _AM_XHELP_DEPARTMENT_SERVERS_PRIORITY . "</label></td> |
|
690
|
|
|
<td width='62%' class='even'>"; |
|
691
|
|
|
for ($i = 1; $i < 6; ++$i) { |
|
692
|
|
|
$checked = ''; |
|
693
|
|
|
if ($deptServer->getVar('priority') == $i) { |
|
694
|
|
|
$checked = 'checked'; |
|
695
|
|
|
} |
|
696
|
|
|
echo("<input type=\"radio\" value=\"$i\" id=\"priority$i\" name=\"priority\" $checked>"); |
|
697
|
|
|
echo("<label for=\"priority$i\"><img src=\"../assets/images/priority$i.png\" title=\"" . Xhelp\Utility::getPriority($i) . "\" alt=\"priority$i\"></label>"); |
|
698
|
|
|
} |
|
699
|
|
|
echo "</td> |
|
700
|
|
|
</tr> |
|
701
|
|
|
<tr> |
|
702
|
|
|
<td class='head'><label for='txtEmailaddress'>" . _AM_XHELP_DEPARTMENT_SERVER_EMAILADDRESS . "</label></td> |
|
703
|
|
|
<td class='even'><input type='text' id='txtEmailaddress' name='emailaddress' value='" . $deptServer->getVar('emailaddress') . "' size='50' maxlength='255'> |
|
704
|
|
|
</tr> |
|
705
|
|
|
<tr> |
|
706
|
|
|
<td class='head'><label for='txtActive'>" . _AM_XHELP_TEXT_ACTIVITY . "</label></td> |
|
707
|
|
|
<td class='even'>"; |
|
708
|
|
|
if (1 == $deptServer->getVar('active')) { |
|
709
|
|
|
echo "<input type='radio' value='1' name='activity' checked>" . _AM_XHELP_TEXT_ACTIVE . " |
|
710
|
|
|
<input type='radio' value='0' name='activity'>" . _AM_XHELP_TEXT_INACTIVE; |
|
711
|
|
|
} else { |
|
712
|
|
|
echo "<input type='radio' value='1' name='activity'>" . _AM_XHELP_TEXT_ACTIVE . " |
|
713
|
|
|
<input type='radio' value='0' name='activity' checked>" . _AM_XHELP_TEXT_INACTIVE; |
|
714
|
|
|
} |
|
715
|
|
|
|
|
716
|
|
|
echo "</td> |
|
717
|
|
|
</tr> |
|
718
|
|
|
|
|
719
|
|
|
<tr class='foot'> |
|
720
|
|
|
<td colspan='2'><div align='right'><span > |
|
721
|
|
|
<input type='button' id='email_test' name='test' value='" . _AM_XHELP_BUTTON_TEST . "' class='formButton'> |
|
722
|
|
|
<input type='submit' name='updateMailbox' value='" . _AM_XHELP_BUTTON_SUBMIT . "' class='formButton'> |
|
723
|
|
|
<input type='button' name='cancel' value='" . _AM_XHELP_BUTTON_CANCEL . "' onclick='history.go(-1)' class='formButton'> |
|
724
|
|
|
</span></div></td> |
|
725
|
|
|
</tr> |
|
726
|
|
|
</table> |
|
727
|
|
|
</form>"; |
|
728
|
|
|
echo '<script type="text/javascript" language="javascript"> |
|
729
|
|
|
<!-- |
|
730
|
|
|
function xhelpEmailTest() |
|
731
|
|
|
{ |
|
732
|
|
|
pop = openWithSelfMain("", "email_test", 250, 150); |
|
733
|
|
|
frm = xoopsGetElementById("edit_server"); |
|
734
|
|
|
newaction = "department.php?op=testMailbox"; |
|
735
|
|
|
oldaction = frm.action; |
|
736
|
|
|
frm.action = newaction; |
|
737
|
|
|
frm.target = "email_test"; |
|
738
|
|
|
frm.submit(); |
|
739
|
|
|
frm.action = oldaction; |
|
740
|
|
|
frm.target = "main"; |
|
741
|
|
|
|
|
742
|
|
|
} |
|
743
|
|
|
|
|
744
|
|
|
xhelpDOMAddEvent(xoopsGetElementById("email_test"), "click", xhelpEmailTest, false); |
|
745
|
|
|
|
|
746
|
|
|
//--> |
|
747
|
|
|
</script>'; |
|
748
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
749
|
|
|
} |
|
750
|
|
|
} |
|
751
|
|
|
|
|
752
|
|
|
/** |
|
753
|
|
|
* |
|
754
|
|
|
*/ |
|
755
|
|
|
function manageDepartments() |
|
756
|
|
|
{ |
|
757
|
|
|
global $xoopsModule, $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort, $dept_search; |
|
758
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
759
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
760
|
|
|
$deptID = 0; |
|
761
|
|
|
|
|
762
|
|
|
/** @var \XoopsGroupHandler $groupHandler */ |
|
763
|
|
|
$groupHandler = xoops_getHandler('group'); |
|
764
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
765
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
766
|
|
|
|
|
767
|
|
|
if (Request::hasVar('addDept', 'POST')) { |
|
768
|
|
|
$hasErrors = false; |
|
769
|
|
|
$errors = []; |
|
770
|
|
|
$groups = ($_POST['groups'] ?? []); |
|
771
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
|
772
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
|
773
|
|
|
|
|
774
|
|
|
//Department Name supplied? |
|
775
|
|
|
if ('' === trim(\Xmf\Request::getString('newDept', '', 'POST'))) { |
|
776
|
|
|
$hasErrors = true; |
|
777
|
|
|
$errors['newDept'][] = _AM_XHELP_MESSAGE_NO_DEPT; |
|
778
|
|
|
} else { |
|
779
|
|
|
//Department Name unique? |
|
780
|
|
|
$criteria = new \Criteria('department', \Xmf\Request::getString('newDept', '', 'POST')); |
|
781
|
|
|
$existingDepts = $departmentHandler->getCount($criteria); |
|
782
|
|
|
if ($existingDepts) { |
|
783
|
|
|
$hasErrors = true; |
|
784
|
|
|
$errors['newDept'][] = _XHELP_MESSAGE_DEPT_EXISTS; |
|
785
|
|
|
} |
|
786
|
|
|
} |
|
787
|
|
|
|
|
788
|
|
|
if ($hasErrors) { |
|
789
|
|
|
$session = Xhelp\Session::getInstance(); |
|
790
|
|
|
//Store existing dept info in session, reload addition page |
|
791
|
|
|
$aDept = []; |
|
792
|
|
|
$aDept['newDept'] = \Xmf\Request::getString('newDept', '', 'POST'); |
|
793
|
|
|
$aDept['groups'] = $groups; |
|
794
|
|
|
$session->set('xhelp_addDepartment', $aDept); |
|
795
|
|
|
$session->set('xhelp_addDepartmentErrors', $errors); |
|
796
|
|
|
redirect_header(Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'manageDepartments'], false)); |
|
|
|
|
|
|
797
|
|
|
} |
|
798
|
|
|
|
|
799
|
|
|
/** @var \XoopsModules\Xhelp\Department $department */ |
|
800
|
|
|
$department = $departmentHandler->create(); |
|
801
|
|
|
$department->setVar('department', \Xmf\Request::getString('newDept', '', 'POST')); |
|
802
|
|
|
|
|
803
|
|
|
if ($departmentHandler->insert($department)) { |
|
804
|
|
|
$deptID = $department->getVar('id'); |
|
805
|
|
|
foreach ($groups as $group) { // Add new group permissions |
|
806
|
|
|
$grouppermHandler->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id); |
|
807
|
|
|
} |
|
808
|
|
|
|
|
809
|
|
|
// Set as default department? |
|
810
|
|
|
if (Request::hasVar('defaultDept', 'POST') && (1 == $_POST['defaultDept'])) { |
|
811
|
|
|
Xhelp\Utility::setMeta('default_department', (string)$deptID); |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
/** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
|
815
|
|
|
$staffHandler = $helper->getHandler('Staff'); |
|
816
|
|
|
$allDeptStaff = $staffHandler->getByAllDepts(); |
|
817
|
|
|
if (count($allDeptStaff) > 0) { |
|
818
|
|
|
/** @var \XoopsModules\Xhelp\MembershipHandler $membershipHandler */ |
|
819
|
|
|
$membershipHandler = $helper->getHandler('Membership'); |
|
820
|
|
|
if ($membershipHandler->addStaffToDept($allDeptStaff, $department->getVar('id'))) { |
|
821
|
|
|
$message = _XHELP_MESSAGE_ADD_DEPT; |
|
822
|
|
|
} else { |
|
823
|
|
|
$message = _AM_XHELP_MESSAGE_STAFF_UPDATE_ERROR; |
|
824
|
|
|
} |
|
825
|
|
|
} else { |
|
826
|
|
|
$message = _XHELP_MESSAGE_ADD_DEPT; |
|
827
|
|
|
} |
|
828
|
|
|
|
|
829
|
|
|
// Add configoption for new department |
|
830
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
831
|
|
|
$configHandler = xoops_getHandler('config'); |
|
832
|
|
|
/** @var \XoopsModules\Xhelp\ConfigOptionHandler $configOptionHandler */ |
|
833
|
|
|
$configOptionHandler = $helper->getHandler('ConfigOption'); |
|
834
|
|
|
|
|
835
|
|
|
$criteria = new \Criteria('conf_name', 'xhelp_defaultDept'); |
|
836
|
|
|
$config = $configHandler->getConfigs($criteria); |
|
837
|
|
|
|
|
838
|
|
|
if (count($config) > 0) { |
|
839
|
|
|
$newOption = $configOptionHandler->create(); |
|
840
|
|
|
$newOption->setVar('confop_name', $department->getVar('department')); |
|
841
|
|
|
$newOption->setVar('confop_value', $department->getVar('id')); |
|
842
|
|
|
$newOption->setVar('conf_id', $config[0]->getVar('conf_id')); |
|
843
|
|
|
|
|
844
|
|
|
if (!$configOptionHandler->insert($newOption)) { |
|
845
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, _AM_XHELP_MSG_ADD_CONFIG_ERR); |
|
846
|
|
|
} |
|
847
|
|
|
} |
|
848
|
|
|
clearAddSessionVars(); |
|
849
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments'); |
|
850
|
|
|
} else { |
|
851
|
|
|
$message = _XHELP_MESSAGE_ADD_DEPT_ERROR . $department->getHtmlErrors(); |
|
852
|
|
|
} |
|
853
|
|
|
|
|
854
|
|
|
$deptID = $department->getVar('id'); |
|
|
|
|
|
|
855
|
|
|
|
|
856
|
|
|
/* Not sure if this is needed. Already exists in if block above (ej) |
|
857
|
|
|
foreach ($groups as $group) { |
|
858
|
|
|
$grouppermHandler->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id); |
|
859
|
|
|
} |
|
860
|
|
|
*/ |
|
861
|
|
|
|
|
862
|
|
|
$helper->redirect('admin/department.php?op=manageDepartments', 3, $message); |
|
863
|
|
|
} else { |
|
864
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentHandler $departmentHandler */ |
|
865
|
|
|
$departmentHandler = $helper->getHandler('Department'); |
|
866
|
|
|
if (false !== $dept_search) { |
|
867
|
|
|
$criteria = new \Criteria('department', "%$dept_search%", 'LIKE'); |
|
868
|
|
|
} else { |
|
869
|
|
|
$criteria = new \Criteria('', ''); |
|
870
|
|
|
} |
|
871
|
|
|
$criteria->setOrder($order); |
|
872
|
|
|
$criteria->setSort($sort); |
|
873
|
|
|
$criteria->setLimit($limit); |
|
874
|
|
|
$criteria->setStart($start); |
|
875
|
|
|
$total = $departmentHandler->getCount($criteria); |
|
876
|
|
|
$departmentInfo = $departmentHandler->getObjects($criteria); |
|
877
|
|
|
|
|
878
|
|
|
$nav = new \XoopsPageNav($total, $limit, $start, 'start', "op=manageDepartments&limit=$limit"); |
|
879
|
|
|
|
|
880
|
|
|
// Get list of all groups |
|
881
|
|
|
$criteria = new \Criteria('', ''); |
|
882
|
|
|
$criteria->setSort('name'); |
|
883
|
|
|
$criteria->setOrder('ASC'); |
|
884
|
|
|
$groups = $groupHandler->getObjects($criteria, true); |
|
885
|
|
|
|
|
886
|
|
|
$aGroups = []; |
|
887
|
|
|
foreach ($groups as $group_id => $group) { |
|
888
|
|
|
$aGroups[$group_id] = $group->getVar('name'); |
|
889
|
|
|
} |
|
890
|
|
|
asort($aGroups); // Set groups in alphabetical order |
|
891
|
|
|
|
|
892
|
|
|
xoops_cp_header(); |
|
893
|
|
|
//echo $oAdminButton->renderButtons('manDept'); |
|
894
|
|
|
$adminObject = Admin::getInstance(); |
|
895
|
|
|
$adminObject->displayNavigation('department.php?op=manageDepartments'); |
|
896
|
|
|
|
|
897
|
|
|
$session = Xhelp\Session::getInstance(); |
|
898
|
|
|
$sess_dept = $session->get('xhelp_addDepartment'); |
|
899
|
|
|
$sess_errors = $session->get('xhelp_addDepartmentErrors'); |
|
900
|
|
|
|
|
901
|
|
|
//Display any form errors |
|
902
|
|
|
if (false === !$sess_errors) { |
|
903
|
|
|
xhelpRenderErrors($sess_errors, Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'clearAddSession'], false)); |
|
|
|
|
|
|
904
|
|
|
} |
|
905
|
|
|
|
|
906
|
|
|
if (false !== !$sess_dept) { |
|
907
|
|
|
$fld_newDept = ''; |
|
908
|
|
|
$fld_groups = []; |
|
909
|
|
|
} else { |
|
910
|
|
|
$fld_newDept = $sess_dept['newDept']; |
|
911
|
|
|
$fld_groups = $sess_dept['groups']; |
|
912
|
|
|
} |
|
913
|
|
|
|
|
914
|
|
|
echo "<form method='post' action='" . XHELP_ADMIN_URL . "/department.php?op=manageDepartments'>"; |
|
915
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'> |
|
916
|
|
|
<tr><th colspan='2'><label for='newDept'>" . _AM_XHELP_LINK_ADD_DEPT . ' </label></th></tr>'; |
|
917
|
|
|
echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_NAME . "</td><td class='even'>"; |
|
918
|
|
|
echo "<input type='text' id='newDept' name='newDept' class='formButton' value='$fld_newDept'></td></tr>"; |
|
919
|
|
|
echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_EDIT_DEPT_PERMS . "</td><td class='even'>"; |
|
920
|
|
|
echo "<select name='groups[]' multiple='multiple'>"; |
|
921
|
|
|
foreach ($aGroups as $group_id => $group) { |
|
922
|
|
|
if (in_array($group_id, $fld_groups)) { |
|
923
|
|
|
echo "<option value='$group_id' selected>$group</option>"; |
|
924
|
|
|
} else { |
|
925
|
|
|
echo "<option value='$group_id'>$group</option>"; |
|
926
|
|
|
} |
|
927
|
|
|
} |
|
928
|
|
|
echo '</select></td></tr>'; |
|
929
|
|
|
echo "<tr><td class='head' width='20%' valign='top'>" . _AM_XHELP_TEXT_DEFAULT_DEPT . "?</td> |
|
930
|
|
|
<td class='even'><input type='checkbox' name='defaultDept' id='defaultDept' value='1'></td></tr>"; |
|
931
|
|
|
echo "<tr><td class='foot' colspan='2'><input type='submit' name='addDept' value='" . _AM_XHELP_BUTTON_SUBMIT . "' class='formButton'></td></tr>"; |
|
932
|
|
|
echo '</table><br>'; |
|
933
|
|
|
echo '</form>'; |
|
934
|
|
|
if ($total > 0) { // Make sure there are departments |
|
935
|
|
|
echo "<form action='" . XHELP_ADMIN_URL . "/department.php?op=manageDepartments' style='margin:0; padding:0;' method='post'>"; |
|
936
|
|
|
echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
|
937
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
938
|
|
|
echo "<tr><td align='right'>" . _AM_XHELP_BUTTON_SEARCH . " |
|
939
|
|
|
<input type='text' name='dept_search' value='$dept_search'> |
|
940
|
|
|
|
|
941
|
|
|
" . _AM_XHELP_TEXT_SORT_BY . " |
|
942
|
|
|
<select name='sort'>"; |
|
943
|
|
|
foreach ($aSortBy as $value => $text) { |
|
944
|
|
|
($sort == $value) ? $selected = 'selected' : $selected = ''; |
|
945
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
946
|
|
|
} |
|
947
|
|
|
echo '</select> |
|
948
|
|
|
|
|
949
|
|
|
' . _AM_XHELP_TEXT_ORDER_BY . " |
|
950
|
|
|
<select name='order'>"; |
|
951
|
|
|
foreach ($aOrderBy as $value => $text) { |
|
952
|
|
|
($order == $value) ? $selected = 'selected' : $selected = ''; |
|
953
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
954
|
|
|
} |
|
955
|
|
|
echo '</select> |
|
956
|
|
|
|
|
957
|
|
|
' . _AM_XHELP_TEXT_NUMBER_PER_PAGE . " |
|
958
|
|
|
<select name='limit'>"; |
|
959
|
|
|
foreach ($aLimitBy as $value => $text) { |
|
960
|
|
|
($limit == $value) ? $selected = 'selected' : $selected = ''; |
|
961
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
962
|
|
|
} |
|
963
|
|
|
echo "</select> |
|
964
|
|
|
<input type='submit' name='dept_sort' id='dept_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "'> |
|
965
|
|
|
</td> |
|
966
|
|
|
</tr>"; |
|
967
|
|
|
echo '</table></form>'; |
|
968
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'> |
|
969
|
|
|
<tr><th colspan='4'>" . _AM_XHELP_EXISTING_DEPARTMENTS . "</th></tr> |
|
970
|
|
|
<tr><td class='head'>" . _AM_XHELP_TEXT_ID . "</td><td class='head'>" . _AM_XHELP_TEXT_DEPARTMENT . "</td><td class='head'>" . _AM_XHELP_TEXT_DEFAULT . "</td><td class='head'>" . _AM_XHELP_TEXT_ACTIONS . '</td></tr>'; |
|
971
|
|
|
|
|
972
|
|
|
if (null !== $departmentInfo) { |
|
|
|
|
|
|
973
|
|
|
$defaultDept = Xhelp\Utility::getMeta('default_department'); |
|
974
|
|
|
foreach ($departmentInfo as $dept) { |
|
975
|
|
|
echo "<tr><td class='even'>" . $dept->getVar('id') . "</td><td class='even'>" . $dept->getVar('department') . '</td>'; |
|
976
|
|
|
if ($dept->getVar('id') != $defaultDept) { |
|
977
|
|
|
echo "<td class='even' width='10%'><a href='" |
|
978
|
|
|
. XHELP_ADMIN_URL |
|
979
|
|
|
. '/department.php?op=updateDefault&id=' |
|
980
|
|
|
. $dept->getVar('id') |
|
981
|
|
|
. "'><img src='" |
|
982
|
|
|
. XHELP_IMAGE_URL |
|
983
|
|
|
. "/off.png' alt='" |
|
984
|
|
|
. _AM_XHELP_TEXT_MAKE_DEFAULT_DEPT |
|
985
|
|
|
. "' title='" |
|
986
|
|
|
. _AM_XHELP_TEXT_MAKE_DEFAULT_DEPT |
|
987
|
|
|
. "'></a></td>"; |
|
988
|
|
|
} else { |
|
989
|
|
|
echo "<td class='even' width='10%'><img src='" . XHELP_IMAGE_URL . "/on.png'</td>"; |
|
990
|
|
|
} |
|
991
|
|
|
//echo "<td class='even' width='10%'><img src='".XHELP_IMAGE_URL."/". (($dept->getVar('id') == $defaultDept) ? "on.png" : "off.png")."'</td>"; |
|
992
|
|
|
echo "<td class='even' width='70'><a href='" |
|
993
|
|
|
. XHELP_ADMIN_URL |
|
994
|
|
|
. '/department.php?op=editDepartment&deptid=' |
|
995
|
|
|
. $dept->getVar('id') |
|
996
|
|
|
. "'><img src='" |
|
997
|
|
|
. XOOPS_URL |
|
998
|
|
|
. "/modules/xhelp/assets/images/button_edit.png' title='" |
|
999
|
|
|
. _AM_XHELP_TEXT_EDIT |
|
1000
|
|
|
. "' name='editDepartment'></a> "; |
|
1001
|
|
|
echo "<a href='" . XHELP_ADMIN_URL . '/delete.php?deleteDept=1&deptid=' . $dept->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/assets/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteDepartment'></a></td></tr>"; |
|
1002
|
|
|
} |
|
1003
|
|
|
} |
|
1004
|
|
|
} |
|
1005
|
|
|
echo '</td></tr></table>'; |
|
1006
|
|
|
echo "<div id='dept_nav'>" . $nav->renderNav() . '</div>'; |
|
1007
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
1008
|
|
|
} |
|
1009
|
|
|
} |
|
1010
|
|
|
|
|
1011
|
|
|
/** |
|
1012
|
|
|
* |
|
1013
|
|
|
*/ |
|
1014
|
|
|
function testMailbox() |
|
1015
|
|
|
{ |
|
1016
|
|
|
$helper = Xhelp\Helper::getInstance(); |
|
1017
|
|
|
/** @var \XoopsModules\Xhelp\DepartmentMailBoxHandler $departmentMailBoxHandler */ |
|
1018
|
|
|
$departmentMailBoxHandler = $helper->getHandler('DepartmentMailBox'); |
|
1019
|
|
|
$server = $departmentMailBoxHandler->create(); |
|
1020
|
|
|
$server->setVar('emailaddress', \Xmf\Request::getString('emailaddress', '', 'POST')); |
|
1021
|
|
|
$server->setVar('server', \Xmf\Request::getString('server', '', 'POST')); |
|
1022
|
|
|
$server->setVar('serverport', \Xmf\Request::getString('port', '', 'POST')); |
|
1023
|
|
|
$server->setVar('username', \Xmf\Request::getString('username', '', 'POST')); |
|
1024
|
|
|
$server->setVar('password', \Xmf\Request::getString('password', '', 'POST')); |
|
1025
|
|
|
$server->setVar('priority', $_POST['priority']); |
|
1026
|
|
|
echo '<html>'; |
|
1027
|
|
|
echo '<head>'; |
|
1028
|
|
|
echo "<link rel='stylesheet' type='text/css' media'screen' href='" . XOOPS_URL . "/xoops.css'> |
|
1029
|
|
|
<link rel='stylesheet' type='text/css' media='screen' href='" . xoops_getcss() . "'> |
|
1030
|
|
|
<link rel='stylesheet' type='text/css' media='screen' href='" . XOOPS_URL . "/modules/system/style.css'>"; |
|
1031
|
|
|
echo '</head>'; |
|
1032
|
|
|
echo '<body>'; |
|
1033
|
|
|
echo "<table style='margin:0; padding:0;' class='outer'>"; |
|
1034
|
|
|
if (@$server->connect()) { |
|
|
|
|
|
|
1035
|
|
|
//Connection Succeeded |
|
1036
|
|
|
echo "<tr><td class='head'>Connection Successful!</td></tr>"; |
|
1037
|
|
|
} else { |
|
1038
|
|
|
//Connection Failed |
|
1039
|
|
|
echo "<tr class='head'><td>Connection Failed!</td></tr>"; |
|
1040
|
|
|
echo "<tr class='even'><td>" . $server->getHtmlErrors() . '</td></tr>'; |
|
1041
|
|
|
} |
|
1042
|
|
|
echo '</table>'; |
|
1043
|
|
|
echo '</body>'; |
|
1044
|
|
|
echo '</html>'; |
|
1045
|
|
|
} |
|
1046
|
|
|
|
|
1047
|
|
|
/** |
|
1048
|
|
|
* |
|
1049
|
|
|
*/ |
|
1050
|
|
|
function clearAddSession() |
|
1051
|
|
|
{ |
|
1052
|
|
|
clearAddSessionVars(); |
|
1053
|
|
|
redirect_header(Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'manageDepartments'], false)); |
|
|
|
|
|
|
1054
|
|
|
} |
|
1055
|
|
|
|
|
1056
|
|
|
/** |
|
1057
|
|
|
* |
|
1058
|
|
|
*/ |
|
1059
|
|
|
function clearAddSessionVars() |
|
1060
|
|
|
{ |
|
1061
|
|
|
$session = Xhelp\Session::getInstance(); |
|
1062
|
|
|
$session->del('xhelp_addDepartment'); |
|
1063
|
|
|
$session->del('xhelp_addDepartmentErrors'); |
|
1064
|
|
|
} |
|
1065
|
|
|
|
|
1066
|
|
|
/** |
|
1067
|
|
|
* |
|
1068
|
|
|
*/ |
|
1069
|
|
|
function clearEditSession() |
|
1070
|
|
|
{ |
|
1071
|
|
|
$deptid = $_REQUEST['deptid']; |
|
1072
|
|
|
clearEditSessionVars($deptid); |
|
1073
|
|
|
redirect_header(Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'editDepartment', 'deptid' => $deptid], false)); |
|
|
|
|
|
|
1074
|
|
|
} |
|
1075
|
|
|
|
|
1076
|
|
|
/** |
|
1077
|
|
|
* @param int $id |
|
1078
|
|
|
*/ |
|
1079
|
|
|
function clearEditSessionVars(int $id) |
|
1080
|
|
|
{ |
|
1081
|
|
|
$id = $id; |
|
1082
|
|
|
$session = Xhelp\Session::getInstance(); |
|
1083
|
|
|
$session->del("xhelp_editDepartment_$id"); |
|
1084
|
|
|
$session->del("xhelp_editDepartmentErrors_$id"); |
|
1085
|
|
|
} |
|
1086
|
|
|
|
|
1087
|
|
|
/** |
|
1088
|
|
|
* |
|
1089
|
|
|
*/ |
|
1090
|
|
|
function updateDefault() |
|
1091
|
|
|
{ |
|
1092
|
|
|
$id = Request::getInt('id', 0, 'REQUEST'); |
|
1093
|
|
|
Xhelp\Utility::setMeta('default_department', (string)$id); |
|
1094
|
|
|
redirect_header(Xhelp\Utility::createURI(XHELP_ADMIN_URL . '/department.php', ['op' => 'manageDepartments'], false)); |
|
|
|
|
|
|
1095
|
|
|
} |
|
1096
|
|
|
|