search.inc.php ➔ presenter_search()   B
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
nc 8
nop 5
dl 0
loc 33
rs 8.7697
c 0
b 0
f 0
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
 * presenter module for xoops
13
 *
14
 * @copyright       XOOPS Project (https://xoops.org)
15
 * @license         GPL 2.0 or later
16
 * @package         presenter
17
 * @since           2.5.5
18
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
19
 * @param $queryarray
20
 * @param $andor
21
 * @param $limit
22
 * @param $offset
23
 * @param $userid
24
 * @return array
25
 */
26
function presenter_search($queryarray, $andor, $limit, $offset, $userid)
27
{
28
    global $xoopsDB;
29
30
    $sql = 'SELECT slides_id, slides_cid FROM ' . $xoopsDB->prefix('slides') . ' WHERE slides_online = 1';
31
32
    if (0 != $userid) {
33
        $sql .= ' AND slides_submitter=' . (int)$userid;
34
    }
35
36
    if (is_array($queryarray) && $count = count($queryarray)) {
37
        $sql .= " AND ((slides_cid LIKE '%$queryarray[0]%' OR slides_uid LIKE '%$queryarray[0]%' OR slides_title LIKE '%$queryarray[0]%' OR slides_content LIKE '%$queryarray[0]%' OR slides_transition_x LIKE '%$queryarray[0]%' OR slides_transition_y LIKE '%$queryarray[0]%' OR slides_transition_z LIKE '%$queryarray[0]%' OR slides_rotation_x LIKE '%$queryarray[0]%' OR slides_rotation_y LIKE '%$queryarray[0]%' OR slides_rotation_z LIKE '%$queryarray[0]%' OR slides_scale_x LIKE '%$queryarray[0]%' OR slides_scale_y LIKE '%$queryarray[0]%' OR slides_scale_z LIKE '%$queryarray[0]%' OR slides_created LIKE '%$queryarray[0]%' OR slides_published LIKE '%$queryarray[0]%' OR slides_position LIKE '%$queryarray[0]%' OR slides_online LIKE '%$queryarray[0]%' OR slides_type LIKE '%$queryarray[0]%' OR slides_notes LIKE '%$queryarray[0]%' OR slides_mp3 LIKE '%$queryarray[0]%' OR slides_time LIKE '%$queryarray[0]%')";
38
39
        for ($i = 1; $i < $count; ++$i) {
40
            $sql .= " $andor ";
41
            $sql .= "(slides_cid LIKE '%$queryarray[$i]%' OR slides_uid LIKE '%$queryarray[$i]%' OR slides_title LIKE '%$queryarray[$i]%' OR slides_content LIKE '%$queryarray[$i]%' OR slides_transition_x LIKE '%$queryarray[$i]%' OR slides_transition_y LIKE '%$queryarray[$i]%' OR slides_transition_z LIKE '%$queryarray[$i]%' OR slides_rotation_x LIKE '%$queryarray[$i]%' OR slides_rotation_y LIKE '%$queryarray[$i]%' OR slides_rotation_z LIKE '%$queryarray[$i]%' OR slides_scale_x LIKE '%$queryarray[$i]%' OR slides_scale_y LIKE '%$queryarray[$i]%' OR slides_scale_z LIKE '%$queryarray[$i]%' OR slides_created LIKE '%$queryarray[$i]%' OR slides_published LIKE '%$queryarray[$i]%' OR slides_position LIKE '%$queryarray[$i]%' OR slides_online LIKE '%$queryarray[$i]%' OR slides_type LIKE '%$queryarray[$i]%' OR slides_notes LIKE '%$queryarray[$i]%' OR slides_mp3 LIKE '%$queryarray[$i]%' OR slides_time LIKE '%$queryarray[0]%')";
42
        }
43
        $sql .= ')';
44
    }
45
46
    $sql    .= ' ORDER BY slides_id DESC';
47
    $result = $xoopsDB->query($sql, $limit, $offset);
48
    $ret    = [];
49
    $i      = 0;
50
    while ($myrow = $xoopsDB->fetchArray($result)) {
51
        $ret[$i]['image'] = 'images/icons/32/slides_search.png';
52
        $ret[$i]['link']  = 'slides.php?slides_id=' . $myrow['slides_id'];
53
        $ret[$i]['title'] = $myrow['slides_cid'];
54
        ++$i;
55
    }
56
57
    return $ret;
58
}
59