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
|
|
|
* Version : 1 Wed 2012/11/28 22:18:22 : Exp $ |
26
|
|
|
* **************************************************************************** |
27
|
|
|
*/ |
28
|
|
|
|
29
|
|
|
use Xmf\Request; |
30
|
|
|
use XoopsModules\Xnewsletter; |
31
|
|
|
|
32
|
|
|
$currentFile = basename(__FILE__); |
33
|
|
|
require_once __DIR__ . '/header.php'; |
34
|
|
|
|
35
|
|
|
$GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_empty.tpl"; |
36
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
37
|
|
|
|
38
|
|
|
$xoTheme->addStylesheet(XNEWSLETTER_URL . '/assets/css/module.css'); |
39
|
|
|
$xoTheme->addMeta('meta', 'keywords', $helper->getConfig('keywords')); // keywords only for index page |
40
|
|
|
$xoTheme->addMeta('meta', 'description', strip_tags(_MA_XNEWSLETTER_DESC)); // description |
41
|
|
|
// breadcrumb |
42
|
|
|
$breadcrumb = new Xnewsletter\Breadcrumb(); |
43
|
|
|
$breadcrumb->addLink($helper->getModule()->getVar('name'), XNEWSLETTER_URL); |
44
|
|
|
$xoopsTpl->assign('xnewsletter_breadcrumb', $breadcrumb->render()); |
45
|
|
|
|
46
|
|
View Code Duplication |
if (!$xoopsUser) { |
|
|
|
|
47
|
|
|
//Guest no Access !!! |
48
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $helper->getModule()->dirname() . '/index.php', 3, _NOPERM); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$op = Request::getString('op', 'list'); |
52
|
|
|
$letter_id = Request::getInt('letter_id', 0); |
53
|
|
|
|
54
|
|
|
if ($letter_id < 1) { |
55
|
|
|
redirect_header('letter.php', 3, _AM_XNEWSLETTER_SEND_ERROR_NO_LETTERID); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$sendletter_perm = xnewsletter_getUserPermissionsByLetter($letter_id); |
59
|
|
|
|
60
|
|
View Code Duplication |
if (!$sendletter_perm['send']) { |
|
|
|
|
61
|
|
|
redirect_header(XOOPS_URL . '/modules/' . $helper->getModule()->dirname() . '/index.php', 3, _NOPERM); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$start_sending = false; |
65
|
|
|
$protocolCriteria = new \CriteriaCompo(); |
66
|
|
|
$protocolCriteria->add(new \Criteria('protocol_letter_id', $letter_id)); |
67
|
|
|
$protocolCriteria->add(new \Criteria('protocol_subscriber_id', 0, '>')); |
68
|
|
|
$protocolCriteria->setLimit(1); |
69
|
|
|
$protocolCount = $helper->getHandler('Protocol')->getCount($protocolCriteria); |
70
|
|
|
if ('send_test' !== $op && $protocolCount > 0) { |
71
|
|
|
if (true === Request::getBool('ok', false, 'POST')) { |
72
|
|
|
$start_sending = true; |
73
|
|
|
} else { |
74
|
|
|
xoops_confirm(['ok' => true, 'op' => $op, 'letter_id' => $letter_id], $_SERVER['REQUEST_URI'], _AM_XNEWSLETTER_SEND_SURE_SENT); |
75
|
|
|
} |
76
|
|
|
} else { |
77
|
|
|
$start_sending = true; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if (true === $start_sending) { |
81
|
|
|
$xn_send_in_packages = $helper->getConfig('xn_send_in_packages'); |
82
|
|
|
if ($xn_send_in_packages > 0) { |
83
|
|
|
$xn_send_in_packages_time = $helper->getConfig('xn_send_in_packages_time'); |
84
|
|
|
} else { |
85
|
|
|
$xn_send_in_packages_time = 0; |
86
|
|
|
} |
87
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/xnewsletter/include/task.inc.php'; |
88
|
|
|
// create tasks |
89
|
|
|
$result_create = xnewsletter_createTasks($op, $letter_id, $xn_send_in_packages, $xn_send_in_packages_time); |
90
|
|
|
// execute tasks |
91
|
|
|
$result_exec = xnewsletter_executeTasks($xn_send_in_packages, $letter_id); |
92
|
|
|
redirect_header('letter.php', 3, $result_exec); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
require_once __DIR__ . '/footer.php'; |
96
|
|
|
|
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.