mymodule3_notify_iteminfo()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 32
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
cc 5
eloc 26
nc 8
nop 2
dl 0
loc 32
rs 9.1928
c 1
b 1
f 1
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
 * My Module 3 module for xoops
14
 *
15
 * @copyright     2020 XOOPS Project (https://xooops.org)
16
 * @license        GPL 2.0 or later
17
 * @package        mymodule3
18
 * @since          1.0
19
 * @min_xoops      2.5.9
20
 * @author         TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org>
21
 */
22
23
/**
24
 * comment callback functions
25
 *
26
 * @param  $category 
27
 * @param  $item_id 
28
 * @return array item|null
29
 */
30
function mymodule3_notify_iteminfo($category, $item_id)
31
{
32
	global $xoopsDB;
33
34
	if (!defined('MYMODULE3_URL')) {
35
		define('MYMODULE3_URL', XOOPS_URL . '/modules/mymodule3');
36
	}
37
38
	switch($category) {
39
		case 'global':
40
			$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...
41
			$item['url']  = '';
42
			return $item;
43
		break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
44
		case 'articles':
45
			$sql          = 'SELECT art_title FROM ' . $xoopsDB->prefix('mymodule3_articles') . ' WHERE art_id = '. $item_id;
46
			$result       = $xoopsDB->query($sql);
47
			$result_array = $xoopsDB->fetchArray($result);
48
			$item['name'] = $result_array['art_title'];
49
			$item['url']  = MYMODULE3_URL . '/articles.php?art_id=' . $item_id;
50
			return $item;
51
		break;
52
		case 'testfields':
53
			$sql          = 'SELECT tf_text FROM ' . $xoopsDB->prefix('mymodule3_testfields') . ' WHERE tf_id = '. $item_id;
54
			$result       = $xoopsDB->query($sql);
55
			$result_array = $xoopsDB->fetchArray($result);
56
			$item['name'] = $result_array['tf_text'];
57
			$item['url']  = MYMODULE3_URL . '/testfields.php?tf_id=' . $item_id;
58
			return $item;
59
		break;
60
	}
61
	return null;
62
}
63