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; |
||
| 23 | use XoopsModules\Wgevents; |
||
| 24 | use XoopsModules\Wgevents\Constants; |
||
| 25 | use XoopsModules\Wgevents\Common; |
||
| 26 | |||
| 27 | require __DIR__ . '/header.php'; |
||
| 28 | // Get all request values |
||
| 29 | $op = Request::getCmd('op', 'list'); |
||
| 30 | $accId = Request::getInt('id'); |
||
| 31 | $save_and_check = Request::getString('save_and_check', 'none'); |
||
| 32 | $start = Request::getInt('start'); |
||
| 33 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||
| 34 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||
| 35 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||
| 36 | |||
| 37 | $moduleDirName = \basename(\dirname(__DIR__)); |
||
| 38 | |||
| 39 | $GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
||
| 40 | |||
| 41 | switch ($op) { |
||
| 42 | case 'check_account': |
||
| 43 | $imgFailed = WGEVENTS_ICONS_URL_16 . '/0.png'; |
||
| 44 | $imgOK = WGEVENTS_ICONS_URL_16 . '/1.png'; |
||
| 45 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 46 | $templateMain = 'wgevents_admin_account.tpl'; |
||
| 47 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('account.php')); |
||
| 48 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_ACCOUNTS, 'account.php?op=list'); |
||
| 49 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 50 | |||
| 51 | $GLOBALS['xoopsTpl']->assign('account_check', true); |
||
| 52 | |||
| 53 | if (0 === $accId) { |
||
| 54 | redirect_header('account.php', 3, _MA_WGEVENTS_INVALID_PARAM); |
||
| 55 | } else { |
||
| 56 | $accountObj = $helper->getHandler('Account')->get($accId); |
||
| 57 | if (!\is_object($accountObj)) { |
||
| 58 | redirect_header('account.php', 3, _MA_WGEVENTS_INVALID_PARAM); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | $account_server_in = $accountObj->getVar('server_in'); |
||
| 63 | $account_port_in = $accountObj->getVar('port_in'); |
||
| 64 | $account_type = $accountObj->getVar('type'); |
||
| 65 | $logDetails = 'account_type:' . $account_type; |
||
| 66 | switch ($account_type) { |
||
| 67 | case Constants::ACCOUNT_TYPE_VAL_POP3: |
||
| 68 | $service = 'pop3'; |
||
| 69 | break; |
||
| 70 | case Constants::ACCOUNT_TYPE_VAL_SMTP: |
||
| 71 | case Constants::ACCOUNT_TYPE_VAL_GMAIL: |
||
| 72 | $service = 'imap'; |
||
| 73 | break; |
||
| 74 | case 'default': |
||
| 75 | default: |
||
| 76 | $service = ''; |
||
| 77 | break; |
||
| 78 | } |
||
| 79 | $account_securetype_in = $accountObj->getVar('securetype_in'); |
||
| 80 | $account_password = $accountObj->getVar('password'); |
||
| 81 | $account_username = $accountObj->getVar('username'); |
||
| 82 | |||
| 83 | $command = $account_server_in . ':' . $account_port_in; |
||
| 84 | if ('' !== $service) { |
||
| 85 | $command .= '/' . $service; |
||
| 86 | } |
||
| 87 | if ('' !== $account_securetype_in) { |
||
| 88 | $command .= '/' . $account_securetype_in; |
||
| 89 | } |
||
| 90 | $logDetails .= '<br>command:' . $command; |
||
| 91 | |||
| 92 | $checks = []; |
||
| 93 | |||
| 94 | try { |
||
| 95 | $mbox = @imap_open('{' . $command . '}', $account_username, $account_password); |
||
| 96 | } |
||
| 97 | catch (phpmailerException $e) { |
||
| 98 | // IN PROGRESS |
||
| 99 | $logHandler->createLog(\_AM_WGEVENTS_ACCOUNT_CHECK_FAILED. 'Result Test account: phpmailerException -' . $e->errorMessage()); |
||
| 100 | $result = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED . '<br>' . imap_last_error() . $e->errorMessage(); |
||
| 101 | $resultImg = $imgFailed; |
||
| 102 | } |
||
| 103 | catch (\Exception $e) { |
||
| 104 | // IN PROGRESS |
||
| 105 | $logHandler->createLog(\_AM_WGEVENTS_ACCOUNT_CHECK_FAILED. 'Result Test account: Exception -' . $e->getMessage()); |
||
| 106 | $result = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED . '<br>' . imap_last_error() . $e->getMessage(); |
||
| 107 | $resultImg = $imgFailed; |
||
| 108 | } |
||
| 109 | |||
| 110 | $checks['openmailbox']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OPEN_MAILBOX; |
||
| 111 | if (false === $mbox) { |
||
| 112 | $checks['openmailbox']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED; |
||
| 113 | $checks['openmailbox']['result_img'] = $imgFailed; |
||
| 114 | $checks['openmailbox']['info'] = \imap_last_error(); |
||
| 115 | $logDetails .= '<br>imap_open > imap_last_error:' . \imap_last_error(); |
||
| 116 | } else { |
||
| 117 | $checks['openmailbox']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OK; |
||
| 118 | $checks['openmailbox']['result_img'] = $imgOK; |
||
| 119 | $logDetails .= '<br>imap_open: OK'; |
||
| 120 | |||
| 121 | $folders = \imap_list($mbox, '{' . $command . '}', '*'); |
||
| 122 | $checks['listfolder']['check'] = \_AM_WGEVENTS_ACCOUNT_CHECK_LIST_FOLDERS; |
||
| 123 | if (false === $folders) { |
||
| 124 | $checks['listfolder']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED; |
||
| 125 | $checks['listfolder']['result_img'] = $imgFailed; |
||
| 126 | $checks['listfolder']['info'] = \imap_last_error(); |
||
| 127 | $logDetails .= '<br>imap_list > imap_last_error:' . \imap_last_error(); |
||
| 128 | } else { |
||
| 129 | $checks['listfolder']['result'] = \_AM_WGEVENTS_ACCOUNT_CHECK_OK; |
||
| 130 | $checks['listfolder']['result_img'] = $imgOK; |
||
| 131 | $checks['listfolder']['info'] = \implode('<br>', $folders); |
||
| 132 | $logDetails .= '<br>imap_list: OK'; |
||
| 133 | |||
| 134 | // send test mail |
||
| 135 | // read data of account |
||
| 136 | $account_yourname = $accountObj->getVar('yourname'); |
||
| 137 | $account_yourmail = $accountObj->getVar('yourmail'); |
||
| 138 | $account_server_out = $accountObj->getVar('server_out'); |
||
| 139 | $account_port_out = $accountObj->getVar('port_out'); |
||
| 140 | $account_securetype_out = $accountObj->getVar('securetype_out'); |
||
| 141 | |||
| 142 | try { |
||
| 143 | if ($account_type == Constants::ACCOUNT_TYPE_VAL_PHP_SENDMAIL) { |
||
| 144 | $pop = new POP3(); |
||
| 145 | $pop->authorise($account_server_out, $account_port_out, 30, $account_username, $account_password, 1); |
||
| 146 | } |
||
| 147 | |||
| 148 | $xoopsMailer = xoops_getMailer(); |
||
| 149 | $logDetails .= '<br>xoopsMailer is_object:' . \is_object($xoopsMailer); |
||
| 150 | |||
| 151 | //$xoopsMailer->useMail(); |
||
| 152 | $xoopsMailer->CharSet = _CHARSET; //use xoops default character set |
||
| 153 | |||
| 154 | //if (Constants::ACCOUNT_TYPE_VAL_PHP_SENDMAIL == $account_type) { |
||
| 155 | //$xoopsMailer->IsSendmail(); Fix Error |
||
| 156 | //} |
||
| 157 | |||
| 158 | $xoopsMailer->Username = $account_username; // SMTP account username |
||
| 159 | $logDetails .= '<br>account_username:' . $account_username; |
||
| 160 | $xoopsMailer->Password = $account_password; // SMTP account password |
||
| 161 | $logDetails .= '<br>account_password:' . $account_password; |
||
| 162 | |||
| 163 | if (Constants::ACCOUNT_TYPE_VAL_POP3 == $account_type) { |
||
| 164 | //xoopsMailer->isSMTP(); |
||
| 165 | //$xoopsMailer->SMTPDebug = 2; |
||
| 166 | $xoopsMailer->Host = $account_server_out; |
||
| 167 | } |
||
| 168 | |||
| 169 | if (Constants::ACCOUNT_TYPE_VAL_SMTP == $account_type |
||
| 170 | || Constants::ACCOUNT_TYPE_VAL_GMAIL == $account_type) { |
||
| 171 | |||
| 172 | $xoopsMailer->multimailer->isSMTP(); |
||
| 173 | $xoopsMailer->multimailer->Port = $account_port_out; // set the SMTP port |
||
| 174 | $xoopsMailer->multimailer->Host = $account_server_out; //sometimes necessary to repeat |
||
| 175 | $xoopsMailer->multimailer->SMTPAuth = true; |
||
| 176 | $xoopsMailer->multimailer->SMTPSecure = $account_securetype_out; |
||
| 177 | $xoopsMailer->multimailer->Username = $account_username; // SMTP account username |
||
| 178 | $xoopsMailer->multimailer->Password = $account_password; // SMTP account password |
||
| 179 | $xoopsMailer->multimailer->SMTPDebug = 4; |
||
| 180 | /* |
||
| 181 | $xoopsMailer->Port = $account_port_out; // set the SMTP port |
||
| 182 | $logDetails .= '<br>account_port_out:' . $account_port_out; |
||
| 183 | $xoopsMailer->Host = $account_server_out; //sometimes necessary to repeat |
||
| 184 | $logDetails .= '<br>account_server_out:' . $account_server_out;*/ |
||
| 185 | } |
||
| 186 | /* old version: |
||
| 187 | if ('' != $account_securetype_out) { |
||
| 188 | $xoopsMailer->SMTPAuth = true; |
||
| 189 | $xoopsMailer->SMTPSecure = $account_securetype_out; // sets the prefix to the server |
||
| 190 | $logDetails .= '<br>account_securetype_out:' . $account_securetype_out; |
||
| 191 | } |
||
| 192 | */ |
||
| 193 | $xoopsMailer->setFromEmail($account_yourmail); |
||
| 194 | $xoopsMailer->setFromName($account_yourname); |
||
| 195 | $logDetails .= '<br>from:' . $account_yourmail . ' ' . $account_yourname; |
||
| 196 | $xoopsMailer->setSubject('Test account'); |
||
| 197 | $xoopsMailer->setBody('This is a mail for testing account on: ' . \XOOPS_URL); |
||
| 198 | $usermail = $GLOBALS['xoopsUser']->email(); |
||
| 199 | $xoopsMailer->setToEmails($usermail); |
||
| 200 | $logDetails .= '<br>setToEmails:' . $usermail; |
||
| 201 | $logHandler->createLog($logDetails); |
||
| 202 | |||
| 203 | //execute sending |
||
| 204 | $export = \var_export($xoopsMailer, TRUE); |
||
| 205 | $export = \preg_replace("/\n/", '<br>', $export); |
||
| 206 | if ($xoopsMailer->send()) { |
||
| 207 | $logHandler->createLog('Result Test send mail to ' . $usermail .': success' . '<br>' . $export); |
||
| 208 | $result = \_AM_WGEVENTS_ACCOUNT_CHECK_OK . '<br>' . $xoopsMailer->getErrors(); |
||
| 209 | $resultImg = $imgOK; |
||
| 210 | } else { |
||
| 211 | $logHandler->createLog('Result Test send mail to ' . $usermail .': failed - ' . $xoopsMailer->getErrors() . '<br>' . $export); |
||
| 212 | $result = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED . '<br>' . $xoopsMailer->getErrors(); |
||
| 213 | $resultImg = $imgFailed; |
||
| 214 | } |
||
| 215 | unset($mail); |
||
| 216 | } |
||
| 217 | catch (phpmailerException $e) { |
||
| 218 | // IN PROGRESS |
||
| 219 | $logHandler->createLog(\_AM_WGEVENTS_ACCOUNT_CHECK_FAILED. 'Result Test account: phpmailerException -' . $e->errorMessage()); |
||
| 220 | $result = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED . '<br>' . imap_last_error() . $e->errorMessage(); |
||
| 221 | $resultImg = $imgFailed; |
||
| 222 | } |
||
| 223 | catch (\Exception $e) { |
||
| 224 | // IN PROGRESS |
||
| 225 | $logHandler->createLog(\_AM_WGEVENTS_ACCOUNT_CHECK_FAILED. 'Result Test account: Exception -' . $e->getMessage()); |
||
| 226 | $result = \_AM_WGEVENTS_ACCOUNT_CHECK_FAILED . '<br>' . imap_last_error() . $e->getMessage(); |
||
| 227 | $resultImg = $imgFailed; |
||
| 228 | } |
||
| 229 | |||
| 230 | $checks['sendtest']['check'] = _AM_WGEVENTS_ACCOUNT_CHECK_SENDTEST; |
||
| 231 | $checks['sendtest']['result'] = $result; |
||
| 232 | $checks['sendtest']['result_img'] = $resultImg; |
||
| 233 | $checks['sendtest']['info'] = $result; |
||
| 234 | } |
||
| 235 | @imap_close($mbox); |
||
|
0 ignored issues
–
show
|
|||
| 236 | } |
||
| 237 | $GLOBALS['xoopsTpl']->assign('checks', $checks); |
||
| 238 | break; |
||
| 239 | case 'list': |
||
| 240 | default: |
||
| 241 | $crAccount = new \CriteriaCompo(); |
||
| 242 | $crAccount->add(new \Criteria('primary', 1)); |
||
| 243 | $accountsCount = $accountHandler->getCount($crAccount); |
||
| 244 | if (0 === $accountsCount) { |
||
| 245 | $GLOBALS['xoopsTpl']->assign('info', \_AM_WGEVENTS_THEREARENT_ACCOUNTS_DESC); |
||
| 246 | } |
||
| 247 | // Define Stylesheet |
||
| 248 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||
| 249 | $templateMain = 'wgevents_admin_account.tpl'; |
||
| 250 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('account.php')); |
||
| 251 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_ACCOUNT, 'account.php?op=new'); |
||
| 252 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 253 | $accountCount = $accountHandler->getCountAccounts(); |
||
| 254 | $GLOBALS['xoopsTpl']->assign('accountCount', $accountCount); |
||
| 255 | $GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL); |
||
| 256 | $GLOBALS['xoopsTpl']->assign('wgevents_icons_url_16', \WGEVENTS_ICONS_URL_16); |
||
| 257 | $GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL); |
||
| 258 | // Table view accounts |
||
| 259 | if ($accountCount > 0) { |
||
| 260 | $accountAll = $accountHandler->getAllAccounts(); |
||
| 261 | foreach (\array_keys($accountAll) as $i) { |
||
| 262 | $account = $accountAll[$i]->getValuesAccount(); |
||
| 263 | if (Constants::ACCOUNT_TYPE_VAL_PHP_MAIL != $account['type'] |
||
| 264 | && Constants::ACCOUNT_TYPE_VAL_PHP_SENDMAIL != $account['type']) { |
||
| 265 | $account['show_check'] = true; |
||
| 266 | } |
||
| 267 | $GLOBALS['xoopsTpl']->append('accounts_list', $account); |
||
| 268 | unset($account); |
||
| 269 | } |
||
| 270 | } |
||
| 271 | break; |
||
| 272 | case 'new': |
||
| 273 | $templateMain = 'wgevents_admin_account.tpl'; |
||
| 274 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms_admin.js'); |
||
| 275 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('account.php')); |
||
| 276 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_ACCOUNTS, 'account.php', 'list'); |
||
| 277 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 278 | // Form Create |
||
| 279 | $accountObj = $accountHandler->create(); |
||
| 280 | $form = $accountObj->getForm(); |
||
| 281 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 282 | break; |
||
| 283 | case 'save': |
||
| 284 | // Security Check |
||
| 285 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 286 | \redirect_header('account.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 287 | } |
||
| 288 | if ($accId > 0) { |
||
| 289 | $accountObj = $accountHandler->get($accId); |
||
| 290 | } else { |
||
| 291 | $accountObj = $accountHandler->create(); |
||
| 292 | } |
||
| 293 | $crAccount = new \CriteriaCompo(); |
||
| 294 | $crAccount->add(new \Criteria('primary', 1)); |
||
| 295 | if ($accId > 0) { |
||
| 296 | $crAccount->add(new \Criteria('id', $accId, '<>')); |
||
| 297 | } |
||
| 298 | $accPrimaryCount = $accountHandler->getCount($crAccount); |
||
| 299 | unset($crAccount); |
||
| 300 | // Set Vars |
||
| 301 | $accountObj->setVar('type', Request::getInt('type')); |
||
| 302 | $accountObj->setVar('name', Request::getString('name')); |
||
| 303 | $accountObj->setVar('yourname', Request::getString('yourname')); |
||
| 304 | $accountObj->setVar('yourmail', Request::getString('yourmail')); |
||
| 305 | $accountObj->setVar('username', Request::getString('username')); |
||
| 306 | $accountObj->setVar('password', Request::getString('password')); |
||
| 307 | $accountObj->setVar('server_in', Request::getString('server_in')); |
||
| 308 | $accountObj->setVar('port_in', Request::getInt('port_in')); |
||
| 309 | $accountObj->setVar('securetype_in', Request::getString('securetype_in')); |
||
| 310 | $accountObj->setVar('server_out', Request::getString('server_out')); |
||
| 311 | $accountObj->setVar('port_out', Request::getInt('port_out')); |
||
| 312 | $accountObj->setVar('securetype_out', Request::getString('securetype_out')); |
||
| 313 | $accPrimary = Request::getInt('primary'); |
||
| 314 | if ($accPrimary > 0 && $accPrimaryCount > 0) { |
||
| 315 | $crAccount = new \CriteriaCompo(); |
||
| 316 | $crAccount->add(new \Criteria('primary', 1)); |
||
| 317 | $accountHandler->updateAll('primary', 0, $crAccount,true); |
||
| 318 | } |
||
| 319 | $accountObj->setVar('primary', Request::getInt('primary')); |
||
| 320 | $accountObj->setVar('limit_hour', Request::getInt('limit_hour')); |
||
| 321 | $accountObj->setVar('datecreated', Request::getInt('datecreated')); |
||
| 322 | $accountObj->setVar('submitter', Request::getInt('submitter')); |
||
| 323 | // Insert Data |
||
| 324 | if ($accountHandler->insert($accountObj)) { |
||
| 325 | $newAccId = $accId > 0 ? $accId : $accountObj->getNewInsertedId(); |
||
| 326 | if ('none' === $save_and_check) { |
||
| 327 | redirect_header('?op=list&start=' . $start . '&limit=' . $limit, 3, _MA_WGEVENTS_FORM_OK); |
||
| 328 | } else { |
||
| 329 | redirect_header('account.php?op=check_account&id=' . $newAccId . '&start=' . $start . '&limit=' . $limit, 3, _MA_WGEVENTS_FORM_OK); |
||
| 330 | } |
||
| 331 | } |
||
| 332 | // Get Form |
||
| 333 | $GLOBALS['xoopsTpl']->assign('error', $accountObj->getHtmlErrors()); |
||
| 334 | $form = $accountObj->getForm(); |
||
| 335 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 336 | break; |
||
| 337 | case 'edit': |
||
| 338 | $templateMain = 'wgevents_admin_account.tpl'; |
||
| 339 | $GLOBALS['xoTheme']->addScript(\WGEVENTS_URL . '/assets/js/forms_admin.js'); |
||
| 340 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('account.php')); |
||
| 341 | $adminObject->addItemButton(\_AM_WGEVENTS_ADD_ACCOUNT, 'account.php?op=new'); |
||
| 342 | $adminObject->addItemButton(\_AM_WGEVENTS_LIST_ACCOUNTS, 'account.php', 'list'); |
||
| 343 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||
| 344 | // Get Form |
||
| 345 | $accountObj = $accountHandler->get($accId); |
||
| 346 | $accountObj->start = $start; |
||
| 347 | $accountObj->limit = $limit; |
||
| 348 | $form = $accountObj->getForm(); |
||
| 349 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 350 | break; |
||
| 351 | case 'delete': |
||
| 352 | $templateMain = 'wgevents_admin_account.tpl'; |
||
| 353 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('account.php')); |
||
| 354 | $accountObj = $accountHandler->get($accId); |
||
| 355 | $accType = $accountObj->getVar('type'); |
||
| 356 | if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) { |
||
| 357 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 358 | \redirect_header('account.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 359 | } |
||
| 360 | if ($accountHandler->delete($accountObj)) { |
||
| 361 | \redirect_header('account.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK); |
||
| 362 | } else { |
||
| 363 | $GLOBALS['xoopsTpl']->assign('error', $accountObj->getHtmlErrors()); |
||
| 364 | } |
||
| 365 | } else { |
||
| 366 | $customConfirm = new Common\Confirm( |
||
| 367 | ['ok' => 1, 'id' => $accId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||
| 368 | $_SERVER['REQUEST_URI'], |
||
| 369 | \sprintf(\_MA_WGEVENTS_FORM_SURE_DELETE, $accountObj->getVar('name'))); |
||
| 370 | $form = $customConfirm->getFormConfirm(); |
||
| 371 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
| 372 | } |
||
| 373 | break; |
||
| 374 | case 'change_yn': |
||
| 375 | if ($accId > 0) { |
||
| 376 | if (Request::getInt('value') > 0) { |
||
| 377 | // reset all to false |
||
| 378 | $crAccount = new \CriteriaCompo(); |
||
| 379 | $crAccount->add(new \Criteria('primary', 1)); |
||
| 380 | $accountHandler->updateAll('primary', 0, $crAccount,true); |
||
| 381 | } |
||
| 382 | $accountObj = $accountHandler->get($accId); |
||
| 383 | $accountObj->setVar(Request::getString('field'), Request::getInt('value')); |
||
| 384 | // Insert Data |
||
| 385 | if ($accountHandler->insert($accountObj, true)) { |
||
| 386 | \redirect_header('account.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK); |
||
| 387 | } |
||
| 388 | } |
||
| 389 | break; |
||
| 390 | } |
||
| 391 | require __DIR__ . '/footer.php'; |
||
| 392 |
If you suppress an error, we recommend checking for the error condition explicitly: