Passed
Push — master ( 41940e...005d4f )
by Michael
36s queued 18s
created

admin/feedback.php (3 issues)

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
 * Feedback plugin for xoops modules
14
 *
15
 * @copyright      XOOPS Project  (https://xoops.org)
16
 * @license        GNU GPL 2 or later (http://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
use Xmf\Request;
22
use XoopsModules\Pedigree;
23
24
require __DIR__ . '/admin_header.php';
25
26
/** @var \Xmf\Module\Admin $adminObject */
27
28
$feedback = XoopsModules\Pedigree\Common\ModuleFeedback::getInstance();
0 ignored issues
show
Are you sure the assignment to $feedback is correct as XoopsModules\Pedigree\Co...Feedback::getInstance() targeting XoopsModules\Pedigree\Co...Feedback::getInstance() 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...
29
30
// It recovered the value of argument op in URL$
31
$op = Request::getCmd('op', 'list');
32
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
33
$helper->loadLanguage('common');
34
35
xoops_cp_header();
36
37
switch ($op) {
38
    case 'list':
39
    default:
40
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php'));
0 ignored issues
show
Are you sure the usage of $adminObject->displayNavigation('feedback.php') targeting Xmf\Module\Admin::displayNavigation() 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...
41
        $feedback->name = $GLOBALS['xoopsUser']->getVar('name');
42
        $feedback->email = $GLOBALS['xoopsUser']->getVar('email');
43
        $feedback->site = XOOPS_URL;
44
        $form = $feedback->getFormFeedback();
45
        echo $form->display();
46
        break;
47
    case 'send':
48
        // Security Check
49
        if (!$GLOBALS['xoopsSecurity']->check()) {
50
            redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
51
        }
52
53
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php'));
0 ignored issues
show
Are you sure the usage of $adminObject->displayNavigation('feedback.php') targeting Xmf\Module\Admin::displayNavigation() 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...
54
55
        $your_name = Request::getString('your_name', '');
56
        $your_site = Request::getString('your_site', '');
57
        $your_mail = Request::getString('your_mail', '');
58
        $fb_type = Request::getString('fb_type', '');
59
        $fb_content = Request::getText('fb_content', '');
60
        $fb_content = str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea
61
62
        $title = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname');
63
        $body = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '<br>';
64
        $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '<br>';
65
        $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '<br>';
66
        $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '<br><br>';
67
        $body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':<br>';
68
        $body .= $fb_content;
69
        $xoopsMailer = xoops_getMailer();
70
        $xoopsMailer->useMail();
71
        $xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail'));
72
        $xoopsMailer->setFromEmail($your_mail);
73
        $xoopsMailer->setFromName($your_name);
74
        $xoopsMailer->setSubject($title);
75
        $xoopsMailer->multimailer->isHTML(true);
76
        $xoopsMailer->setBody($body);
77
        $ret = $xoopsMailer->send();
78
        if ($ret) {
79
            redirect_header('index.php', 3, constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS'));
80
        }
81
82
        // show form with content again
83
        $feedback->name = $your_name;
84
        $feedback->email = $your_mail;
85
        $feedback->site = $your_site;
86
        $feedback->type = $fb_type;
87
        $feedback->content = $fb_content;
88
        echo '<div style="text-align: center; width: 80%; padding: 10px; border: 2px solid #ff0000; color: #ff0000; margin-right:auto;margin-left:auto;">
89
            <h3>' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '</h3>
90
            </div>';
91
        $form = $feedback->getFormFeedback();
92
        echo $form->display();
93
94
        break;
95
}
96
require __DIR__ . '/admin_footer.php';
97