| @@ 499-553 (lines=55) @@ | ||
| 496 | * @param integer $isactive |
|
| 497 | * @return array |
|
| 498 | */ |
|
| 499 | public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1) |
|
| 500 | { |
|
| 501 | $isactive = (int)$isactive; |
|
| 502 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 503 | $ret = array(); |
|
| 504 | if (isset($groupid)) { |
|
| 505 | $sql = 'SELECT DISTINCT gperm_itemid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name = 'block_read' AND gperm_modid = 1"; |
|
| 506 | if (is_array($groupid)) { |
|
| 507 | $sql .= ' AND gperm_groupid IN (' . implode(',', $groupid) . ')'; |
|
| 508 | } else { |
|
| 509 | if ((int)$groupid > 0) { |
|
| 510 | $sql .= ' AND gperm_groupid=' . (int)$groupid; |
|
| 511 | } |
|
| 512 | } |
|
| 513 | $result = $db->query($sql); |
|
| 514 | $blockids = array(); |
|
| 515 | while ($myrow = $db->fetchArray($result)) { |
|
| 516 | $blockids[] = $myrow['gperm_itemid']; |
|
| 517 | } |
|
| 518 | if (empty($blockids)) { |
|
| 519 | return $blockids; |
|
| 520 | } |
|
| 521 | } |
|
| 522 | $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid'; |
|
| 523 | $sql .= ' AND b.isactive=' . $isactive; |
|
| 524 | if (isset($visible)) { |
|
| 525 | $sql .= ' AND b.visible=' . (int)$visible; |
|
| 526 | } |
|
| 527 | if (!isset($module_id)) { |
|
| 528 | } elseif (!empty($module_id)) { |
|
| 529 | $sql .= ' AND m.module_id IN (0,' . (int)$module_id; |
|
| 530 | if ($toponlyblock) { |
|
| 531 | $sql .= ',-1'; |
|
| 532 | } |
|
| 533 | $sql .= ')'; |
|
| 534 | } else { |
|
| 535 | if ($toponlyblock) { |
|
| 536 | $sql .= ' AND m.module_id IN (0,-1)'; |
|
| 537 | } else { |
|
| 538 | $sql .= ' AND m.module_id=0'; |
|
| 539 | } |
|
| 540 | } |
|
| 541 | if (!empty($blockids)) { |
|
| 542 | $sql .= ' AND b.bid IN (' . implode(',', $blockids) . ')'; |
|
| 543 | } |
|
| 544 | $sql .= ' ORDER BY ' . $orderby; |
|
| 545 | $result = $db->query($sql); |
|
| 546 | while ($myrow = $db->fetchArray($result)) { |
|
| 547 | $block = new XoopsBlock($myrow); |
|
| 548 | $ret[$myrow['bid']] = &$block; |
|
| 549 | unset($block); |
|
| 550 | } |
|
| 551 | ||
| 552 | return $ret; |
|
| 553 | } |
|
| 554 | ||
| 555 | /** |
|
| 556 | * XoopsBlock::getNonGroupedBlocks() |
|
| @@ 495-549 (lines=55) @@ | ||
| 492 | * |
|
| 493 | * @return array |
|
| 494 | */ |
|
| 495 | public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1) |
|
| 496 | { |
|
| 497 | $isactive = (int)$isactive; |
|
| 498 | $db = $GLOBALS['xoopsDB']; |
|
| 499 | $ret = array(); |
|
| 500 | if (isset($groupid)) { |
|
| 501 | $sql = 'SELECT DISTINCT gperm_itemid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name = 'block_read' AND gperm_modid = 1"; |
|
| 502 | if (is_array($groupid)) { |
|
| 503 | $sql .= ' AND gperm_groupid IN (' . implode(',', $groupid) . ')'; |
|
| 504 | } else { |
|
| 505 | if ((int)$groupid > 0) { |
|
| 506 | $sql .= ' AND gperm_groupid=' . (int)$groupid; |
|
| 507 | } |
|
| 508 | } |
|
| 509 | $result = $db->query($sql); |
|
| 510 | $blockids = array(); |
|
| 511 | while ($myrow = $db->fetchArray($result)) { |
|
| 512 | $blockids[] = $myrow['gperm_itemid']; |
|
| 513 | } |
|
| 514 | if (empty($blockids)) { |
|
| 515 | return $blockids; |
|
| 516 | } |
|
| 517 | } |
|
| 518 | $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid'; |
|
| 519 | $sql .= ' AND b.isactive=' . $isactive; |
|
| 520 | if (isset($visible)) { |
|
| 521 | $sql .= ' AND b.visible=' . (int)$visible; |
|
| 522 | } |
|
| 523 | if (!isset($module_id)) { |
|
| 524 | } elseif (!empty($module_id)) { |
|
| 525 | $sql .= ' AND m.module_id IN (0,' . (int)$module_id; |
|
| 526 | if ($toponlyblock) { |
|
| 527 | $sql .= ',-1'; |
|
| 528 | } |
|
| 529 | $sql .= ')'; |
|
| 530 | } else { |
|
| 531 | if ($toponlyblock) { |
|
| 532 | $sql .= ' AND m.module_id IN (0,-1)'; |
|
| 533 | } else { |
|
| 534 | $sql .= ' AND m.module_id=0'; |
|
| 535 | } |
|
| 536 | } |
|
| 537 | if (!empty($blockids)) { |
|
| 538 | $sql .= ' AND b.bid IN (' . implode(',', $blockids) . ')'; |
|
| 539 | } |
|
| 540 | $sql .= ' ORDER BY ' . $orderby; |
|
| 541 | $result = $db->query($sql); |
|
| 542 | while ($myrow = $db->fetchArray($result)) { |
|
| 543 | $block = new XoopsBlock($myrow); |
|
| 544 | $ret[$myrow['bid']] =& $block; |
|
| 545 | unset($block); |
|
| 546 | } |
|
| 547 | ||
| 548 | return $ret; |
|
| 549 | } |
|
| 550 | ||
| 551 | /** |
|
| 552 | * @param int $module_id |
|