Passed
Branch master (a5e4e1)
by Michael
12:01
created

admin/feedback.php (2 issues)

Labels
Severity
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
 * Feedback plugin for xoops modules
14
 *
15
 * @copyright      XOOPS Project  (https://xoops.org)
16
 * @license        GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @author         Michael Beck <[email protected]>
18
 * @author         Wedega - Email:<[email protected]>
19
 * @author         Fernando Santos (topet05) <[email protected]>
20
 */
21
22
use Xmf\Module\Admin;
23
use Xmf\Request;
24
use XoopsModules\Publisher\Common\ModuleFeedback;
25
26
require_once __DIR__ . '/admin_header.php';
27
28
$adminObject = Admin::getInstance();
29
30
$feedback = new ModuleFeedback();
31
32
// It recovered the value of argument op in URL$
33
$op                 = Request::getString('op', 'list');
34
$moduleDirName      = $GLOBALS['xoopsModule']->getVar('dirname');
35
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
36
xoops_loadLanguage('feedback', $moduleDirName);
37
38
xoops_cp_header();
39
40
switch ($op) {
41
    case 'list':
42
    default:
43
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php'));
44
        $feedback->name  = $GLOBALS['xoopsUser']->getVar('name');
45
        $feedback->email = $GLOBALS['xoopsUser']->getVar('email');
46
        $feedback->site  = XOOPS_URL;
47
        $form            = $feedback->getFormFeedback();
48
        echo $form->display();
0 ignored issues
show
Are you sure the usage of $form->display() targeting XoopsForm::display() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

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

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

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

Loading history...
49
        break;
50
    case 'send':
51
        // Security Check
52
        if (!$GLOBALS['xoopsSecurity']->check()) {
53
            redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
54
        }
55
56
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php'));
57
58
        $your_name  = Request::getString('your_name', '');
59
        $your_site  = Request::getString('your_site', '');
60
        $yourMail   = Request::getString('your_mail', '');
61
        $fb_type    = Request::getString('fb_type', '');
62
        $fb_content = Request::getText('fb_content', '');
63
        $fb_content = str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea
64
65
        $title       = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname');
66
        $body        = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '<br>';
67
        $body        .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $yourMail . '<br>';
68
        $body        .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '<br>';
69
        $body        .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '<br><br>';
70
        $body        .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':<br>';
71
        $body        .= $fb_content;
72
        $xoopsMailer = xoops_getMailer();
73
        $xoopsMailer->useMail();
74
        $xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail'));
75
        $xoopsMailer->setFromEmail($yourMail);
76
        $xoopsMailer->setFromName($your_name);
77
        $xoopsMailer->setSubject($title);
78
        $xoopsMailer->multimailer->isHTML(true);
79
        $xoopsMailer->setBody($body);
80
        $ret = $xoopsMailer->send();
81
        if ($ret) {
82
            redirect_header('index.php', 3, constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS'));
83
        }
84
85
        // show form with content again
86
        $feedback->name    = $your_name;
87
        $feedback->email   = $yourMail;
88
        $feedback->site    = $your_site;
89
        $feedback->type    = $fb_type;
90
        $feedback->content = $fb_content;
91
        echo '<div align="center" style="width: 80%; padding: 10px; border: 2px solid #ff0000; color: #ff0000; margin-right:auto;margin-left:auto;">
92
            <h3>' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '</h3>
93
            </div>';
94
        $form = $feedback->getFormFeedback();
95
        echo $form->display();
0 ignored issues
show
Are you sure the usage of $form->display() targeting XoopsForm::display() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

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

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

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

Loading history...
96
97
        break;
98
}
99
require_once __DIR__ . '/admin_footer.php';
100