b_news_topics_moderate_onthefly()   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
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
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
 * @copyright      {@link https://xoops.org/ XOOPS Project}
14
 * @license        {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @author         XOOPS Development Team
16
 */
17
18
use XoopsModules\News;
19
use XoopsModules\News\Helper;
20
use XoopsModules\News\NewsStory;
21
22
/**
23
 * Display a block where news moderators can show news that needs to be moderated.
24
 */
25
function b_news_topics_moderate()
26
{
27
    // require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
28
29
    /** @var Helper $helper */
30
    if (!class_exists(Helper::class)) {
31
        return false;
32
    }
33
34
    $helper = Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
35
36
    $block      = [];
37
    $dateformat = News\Utility::getModuleOption('dateformat');
38
    $infotips   = News\Utility::getModuleOption('infotips');
39
40
    $storyarray = NewsStory:: getAllSubmitted(0, true, News\Utility::getModuleOption('restrictindex'));
41
    if (count($storyarray) > 0) {
42
        $block['lang_story_title']  = _MB_TITLE;
43
        $block['lang_story_date']   = _MB_POSTED;
44
        $block['lang_story_author'] = _MB_POSTER;
45
        $block['lang_story_action'] = _MB_ACTION;
46
        $block['lang_story_topic']  = _MB_TOPIC;
47
        $myts                       = \MyTextSanitizer::getInstance();
48
        foreach ($storyarray as $newstory) {
49
            $title     = $newstory->title();
50
            $htmltitle = '';
51
            if ($infotips > 0) {
52
                $story['infotips'] = News\Utility::makeInfotips($newstory->hometext());
53
                $htmltitle         = ' title="' . $story['infotips'] . '"';
54
            }
55
56
            if (!isset($title) || ('' == $title)) {
57
                $linktitle = "<a href='" . XOOPS_URL . '/modules/news/index.php?op=edit&amp;storyid=' . $newstory->storyid() . "' target='_blank'" . $htmltitle . '>' . _MD_NEWS_NOSUBJECT . '</a>';
58
            } else {
59
                $linktitle = "<a href='" . XOOPS_URL . '/modules/news/submit.php?op=edit&amp;storyid=' . $newstory->storyid() . "' target='_blank'" . $htmltitle . '>' . $title . '</a>';
60
            }
61
            $story                = [];
62
            $story['title']       = $linktitle;
63
            $story['date']        = formatTimestamp($newstory->created(), $dateformat);
64
            $story['author']      = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $newstory->uid() . "'>" . $newstory->uname() . '</a>';
65
            $story['action']      = "<a href='" . XOOPS_URL . '/modules/news/admin/index.php?op=edit&amp;storyid=' . $newstory->storyid() . "'>" . _EDIT . "</a> - <a href='" . XOOPS_URL . '/modules/news/admin/index.php?op=delete&amp;storyid=' . $newstory->storyid() . "'>" . _MB_DELETE . '</a>';
66
            $story['topic_title'] = $newstory->topic_title();
67
            $story['topic_color'] = '#' . $myts->displayTarea($newstory->topic_color);
68
            $block['picture']     = XOOPS_URL . '/uploads/news/image/' . $newstory->picture();
69
            $block['pictureinfo'] = $newstory->pictureinfo();
70
            $block['stories'][]   = &$story;
71
            unset($story);
72
        }
73
    }
74
75
    return $block;
76
}
77
78
/**
79
 * @param $options
80
 */
81
function b_news_topics_moderate_onthefly($options): void
82
{
83
    $options = explode('|', $options);
84
    $block   = b_news_topics_moderate($options);
0 ignored issues
show
Unused Code introduced by
The call to b_news_topics_moderate() has too many arguments starting with $options. ( Ignorable by Annotation )

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

84
    $block   = /** @scrutinizer ignore-call */ b_news_topics_moderate($options);

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...
85
86
    $tpl = new \XoopsTpl();
87
    $tpl->assign('block', $block);
88
    $tpl->display('db:news_block_moderate.tpl');
89
}
90