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
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
39
/**
40
 * @param $options
41
 * @return string
42
 */
43
function memberswelcome_edit($options)
44
{
45
    $form = _MB_XOOPSMEMBERS_SHOWMEMBERSRANK . '&nbsp;';
46
    if (1 == $options[0]) {
47
        $chk = " checked";
48
    }
49
    $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...
50
    $chk  = '';
51
    if (0 == $options[0]) {
52
        $chk = " checked";
53
    }
54
    $form .= "&nbsp;<input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>';
55
56
    $form .= _MB_XOOPSMEMBERS_USEREALNAME . '&nbsp;';
57
    if (1 == $options[1]) {
58
        $chk = " checked";
59
    }
60
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
61
    $chk  = '';
62
    if (0 == $options[1]) {
63
        $chk = " checked";
64
    }
65
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>';
66
67
    return $form;
68
}
69
70