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 declare(strict_types=1); |
||
| 2 | |||
| 3 | |||
| 4 | namespace XoopsModules\Wgevents; |
||
| 5 | |||
| 6 | /* |
||
| 7 | You may not change or alter any portion of this comment or credits |
||
| 8 | of supporting developers from this source code or any supporting source code |
||
| 9 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, |
||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 14 | */ |
||
| 15 | |||
| 16 | /** |
||
| 17 | * wgEvents module for xoops |
||
| 18 | * |
||
| 19 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||
| 20 | * @license GPL 2.0 or later |
||
| 21 | * @package wgevents |
||
| 22 | * @since 1.0.0 |
||
| 23 | * @min_xoops 2.5.11 Beta1 |
||
| 24 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||
| 25 | */ |
||
| 26 | |||
| 27 | use XoopsModules\Wgevents; |
||
| 28 | |||
| 29 | \defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Class Object Answer |
||
| 33 | */ |
||
| 34 | class Answer extends \XoopsObject |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * @var int |
||
| 38 | */ |
||
| 39 | public $start = 0; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var int |
||
| 43 | */ |
||
| 44 | public $limit = 0; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Constructor |
||
| 48 | * |
||
| 49 | */ |
||
| 50 | public function __construct() |
||
| 51 | { |
||
| 52 | $this->initVar('id', \XOBJ_DTYPE_INT); |
||
| 53 | $this->initVar('regid', \XOBJ_DTYPE_INT); |
||
| 54 | $this->initVar('queid', \XOBJ_DTYPE_INT); |
||
| 55 | $this->initVar('evid', \XOBJ_DTYPE_INT); |
||
| 56 | $this->initVar('text', \XOBJ_DTYPE_TXTBOX); |
||
| 57 | $this->initVar('datecreated', \XOBJ_DTYPE_INT); |
||
| 58 | $this->initVar('submitter', \XOBJ_DTYPE_INT); |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @static function &getInstance |
||
| 63 | * |
||
| 64 | */ |
||
| 65 | public static function getInstance() |
||
| 66 | { |
||
| 67 | static $instance = false; |
||
| 68 | if (!$instance) { |
||
| 69 | $instance = new self(); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * The new inserted $Id |
||
| 75 | * @return inserted id |
||
| 76 | */ |
||
| 77 | public function getNewInsertedId() |
||
| 78 | { |
||
| 79 | return $GLOBALS['xoopsDB']->getInsertId(); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @public function getForm |
||
| 84 | * @param bool $action |
||
| 85 | * @return \XoopsThemeForm |
||
| 86 | */ |
||
| 87 | public function getForm($action = false) |
||
| 88 | { |
||
| 89 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
| 90 | if (!$action) { |
||
| 91 | $action = $_SERVER['REQUEST_URI']; |
||
| 92 | } |
||
| 93 | $isAdmin = (\is_object($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsModule'])) ? $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid()) : false; |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 94 | // Title |
||
| 95 | $title = $this->isNew() ? \_MA_WGEVENTS_ANSWER_ADD : \_MA_WGEVENTS_ANSWER_EDIT; |
||
| 96 | // Get Theme Form |
||
| 97 | \xoops_load('XoopsFormLoader'); |
||
| 98 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||
| 99 | $form->setExtra('enctype="multipart/form-data"'); |
||
| 100 | // Form Table registrations |
||
| 101 | $registrationHandler = $helper->getHandler('Registration'); |
||
| 102 | $ansResidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_ANSWER_REGID, 'regid', $this->getVar('regid')); |
||
| 103 | $ansResidSelect->addOptionArray($registrationHandler->getList()); |
||
| 104 | $form->addElement($ansResidSelect); |
||
| 105 | // Form Table questions |
||
| 106 | $questionHandler = $helper->getHandler('Question'); |
||
| 107 | $ansAddidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_ANSWER_QUEID, 'queid', $this->getVar('queid')); |
||
| 108 | $crQuestion = new \CriteriaCompo(); |
||
| 109 | $crQuestion->add(new \Criteria('evid', $this->getVar('evid'))); |
||
| 110 | $questionsCount = $questionHandler->getCount($crQuestion); |
||
| 111 | // Table view questions |
||
| 112 | if ($questionsCount > 0) { |
||
| 113 | $crQuestion->setSort('weight ASC, id'); |
||
| 114 | $crQuestion->setOrder('DESC'); |
||
| 115 | $questionsAll = $questionHandler->getAll($crQuestion); |
||
| 116 | foreach (\array_keys($questionsAll) as $i) { |
||
| 117 | $ansAddidSelect->addOption($questionsAll[$i]->getVar('id'), $questionsAll[$i]->getVar('caption')); |
||
| 118 | } |
||
| 119 | } |
||
| 120 | $form->addElement($ansAddidSelect); |
||
| 121 | // Form Table events |
||
| 122 | $eventHandler = $helper->getHandler('Event'); |
||
| 123 | $ansEvidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_ANSWER_EVID, 'evid', $this->getVar('evid')); |
||
| 124 | $ansEvidSelect->addOptionArray($eventHandler->getList()); |
||
| 125 | $form->addElement($ansEvidSelect); |
||
| 126 | // Form Text ansText |
||
| 127 | $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_ANSWER_TEXT, 'text', 50, 255, $this->getVar('text'))); |
||
| 128 | // Form Text Date Select ansDatecreated |
||
| 129 | $ansDatecreated = $this->isNew() ? \time() : $this->getVar('datecreated'); |
||
| 130 | $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $ansDatecreated)); |
||
| 131 | // Form Select User ansSubmitter |
||
| 132 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||
| 133 | $ansSubmitter = $this->isNew() ? $uidCurrent : $this->getVar('submitter'); |
||
| 134 | $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $ansSubmitter)); |
||
| 135 | // To Save |
||
| 136 | $form->addElement(new \XoopsFormHidden('op', 'save')); |
||
| 137 | $form->addElement(new \XoopsFormHidden('start', $this->start)); |
||
| 138 | $form->addElement(new \XoopsFormHidden('limit', $this->limit)); |
||
| 139 | $form->addElement(new \XoopsFormButtonTray('', \_SUBMIT, 'submit', '', false)); |
||
| 140 | return $form; |
||
| 141 | } |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Get Values |
||
| 145 | * @param null $keys |
||
| 146 | * @param null $format |
||
| 147 | * @param null $maxDepth |
||
| 148 | * @return array |
||
| 149 | */ |
||
| 150 | public function getValuesAnswers($keys = null, $format = null, $maxDepth = null) |
||
| 151 | { |
||
| 152 | $helper = \XoopsModules\Wgevents\Helper::getInstance(); |
||
| 153 | $ret = $this->getValues($keys, $format, $maxDepth); |
||
| 154 | $questionHandler = $helper->getHandler('Question'); |
||
| 155 | $questionObj = $questionHandler->get($this->getVar('queid')); |
||
| 156 | $queCaption = ''; |
||
| 157 | if (\is_object($questionObj)) { |
||
| 158 | $queCaption = $questionObj->getVar('caption'); |
||
| 159 | } |
||
| 160 | $ret['quecaption'] = $queCaption; |
||
| 161 | $eventHandler = $helper->getHandler('Event'); |
||
| 162 | $eventObj = $eventHandler->get($this->getVar('evid')); |
||
| 163 | $evName = 'invalid event'; |
||
| 164 | if (\is_object($eventObj)) { |
||
| 165 | $evName = $eventObj->getVar('name'); |
||
| 166 | } |
||
| 167 | $ret['eventname'] = $evName; |
||
| 168 | $ret['datecreated_text'] = \formatTimestamp($this->getVar('datecreated'), 's'); |
||
| 169 | $ret['submitter_text'] = \XoopsUser::getUnameFromId($this->getVar('submitter')); |
||
| 170 | return $ret; |
||
| 171 | } |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Returns an array representation of the object |
||
| 175 | * |
||
| 176 | * @return array |
||
| 177 | */ |
||
| 178 | /* |
||
| 179 | public function toArray() |
||
| 180 | { |
||
| 181 | $ret = []; |
||
| 182 | $vars = $this->getVars(); |
||
| 183 | foreach (\array_keys($vars) as $var) { |
||
| 184 | $ret[$var] = $this->getVar($var); |
||
| 185 | } |
||
| 186 | return $ret; |
||
| 187 | } |
||
| 188 | */ |
||
| 189 | } |
||
| 190 |