|
| 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 | + * |
| 11 | + * @category Module |
| 12 | + * @author XOOPS Development Team |
| 13 | + * @copyright XOOPS Project |
| 14 | + * @link https://xoops.org |
| 15 | + * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
| 16 | + */ |
| 17 | + |
| 18 | +use Xmf\Module\Admin; |
| 19 | +use Xmf\Request; |
| 20 | +use XoopsModules\Tag\{ |
| 21 | + Common\Blocksadmin, |
| 22 | + Helper |
| 23 | +}; |
| 24 | + |
| 25 | +/** @var Admin $adminObject */ |
| 26 | +/** @var Helper $helper */ |
| 27 | + |
| 28 | +require __DIR__ . '/admin_header.php'; |
| 29 | +xoops_cp_header(); |
| 30 | + |
| 31 | +$moduleDirName = $helper->getDirname(); |
| 32 | +$moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
| 33 | + |
| 34 | +/** @var \XoopsMySQLDatabase $xoopsDB */ |
| 35 | +$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
| 36 | +$blocksadmin = new Blocksadmin($xoopsDB, $helper); |
| 37 | + |
| 38 | +$xoopsModule = XoopsModule::getByDirname($moduleDirName); |
| 39 | + |
| 40 | +if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule) |
| 41 | + || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
| 42 | + exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403')); |
| 43 | +} |
| 44 | +if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) { |
| 45 | + require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
| 46 | + |
| 47 | + $op = Request::getCmd('op', 'list'); |
| 48 | + if (!empty($_POST)) { |
| 49 | + $ok = Request::getInt('ok', 0, 'POST'); |
| 50 | + $confirm_submit = Request::getCmd('confirm_submit', '', 'POST'); |
| 51 | + $submit = Request::getString('submit', '', 'POST'); |
| 52 | + $bside = Request::getString('bside', '0', 'POST'); |
| 53 | + $bweight = Request::getString('bweight', '0', 'POST'); |
| 54 | + $bvisible = Request::getString('bvisible', '0', 'POST'); |
| 55 | + $bmodule = Request::getArray('bmodule', [], 'POST'); |
| 56 | + $btitle = Request::getString('btitle', '', 'POST'); |
| 57 | + $bcachetime = Request::getString('bcachetime', '0', 'POST'); |
| 58 | + $groups = Request::getArray('groups', [], 'POST'); |
| 59 | + $options = Request::getArray('options', [], 'POST'); |
| 60 | + $submitblock = Request::getString('submitblock', '', 'POST'); |
| 61 | + $fct = Request::getString('fct', '', 'POST'); |
| 62 | + $title = Request::getString('title', '', 'POST'); |
| 63 | + $side = Request::getString('side', '0', 'POST'); |
| 64 | + $weight = Request::getString('weight', '0', 'POST'); |
| 65 | + $visible = Request::getString('visible', '0', 'POST'); |
| 66 | + } |
| 67 | + |
| 68 | + if ('list' === $op) { |
| 69 | + // xoops_cp_header(); |
| 70 | + $blocksadmin->listBlocks(); |
| 71 | + require_once __DIR__ . '/admin_footer.php'; |
| 72 | + exit(); |
| 73 | + } |
| 74 | + |
| 75 | + if (\in_array($op, ['edit', 'edit_ok', 'delete', 'delete_ok', 'clone', 'clone_ok'])) { |
| 76 | + $bid = Request::getInt('bid', 0); |
| 77 | + $ok = Request::getInt('ok', 0); |
| 78 | + |
| 79 | + if ('clone' === $op) { |
| 80 | + $blocksadmin->cloneBlock($bid); |
| 81 | + } |
| 82 | + |
| 83 | + if ('delete' === $op) { |
| 84 | + if (1 === $ok) { |
| 85 | + // if (!$GLOBALS['xoopsSecurity']->check()) { |
| 86 | + // redirect_header($helper->url('admin/blocksadmin.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
| 87 | + // } |
| 88 | + $blocksadmin->deleteBlock($bid); |
| 89 | + } else { |
| 90 | + // xoops_cp_header(); |
| 91 | + xoops_confirm(['ok' => 1, 'op' => 'delete', 'bid' => $bid], 'blocksadmin.php', constant('CO_' . $moduleDirNameUpper . '_' . 'DELETE_BLOCK_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true); |
| 92 | + xoops_cp_footer(); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + if ('edit' === $op) { |
| 97 | + $blocksadmin->editBlock($bid); |
| 98 | + } |
| 99 | + |
| 100 | + if ('edit_ok' === $op) { |
| 101 | + $blocksadmin->updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
| 102 | + } |
| 103 | + |
| 104 | + if ('clone_ok' === $op) { |
| 105 | + $blocksadmin->isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups); |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + if ('order' === $op) { |
| 110 | + $bid = Request::getArray('bid', []); |
| 111 | + |
| 112 | + $title = Request::getArray('title', [], 'POST'); |
| 113 | + $side = Request::getArray('side', [], 'POST'); |
| 114 | + $weight = Request::getArray('weight', [], 'POST'); |
| 115 | + $visible = Request::getArray('visible', [], 'POST'); |
| 116 | + $bcachetime = Request::getArray('bcachetime', [], 'POST'); |
| 117 | + $bmodule = Request::getArray('bmodule', [], 'POST');//mb |
| 118 | + |
| 119 | + $oldtitle = Request::getArray('oldtitle', [], 'POST'); |
| 120 | + $oldside = Request::getArray('oldside', [], 'POST'); |
| 121 | + $oldweight = Request::getArray('oldweight', [], 'POST'); |
| 122 | + $oldvisible = Request::getArray('oldvisible', [], 'POST'); |
| 123 | + $oldgroups = Request::getArray('oldgroups', [], 'POST'); |
| 124 | + $oldbcachetime = Request::getArray('oldcachetime', [], 'POST'); |
| 125 | + $oldbmodule = Request::getArray('oldbmodule', [], 'POST');//mb |
| 126 | + |
| 127 | + $blocksadmin->orderBlock( |
| 128 | + $bid, |
| 129 | + $oldtitle, |
| 130 | + $oldside, |
| 131 | + $oldweight, |
| 132 | + $oldvisible, |
| 133 | + $oldgroups, |
| 134 | + $oldbcachetime, |
| 135 | + $oldbmodule, |
| 136 | + $title, |
| 137 | + $weight, |
| 138 | + $visible, |
| 139 | + $side, |
| 140 | + $bcachetime, |
| 141 | + $groups, |
| 142 | + $bmodule |
| 143 | + ); |
| 144 | + } |
| 145 | +} else { |
| 146 | + echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'); |
| 147 | +} |
| 148 | + |
| 149 | +require __DIR__ . '/admin_footer.php'; |
0 commit comments