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
|
|
|
|
22
|
|
|
use Xmf\Request; |
23
|
|
|
use XoopsModules\Smallworld\Constants; |
24
|
|
|
|
25
|
|
|
include __DIR__ . '/admin_header.php'; |
26
|
|
|
/** |
27
|
|
|
* Vars defined by inclusion of ./admin_header.php |
28
|
|
|
* |
29
|
|
|
* @var \XoopsModules\Smallworld\Admin $admin |
30
|
|
|
* @var \XoopsModules\Smallworld\DoSync $d |
31
|
|
|
* @var \XoopsModules\Smallworld\User $check |
32
|
|
|
* @var \XoopsModules\Smallworld\SwDatabase $swDB |
33
|
|
|
* @var \XoopsModules\Smallworld\WallUpdates $wall |
34
|
|
|
* @var \Xmf\Module\Admin $adminObject |
35
|
|
|
* @var \XoopsModules\Smallworld\Helper $helper |
36
|
|
|
* @var string $moduleDirName |
37
|
|
|
* @var string $moduleDirNameUpper |
38
|
|
|
*/ |
39
|
|
|
|
40
|
|
|
$helper->loadLanguage('feedback'); |
41
|
|
|
|
42
|
|
|
$feedback = new \XoopsModules\Smallworld\Common\ModuleFeedback(); |
43
|
|
|
$op = Request::getCmd('op', 'list'); |
44
|
|
|
|
45
|
|
|
xoops_cp_header(); |
46
|
|
|
|
47
|
|
|
switch ($op) { |
48
|
|
|
case 'list': |
49
|
|
|
default: |
50
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); |
51
|
|
|
$feedback->name = $GLOBALS['xoopsUser']->getVar('name'); |
52
|
|
|
$feedback->email = $GLOBALS['xoopsUser']->getVar('email'); |
53
|
|
|
$feedback->site = XOOPS_URL; |
54
|
|
|
$form = $feedback->getFormFeedback(); |
55
|
|
|
$form->display(); |
56
|
|
|
break; |
57
|
|
|
case 'send': |
58
|
|
|
// Security Check |
59
|
|
View Code Duplication |
if (!$GLOBALS['xoopsSecurity']->check()) { |
|
|
|
|
60
|
|
|
$helper->redirect('admin/index.php', Constants::REDIRECT_DELAY_MEDIUM, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('feedback.php')); |
64
|
|
|
|
65
|
|
|
$your_name = Request::getString('your_name', ''); |
66
|
|
|
$your_site = Request::getString('your_site', ''); |
67
|
|
|
$your_mail = Request::getString('your_mail', ''); |
68
|
|
|
$fb_type = Request::getString('fb_type', ''); |
69
|
|
|
$fb_content = Request::getText('fb_content', ''); |
70
|
|
|
$fb_content = str_replace(["\r\n", "\n", "\r"], '<br>', $fb_content); //clean line break from dhtmltextarea |
71
|
|
|
|
72
|
|
|
$title = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_FOR') . $GLOBALS['xoopsModule']->getVar('dirname'); |
73
|
|
|
$body = constant('CO_' . $moduleDirNameUpper . '_' . 'FB_NAME') . ': ' . $your_name . '<br>'; |
74
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_MAIL') . ': ' . $your_mail . '<br>'; |
75
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SITE') . ': ' . $your_site . '<br>'; |
76
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE') . ': ' . $fb_type . '<br><br>'; |
77
|
|
|
$body .= constant('CO_' . $moduleDirNameUpper . '_' . 'FB_TYPE_CONTENT') . ':<br>'; |
78
|
|
|
$body .= $fb_content; |
79
|
|
|
$xoopsMailer = xoops_getMailer(); |
80
|
|
|
$xoopsMailer->useMail(); |
81
|
|
|
$xoopsMailer->setToEmails($GLOBALS['xoopsModule']->getInfo('author_mail')); |
82
|
|
|
$xoopsMailer->setFromEmail($your_mail); |
83
|
|
|
$xoopsMailer->setFromName($your_name); |
84
|
|
|
$xoopsMailer->setSubject($title); |
85
|
|
|
$xoopsMailer->multimailer->isHTML(true); |
86
|
|
|
$xoopsMailer->setBody($body); |
87
|
|
|
$ret = $xoopsMailer->send(); |
88
|
|
|
if ($ret) { |
89
|
|
|
redirect_header('index.php', Constants::REDIRECT_DELAY_MEDIUM, constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_SUCCESS')); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
// show form with content again |
93
|
|
|
$feedback->name = $your_name; |
94
|
|
|
$feedback->email = $your_mail; |
95
|
|
|
$feedback->site = $your_site; |
96
|
|
|
$feedback->type = $fb_type; |
97
|
|
|
$feedback->content = $fb_content; |
98
|
|
|
echo '<div align="center" style="width: 80%; padding: 10px; border: 2px solid #ff0000; color: #ff0000; margin-right:auto;margin-left:auto;"> |
99
|
|
|
<h3>' . constant('CO_' . $moduleDirNameUpper . '_' . 'FB_SEND_ERROR') . '</h3> |
100
|
|
|
</div>'; |
101
|
|
|
$form = $feedback->getFormFeedback(); |
102
|
|
|
$form->display(); |
103
|
|
|
break; |
104
|
|
|
} |
105
|
|
|
require __DIR__ . '/admin_footer.php'; |
106
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.