waiting.plugin.php ➔ b_waiting_APCal_base()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 1
dl 0
loc 20
rs 9.6
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
/**
13
 * @copyright   {@link http://xoops.org/ XOOPS Project}
14
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team,
18
 * @author       GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/)
19
 */
20
21
defined('XOOPS_ROOT_PATH') || exit('XOOPS Root Path not defined');
22
23
$moduleDirName = basename(dirname(__DIR__));
24
25
eval('
26
27
function b_waiting_' . $moduleDirName . '(){
28
    return b_waiting_APCal_base( "' . $moduleDirName . '" ) ;
29
}
30
31
');
32
33
if (!function_exists('b_waiting_APCal_base')) {
34
    /**
35
     * @param $moduleDirName
36
     * @return array
37
     */
38
    function b_waiting_APCal_base($moduleDirName)
39
    {
40
        $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
Unused Code introduced by
$xoopsDB is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
41
        $block   = array();
42
43
        // get $mydirnumber
44
        if (!preg_match('/^(\D+)(\d*)$/', $moduleDirName, $regs)) {
45
            echo('invalid dirname: ' . htmlspecialchars($moduleDirName));
46
        }
47
        $mydirnumber = $regs[2] === '' ? '' : (int)$regs[2];
48
49
        $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix("apcal{$mydirnumber}_event") . ' WHERE admission<1 AND (rrule_pid=0 OR rrule_pid=id)');
50
        if ($result) {
51
            $block['adminlink'] = XOOPS_URL . "/modules/$moduleDirName/admin/admission.php";
52
            list($block['pendingnum']) = $GLOBALS['xoopsDB']->fetchRow($result);
53
            $block['lang_linkname'] = _PI_WAITING_EVENTS;
54
        }
55
56
        return $block;
57
    }
58
}
59