1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* alumni module |
14
|
|
|
* Edited by John Mordo (jlm69) |
15
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
17
|
|
|
* @since 2.6.0 |
18
|
|
|
* @author Mage Grégory (AKA Mage) |
19
|
|
|
* @version $Id: $ |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
use Xoops\Core\Request; |
23
|
|
|
use Xoops\Module\Plugin\PluginAbstract; |
24
|
|
|
use Xmf\Metagen; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class AlumniSearchPlugin |
28
|
|
|
*/ |
29
|
|
|
class AlumniSearchPlugin extends PluginAbstract implements SearchPluginInterface |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @param string[] $queries |
33
|
|
|
* @param string $andor |
34
|
|
|
* @param int $limit |
35
|
|
|
* @param int $start |
36
|
|
|
* @param \type $userid |
37
|
|
|
* @return array |
38
|
|
|
*/ |
39
|
|
|
public function search($queries, $andor, $limit, $start, $userid) |
40
|
|
|
{ |
41
|
|
|
$xoops = Xoops::getInstance(); |
42
|
|
|
$alumni = Alumni::getInstance(); |
|
|
|
|
43
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
|
|
|
44
|
|
|
$by_cat = Request::getInt('by_cat', ''); |
|
|
|
|
45
|
|
|
$andor = Request::getWord('andor', 'AND'); |
|
|
|
|
46
|
|
|
$queries = []; |
|
|
|
|
47
|
|
|
$query = Request::getString('query', ''); |
48
|
|
|
$start = Request::getInt('start', '0'); |
49
|
|
|
|
50
|
|
|
$helper = Xoops::getModuleHelper('alumni'); |
51
|
|
|
$module_id = $helper->getModule()->getVar('mid'); |
|
|
|
|
52
|
|
|
$listingHandler = $helper->getHandler('listing'); |
53
|
|
|
$groups = $xoops->getUserGroups(); |
54
|
|
|
$alumni_ids = $xoops->getHandlerGroupperm()->getItemIds('alumni_view', $groups, $module_id); |
|
|
|
|
55
|
|
|
$all_ids = implode(', ', $alumni_ids); |
|
|
|
|
56
|
|
|
|
57
|
|
|
$criteria = new CriteriaCompo(); |
58
|
|
|
$criteria->add(new Criteria('valid', 1, '=')); |
59
|
|
|
// $criteria->add(new Criteria('date', time(), '<=')); |
|
|
|
|
60
|
|
|
$criteria->add(new Criteria('cid', '(' . $all_ids . ')', 'IN')); |
|
|
|
|
61
|
|
|
if (0 != $userid) { |
62
|
|
|
$criteria->add(new Criteria('usid', $userid, '=')); |
63
|
|
|
} |
64
|
|
|
if ($by_cat) { |
|
|
|
|
65
|
|
|
$criteria->add(new Criteria('cid', $by_cat, '=')); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$queries = [$query]; |
69
|
|
|
$queries = implode('+', $queries); |
70
|
|
|
|
71
|
|
|
$count = 0; |
|
|
|
|
72
|
|
|
$i = 0; |
|
|
|
|
73
|
|
|
|
74
|
|
|
$criteria->add(new Criteria('name', '%' . $queries . '%', 'LIKE'), 'AND'); |
75
|
|
|
$criteria->add(new Criteria('mname', '%' . $queries . '%', 'LIKE'), 'OR'); |
76
|
|
|
$criteria->add(new Criteria('lname', '%' . $queries . '%', 'LIKE'), 'OR'); |
77
|
|
|
$criteria->add(new Criteria('school', '%' . $queries . '%', 'LIKE'), 'OR'); |
78
|
|
|
$criteria->add(new Criteria('year', '%' . $queries . '%', 'LIKE'), 'OR'); |
79
|
|
|
|
80
|
|
|
$criteria->setLimit($limit); |
81
|
|
|
$criteria->setSort('date'); |
82
|
|
|
$criteria->setOrder('DESC'); |
83
|
|
|
$criteria->setStart($start); |
84
|
|
|
|
85
|
|
|
$numrows = $listingHandler->getCount(); |
|
|
|
|
86
|
|
|
$this_search = $listingHandler->getall($criteria); |
|
|
|
|
87
|
|
|
|
88
|
|
|
$ret = []; |
89
|
|
|
$k = 0; |
|
|
|
|
90
|
|
|
|
91
|
|
|
foreach ($this_search as $obj) { |
|
|
|
|
92
|
|
|
$ret[$k]['image'] = 'images/cat/default.gif'; |
93
|
|
|
$ret[$k]['link'] = 'listing.php?lid=' . $obj->getVar('lid') . ''; |
94
|
|
|
$ret[$k]['title'] = $obj->getVar('name') . ' ' . $obj->getVar('mname') . ' ' . $obj->getVar('lname') . ' --- ' . $obj->getVar('school') . ' |
95
|
|
|
--- ' . $obj->getVar('year'); |
96
|
|
|
$ret[$k]['time'] = $obj->getVar('date'); |
97
|
|
|
$ret[$k]['uid'] = $obj->getVar('usid'); |
98
|
|
|
$k++; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
return $ret; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.