XoopsModules25x /
xnewsletter
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 | require_once __DIR__ . '/header.php'; |
||
| 30 | |||
| 31 | // protocol_level |
||
| 32 | // 0 = no protocol items will be created |
||
| 33 | // 1 = protocol will be created when newsletter sent or an error occurs (recommended) |
||
| 34 | // 2 = protocol will be created for all events (only for testing) |
||
| 35 | $protocol_level = 1; |
||
| 36 | |||
| 37 | echo '<br>start cron.php'; |
||
| 38 | |||
| 39 | require_once XOOPS_ROOT_PATH . '/modules/xnewsletter/include/task.inc.php'; |
||
| 40 | // execute all pending tasks |
||
| 41 | $result_exec = xnewsletter_executeTasks($helper->getConfig('xn_send_in_packages'), 0); |
||
| 42 | |||
| 43 | if ($protocol_level > 0) { |
||
| 44 | echo '<br>protocol_level:' . $protocol_level; |
||
| 45 | echo '<br>is_object(helper):'.is_object($helper); |
||
| 46 | echo '<br>xn_send_in_packages:'.$helper->getConfig('xn_send_in_packages'); |
||
| 47 | if ('' === $result_exec) { |
||
| 48 | $status = 'cron no task'; |
||
| 49 | View Code Duplication | if (2 == $protocol_level) { |
|
|
0 ignored issues
–
show
|
|||
| 50 | echo '<br>no letters for sending available'; |
||
| 51 | $protocolObj = $helper->getHandler('Protocol')->create(); |
||
| 52 | echo '<br>is_object(protocolObj):'.is_object($protocolObj); |
||
| 53 | $protocolObj->setVar('protocol_letter_id', 0); |
||
| 54 | $protocolObj->setVar('protocol_subscriber_id', 0); |
||
| 55 | $protocolObj->setVar('protocol_status', 'Cron job: No Task'); |
||
| 56 | $protocolObj->setVar('protocol_status_str_id', $status); |
||
| 57 | $protocolObj->setVar('protocol_status_vars', []); |
||
| 58 | $protocolObj->setVar('protocol_success', true); |
||
| 59 | $protocolObj->setVar('protocol_submitter', 0); |
||
| 60 | $protocolObj->setVar('protocol_created', time()); |
||
| 61 | |||
| 62 | if ($helper->getHandler('Protocol')->insert($protocolObj)) { |
||
| 63 | echo '<br>protocol successfully created'; |
||
| 64 | } else { |
||
| 65 | echo $protocolObj->getHtmlErrors(); |
||
| 66 | echo '<br>errors when creating protocol'; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | View Code Duplication | } else { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
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. Loading history...
|
|||
| 70 | $status = 'cron task available'; |
||
| 71 | echo "<br>result cron: {$result_exec}"; |
||
| 72 | //you can enable the block for creating protocol for cron |
||
| 73 | $protocolObj = $helper->getHandler('Protocol')->create(); |
||
| 74 | echo '<br>is_object(protocolObj):'.is_object($protocolObj); |
||
| 75 | $protocolObj->setVar('protocol_letter_id', 0); |
||
| 76 | $protocolObj->setVar('protocol_subscriber_id', 0); |
||
| 77 | $protocolObj->setVar('protocol_status', 'Cron job: ' . $result_exec); |
||
| 78 | $protocolObj->setVar('protocol_status_str_id', $status); |
||
| 79 | $protocolObj->setVar('protocol_status_vars', []); |
||
| 80 | $protocolObj->setVar('protocol_success', true); |
||
| 81 | $protocolObj->setVar('protocol_submitter', 0); |
||
| 82 | $protocolObj->setVar('protocol_created', time()); |
||
| 83 | |||
| 84 | if ($helper->getHandler('Protocol')->insert($protocolObj)) { |
||
| 85 | echo '<br>protocol about exec task successfully created'; |
||
| 86 | } else { |
||
| 87 | echo $protocolObj->getHtmlErrors(); |
||
| 88 | echo '<br>errors when creating protocol'; |
||
| 89 | } |
||
| 90 | } |
||
| 91 | echo '<br>status: ' . $status; |
||
| 92 | } |
||
| 93 | echo '<br>finished cron.php'; |
||
| 94 |
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.