Completed
Pull Request — master (#4)
by Michael
03:05
created

blocks/news_moderate.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
// 
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                  Copyright (c) 2000-2016 XOOPS.org                        //
6
//                       <http://xoops.org/>                             //
7
// ------------------------------------------------------------------------- //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
28
29
/**
30
 * Dispay a block where news moderators can show news that need to be moderated.
31
 */
32
function b_news_topics_moderate()
33
{
34
    include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
35
    include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php';
36
    $block      = array();
37
    $dateformat = news_getmoduleoption('dateformat');
38
    $infotips   = news_getmoduleoption('infotips');
39
40
    $storyarray = NewsStory:: getAllSubmitted(0, true, news_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_make_infotips($newstory->hometext());
0 ignored issues
show
Are you sure the assignment to $story['infotips'] is correct as news_make_infotips($newstory->hometext()) (which targets news_make_infotips()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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                = array();
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/' . $story->picture();
69
            $block['pictureinfo'] = $story->pictureinfo();
70
            $block['stories'][]   =& $story;
71
            unset($story);
72
        }
73
    }
74
75
    return $block;
76
}
77
78
/**
79
 * @param $options
80
 */
81 View Code Duplication
function b_news_topics_moderate_onthefly($options)
82
{
83
    $options = explode('|', $options);
84
    $block   = &b_news_topics_moderate($options);
85
86
    $tpl = new XoopsTpl();
87
    $tpl->assign('block', $block);
88
    $tpl->display('db:news_block_moderate.tpl');
89
}
90