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\Xhelp; |
23
|
|
|
|
24
|
|
|
require_once __DIR__ . '/header.php'; |
25
|
|
|
$helper = Xhelp\Helper::getInstance(); |
26
|
|
|
|
27
|
|
|
/** @var \XoopsModules\Xhelp\StaffHandler $staffHandler */ |
28
|
|
|
$staffHandler = $helper->getHandler('Staff'); |
29
|
|
|
|
30
|
|
|
//Allow only staff members to view this page |
31
|
|
|
if (!$xoopsUser) { |
32
|
|
|
redirect_header(XOOPS_URL, 3, _NOPERM); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$inadmin = 0; |
36
|
|
|
if (Request::hasVar('admin', 'REQUEST') && 1 === $_REQUEST['admin']) { |
37
|
|
|
$inadmin = 1; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
if (!$inadmin && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
41
|
|
|
if (!$staffHandler->isStaff($xoopsUser->getVar('uid'))) { |
42
|
|
|
redirect_header(XOOPS_URL . '/modules/xhelp/index.php', 3, _NOPERM); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
// Initialize Smarty Template Engine |
47
|
|
|
require_once XOOPS_ROOT_PATH . '/class/template.php'; |
48
|
|
|
$xoopsTpl = new \XoopsTpl(); |
49
|
|
|
$xoopsTpl->assign('xhelp_imagePath', XOOPS_URL . '/modules/xhelp/assets/images/'); |
50
|
|
|
$xoopsTpl->assign('sitename', $xoopsConfig['sitename']); |
51
|
|
|
$xoopsTpl->assign('xoops_themecss', xoops_getcss()); |
52
|
|
|
$xoopsTpl->assign('xoops_url', XOOPS_URL); |
53
|
|
|
$xoopsTpl->assign('xhelp_inadmin', $inadmin); |
54
|
|
|
$xoopsTpl->assign('xhelp_adminURL', XHELP_ADMIN_URL); |
|
|
|
|
55
|
|
|
|
56
|
|
|
if (Request::hasVar('search', 'POST')) { |
57
|
|
|
if (Request::hasVar('searchText', 'POST')) { |
58
|
|
|
$text = \Xmf\Request::getString('searchText', '', 'POST'); |
59
|
|
|
} |
60
|
|
|
if (Request::hasVar('subject', 'POST')) { |
61
|
|
|
$subject = \Xmf\Request::getString('subject', '', 'POST'); |
62
|
|
|
} |
63
|
|
|
$xoopsTpl->assign('xhelp_viewResults', true); |
64
|
|
|
|
65
|
|
|
/** @var \XoopsUserHandler $userHandler */ |
66
|
|
|
$userHandler = xoops_getHandler('user'); |
67
|
|
|
$criteria = new \Criteria($subject, '%' . $text . '%', 'LIKE'); |
68
|
|
|
$criteria->setSort($subject); |
69
|
|
|
$users = $userHandler->getObjects($criteria); |
70
|
|
|
foreach ($users as $user) { |
71
|
|
|
$aUsers[] = [ |
72
|
|
|
'uid' => $user->getVar('uid'), |
73
|
|
|
'uname' => $user->getVar('uname'), |
74
|
|
|
'name' => $user->getVar('name'), |
75
|
|
|
'email' => $user->getVar('email'), |
76
|
|
|
]; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
$xoopsTpl->assign('xhelp_matches', $aUsers); |
80
|
|
|
$xoopsTpl->assign('xhelp_matchCount', count($aUsers)); |
81
|
|
|
} else { |
82
|
|
|
$xoopsTpl->assign('xhelp_viewResults', false); |
83
|
|
|
} |
84
|
|
|
$xoopsTpl->display('db:xhelp_lookup.tpl'); |
85
|
|
|
|
86
|
|
|
exit(); |
87
|
|
|
|