ggoffy /
wgevents
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | |||
| 6 | namespace XoopsModules\Wgevents; |
||
| 7 | |||
| 8 | /* |
||
| 9 | You may not change or alter any portion of this comment or credits |
||
| 10 | of supporting developers from this source code or any supporting source code |
||
| 11 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 12 | |||
| 13 | This program is distributed in the hope that it will be useful, |
||
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 16 | */ |
||
| 17 | |||
| 18 | /** |
||
| 19 | * wgEvents module for xoops |
||
| 20 | * |
||
| 21 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 22 | * @license GPL 2.0 or later |
||
| 23 | * @package wgevents |
||
| 24 | * @since 1.0.0 |
||
| 25 | * @min_xoops 2.5.11 Beta1 |
||
| 26 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 27 | */ |
||
| 28 | |||
| 29 | use XoopsModules\Wgevents; |
||
| 30 | |||
| 31 | \defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Class Object Task |
||
| 35 | */ |
||
| 36 | class Task extends \XoopsObject |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * Constructor |
||
| 40 | * |
||
| 41 | */ |
||
| 42 | public function __construct() |
||
| 43 | { |
||
| 44 | $this->initVar('id', \XOBJ_DTYPE_INT); |
||
| 45 | $this->initVar('type', \XOBJ_DTYPE_INT); |
||
| 46 | $this->initVar('params', \XOBJ_DTYPE_TXTAREA); |
||
| 47 | $this->initVar('recipient', \XOBJ_DTYPE_TXTBOX); |
||
| 48 | $this->initVar('datecreated', \XOBJ_DTYPE_INT); |
||
| 49 | $this->initVar('submitter', \XOBJ_DTYPE_INT); |
||
| 50 | $this->initVar('status', \XOBJ_DTYPE_INT); |
||
| 51 | $this->initVar('datedone', \XOBJ_DTYPE_INT); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @static function &getInstance |
||
| 56 | * |
||
| 57 | */ |
||
| 58 | public static function getInstance() |
||
| 59 | { |
||
| 60 | static $instance = false; |
||
| 61 | if (!$instance) { |
||
| 62 | $instance = new self(); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * The new inserted $Id |
||
| 68 | * @return inserted id |
||
| 69 | */ |
||
| 70 | public function getNewInsertedIdTasks() |
||
| 71 | { |
||
| 72 | return $GLOBALS['xoopsDB']->getInsertId(); |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @public function getForm |
||
| 77 | * @param bool $action |
||
| 78 | * @return \XoopsThemeForm |
||
| 79 | */ |
||
| 80 | public function getFormTasks($action = false) |
||
| 81 | { |
||
| 82 | if (!$action) { |
||
| 83 | $action = $_SERVER['REQUEST_URI']; |
||
| 84 | } |
||
| 85 | // Title |
||
| 86 | $title = $this->isNew() ? \_AM_WGEVENTS_ADD_TASK : \_AM_WGEVENTS_EDIT_TASK; |
||
| 87 | // Get Theme Form |
||
| 88 | \xoops_load('XoopsFormLoader'); |
||
| 89 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||
| 90 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 91 | // Form Select taskType |
||
| 92 | $form->addElement(new \XoopsFormText(\_AM_WGEVENTS_TASK_TYPE, 'type', 50, 255, $this->getVar('type'))); |
||
| 93 | // Form Editor TextArea taskParams |
||
| 94 | $form->addElement(new \XoopsFormTextArea(\_AM_WGEVENTS_TASK_PARAMS, 'params', $this->getVar('params', 'e'), 10, 47)); |
||
| 95 | // Form Editor TextArea taskRecipient |
||
| 96 | $form->addElement(new \XoopsFormText(\_AM_WGEVENTS_TASK_RECIPIENT, 'recipient', 50, 255, $this->getVar('recipient'))); |
||
| 97 | // Form Text Date Select taskDatecreated |
||
| 98 | $taskDatecreated = $this->isNew() ? \time() : $this->getVar('datecreated'); |
||
| 99 | $form->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $taskDatecreated), true); |
||
| 100 | // Form Select User taskSubmitter |
||
| 101 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
| 102 | $taskSubmitter = $this->isNew() ? $uidCurrent : $this->getVar('submitter'); |
||
| 103 | $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $taskSubmitter), true); |
||
| 104 | // Form Select Status taskStatus |
||
| 105 | $taskStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $this->getVar('status')); |
||
| 106 | $taskStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE); |
||
| 107 | $taskStatusSelect->addOption(Constants::STATUS_PENDING, \_MA_WGEVENTS_STATUS_PENDING); |
||
| 108 | $taskStatusSelect->addOption(Constants::STATUS_PROCESSING, \_MA_WGEVENTS_STATUS_PROCESSING); |
||
| 109 | $taskStatusSelect->addOption(Constants::STATUS_DONE, \_MA_WGEVENTS_STATUS_DONE); |
||
| 110 | $form->addElement($taskStatusSelect, true); |
||
| 111 | // Form Text Date Select taskDatedone |
||
| 112 | $taskDatedone = $this->isNew() ? \time() : $this->getVar('datedone'); |
||
| 113 | $form->addElement(new \XoopsFormDateTime(\_AM_WGEVENTS_TASK_DATEDONE, 'datedone', '', $taskDatedone), true); |
||
| 114 | // To Save |
||
| 115 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||
| 116 | $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); |
||
| 117 | return $form; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Get Values |
||
| 122 | * @param null $keys |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 123 | * @param null $format |
||
|
0 ignored issues
–
show
|
|||
| 124 | * @param null $maxDepth |
||
|
0 ignored issues
–
show
|
|||
| 125 | * @return array |
||
| 126 | */ |
||
| 127 | public function getValuesTasks($keys = null, $format = null, $maxDepth = null) |
||
| 128 | { |
||
| 129 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
| 130 | $utility = new \XoopsModules\Wgevents\Utility(); |
||
| 131 | $editorMaxchar = $helper->getConfig('editor_maxchar'); |
||
| 132 | $ret = $this->getValues($keys, $format, $maxDepth); |
||
| 133 | $ret['type_text'] = $this->getMailNotificationText($this->getVar('type')); |
||
| 134 | $ret['params_text'] = $this->getVar('params', 'e'); |
||
| 135 | $ret['params_short'] = $utility::truncateHtml($ret['params'], $editorMaxchar); |
||
| 136 | $ret['datecreated_text'] = \formatTimestamp($this->getVar('datecreated'), 'm'); |
||
| 137 | $ret['submitter_text'] = \XoopsUser::getUnameFromId($this->getVar('submitter')); |
||
| 138 | $ret['status_text'] = Utility::getStatusText($this->getVar('status')); |
||
| 139 | $ret['datedone_text'] = \formatTimestamp($this->getVar('datedone'), 'm'); |
||
| 140 | return $ret; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @public function to get text constants mail notification |
||
| 145 | * @param $const |
||
| 146 | * @return string |
||
| 147 | */ |
||
| 148 | public function getMailNotificationText($const) |
||
| 149 | { |
||
| 150 | switch ($const) { |
||
| 151 | case Constants::MAIL_REG_CONFIRM_IN: |
||
| 152 | $const_text = 'MAIL_REG_CONFIRM_IN'; |
||
| 153 | break; |
||
| 154 | case Constants::MAIL_REG_CONFIRM_OUT: |
||
| 155 | $const_text = 'MAIL_REG_CONFIRM_OUT'; |
||
| 156 | break; |
||
| 157 | case Constants::MAIL_REG_CONFIRM_MODIFY: |
||
| 158 | $const_text = 'MAIL_REG_CONFIRM_MODIFY'; |
||
| 159 | break; |
||
| 160 | case Constants::MAIL_REG_NOTIFY_IN: |
||
| 161 | $const_text = 'MAIL_REG_NOTIFY_IN'; |
||
| 162 | break; |
||
| 163 | case Constants::MAIL_REG_NOTIFY_OUT: |
||
| 164 | $const_text = 'MAIL_REG_NOTIFY_OUT'; |
||
| 165 | break; |
||
| 166 | case Constants::MAIL_REG_NOTIFY_MODIFY: |
||
| 167 | $const_text = 'MAIL_REG_NOTIFY_MODIFY'; |
||
| 168 | break; |
||
| 169 | case Constants::MAIL_EVENT_NOTIFY_MODIFY: |
||
| 170 | $const_text = 'MAIL_EVENT_NOTIFY_MODIFY'; |
||
| 171 | break; |
||
| 172 | case Constants::MAIL_EVENT_NOTIFY_ALL: |
||
| 173 | $const_text = 'MAIL_EVENT_NOTIFY_ALL'; |
||
| 174 | break; |
||
| 175 | case Constants::MAIL_REG_NOTIFY_CANCEL: |
||
| 176 | $const_text = 'MAIL_REG_NOTIFY_CANCEL'; |
||
| 177 | break; |
||
| 178 | case Constants::MAIL_REG_CONFIRM_CANCEL: |
||
| 179 | $const_text = 'MAIL_REG_CONFIRM_CANCEL'; |
||
| 180 | break; |
||
| 181 | case 0: |
||
| 182 | default: |
||
| 183 | $const_text = 'invalid constant text'; |
||
| 184 | break; |
||
| 185 | } |
||
| 186 | |||
| 187 | return $const_text; |
||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * Returns an array representation of the object |
||
| 192 | * |
||
| 193 | * @return array |
||
| 194 | */ |
||
| 195 | public function toArrayTasks() |
||
| 196 | { |
||
| 197 | $ret = []; |
||
| 198 | $vars = $this->getVars(); |
||
| 199 | foreach (\array_keys($vars) as $var) { |
||
| 200 | $ret[$var] = $this->getVar($var); |
||
| 201 | } |
||
| 202 | return $ret; |
||
| 203 | } |
||
| 204 | } |
||
| 205 |