oledrion_set_module_option()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 * @param int    $currentoption
19
 * @param string $breadcrumb
20
 */
21
function oledrion_adminMenu($currentoption = 0, $breadcrumb = '')
0 ignored issues
show
Unused Code introduced by
The parameter $breadcrumb is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
function oledrion_adminMenu($currentoption = 0, /** @scrutinizer ignore-unused */ $breadcrumb = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $currentoption is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

21
function oledrion_adminMenu(/** @scrutinizer ignore-unused */ $currentoption = 0, $breadcrumb = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
{
23
}
24
25
/**
26
 * Internal function
27
 */
28
function oledrion_get_mid()
29
{
30
    global $xoopsModule;
31
32
    return $xoopsModule->getVar('mid');
33
}
34
35
/**
36
 * Internal function
37
 */
38
function oledrion_get_configHandler()
39
{
40
    $configHandler = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $configHandler is dead and can be removed.
Loading history...
41
    $configHandler = xoops_getHandler('config');
42
    if (!is_object($configHandler)) {
43
        trigger_error('Error, unable to get and handler on the Config object');
44
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
45
    }
46
47
    return $configHandler;
48
}
49
50
/**
51
 * Returns a module option
52
 *
53
 * @param  string $optionName The module's option
54
 * @return \XoopsConfigOption The requested module's option
55
 */
56
function oledrion_get_module_option($optionName = '')
57
{
58
    $ret           = null;
59
    $tbl_options   = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $tbl_options is dead and can be removed.
Loading history...
60
    $mid           = oledrion_get_mid();
61
    $configHandler = oledrion_get_configHandler();
62
    $critere       = new \CriteriaCompo();
63
    $critere->add(new \Criteria('conf_modid', $mid, '='));
64
    $critere->add(new \Criteria('conf_name', $optionName, '='));
65
    $tbl_options = $configHandler->getConfigs($critere, false, false);
66
    if (count($tbl_options) > 0) {
67
        $option = $tbl_options[0];
68
        $ret    = $option;
69
    }
70
71
    return $ret;
72
}
73
74
/**
75
 * Set a module's option
76
 * @param string $optionName
77
 * @param string $optionValue
78
 * @return bool
79
 */
80
function oledrion_set_module_option($optionName = '', $optionValue = '')
81
{
82
    $configHandler = oledrion_get_configHandler();
83
    $option        = oledrion_get_module_option($optionName, true);
0 ignored issues
show
Unused Code introduced by
The call to oledrion_get_module_option() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

83
    $option        = /** @scrutinizer ignore-call */ oledrion_get_module_option($optionName, true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
84
    $option->setVar('conf_value', $optionValue);
85
    $retval = $configHandler->insertConfig($option, true);
86
87
    return $retval;
88
}
89
90
/**
91
 * Affichage du pied de page de l'administration
92
 *
93
 * @return string La chaine à afficher
94
 */
95
function show_footer()
96
{
97
    //  echo "<br><br><div align='center'><a href='http://www.herve-thouzard.com/' target='_blank'><img src='../assets/images/instantzero.gif'></a></div>";
98
}
99