Wfsection   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
c 0
b 0
f 0
dl 0
loc 59
rs 10
wmc 9

2 Methods

Rating   Name   Duplication   Size   Complexity  
A grabEntries() 0 33 5
A loadModule() 0 12 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Rssfit\Plugins;
6
7
/*
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
17
/**
18
 * @copyright    XOOPS Project (https://xoops.org)
19
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @package      RSSFit - Extendable XML news feed generator
21
 * @author       NS Tai (aka tuff) <http://www.brandycoke.com>
22
 * @author       XOOPS Development Team
23
 */
24
25
/*
26
* About this RSSFit plug-in
27
* Author: tuff <http://www.brandycoke.com>
28
* Requirements (Tested with):
29
*  Module: WF-section <http://www.wf-projects.com>
30
*  Version: 1.x
31
*  RSSFit verision: 1.2
32
*  XOOPS version: 2.0.13.2
33
*/
34
35
if (!\defined('RSSFIT_ROOT_PATH')) {
36
    exit();
37
}
38
39
/**
40
 * Class Wfsection
41
 * @package XoopsModules\Rssfit\Plugins
42
 */
43
class Wfsection
44
{
45
    public $dirname = 'wfsection';
46
    public $modname;
47
    public $grab;
48
49
    /**
50
     * @return \XoopsModule
51
     */
52
    public function loadModule():?\XoopsModule
53
    {
54
        $mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
55
        if (!$mod || !$mod->getVar('isactive')) {
56
            return null;
57
        }
58
        $this->modname = $mod->getVar('name');
59
        if ($mod->getVar('version') >= 200) {
60
            return null;
61
        }
62
63
        return $mod;
64
    }
65
66
    /**
67
     * @return array
68
     */
69
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB):?array
70
    {
71
        @require_once XOOPS_ROOT_PATH . '/modules/wfsection/include/groupaccess.php';
72
        $ret = null;
73
        $i = 0;
74
        $sql = 'SELECT a.articleid, a.title as atitle, a.published, a.expired, a.counter, a.groupid, a.maintext, a.summary, b.title as btitle FROM '
75
               . $xoopsDB->prefix('wfs_article')
76
               . ' a, '
77
               . $xoopsDB->prefix('wfs_category')
78
               . ' b WHERE a.published < '
79
               . \time()
80
               . ' AND a.published > 0 AND (a.expired = 0 OR a.expired > '
81
               . \time()
82
               . ') AND a.noshowart = 0 AND a.offline = 0 AND a.categoryid = b.id ORDER BY published DESC';
83
84
        $result = $xoopsDB->query($sql, $this->grab, 0);
85
        if ($result instanceof \mysqli_result) {
86
            $ret = [];
87
            while (false !== ($row = $xoopsDB->fetchArray($result))) {
88
                if (checkAccess($row['groupid'])) {
0 ignored issues
show
Bug introduced by
The function checkAccess was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

88
                if (/** @scrutinizer ignore-call */ checkAccess($row['groupid'])) {
Loading history...
89
                    $link                   = XOOPS_URL . '/modules/' . $this->dirname . '/article.php?articleid=' . $row['articleid'];
90
                    $ret[$i]['title']       = $row['atitle'];
91
                    $ret[$i]['link']        = $link;
92
                    $ret[$i]['guid']        = $link;
93
                    $ret[$i]['timestamp']   = $row['published'];
94
                    $ret[$i]['description'] = $myts->displayTarea(!empty($row['summary']) ? $row['summary'] : $row['maintext']);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $myts seems to be never defined.
Loading history...
95
                    $ret[$i]['category']    = $this->modname;
96
                    $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
97
                    $i++;
98
                }
99
            }
100
        }
101
        return $ret;
102
    }
103
}
104