Passed
Push — master ( 059d9f...ba4972 )
by Michael
33s queued 12s
created

memberswelcome_edit()   A

Complexity

Conditions 5
Paths 16

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 17
c 1
b 0
f 0
nc 16
nop 1
dl 0
loc 25
rs 9.3888
1
<?php
2
// Author: Lio MJ
3
// Website: https://www.github.com/liomj/
4
5
if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;
6
   
7
    function show_memberswelcome_block($options) {
8
	    global $xoopsConfig, $xoopsUser, $xoopsModule, $xoopsDB, $_SERVER;
9
10
		if (is_object($xoopsUser)) {
11
        $block['uid']=$xoopsUser->getVar('uid');
0 ignored issues
show
Comprehensibility Best Practice introduced by
$block was never initialized. Although not strictly required by PHP, it is generally a good practice to add $block = array(); before regardless.
Loading history...
12
		$realname=$xoopsUser->getVar('name');
13
		
14
		if ($options[1]=='1' && $realname!='')
15
		{
16
        $block['membername']=$xoopsUser->getVar('name');
17
        }
18
		else
19
		{	
20
		$block['membername']=$xoopsUser->getVar('uname');
21
		}
22
		$block['user_avatar']=$xoopsUser->getVar('user_avatar');
23
24
		$ranking=$xoopsUser->rank();        
25
		$block['rankimage']=$ranking['image'];
26
		$block['ranktitle']=$ranking['title'];
27
		$block['showrank'] = $options[0];
28
		}
29
	 
30
    return $block; 
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $block does not seem to be defined for all execution paths leading up to this point.
Loading history...
31
}
32
33
34
function memberswelcome_edit($options) {
35
	
36
$form = _MB_XOOPSMEMBERS_SHOWMEMBERSRANK."&nbsp;";
37
	if ( $options[0] == 1 ) {
38
		$chk = " checked='checked'";
39
	}
40
	$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...
41
	$chk = "";
42
	if ( $options[0] == 0 ) {
43
		$chk = " checked='checked'";
44
	}
45
	$form .= "&nbsp;<input type='radio' name='options[0]' value='0'".$chk." />"._NO."<br />";
46
47
	$form .= _MB_XOOPSMEMBERS_USEREALNAME."&nbsp;";
48
	if ( $options[1] == 1 ) {
49
		$chk = " checked='checked'";
50
	}
51
	$form .= "<input type='radio' name='options[1]' value='1'".$chk." />&nbsp;"._YES."";
52
	$chk = "";
53
	if ( $options[1] == 0 ) {
54
		$chk = " checked='checked'";
55
	}
56
	$form .= "&nbsp;<input type='radio' name='options[1]' value='0'".$chk." />"._NO."<br />";
57
58
	return $form;
59
}
60
61
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
62