ggoffy /
wgevents
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | You may not change or alter any portion of this comment or credits |
||
| 7 | of supporting developers from this source code or any supporting source code |
||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * wgEvents module for xoops |
||
| 17 | * |
||
| 18 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 19 | * @license GPL 2.0 or later |
||
| 20 | * @package wgevents |
||
| 21 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 22 | */ |
||
| 23 | |||
| 24 | use XoopsModules\Wgevents; |
||
| 25 | use XoopsModules\Wgevents\{ |
||
| 26 | Constants, |
||
| 27 | TaskHandler |
||
| 28 | }; |
||
| 29 | |||
| 30 | $currentFile = basename(__FILE__); |
||
| 31 | require_once __DIR__ . '/header.php'; |
||
| 32 | |||
| 33 | echo '<br>start cron.php'; |
||
| 34 | |||
| 35 | //require_once __DIR__ . '/class/TaskHandler.php'; |
||
| 36 | // log_level |
||
| 37 | // 0 = no log items will be created |
||
| 38 | // 1 = log will be created when newsletter sent or an error occurs (recommended) |
||
| 39 | // 2 = log will be created for all events (only for testing) |
||
| 40 | $log_level = 2; |
||
| 41 | |||
| 42 | // execute all pending tasks |
||
| 43 | $result_exec = $taskHandler->processTasks($log_level); |
||
| 44 | |||
| 45 | if ($log_level > 0) { |
||
| 46 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
| 47 | |||
| 48 | $logHandler = $helper->getHandler('Log'); |
||
| 49 | // get limit_hour from primary account |
||
| 50 | $accountHandler = $helper->getHandler('Account'); |
||
| 51 | $limitHour = $accountHandler->getLimitHour(); |
||
| 52 | |||
| 53 | echo '<br>log_level:' . $log_level; |
||
| 54 | echo '<br>is_object(helper):' . is_object($helper); |
||
| 55 | echo '<br>limit_hour: ' . $limitHour; |
||
| 56 | if (0 === $result_exec['pending']) { |
||
| 57 | echo '<br>status: ' . 'cron no task'; |
||
| 58 | if (2 == $log_level) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 59 | echo '<br>no mails for sending available'; |
||
| 60 | $logObj = $logHandler->create(); |
||
| 61 | echo '<br>is_object(logObj):'.is_object($logObj); |
||
| 62 | // Set Vars |
||
| 63 | $logObj->setVar('text', 'cron no pending task'); |
||
| 64 | $logObj->setVar('datecreated', time()); |
||
| 65 | $logObj->setVar('submitter', 0); |
||
| 66 | // Insert Data |
||
| 67 | if ($logHandler->insert($logObj)) { |
||
| 68 | echo '<br>log successfully created'; |
||
| 69 | } else { |
||
| 70 | echo $logObj->getHtmlErrors(); |
||
| 71 | echo '<br>errors when creating log'; |
||
| 72 | } |
||
| 73 | } |
||
| 74 | } else { |
||
| 75 | echo '<br>status: ' . 'cron task available'; |
||
| 76 | echo "<br>result cron: Pending: " . $result_exec['pending'] . " / Done: " . $result_exec['done']; |
||
| 77 | } |
||
| 78 | } |
||
| 79 | echo '<br>finished cron.php'; |
||
| 80 |