| Total Complexity | 80 |
| Total Lines | 685 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 1 |
Complex classes like Blocksadmin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Blocksadmin, and based on these observations, apply Extract Interface, too.
| 1 | <?php declare(strict_types=1); |
||
| 29 | class Blocksadmin |
||
| 30 | { |
||
| 31 | /** |
||
| 32 | * @var \XoopsMySQLDatabase|null |
||
| 33 | */ |
||
| 34 | public $db; |
||
| 35 | /** |
||
| 36 | * @var \XoopsModules\Tag\Helper |
||
| 37 | */ |
||
| 38 | public $helper; |
||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | public $moduleDirName; |
||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | public $moduleDirNameUpper; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Blocksadmin constructor. |
||
| 50 | */ |
||
| 51 | public function __construct(?\XoopsDatabase $db, \Xmf\Module\Helper $helper) |
||
| 52 | { |
||
| 53 | if (null === $db) { |
||
| 54 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 55 | } |
||
| 56 | $this->db = $db; |
||
| 57 | $this->helper = $helper; |
||
|
|
|||
| 58 | $this->moduleDirName = \basename(\dirname(__DIR__, 2)); |
||
| 59 | $this->moduleDirNameUpper = \mb_strtoupper($this->moduleDirName); |
||
| 60 | \xoops_loadLanguage('admin', 'system'); |
||
| 61 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
| 62 | \xoops_loadLanguage('admin/groups', 'system'); |
||
| 63 | \xoops_loadLanguage('common', $this->moduleDirName); |
||
| 64 | \xoops_loadLanguage('blocksadmin', $this->moduleDirName); |
||
| 65 | } |
||
| 66 | |||
| 67 | public function listBlocks(): void |
||
| 68 | { |
||
| 69 | global $xoopsModule, $pathIcon16; |
||
| 70 | require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
| 71 | // xoops_loadLanguage('admin', 'system'); |
||
| 72 | // xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
| 73 | // xoops_loadLanguage('admin/groups', 'system'); |
||
| 74 | // xoops_loadLanguage('common', $moduleDirName); |
||
| 75 | // xoops_loadLanguage('blocks', $moduleDirName); |
||
| 76 | |||
| 77 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 78 | $moduleHandler = \xoops_getHandler('module'); |
||
| 79 | /** @var \XoopsMemberHandler $memberHandler */ |
||
| 80 | $memberHandler = \xoops_getHandler('member'); |
||
| 81 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 82 | $grouppermHandler = \xoops_getHandler('groupperm'); |
||
| 83 | $groups = $memberHandler->getGroups(); |
||
| 84 | $criteria = new \CriteriaCompo(new \Criteria('hasmain', '1')); |
||
| 85 | $criteria->add(new \Criteria('isactive', '1')); |
||
| 86 | $moduleList = $moduleHandler->getList($criteria); |
||
| 87 | $moduleList[-1] = \_AM_SYSTEM_BLOCKS_TOPPAGE; |
||
| 88 | $moduleList[0] = \_AM_SYSTEM_BLOCKS_ALLPAGES; |
||
| 89 | \ksort($moduleList); |
||
| 90 | echo " |
||
| 91 | <h4 style='text-align:left;'>" . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</h4>'; |
||
| 92 | echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>"; |
||
| 93 | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); |
||
| 94 | echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'> |
||
| 95 | <tr valign='middle'><th align='center'>" |
||
| 96 | . \_AM_SYSTEM_BLOCKS_TITLE |
||
| 97 | . "</th><th align='center' nowrap='nowrap'>" |
||
| 98 | . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'SIDE') |
||
| 99 | . '<br>' |
||
| 100 | . _LEFT |
||
| 101 | . '-' |
||
| 102 | . _CENTER |
||
| 103 | . '-' |
||
| 104 | . _RIGHT |
||
| 105 | . "</th><th align='center'>" |
||
| 106 | . \constant( |
||
| 107 | 'CO_' . $this->moduleDirNameUpper . '_' . 'WEIGHT' |
||
| 108 | ) |
||
| 109 | . "</th><th align='center'>" |
||
| 110 | . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'VISIBLE') |
||
| 111 | . "</th><th align='center'>" |
||
| 112 | . \_AM_SYSTEM_BLOCKS_VISIBLEIN |
||
| 113 | . "</th><th align='center'>" |
||
| 114 | . \_AM_SYSTEM_ADGS |
||
| 115 | . "</th><th align='center'>" |
||
| 116 | . \_AM_SYSTEM_BLOCKS_BCACHETIME |
||
| 117 | . "</th><th align='center'>" |
||
| 118 | . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'ACTION') |
||
| 119 | . '</th></tr> |
||
| 120 | '; |
||
| 121 | $blockArray = \XoopsBlock::getByModule($xoopsModule->mid()); |
||
| 122 | $blockCount = \count($blockArray); |
||
| 123 | $class = 'even'; |
||
| 124 | $cachetimes = [ |
||
| 125 | 0 => _NOCACHE, |
||
| 126 | 30 => \sprintf(_SECONDS, 30), |
||
| 127 | 60 => _MINUTE, |
||
| 128 | 300 => \sprintf(_MINUTES, 5), |
||
| 129 | 1800 => \sprintf(_MINUTES, 30), |
||
| 130 | 3600 => _HOUR, |
||
| 131 | 18000 => \sprintf(_HOURS, 5), |
||
| 132 | 86400 => _DAY, |
||
| 133 | 259200 => \sprintf(_DAYS, 3), |
||
| 134 | 604800 => _WEEK, |
||
| 135 | 2592000 => _MONTH, |
||
| 136 | ]; |
||
| 137 | foreach ($blockArray as $i) { |
||
| 138 | $groupsPermissions = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid')); |
||
| 139 | $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid'); |
||
| 140 | $result = $this->db->query($sql); |
||
| 141 | $modules = []; |
||
| 142 | if (!$this->db->isResultSet($result)) { |
||
| 143 | \trigger_error("Query Failed! SQL: $sql Error: " . $this->db->error(), \E_USER_ERROR); |
||
| 144 | } |
||
| 145 | while (false !== ($row = $this->db->fetchArray($result))) { |
||
| 146 | $modules[] = (int)$row['module_id']; |
||
| 147 | } |
||
| 148 | |||
| 149 | $cachetimeOptions = ''; |
||
| 150 | foreach ($cachetimes as $cachetime => $cachetimeName) { |
||
| 151 | if ($i->getVar('bcachetime') == $cachetime) { |
||
| 152 | $cachetimeOptions .= "<option value='$cachetime' selected='selected'>$cachetimeName</option>\n"; |
||
| 153 | } else { |
||
| 154 | $cachetimeOptions .= "<option value='$cachetime'>$cachetimeName</option>\n"; |
||
| 155 | } |
||
| 156 | } |
||
| 157 | |||
| 158 | $ssel7 = ''; |
||
| 159 | $ssel6 = $ssel7; |
||
| 160 | $ssel5 = $ssel6; |
||
| 161 | $ssel4 = $ssel5; |
||
| 162 | $ssel3 = $ssel4; |
||
| 163 | $ssel2 = $ssel3; |
||
| 164 | $ssel1 = $ssel2; |
||
| 165 | $ssel0 = $ssel1; |
||
| 166 | $sel1 = $ssel0; |
||
| 167 | $sel0 = $sel1; |
||
| 168 | if (1 === $i->getVar('visible')) { |
||
| 169 | $sel1 = ' checked'; |
||
| 170 | } else { |
||
| 171 | $sel0 = ' checked'; |
||
| 172 | } |
||
| 173 | if (\XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) { |
||
| 174 | $ssel0 = ' checked'; |
||
| 175 | } elseif (\XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) { |
||
| 176 | $ssel1 = ' checked'; |
||
| 177 | } elseif (\XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) { |
||
| 178 | $ssel2 = ' checked'; |
||
| 179 | } elseif (\XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) { |
||
| 180 | $ssel4 = ' checked'; |
||
| 181 | } elseif (\XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) { |
||
| 182 | $ssel3 = ' checked'; |
||
| 183 | } elseif (\XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) { |
||
| 184 | $ssel5 = ' checked'; |
||
| 185 | } elseif (\XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) { |
||
| 186 | $ssel6 = ' checked'; |
||
| 187 | } elseif (\XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) { |
||
| 188 | $ssel7 = ' checked'; |
||
| 189 | } |
||
| 190 | if ('' === $i->getVar('title')) { |
||
| 191 | $title = ' '; |
||
| 192 | } else { |
||
| 193 | $title = $i->getVar('title'); |
||
| 194 | } |
||
| 195 | $name = $i->getVar('name'); |
||
| 196 | echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title[" |
||
| 197 | . $i->getVar('bid') |
||
| 198 | . "]' value='" |
||
| 199 | . $title |
||
| 200 | . "'></td><td class='$class' align='center' nowrap='nowrap'> |
||
| 201 | <div align='center' > |
||
| 202 | <input type='radio' name='side[" |
||
| 203 | . $i->getVar('bid') |
||
| 204 | . "]' value='" |
||
| 205 | . \XOOPS_CENTERBLOCK_LEFT |
||
| 206 | . "'$ssel2> |
||
| 207 | <input type='radio' name='side[" |
||
| 208 | . $i->getVar('bid') |
||
| 209 | . "]' value='" |
||
| 210 | . \XOOPS_CENTERBLOCK_CENTER |
||
| 211 | . "'$ssel3> |
||
| 212 | <input type='radio' name='side[" |
||
| 213 | . $i->getVar('bid') |
||
| 214 | . "]' value='" |
||
| 215 | . \XOOPS_CENTERBLOCK_RIGHT |
||
| 216 | . "'$ssel4> |
||
| 217 | </div> |
||
| 218 | <div> |
||
| 219 | <span style='float:right;'><input type='radio' name='side[" |
||
| 220 | . $i->getVar('bid') |
||
| 221 | . "]' value='" |
||
| 222 | . \XOOPS_SIDEBLOCK_RIGHT |
||
| 223 | . "'$ssel1></span> |
||
| 224 | <div align='left'><input type='radio' name='side[" |
||
| 225 | . $i->getVar('bid') |
||
| 226 | . "]' value='" |
||
| 227 | . \XOOPS_SIDEBLOCK_LEFT |
||
| 228 | . "'$ssel0></div> |
||
| 229 | </div> |
||
| 230 | <div align='center'> |
||
| 231 | <input type='radio' name='side[" |
||
| 232 | . $i->getVar('bid') |
||
| 233 | . "]' value='" |
||
| 234 | . \XOOPS_CENTERBLOCK_BOTTOMLEFT |
||
| 235 | . "'$ssel5> |
||
| 236 | <input type='radio' name='side[" |
||
| 237 | . $i->getVar('bid') |
||
| 238 | . "]' value='" |
||
| 239 | . \XOOPS_CENTERBLOCK_BOTTOM |
||
| 240 | . "'$ssel7> |
||
| 241 | <input type='radio' name='side[" |
||
| 242 | . $i->getVar('bid') |
||
| 243 | . "]' value='" |
||
| 244 | . \XOOPS_CENTERBLOCK_BOTTOMRIGHT |
||
| 245 | . "'$ssel6> |
||
| 246 | </div> |
||
| 247 | </td><td class='$class' align='center'><input type='text' name='weight[" |
||
| 248 | . $i->getVar('bid') |
||
| 249 | . "]' value='" |
||
| 250 | . $i->getVar('weight') |
||
| 251 | . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible[" |
||
| 252 | . $i->getVar('bid') |
||
| 253 | . "]' value='1'$sel1>" |
||
| 254 | . _YES |
||
| 255 | . " <input type='radio' name='visible[" |
||
| 256 | . $i->getVar('bid') |
||
| 257 | . "]' value='0'$sel0>" |
||
| 258 | . _NO |
||
| 259 | . '</td>'; |
||
| 260 | |||
| 261 | echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||
| 262 | foreach ($moduleList as $k => $v) { |
||
| 263 | echo "<option value='$k'" . (\in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>"; |
||
| 264 | } |
||
| 265 | echo '</select></td>'; |
||
| 266 | |||
| 267 | echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>"; |
||
| 268 | foreach ($groups as $grp) { |
||
| 269 | echo "<option value='" . $grp->getVar('groupid') . "' " . (\in_array($grp->getVar('groupid'), $groupsPermissions) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>'; |
||
| 270 | } |
||
| 271 | echo '</select></td>'; |
||
| 272 | |||
| 273 | // Cache lifetime |
||
| 274 | echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetimeOptions . '</select> |
||
| 275 | </td>'; |
||
| 276 | |||
| 277 | // Actions |
||
| 278 | |||
| 279 | echo "<td class='$class' align='center'> |
||
| 280 | <a href='blocksadmin.php?op=edit&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
| 281 | <a href='blocksadmin.php?op=clone&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
| 282 | // if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { |
||
| 283 | // echo " <a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&op=delete&bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'> |
||
| 284 | // </a>"; |
||
| 285 | // } |
||
| 286 | |||
| 287 | // if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) { |
||
| 288 | if (!\in_array($i->getVar('block_type'), ['M', 'S'])) { |
||
| 289 | echo " |
||
| 290 | <a href='blocksadmin.php?op=delete&bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'> |
||
| 291 | </a>"; |
||
| 292 | } |
||
| 293 | echo " |
||
| 294 | <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'> |
||
| 295 | <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'> |
||
| 296 | <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'> |
||
| 297 | <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'> |
||
| 298 | <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'> |
||
| 299 | <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'> |
||
| 300 | <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'> |
||
| 301 | </td></tr> |
||
| 302 | "; |
||
| 303 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
| 304 | } |
||
| 305 | echo "<tr><td class='foot' align='center' colspan='8'> |
||
| 306 | <input type='hidden' name='op' value='order'> |
||
| 307 | " . $GLOBALS['xoopsSecurity']->getTokenHTML() . " |
||
| 308 | <input type='submit' name='submit' value='" . _SUBMIT . "'> |
||
| 309 | </td></tr></table> |
||
| 310 | </form> |
||
| 311 | <br><br>"; |
||
| 312 | } |
||
| 313 | |||
| 314 | public function deleteBlock(int $bid): void |
||
| 331 | } |
||
| 332 | |||
| 333 | public function cloneBlock(int $bid): void |
||
| 375 | // xoops_cp_footer(); |
||
| 376 | // require_once __DIR__ . '/admin_footer.php'; |
||
| 377 | // exit(); |
||
| 378 | } |
||
| 379 | |||
| 380 | public function isBlockCloned(int $bid, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void |
||
| 443 | } |
||
| 444 | |||
| 445 | public function setOrder(string $bid, string $title, string $weight, string $visible, string $side, string $bcachetime, ?array $bmodule = null): void |
||
| 446 | { |
||
| 447 | $myblock = new \XoopsBlock($bid); |
||
| 448 | $myblock->setVar('title', $title); |
||
| 449 | $myblock->setVar('weight', $weight); |
||
| 450 | $myblock->setVar('visible', $visible); |
||
| 451 | $myblock->setVar('side', $side); |
||
| 452 | $myblock->setVar('bcachetime', $bcachetime); |
||
| 453 | $myblock->store(); |
||
| 454 | // /** @var \XoopsBlockHandler $blockHandler */ |
||
| 455 | // $blockHandler = \xoops_getHandler('block'); |
||
| 456 | // return $blockHandler->insert($myblock); |
||
| 457 | } |
||
| 458 | |||
| 459 | public function editBlock(int $bid): void |
||
| 460 | { |
||
| 461 | // require_once \dirname(__DIR__,2) . '/admin/admin_header.php'; |
||
| 462 | // \xoops_cp_header(); |
||
| 463 | \xoops_loadLanguage('admin', 'system'); |
||
| 464 | \xoops_loadLanguage('admin/blocksadmin', 'system'); |
||
| 465 | \xoops_loadLanguage('admin/groups', 'system'); |
||
| 466 | // mpu_adm_menu(); |
||
| 467 | $myblock = new \XoopsBlock($bid); |
||
| 468 | $sql = 'SELECT module_id FROM ' . $this->db->prefix('block_module_link') . ' WHERE block_id=' . $bid; |
||
| 469 | $result = $this->db->query($sql); |
||
| 470 | $modules = []; |
||
| 471 | if ($this->db->isResultSet($result)) { |
||
| 472 | while (false !== ($row = $this->db->fetchArray($result))) { |
||
| 473 | $modules[] = (int)$row['module_id']; |
||
| 474 | } |
||
| 475 | } |
||
| 476 | $isCustom = \in_array($myblock->getVar('block_type'), ['C', 'E']); |
||
| 477 | $block = [ |
||
| 478 | 'title' => $myblock->getVar('title'), |
||
| 479 | 'form_title' => \_AM_SYSTEM_BLOCKS_EDITBLOCK, |
||
| 480 | // 'name' => $myblock->getVar('name'), |
||
| 481 | 'side' => $myblock->getVar('side'), |
||
| 482 | 'weight' => $myblock->getVar('weight'), |
||
| 483 | 'visible' => $myblock->getVar('visible'), |
||
| 484 | 'content' => $myblock->getVar('content', 'N'), |
||
| 485 | 'modules' => $modules, |
||
| 486 | 'is_custom' => $isCustom, |
||
| 487 | 'ctype' => $myblock->getVar('c_type'), |
||
| 488 | 'bcachetime' => $myblock->getVar('bcachetime'), |
||
| 489 | 'op' => 'edit_ok', |
||
| 490 | 'bid' => $myblock->getVar('bid'), |
||
| 491 | 'edit_form' => $myblock->getOptions(), |
||
| 492 | 'template' => $myblock->getVar('template'), |
||
| 493 | 'options' => $myblock->getVar('options'), |
||
| 494 | ]; |
||
| 495 | echo '<a href="blocksadmin.php">' . \constant('CO_' . $this->moduleDirNameUpper . '_' . 'BADMIN') . '</a> <span style="font-weight:bold;">»»</span> ' . \_AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>'; |
||
| 496 | |||
| 497 | echo $this->render($block); |
||
| 498 | } |
||
| 499 | |||
| 500 | public function updateBlock(int $bid, string $btitle, string $bside, string $bweight, string $bvisible, string $bcachetime, ?array $bmodule, ?array $options, ?array $groups): void |
||
| 549 | } |
||
| 550 | |||
| 551 | public function orderBlock( |
||
| 552 | array $bid, |
||
| 553 | array $oldtitle, |
||
| 554 | array $oldside, |
||
| 555 | array $oldweight, |
||
| 556 | array $oldvisible, |
||
| 557 | array $oldgroups, |
||
| 558 | array $oldbcachetime, |
||
| 559 | array $oldbmodule, |
||
| 560 | array $title, |
||
| 561 | array $weight, |
||
| 562 | array $visible, |
||
| 563 | array $side, |
||
| 564 | array $bcachetime, |
||
| 565 | array $groups, |
||
| 566 | array $bmodule |
||
| 567 | ): void { |
||
| 568 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 569 | \redirect_header($_SERVER['SCRIPT_NAME'], 3, \implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 570 | } |
||
| 571 | foreach (\array_keys($bid) as $i) { |
||
| 572 | if ($oldtitle[$i] !== $title[$i] |
||
| 573 | || $oldweight[$i] !== $weight[$i] |
||
| 574 | || $oldvisible[$i] !== $visible[$i] |
||
| 575 | || $oldside[$i] !== $side[$i] |
||
| 576 | || $oldbcachetime[$i] !== $bcachetime[$i] |
||
| 577 | || $oldbmodule[$i] !== $bmodule[$i]) { |
||
| 578 | $this->setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]); |
||
| 579 | } |
||
| 580 | if (!empty($bmodule[$i]) && \count($bmodule[$i]) > 0) { |
||
| 581 | $sql = \sprintf('DELETE FROM `%s` WHERE block_id = %u', $this->db->prefix('block_module_link'), $bid[$i]); |
||
| 582 | $this->db->query($sql); |
||
| 583 | if (\in_array(0, $bmodule[$i], true)) { |
||
| 584 | $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], 0); |
||
| 585 | $this->db->query($sql); |
||
| 586 | } else { |
||
| 587 | foreach ($bmodule[$i] as $bmid) { |
||
| 588 | $sql = \sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $this->db->prefix('block_module_link'), $bid[$i], (int)$bmid); |
||
| 589 | $this->db->query($sql); |
||
| 590 | } |
||
| 591 | } |
||
| 592 | } |
||
| 593 | $sql = \sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $this->db->prefix('group_permission'), $bid[$i]); |
||
| 594 | $this->db->query($sql); |
||
| 595 | if (!empty($groups[$i])) { |
||
| 596 | foreach ($groups[$i] as $grp) { |
||
| 597 | $sql = \sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $this->db->prefix('group_permission'), $grp, $bid[$i]); |
||
| 598 | $this->db->query($sql); |
||
| 599 | } |
||
| 600 | } |
||
| 601 | } |
||
| 602 | |||
| 603 | $this->helper->redirect('admin/blocksadmin.php', 1, \constant('CO_' . $this->moduleDirNameUpper . '_' . 'UPDATE_SUCCESS')); |
||
| 604 | } |
||
| 605 | |||
| 606 | public function render(?array $block = null) |
||
| 714 | } |
||
| 715 | } |
||
| 716 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.