Code Duplication    Length = 31-31 lines in 2 locations

class/utility.php 1 location

@@ 164-194 (lines=31) @@
161
     * @param  string     $repmodule
162
     * @return bool|mixed
163
     */
164
    public static function getModuleOption($option, $repmodule = 'news')
165
    {
166
        global $xoopsModuleConfig, $xoopsModule;
167
        static $tbloptions = [];
168
        if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) {
169
            return $tbloptions[$option];
170
        }
171
172
        $retval = false;
173
        if (isset($xoopsModuleConfig)
174
            && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule
175
                && $xoopsModule->getVar('isactive'))) {
176
            if (isset($xoopsModuleConfig[$option])) {
177
                $retval = $xoopsModuleConfig[$option];
178
            }
179
        } else {
180
            /** @var XoopsModuleHandler $moduleHandler */
181
            $moduleHandler = xoops_getHandler('module');
182
            $module        = $moduleHandler->getByDirname($repmodule);
183
            $configHandler = xoops_getHandler('config');
184
            if ($module) {
185
                $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
186
                if (isset($moduleConfig[$option])) {
187
                    $retval = $moduleConfig[$option];
188
                }
189
            }
190
        }
191
        $tbloptions[$option] = $retval;
192
193
        return $retval;
194
    }
195
196
    /**
197
     * Updates rating data in item table for a given item

include/functions.php 1 location

@@ 42-72 (lines=31) @@
39
 * @param  string     $repmodule
40
 * @return bool|mixed
41
 */
42
function news_getmoduleoption($option, $repmodule = 'news')
43
{
44
    global $xoopsModuleConfig, $xoopsModule;
45
    static $tbloptions = [];
46
    if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) {
47
        return $tbloptions[$option];
48
    }
49
50
    $retval = false;
51
    if (isset($xoopsModuleConfig)
52
        && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule
53
            && $xoopsModule->getVar('isactive'))) {
54
        if (isset($xoopsModuleConfig[$option])) {
55
            $retval = $xoopsModuleConfig[$option];
56
        }
57
    } else {
58
        /** @var XoopsModuleHandler $moduleHandler */
59
        $moduleHandler = xoops_getHandler('module');
60
        $module        = $moduleHandler->getByDirname($repmodule);
61
        $configHandler = xoops_getHandler('config');
62
        if ($module) {
63
            $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
64
            if (isset($moduleConfig[$option])) {
65
                $retval = $moduleConfig[$option];
66
            }
67
        }
68
    }
69
    $tbloptions[$option] = $retval;
70
71
    return $retval;
72
}
73
74
/**
75
 * Updates rating data in item table for a given item