wgevents_notify_iteminfo()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 29
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 23
c 1
b 0
f 0
nc 8
nop 2
dl 0
loc 29
rs 9.2408
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
 * wgEvents module for xoops
15
 *
16
 * @copyright    2021 XOOPS Project (https://xoops.org)
17
 * @license      GPL 2.0 or later
18
 * @package      wgevents
19
 * @since        1.0.0
20
 * @min_xoops    2.5.11 Beta1
21
 * @author       Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com
22
 */
23
24
/**
25
 * comment callback functions
26
 *
27
 * @param  $category
28
 * @param  $item_id
29
 * @return array item|null
30
 */
31
function wgevents_notify_iteminfo($category, $item_id)
32
{
33
    global $xoopsDB;
34
35
    if (!\defined('WGEVENTS_URL')) {
36
        \define('WGEVENTS_URL', \XOOPS_URL . '/modules/wgevents');
37
    }
38
39
    switch ($category) {
40
        case 'global':
41
            $item['name'] = '';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$item was never initialized. Although not strictly required by PHP, it is generally a good practice to add $item = array(); before regardless.
Loading history...
42
            $item['url']  = '';
43
            return $item;
44
        case 'events':
45
            $sql          = 'SELECT name FROM ' . $xoopsDB->prefix('wgevents_event') . ' WHERE id = '. $item_id;
46
            $result       = $xoopsDB->query($sql);
47
            $result_array = $xoopsDB->fetchArray($result);
48
            $item['name'] = $result_array['name'];
49
            $item['url']  = \WGEVENTS_URL . '/event.php?id=' . $item_id;
50
            return $item;
51
        case 'registrations':
52
            $sql          = 'SELECT evid FROM ' . $xoopsDB->prefix('wgevents_registrations') . ' WHERE id = '. $item_id;
53
            $result       = $xoopsDB->query($sql);
54
            $result_array = $xoopsDB->fetchArray($result);
55
            $item['name'] = $result_array['evid'];
56
            $item['url']  = \WGEVENTS_URL . '/registration.php?id=' . $item_id;
57
            return $item;
58
    }
59
    return null;
60
}
61