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 | You may not change or alter any portion of this comment or credits |
||||
| 5 | of supporting developers from this source code or any supporting source code |
||||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 7 | |||||
| 8 | This program is distributed in the hope that it will be useful, |
||||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 11 | */ |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * wgEvents module for xoops |
||||
| 15 | * |
||||
| 16 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||||
| 17 | * @license GPL 2.0 or later |
||||
| 18 | * @package wgevents |
||||
| 19 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||||
| 20 | */ |
||||
| 21 | |||||
| 22 | use Xmf\Request; |
||||
|
0 ignored issues
–
show
|
|||||
| 23 | use XoopsModules\Wgevents; |
||||
| 24 | use XoopsModules\Wgevents\{ |
||||
| 25 | Constants, |
||||
| 26 | Common |
||||
| 27 | }; |
||||
| 28 | |||||
| 29 | require __DIR__ . '/header.php'; |
||||
| 30 | $GLOBALS['xoopsOption']['template_main'] = 'wgevents_question.tpl'; |
||||
| 31 | require_once \XOOPS_ROOT_PATH . '/header.php'; |
||||
| 32 | |||||
| 33 | $op = Request::getCmd('op', 'list'); |
||||
| 34 | $queId = Request::getInt('id'); |
||||
| 35 | $queEvid = Request::getInt('evid'); |
||||
| 36 | $start = Request::getInt('start'); |
||||
| 37 | $limit = Request::getInt('limit', $helper->getConfig('userpager')); |
||||
| 38 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||||
| 39 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||||
| 40 | |||||
| 41 | // Define Stylesheet |
||||
| 42 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||||
| 43 | // Paths |
||||
| 44 | $GLOBALS['xoopsTpl']->assign('xoops_icons32_url', \XOOPS_ICONS32_URL); |
||||
| 45 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||||
| 46 | // Keywords |
||||
| 47 | $keywords = []; |
||||
| 48 | // Breadcrumbs |
||||
| 49 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_INDEX, 'link' => 'index.php']; |
||||
| 50 | |||||
| 51 | $GLOBALS['xoopsTpl']->assign('addEvid', $queEvid); |
||||
| 52 | |||||
| 53 | switch ($op) { |
||||
| 54 | case 'show': |
||||
| 55 | case 'list': |
||||
| 56 | default: |
||||
| 57 | $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js'); |
||||
| 58 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/jquery-ui.min.js'); |
||||
| 59 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/sortables.js'); |
||||
| 60 | |||||
| 61 | // check whether there are textblocks available |
||||
| 62 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||||
| 63 | $crTextblock = new \CriteriaCompo(); |
||||
| 64 | $crTextblock->add(new \Criteria('class', Constants::TEXTBLOCK_CLASS_PUBLIC)); |
||||
| 65 | $crTextblock->add(new \Criteria('submitter', $uidCurrent), 'OR'); |
||||
| 66 | $textblocksCount = $textblockHandler->getCount($crTextblock); |
||||
| 67 | $GLOBALS['xoopsTpl']->assign('textblocksCount', $textblocksCount); |
||||
| 68 | |||||
| 69 | // get default fields |
||||
| 70 | $regdefaults = []; |
||||
| 71 | $regdefaults[] = [ |
||||
| 72 | 'type_text' => \_MA_WGEVENTS_FIELD_TEXTBOX, |
||||
| 73 | 'caption' => \_MA_WGEVENTS_REGISTRATION_FIRSTNAME, |
||||
| 74 | 'value_list' => '', |
||||
| 75 | 'placeholder' => \_MA_WGEVENTS_REGISTRATION_FIRSTNAME_PLACEHOLDER, |
||||
| 76 | 'required' => \_YES, |
||||
| 77 | 'print' => \_YES |
||||
| 78 | ]; |
||||
| 79 | $regdefaults[] = [ |
||||
| 80 | 'type_text' => \_MA_WGEVENTS_FIELD_TEXTBOX, |
||||
| 81 | 'caption' => \_MA_WGEVENTS_REGISTRATION_LASTNAME, |
||||
| 82 | 'value_list' => '', |
||||
| 83 | 'placeholder' => \_MA_WGEVENTS_REGISTRATION_LASTNAME_PLACEHOLDER, |
||||
| 84 | 'required' => \_YES, |
||||
| 85 | 'print' => \_YES |
||||
| 86 | ]; |
||||
| 87 | $regdefaults[] = [ |
||||
| 88 | 'type_text' => \_MA_WGEVENTS_FIELD_TEXTBOX, |
||||
| 89 | 'caption' => \_MA_WGEVENTS_REGISTRATION_EMAIL, |
||||
| 90 | 'value_list' => '', |
||||
| 91 | 'placeholder' => \_MA_WGEVENTS_REGISTRATION_EMAIL_PLACEHOLDER, |
||||
| 92 | 'required' => \_YES, |
||||
| 93 | 'print' => \_YES |
||||
| 94 | ]; |
||||
| 95 | $GLOBALS['xoopsTpl']->assign('regdefaults', $regdefaults); |
||||
| 96 | |||||
| 97 | //get event details |
||||
| 98 | $eventObj = $eventHandler->get($queEvid); |
||||
| 99 | $evName = $eventObj->getVar('name'); |
||||
| 100 | $evSubmitter = $eventObj->getVar('submitter'); |
||||
| 101 | $evStatus = $eventObj->getVar('status'); |
||||
| 102 | $keywords[] = $evName; |
||||
| 103 | |||||
| 104 | // Breadcrumbs |
||||
| 105 | if ('' !== $evName) { |
||||
| 106 | $xoBreadcrumbs[] = ['title' => $evName]; |
||||
| 107 | } |
||||
| 108 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_QUESTIONS_LIST]; |
||||
| 109 | |||||
| 110 | // get question fields |
||||
| 111 | $crQuestion = new \CriteriaCompo(); |
||||
| 112 | $crQuestion->add(new \Criteria('evid', $queEvid)); |
||||
| 113 | $questionsCount = $questionHandler->getCount($crQuestion); |
||||
| 114 | $GLOBALS['xoopsTpl']->assign('questionsCount', $questionsCount); |
||||
| 115 | $crQuestion->setSort('weight ASC, id'); |
||||
| 116 | $crQuestion->setOrder('DESC'); |
||||
| 117 | $crQuestion->setStart($start); |
||||
| 118 | $crQuestion->setLimit($limit); |
||||
| 119 | if ($questionsCount > 0) { |
||||
| 120 | $questionsAll = $questionHandler->getAll($crQuestion); |
||||
| 121 | $questions = []; |
||||
| 122 | $evName = ''; |
||||
| 123 | $evSubmitter = 0; |
||||
| 124 | $evStatus = 0; |
||||
| 125 | // Get All Question |
||||
| 126 | foreach (\array_keys($questionsAll) as $i) { |
||||
| 127 | $questions[$i] = $questionsAll[$i]->getValuesQuestions(); |
||||
| 128 | } |
||||
| 129 | $GLOBALS['xoopsTpl']->assign('questions', $questions); |
||||
| 130 | unset($questions); |
||||
| 131 | // Display Navigation |
||||
| 132 | if ($questionsCount > $limit) { |
||||
| 133 | require_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
| 134 | $pagenav = new \XoopsPageNav($questionsCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
||||
| 135 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||||
| 136 | } |
||||
| 137 | $GLOBALS['xoopsTpl']->assign('eventName', $evName); |
||||
| 138 | $permEdit = $permissionsHandler->getPermQuestionsAdmin($evSubmitter, $evStatus); |
||||
| 139 | $GLOBALS['xoopsTpl']->assign('permEdit', $permEdit); |
||||
| 140 | $GLOBALS['xoopsTpl']->assign('wgevents_icons_url_16', \WGEVENTS_ICONS_URL_16); |
||||
| 141 | |||||
| 142 | $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', \strip_tags($evName . ' - ' . $GLOBALS['xoopsModule']->getVar('name'))); |
||||
| 143 | |||||
| 144 | } |
||||
| 145 | break; |
||||
| 146 | case 'save': |
||||
| 147 | // Security Check |
||||
| 148 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 149 | \redirect_header('question.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 150 | } |
||||
| 151 | $eventObj = $eventHandler->get($queEvid); |
||||
| 152 | // Check permissions |
||||
| 153 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 154 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 155 | } |
||||
| 156 | if ($queId > 0) { |
||||
| 157 | $questionObj = $questionHandler->get($queId); |
||||
| 158 | } else { |
||||
| 159 | $questionObj = $questionHandler->create(); |
||||
| 160 | } |
||||
| 161 | $questionObj->setVar('evid', $queEvid); |
||||
| 162 | $queType = Request::getInt('type'); |
||||
| 163 | $questionObj->setVar('fdid', $queType); |
||||
| 164 | $fieldObj = $fieldHandler->get($queType); |
||||
| 165 | $fieldType = $fieldObj->getVar('type'); |
||||
| 166 | $questionObj->setVar('type', $fieldType); |
||||
| 167 | $questionObj->setVar('caption', Request::getString('caption')); |
||||
| 168 | $questionObj->setVar('desc', Request::getText('desc')); |
||||
| 169 | $queValuesText = ''; |
||||
| 170 | $queValues = Request::getString('values'); |
||||
| 171 | if ('' !== $queValues) { |
||||
| 172 | if (Constants::FIELD_COMBOBOX == $fieldType || |
||||
| 173 | Constants::FIELD_SELECTBOX == $fieldType || |
||||
| 174 | Constants::FIELD_RADIO == $fieldType || |
||||
| 175 | Constants::FIELD_CHECKBOX == $fieldType) { |
||||
| 176 | $queValuesText = \serialize(\preg_split('/\r\n|\r|\n/', $queValues)); |
||||
| 177 | } else { |
||||
| 178 | $tmpArr = [$queValues]; |
||||
| 179 | $queValuesText = \serialize($tmpArr); |
||||
| 180 | } |
||||
| 181 | } |
||||
| 182 | $questionObj->setVar('values', $queValuesText); |
||||
| 183 | $questionObj->setVar('placeholder', Request::getString('placeholder')); |
||||
| 184 | $questionObj->setVar('required', Request::getInt('required')); |
||||
| 185 | $questionObj->setVar('print', Request::getInt('print')); |
||||
| 186 | $questionObj->setVar('weight', Request::getInt('weight')); |
||||
| 187 | if (Request::hasVar('datecreated_int')) { |
||||
| 188 | $questionObj->setVar('datecreated', Request::getInt('datecreated_int')); |
||||
| 189 | } else { |
||||
| 190 | $questionDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated')); |
||||
| 191 | $questionObj->setVar('datecreated', $questionDatecreatedObj->getTimestamp()); |
||||
| 192 | } |
||||
| 193 | $questionObj->setVar('submitter', Request::getInt('submitter')); |
||||
| 194 | // Insert Data |
||||
| 195 | if ($questionHandler->insert($questionObj)) { |
||||
| 196 | // redirect after insert |
||||
| 197 | \redirect_header('question.php?op=list&evid=' . $queEvid . '&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||||
| 198 | } |
||||
| 199 | // Get Form Error |
||||
| 200 | $GLOBALS['xoopsTpl']->assign('error', $questionObj->getHtmlErrors()); |
||||
| 201 | $form = $questionObj->getForm(); |
||||
| 202 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
| 203 | break; |
||||
| 204 | case 'save_textblock': |
||||
| 205 | // Security Check |
||||
| 206 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 207 | \redirect_header('question.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 208 | } |
||||
| 209 | $eventObj = $eventHandler->get($queEvid); |
||||
| 210 | // Check permissions |
||||
| 211 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 212 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 213 | } |
||||
| 214 | $weight = $questionHandler->getNextWeight($queEvid); |
||||
| 215 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||||
| 216 | |||||
| 217 | $cbTextblocks = Request::getArray('cbTextblock'); |
||||
| 218 | $errors = ''; |
||||
| 219 | foreach (\array_keys($cbTextblocks) as $i) { |
||||
| 220 | $textblockObj = $textblockHandler->get($i); |
||||
| 221 | |||||
| 222 | $questionObj = $questionHandler->create(); |
||||
| 223 | $questionObj->setVar('evid', $queEvid); |
||||
| 224 | $questionObj->setVar('fdid', Constants::FIELD_LABEL); |
||||
| 225 | $fieldObj = $fieldHandler->get(Constants::FIELD_LABEL); |
||||
| 226 | $questionObj->setVar('type', $fieldObj->getVar('type')); |
||||
| 227 | $questionObj->setVar('caption', $textblockObj->getVar('name')); |
||||
| 228 | $questionObj->setVar('desc', $textblockObj->getVar('text')); |
||||
| 229 | $questionObj->setVar('values', ''); |
||||
| 230 | $questionObj->setVar('placeholder', ''); |
||||
| 231 | $questionObj->setVar('required', 0); |
||||
| 232 | $questionObj->setVar('print', 0); |
||||
| 233 | $questionObj->setVar('weight', $weight); |
||||
| 234 | $questionObj->setVar('datecreated', \time()); |
||||
| 235 | $questionObj->setVar('submitter', $uidCurrent); |
||||
| 236 | // Insert Data |
||||
| 237 | if (!$questionHandler->insert($questionObj)) { |
||||
| 238 | $errors .= $questionHandler.getHtmlErrors(); |
||||
|
0 ignored issues
–
show
The function
getHtmlErrors was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 239 | } |
||||
| 240 | $weight++; |
||||
| 241 | } |
||||
| 242 | if ('' === $errors) { |
||||
| 243 | // redirect after insert |
||||
| 244 | \redirect_header('question.php?op=list&evid=' . $queEvid . '&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||||
| 245 | } else { |
||||
| 246 | $GLOBALS['xoopsTpl']->assign('error', $errors); |
||||
| 247 | } |
||||
| 248 | break; |
||||
| 249 | case 'newset': |
||||
| 250 | $eventObj = $eventHandler->get($queEvid); |
||||
| 251 | // Check permissions |
||||
| 252 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 253 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 254 | } |
||||
| 255 | $questionHandler->createQuestionsDefaultset($queEvid); |
||||
| 256 | \redirect_header('question.php?op=list&evid=' . $queEvid . '&start=' . $start . '&limit=' . $limit, 0, \_MA_WGEVENTS_FORM_OK); |
||||
| 257 | break; |
||||
| 258 | case 'add_textblock': |
||||
| 259 | $eventObj = $eventHandler->get($queEvid); |
||||
| 260 | // Check permissions |
||||
| 261 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 262 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 263 | } |
||||
| 264 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_TEXTBLOCK_ADD]; |
||||
| 265 | |||||
| 266 | $uidCurrent = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0; |
||||
| 267 | $crTextblock = new \CriteriaCompo(); |
||||
| 268 | $crTextblock->add(new \Criteria('class', Constants::TEXTBLOCK_CLASS_PUBLIC)); |
||||
| 269 | $crTextblock->add(new \Criteria('submitter', $uidCurrent), 'OR'); |
||||
| 270 | $textblocksCount = $textblockHandler->getCount($crTextblock); |
||||
| 271 | $GLOBALS['xoopsTpl']->assign('textblocksCount', $textblocksCount); |
||||
| 272 | if ($textblocksCount > 0) { |
||||
| 273 | $crTextblock->setStart($start); |
||||
| 274 | $crTextblock->setLimit($limit); |
||||
| 275 | $textblocksAll = $textblockHandler->getAll($crTextblock); |
||||
| 276 | $formTextblockSelect = $textblockHandler->getFormSelect($textblocksAll); |
||||
| 277 | |||||
| 278 | $GLOBALS['xoopsTpl']->assign('formTextblockSelect', $formTextblockSelect->render()); |
||||
| 279 | unset($textblocks); |
||||
| 280 | // Display Navigation |
||||
| 281 | if ($textblocksCount > $limit) { |
||||
| 282 | require_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
| 283 | $pagenav = new \XoopsPageNav($textblocksCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
||||
| 284 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav()); |
||||
| 285 | } |
||||
| 286 | } |
||||
| 287 | break; |
||||
| 288 | case 'new': |
||||
| 289 | $eventObj = $eventHandler->get($queEvid); |
||||
| 290 | // Check permissions |
||||
| 291 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 292 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 293 | } |
||||
| 294 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||||
| 295 | // Breadcrumbs |
||||
| 296 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_QUESTION_ADD]; |
||||
| 297 | // Form Create |
||||
| 298 | $questionObj = $questionHandler->create(); |
||||
| 299 | $questionObj->setVar('evid', $queEvid); |
||||
| 300 | $form = $questionObj->getForm(); |
||||
| 301 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
| 302 | break; |
||||
| 303 | case 'test': |
||||
| 304 | $eventObj = $eventHandler->get($queEvid); |
||||
| 305 | // Check permissions |
||||
| 306 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 307 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 308 | } |
||||
| 309 | // Breadcrumbs |
||||
| 310 | $xoBreadcrumbs[] = ['title' => $eventObj->getVar('name')]; |
||||
| 311 | // Form Create |
||||
| 312 | $registrationObj = $registrationHandler->create(); |
||||
| 313 | $registrationObj->setVar('evid', $queEvid); |
||||
| 314 | $form = $registrationObj->getForm('', true); |
||||
| 315 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
| 316 | break; |
||||
| 317 | case 'edit': |
||||
| 318 | $eventObj = $eventHandler->get($queEvid); |
||||
| 319 | // Check permissions |
||||
| 320 | if (!$permissionsHandler->getPermQuestionsAdmin($eventObj->getVar('submitter'), $eventObj->getVar('status'))) { |
||||
| 321 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||
| 322 | } |
||||
| 323 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms.js'); |
||||
| 324 | // Breadcrumbs |
||||
| 325 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_QUESTION_EDIT]; |
||||
| 326 | // Check params |
||||
| 327 | if (0 === $queId) { |
||||
| 328 | \redirect_header('question.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM); |
||||
| 329 | } |
||||
| 330 | // Get Form |
||||
| 331 | $questionObj = $questionHandler->get($queId); |
||||
| 332 | $questionObj->start = $start; |
||||
| 333 | $questionObj->limit = $limit; |
||||
| 334 | $form = $questionObj->getForm(); |
||||
| 335 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
| 336 | break; |
||||
| 337 | case 'clone': |
||||
| 338 | // Breadcrumbs |
||||
| 339 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_QUESTION_CLONE]; |
||||
| 340 | // Request source |
||||
| 341 | $queIdSource = Request::getInt('id_source'); |
||||
| 342 | // Check params |
||||
| 343 | if (0 === $queIdSource) { |
||||
| 344 | \redirect_header('question.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM); |
||||
| 345 | } |
||||
| 346 | // Get Form |
||||
| 347 | $questionObjSource = $questionHandler->get($queIdSource); |
||||
| 348 | $questionObj = $questionHandler->create(); |
||||
| 349 | $questionObj->setVar('evid', $questionObjSource->getVar('evid')); |
||||
| 350 | $questionObj->setVar('fdid', $questionObjSource->getVar('fdid')); |
||||
| 351 | $questionObj->setVar('type', $questionObjSource->getVar('type')); |
||||
| 352 | $questionObj->setVar('caption', $questionObjSource->getVar('caption')); |
||||
| 353 | $questionObj->setVar('desc', $questionObjSource->getVar('desc')); |
||||
| 354 | $questionObj->setVar('values', $questionObjSource->getVar('values')); |
||||
| 355 | $questionObj->setVar('placeholder', $questionObjSource->getVar('placeholder')); |
||||
| 356 | $questionObj->setVar('required', $questionObjSource->getVar('required')); |
||||
| 357 | $questionObj->setVar('print', $questionObjSource->getVar('print')); |
||||
| 358 | $questionObj->setVar('weight', $questionObjSource->getVar('weight')); |
||||
| 359 | $form = $questionObj->getForm('question.php?op=save'); |
||||
| 360 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
| 361 | unset($questionObjSource); |
||||
| 362 | break; |
||||
| 363 | case 'delete': |
||||
| 364 | // Breadcrumbs |
||||
| 365 | $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_QUESTION_DELETE]; |
||||
| 366 | // Check params |
||||
| 367 | if (0 === $queId) { |
||||
| 368 | \redirect_header('question.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM); |
||||
| 369 | } |
||||
| 370 | $questionObj = $questionHandler->get($queId); |
||||
| 371 | $queEvid = $questionObj->getVar('evid'); |
||||
| 372 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||||
| 373 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 374 | \redirect_header('question.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 375 | } |
||||
| 376 | if ($questionHandler->delete($questionObj)) { |
||||
| 377 | \redirect_header('question.php?list&evid=' . $queEvid, 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||||
| 378 | } else { |
||||
| 379 | $GLOBALS['xoopsTpl']->assign('error', $questionObj->getHtmlErrors()); |
||||
| 380 | } |
||||
| 381 | } else { |
||||
| 382 | $customConfirm = new Common\Confirm( |
||||
| 383 | ['ok' => 1, 'id' => $queId, 'evid' => $queEvid, 'op' => 'delete'], |
||||
| 384 | $_SERVER['REQUEST_URI'], |
||||
| 385 | \sprintf(\_MA_WGEVENTS_CONFIRMDELETE_QUESTION, $questionObj->getVar('caption')), \_MA_WGEVENTS_CONFIRMDELETE_TITLE, \_MA_WGEVENTS_CONFIRMDELETE_LABEL); |
||||
| 386 | $form = $customConfirm->getFormConfirm(); |
||||
| 387 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
| 388 | } |
||||
| 389 | break; |
||||
| 390 | case 'order': |
||||
| 391 | $order = $_POST['order']; |
||||
| 392 | for ($i = 0, $iMax = \count($order); $i < $iMax; $i++) { |
||||
| 393 | $questionObj = $questionHandler->get($order[$i]); |
||||
| 394 | $questionObj->setVar('weight', $i + 1); |
||||
| 395 | $questionHandler->insert($questionObj); |
||||
| 396 | } |
||||
| 397 | break; |
||||
| 398 | } |
||||
| 399 | |||||
| 400 | // Keywords |
||||
| 401 | wgeventsMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords)); |
||||
| 402 | unset($keywords); |
||||
| 403 | |||||
| 404 | // Description |
||||
| 405 | wgeventsMetaDescription(\_MA_WGEVENTS_QUESTIONS_DESC); |
||||
| 406 | $GLOBALS['xoopsTpl']->assign('xoops_mpageurl', \WGEVENTS_URL.'/question.php'); |
||||
| 407 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||||
| 408 | |||||
| 409 | require __DIR__ . '/footer.php'; |
||||
| 410 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: