Completed
Push — master ( 48ecb4...5fe85d )
by Michael
01:45
created

functions.php ➔ instr_getWysiwygForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nc 1
nop 3
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
// Права
3 View Code Duplication
function instr_MygetItemIds($permtype = 'instruction_view')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
4
{
5
	//global $xoopsUser;
6
	static $permissions = [];
7
	// Если есть в статике
8
	if(is_array($permissions) && array_key_exists($permtype, $permissions)) {
9
		return $permissions[$permtype];
10
	}
11
	// Находим из базы
12
	$module_handler         = xoops_gethandler('module');
13
	$instrModule            = $module_handler->getByDirname('instruction');
14
	$groups                 = is_object( $GLOBALS['xoopsUser'] ) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
15
	$gperm_handler          = xoops_gethandler('groupperm');
16
	$categories             = $gperm_handler->getItemIds($permtype, $groups, $instrModule->getVar('mid'));
17
	$permissions[$permtype] = $categories;
18
	return $categories;
19
}
20
21
// Редактор
22 View Code Duplication
function &instr_getWysiwygForm($caption, $name, $value = '')
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
{
24
	$editor = false;
0 ignored issues
show
Unused Code introduced by
$editor 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...
25
	$editor_configs = [];
26
	$editor_configs['name']   = $name;
27
	$editor_configs['value']  = $value;
28
	$editor_configs['rows']   = 35;
29
	$editor_configs['cols']   = 60;
30
	$editor_configs['width']  = '100%';
31
	$editor_configs['height'] = '350px';
32
	$editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction'));
33
34
	$editor = new XoopsFormEditor($caption, $name, $editor_configs);
35
	return $editor;
36
}
37
38
// Получение значения переменной, переданной через GET или POST запрос
39
function instr_CleanVars(&$global, $key, $default = '', $type = 'int') {
40
    switch ($type) {
41
        case 'string':
42
            $ret = (isset($global[$key])) ? $global[$key] : $default;
43
            break;
44
        case 'int':
45
        default:
46
            $ret = (isset($global[$key])) ? intval($global[$key]) : intval($default);
47
            break;
48
    }
49
    if ($ret === false) {
50
        return $default;
51
    }
52
    return $ret;
53
}
54