Passed
Pull Request — master (#29)
by Michael
13:00 queued 02:18
created

blocks/countdown-block.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
use XoopsModules\Countdown;
6
use XoopsModules\Countdown\Helper;
7
use XoopsModules\Countdown\Constants;
8
9
include_once XOOPS_ROOT_PATH . '/modules/countdown/include/common.php';
10
11
function showCountdown($options)
12
{
13
    /** @var Helper $helper */
14
    if (!class_exists(Helper::class)) {
15
        return false;
16
    }
17
18
    $helper = Helper::getInstance();
19
    $helper->loadLanguage('main');
20
21
    $myts = \MyTextSanitizer::getInstance();
22
23
    $block             = [];
24
    $block['event_id'] = $options[0];
25
    $selected_id       = $block['event_id'];
26
27
    $sql    = "SELECT * FROM " . $GLOBALS['xoopsDB']->prefix("countdown_events") . " WHERE event_id=$selected_id";
28
    $result = $GLOBALS['xoopsDB']->query($sql);
29
30
    while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
31
        $block['id']           = $row['event_id'];
32
        $block['uid']          = $row['event_uid'];
33
        $block['submitter']    = \XoopsUser::getUnameFromId($row['event_uid']);
34
        $block['name']         = $row['event_name'];
35
        $block['description']  = $row['event_description'];
36
        $block['categoryid']   = $row['event_categoryid'];
37
        $categoryid            = $row['event_categoryid'];
38
        $categoryHandler       = $helper->getHandler('category');
39
        $categoryObj           = $categoryHandler->get($categoryid);
40
        $block['categoryname'] = $categoryObj->getVar('category_title');
41
        $categoryname          = $categoryObj->getVar('category_title');
42
        $block['logo']         = $row['event_logo'];
43
        $block['date']         = date(_DATESTRING, strtotime($row['event_date']));
44
        $block['dateiso']      = $row['event_date'];
45
        $block['usertime']     = formatTimeStamp(time(), 'mysql');
46
        $block['date_created'] = formatTimestamp($row['date_created']);
47
        $date_created          = formatTimestamp($row['date_created']);
48
        $block['date_updated'] = formatTimestamp($row['date_updated']);
49
        $date_updated          = formatTimestamp($row['date_updated']);
50
51
        if ($date_created == $date_updated) {
52
            $block['info'] = sprintf(_MB_COUNTDOWN_POSTEDBY, \XoopsUser::getUnameFromId($row['event_uid']), formatTimestamp($row['date_created'], 'M d Y'), $categoryname);
0 ignored issues
show
It seems like $categoryname can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

52
            $block['info'] = sprintf(_MB_COUNTDOWN_POSTEDBY, \XoopsUser::getUnameFromId($row['event_uid']), formatTimestamp($row['date_created'], 'M d Y'), /** @scrutinizer ignore-type */ $categoryname);
Loading history...
53
        } else {
54
            $block['info'] = sprintf(_MB_COUNTDOWN_POSTEDBY, \XoopsUser::getUnameFromId($row['event_uid']), formatTimestamp($row['date_updated'], 'M d Y'), $categoryname);
55
        }
56
    }
57
    $block['displayinfo']      = $options[1];
58
    $block['displayeventlogo'] = $options[2];
59
    return $block;
60
}
61
62
function editCountdown($options)
63
{
64
    $form = _MB_COUNTDOWN_EVENTTODISPLAY . '&nbsp;';;
65
    $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "'>&nbsp;";
66
    $form .= "<select name='options[0]'>";
67
    $form .= "<option>" . _MB_COUNTDOWN_EVENTTODISPLAY . "</option>";
68
69
    $sql       = "SELECT c.category_title,c.category_id,e.event_id,e.event_name,event_categoryid FROM " . $GLOBALS['xoopsDB']->prefix("countdown_events") . " AS e JOIN " . $GLOBALS['xoopsDB']->prefix("countdown_categories") . " AS c WHERE category_id=event_categoryid";
70
    $result    = $GLOBALS['xoopsDB']->query($sql);
71
    $totaldata = $GLOBALS['xoopsDB']->getRowsNum($result);
72
    if ($totaldata > 0) {
73
        while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) {
74
            $event[$myrow['category_title']][] = $myrow;
75
        }
76
        foreach ($event as $key => $values) {
77
            $form .= '<optgroup label="' . $key . '">';
78
            foreach ($values as $value) {
79
                if ($options[0] == $value['event_id']) {
80
                    $form .= '<option value="' . $options[0] . '" selected>' . $value['event_name'] . '</option>';
81
                } else {
82
                    $form .= '<option value="' . $value['event_id'] . '">' . $value['event_name'] . '</option>';
83
                }
84
            }
85
            $form .= "</optgroup>";
86
        }
87
    } else {
88
    }
89
    $form .= "</select><br>";
90
91
    $form .= _MB_COUNTDOWN_DISPLAYEVENTDESCRIPTION . '&nbsp;';
92
    if (1 == $options[1]) {
93
        $chk = " checked";
94
    }
95
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
96
    $chk  = '';
97
    if (0 == $options[1]) {
98
        $chk = " checked";
99
    }
100
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>';
101
102
    $form .= _MB_COUNTDOWN_DISPLAYEVENTLOGO . '&nbsp;';
103
    if (1 == $options[2]) {
104
        $chk = " checked";
105
    }
106
    $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
107
    $chk  = '';
108
    if (0 == $options[2]) {
109
        $chk = " checked";
110
    }
111
    $form .= "&nbsp;<input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>';
112
113
    $form .= _MB_COUNTDOWN_DISPLAYINFO . '&nbsp;';
114
    if (1 == $options[3]) {
115
        $chk = " checked";
116
    }
117
    $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
118
    $chk  = '';
119
    if (0 == $options[3]) {
120
        $chk = " checked";
121
    }
122
    $form .= "&nbsp;<input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>';
123
    return $form;
124
}
125
126
?>
127