show_memberswelcome_block()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
cc 4
eloc 15
c 3
b 1
f 0
nc 3
nop 1
dl 0
loc 21
rs 9.7666
1
<?php declare(strict_types=1);
2
// Author: Lio MJ
3
// Website: https://www.github.com/liomj/
4
5
if (!defined('XOOPS_ROOT_PATH')) {
6
    exit;
7
}
8
9
/**
10
 * @param $options
11
 * @return mixed
12
 */
13
function show_memberswelcome_block($options)
14
{
15
    global $xoopsConfig, $xoopsUser, $xoopsModule, $xoopsDB, $_SERVER;
16
    if (is_object($xoopsUser)) {
17
        $block        = [];
18
        $block['uid'] = $xoopsUser->getVar('uid');
19
        $realname     = $xoopsUser->getVar('name');
20
21
        if ('1' == $options[1] && '' != $realname) {
22
            $block['membername'] = $xoopsUser->getVar('name');
23
        } else {
24
            $block['membername'] = $xoopsUser->getVar('uname');
25
        }
26
        $block['user_avatar'] = $xoopsUser->getVar('user_avatar');
27
28
        $ranking            = $xoopsUser->rank();
29
        $block['rankimage'] = $ranking['image'];
30
        $block['ranktitle'] = $ranking['title'];
31
        $block['showrank']  = $options[0];
32
33
        return $block;
34
    }
35
}
36
37
/**
38
 * @param $options
39
 * @return string
40
 */
41
function memberswelcome_edit($options)
42
{
43
    $form = _MB_XOOPSMEMBERS_SHOWMEMBERSRANK . '&nbsp;';
44
    if (1 == $options[0]) {
45
        $chk = ' checked';
46
    }
47
    $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $chk does not seem to be defined for all execution paths leading up to this point.
Loading history...
48
    $chk  = '';
49
    if (0 == $options[0]) {
50
        $chk = ' checked';
51
    }
52
    $form .= "&nbsp;<input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>';
53
54
    $form .= _MB_XOOPSMEMBERS_USEREALNAME . '&nbsp;';
55
    if (1 == $options[1]) {
56
        $chk = ' checked';
57
    }
58
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
59
    $chk  = '';
60
    if (0 == $options[1]) {
61
        $chk = ' checked';
62
    }
63
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>';
64
65
    return $form;
66
}
67