news_notify_iteminfo()   B
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 42
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 24
c 0
b 0
f 0
dl 0
loc 42
rs 8.9137
cc 6
nc 6
nop 2
1
<?php declare(strict_types=1);
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
 * @copyright      {@link https://xoops.org/ XOOPS Project}
14
 * @license        {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @author         XOOPS Development Team
16
 * @param mixed $category
17
 * @param mixed $item_id
18
 */
19
20
/**
21
 * @param $category
22
 * @param $item_id
23
 */
24
function news_notify_iteminfo($category, $item_id)
25
{
26
    if ('global' === $category) {
27
        $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...
28
        $item['url']  = '';
29
30
        return $item;
31
    }
32
33
    global $xoopsDB;
34
35
    if ('story' === $category) {
36
        // Assume we have a valid story id
37
        $sql    = 'SELECT title FROM ' . $xoopsDB->prefix('news_stories') . ' WHERE storyid = ' . (int)$item_id;
38
        $result = $xoopsDB->query($sql);
39
        if ($result) {
40
            $result_array = $xoopsDB->fetchArray($result);
41
            $item['name'] = $result_array['title'];
42
            $item['url']  = XOOPS_URL . '/modules/news/article.php?storyid=' . (int)$item_id;
43
44
            return $item;
45
        }
46
47
        return null;
48
    }
49
50
    // Added by Lankford on 2007/3/23
51
    if ('category' === $category) {
52
        $sql    = 'SELECT title FROM ' . $xoopsDB->prefix('news_topics') . ' WHERE topic_id = ' . (int)$item_id;
53
        $result = $xoopsDB->query($sql);
54
        if ($result) {
55
            $result_array = $xoopsDB->fetchArray($result);
56
            $item['name'] = $result_array['topic_id'];
57
            $item['url']  = XOOPS_URL . '/modules/news/index.php?storytopic=' . (int)$item_id;
58
59
            return $item;
60
        }
61
62
        return null;
63
    }
64
65
    return null;
66
}
67