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 | * - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
||
5 | * **************************************************************************** |
||
6 | * XNEWSLETTER - MODULE FOR XOOPS |
||
7 | * Copyright (c) 2007 - 2012 |
||
8 | * Goffy ( wedega.com ) |
||
9 | * |
||
10 | * You may not change or alter any portion of this comment or credits |
||
11 | * of supporting developers from this source code or any supporting |
||
12 | * source code which is considered copyrighted (c) material of the |
||
13 | * original comment or credit authors. |
||
14 | * |
||
15 | * This program is distributed in the hope that it will be useful, |
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | * GNU General Public License for more details. |
||
19 | * --------------------------------------------------------------------------- |
||
20 | * @copyright Goffy ( wedega.com ) |
||
21 | * @license GPL 2.0 |
||
22 | * @package xnewsletter |
||
23 | * @author Goffy ( [email protected] ) |
||
24 | * |
||
25 | * **************************************************************************** |
||
26 | */ |
||
27 | |||
28 | $currentFile = basename(__FILE__); |
||
29 | include_once __DIR__ . '/header.php'; |
||
30 | |||
31 | $xoopsOption['template_main'] = 'xnewsletter_letter.tpl'; |
||
32 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
33 | |||
34 | $xoTheme->addStylesheet(XNEWSLETTER_URL . '/assets/css/module.css'); |
||
35 | $xoTheme->addMeta('meta', 'keywords', $xnewsletter->getConfig('keywords')); // keywords only for index page |
||
36 | $xoTheme->addMeta('meta', 'description', strip_tags(_MA_XNEWSLETTER_DESC)); // description |
||
37 | |||
38 | // Breadcrumb |
||
39 | $breadcrumb = new XnewsletterBreadcrumb(); |
||
40 | $breadcrumb->addLink($xnewsletter->getModule()->getVar('name'), XNEWSLETTER_URL); |
||
41 | $xoopsTpl->assign('xnewsletter_breadcrumb', $breadcrumb->render()); |
||
42 | |||
43 | include XOOPS_ROOT_PATH . '/modules/xnewsletter/include/task.inc.php'; |
||
44 | |||
45 | View Code Duplication | if (!$xoopsUser) { |
|
0 ignored issues
–
show
|
|||
46 | //Guest no Access !!! |
||
47 | redirect_header(XOOPS_URL . '/modules/' . $xnewsletter->getModule()->dirname() . '/index.php', 3, _NOPERM); |
||
48 | } |
||
49 | |||
50 | $op = XoopsRequest::getString('op', 'list'); |
||
51 | $letter_id = XoopsRequest::getInt('letter_id', 0); |
||
52 | |||
53 | if ($letter_id < 1) { |
||
54 | redirect_header('letter.php', 3, _AM_XNEWSLETTER_SEND_ERROR_NO_LETTERID); |
||
55 | } |
||
56 | |||
57 | $sendletter_perm = xnewsletter_getUserPermissionsByLetter($letter_id); |
||
58 | |||
59 | View Code Duplication | if (!$sendletter_perm['send']) { |
|
60 | redirect_header(XOOPS_URL . '/modules/' . $xnewsletter->getModule()->dirname() . '/index.php', 3, _NOPERM); |
||
61 | } |
||
62 | |||
63 | $start_sending = false; |
||
64 | $protocolCriteria = new CriteriaCompo(); |
||
65 | $protocolCriteria->add(new Criteria('protocol_letter_id', $letter_id)); |
||
66 | $protocolCriteria->add(new Criteria('protocol_subscriber_id', 0, '>')); |
||
67 | $protocolCriteria->setLimit(1); |
||
68 | $protocolCount = $xnewsletter->getHandler('protocol')->getCount($protocolCriteria); |
||
69 | if ($protocolCount > 0) { |
||
70 | if (isset($_REQUEST['ok']) && $_REQUEST['ok'] == true) { |
||
71 | $start_sending = true; |
||
72 | } else { |
||
73 | xoops_confirm(['ok' => true, 'op' => $op, 'letter_id' => $letter_id], $_SERVER['REQUEST_URI'], _AM_XNEWSLETTER_SEND_SURE_SENT ); |
||
74 | } |
||
75 | } else { |
||
76 | $start_sending = true; |
||
77 | } |
||
78 | |||
79 | if ($start_sending == true) { |
||
0 ignored issues
–
show
|
|||
80 | $xn_send_in_packages = $xnewsletter->getConfig('xn_send_in_packages'); |
||
81 | if ($xn_send_in_packages > 0) { |
||
82 | $xn_send_in_packages_time = $xnewsletter->getConfig('xn_send_in_packages_time'); |
||
83 | } else { |
||
84 | $xn_send_in_packages_time = 0; |
||
85 | } |
||
86 | $result_create = xnewsletter_createTasks($op, $letter_id, $xn_send_in_packages, $xn_send_in_packages_time); |
||
87 | $result_exec = xnewsletter_executeTasks($xn_send_in_packages, $letter_id); |
||
88 | redirect_header('letter.php', 3, $result_exec); |
||
89 | } |
||
90 | |||
91 | include __DIR__ . '/footer.php'; |
||
92 |
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.