Passed
Pull Request — master (#21)
by Michael
02:48
created

whoswho.php (1 issue)

Labels
Severity
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
 * @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
 * @package
16
 * @since
17
 * @author         XOOPS Development Team
18
 */
19
20
/*
21
 * Created on 28 oct. 2006
22
 *
23
 * This page will display a list of the authors of the site
24
 *
25
 * @package News
26
 * @author Hervé Thouzard
27
 * @copyright (c) Hervé Thouzard (http://www.herve-thouzard.com)
28
 */
29
30
use XoopsModules\News;
31
use XoopsModules\News\NewsStory;
32
33
require_once dirname(__DIR__, 2) . '/mainfile.php';
34
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
35
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php';
36
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php';
37
38
if (!News\Utility::getModuleOption('newsbythisauthor')) {
39
    redirect_header('index.php', 2, _ERRORS);
40
}
41
42
$GLOBALS['xoopsOption']['template_main'] = 'news_whos_who.tpl';
43
require_once XOOPS_ROOT_PATH . '/header.php';
44
45
$option  = News\Utility::getModuleOption('displayname');
46
$article = new NewsStory();
47
$uid_ids = [];
48
$uid_ids = $article->getWhosWho(News\Utility::getModuleOption('restrictindex'));
49
if (count($uid_ids) > 0) {
50
    $lst_uid = implode(',', $uid_ids);
0 ignored issues
show
It seems like $uid_ids can also be of type null; however, parameter $pieces of implode() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

50
    $lst_uid = implode(',', /** @scrutinizer ignore-type */ $uid_ids);
Loading history...
51
    /** @var \XoopsMemberHandler $memberHandler */
52
    $memberHandler = xoops_getHandler('member');
53
    $critere       = new \Criteria('uid', '(' . $lst_uid . ')', 'IN');
54
    $tbl_users     = $memberHandler->getUsers($critere);
55
    foreach ($tbl_users as $one_user) {
56
        $uname = '';
57
        switch ($option) {
58
            case 1: // Username
59
                $uname = $one_user->getVar('uname');
60
                break;
61
            case 2: // Display full name (if it is not empty)
62
                if ('' !== xoops_trim($one_user->getVar('name'))) {
63
                    $uname = $one_user->getVar('name');
64
                } else {
65
                    $uname = $one_user->getVar('uname');
66
                }
67
                break;
68
        }
69
        $xoopsTpl->append(
70
            'whoswho',
71
            [
72
                'uid'            => $one_user->getVar('uid'),
73
                'name'           => $uname,
74
                'user_avatarurl' => XOOPS_URL . '/uploads/' . $one_user->getVar('user_avatar'),
75
            ]
76
        );
77
    }
78
}
79
80
$xoopsTpl->assign('advertisement', News\Utility::getModuleOption('advertisement'));
81
82
/**
83
 * Manage all the meta datas
84
 */
85
News\Utility::createMetaDatas($article);
86
87
$xoopsTpl->assign('xoops_pagetitle', _AM_NEWS_WHOS_WHO);
88
$myts             = \MyTextSanitizer::getInstance();
89
$meta_description = _AM_NEWS_WHOS_WHO . ' - ' . $xoopsModule->name('s');
90
if (isset($xoTheme) && is_object($xoTheme)) {
91
    $xoTheme->addMeta('meta', 'description', $meta_description);
92
} else { // Compatibility for old Xoops versions
93
    $xoopsTpl->assign('xoops_meta_description', $meta_description);
94
}
95
96
require_once XOOPS_ROOT_PATH . '/footer.php';
97