-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsearch.php
58 lines (49 loc) · 2.18 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* SmallWorld
*
* @copyright The XOOPS Project (https://xoops.org)
* @copyright 2011 Culex
* @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/)
* @package \XoopsModules\SmallWorld
* @since 1.0
* @author Michael Albertsen (http://culex.dk) <[email protected]>
*/
use Xmf\Request;
use XoopsModules\Smallworld;
require_once __DIR__ . '/header.php';
$GLOBALS['xoopsOption']['template_main'] = 'smallworld_index.tpl';
require_once XOOPS_ROOT_PATH . '/header.php';
/** @var \XoopsModules\Smallworld\Helper $helper */
require_once $helper->path('include/functions.php');
require_once $helper->path('include/arrays.php');
$GLOBALS['xoopsLogger']->activated = false;
if (isset($_GET) && !empty($_GET)) {
$swUserHandler = $helper->getHandler('SwUser');
$q = smallworld_sanitize(Request::getString('term', '', 'GET'));
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . " WHERE realname LIKE '%" . $q . "%' OR username LIKE '%" . $q . "%' ORDER BY userid LIMIT 5";
$result = $GLOBALS['xoopsDB']->query($sql);
$data = [];
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
$user = new \XoopsUser($row['userid']);
$image = '<img src="' . $swUserHandler->getAvatarLink($row['userid'], $row['userimage']) . '" height="20" >';
//@todo figure out where the $imageSize[] array comes from
$imageHw = smallworld_imageResize($imageSize[0], $imageSize[1], 30);
$data[] = [
'label' => $image . ' ' . '<span class="searchusername">' . $row['realname'] . ' (' . $row['username'] . ')</span>',
'value' => $user->uname(),
];
}
// jQuery wants JSON data
echo json_encode($data);
flush();
}