| @@ 565-615 (lines=51) @@ | ||
| 562 | * @param integer $isactive |
|
| 563 | * @return array |
|
| 564 | */ |
|
| 565 | public function getNonGroupedBlocks($module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1) |
|
| 566 | { |
|
| 567 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 568 | $ret = array(); |
|
| 569 | $bids = array(); |
|
| 570 | $sql = 'SELECT DISTINCT(bid) from ' . $db->prefix('newblocks'); |
|
| 571 | if ($result = $db->query($sql)) { |
|
| 572 | while ($myrow = $db->fetchArray($result)) { |
|
| 573 | $bids[] = $myrow['bid']; |
|
| 574 | } |
|
| 575 | } |
|
| 576 | $sql = 'SELECT DISTINCT(p.gperm_itemid) from ' . $db->prefix('group_permission') . ' p, ' . $db->prefix('groups') . " g WHERE g.groupid=p.gperm_groupid AND p.gperm_name='block_read'"; |
|
| 577 | $grouped = array(); |
|
| 578 | if ($result = $db->query($sql)) { |
|
| 579 | while ($myrow = $db->fetchArray($result)) { |
|
| 580 | $grouped[] = $myrow['gperm_itemid']; |
|
| 581 | } |
|
| 582 | } |
|
| 583 | $non_grouped = array_diff($bids, $grouped); |
|
| 584 | if (!empty($non_grouped)) { |
|
| 585 | $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid'; |
|
| 586 | $sql .= ' AND b.isactive=' . (int)$isactive; |
|
| 587 | if (isset($visible)) { |
|
| 588 | $sql .= ' AND b.visible=' . (int)$visible; |
|
| 589 | } |
|
| 590 | if (!isset($module_id)) { |
|
| 591 | } elseif (!empty($module_id)) { |
|
| 592 | $sql .= ' AND m.module_id IN (0,' . (int)$module_id; |
|
| 593 | if ($toponlyblock) { |
|
| 594 | $sql .= ',-1'; |
|
| 595 | } |
|
| 596 | $sql .= ')'; |
|
| 597 | } else { |
|
| 598 | if ($toponlyblock) { |
|
| 599 | $sql .= ' AND m.module_id IN (0,-1)'; |
|
| 600 | } else { |
|
| 601 | $sql .= ' AND m.module_id=0'; |
|
| 602 | } |
|
| 603 | } |
|
| 604 | $sql .= ' AND b.bid IN (' . implode(',', $non_grouped) . ')'; |
|
| 605 | $sql .= ' ORDER BY ' . $orderby; |
|
| 606 | $result = $db->query($sql); |
|
| 607 | while ($myrow = $db->fetchArray($result)) { |
|
| 608 | $block = new XoopsBlock($myrow); |
|
| 609 | $ret[$myrow['bid']] =& $block; |
|
| 610 | unset($block); |
|
| 611 | } |
|
| 612 | } |
|
| 613 | ||
| 614 | return $ret; |
|
| 615 | } |
|
| 616 | ||
| 617 | /** |
|
| 618 | * XoopsBlock::countSimilarBlocks() |
|
| @@ 560-610 (lines=51) @@ | ||
| 557 | * |
|
| 558 | * @return array |
|
| 559 | */ |
|
| 560 | public function getNonGroupedBlocks($module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1) |
|
| 561 | { |
|
| 562 | $db = $GLOBALS['xoopsDB']; |
|
| 563 | $ret = array(); |
|
| 564 | $bids = array(); |
|
| 565 | $sql = 'SELECT DISTINCT(bid) from ' . $db->prefix('newblocks'); |
|
| 566 | if ($result = $db->query($sql)) { |
|
| 567 | while ($myrow = $db->fetchArray($result)) { |
|
| 568 | $bids[] = $myrow['bid']; |
|
| 569 | } |
|
| 570 | } |
|
| 571 | $sql = 'SELECT DISTINCT(p.gperm_itemid) from ' . $db->prefix('group_permission') . ' p, ' . $db->prefix('groups') . " g WHERE g.groupid=p.gperm_groupid AND p.gperm_name='block_read'"; |
|
| 572 | $grouped = array(); |
|
| 573 | if ($result = $db->query($sql)) { |
|
| 574 | while ($myrow = $db->fetchArray($result)) { |
|
| 575 | $grouped[] = $myrow['gperm_itemid']; |
|
| 576 | } |
|
| 577 | } |
|
| 578 | $non_grouped = array_diff($bids, $grouped); |
|
| 579 | if (!empty($non_grouped)) { |
|
| 580 | $sql = 'SELECT b.* FROM ' . $db->prefix('newblocks') . ' b, ' . $db->prefix('block_module_link') . ' m WHERE m.block_id=b.bid'; |
|
| 581 | $sql .= ' AND b.isactive=' . (int)$isactive; |
|
| 582 | if (isset($visible)) { |
|
| 583 | $sql .= ' AND b.visible=' . (int)$visible; |
|
| 584 | } |
|
| 585 | if (!isset($module_id)) { |
|
| 586 | } elseif (!empty($module_id)) { |
|
| 587 | $sql .= ' AND m.module_id IN (0,' . (int)$module_id; |
|
| 588 | if ($toponlyblock) { |
|
| 589 | $sql .= ',-1'; |
|
| 590 | } |
|
| 591 | $sql .= ')'; |
|
| 592 | } else { |
|
| 593 | if ($toponlyblock) { |
|
| 594 | $sql .= ' AND m.module_id IN (0,-1)'; |
|
| 595 | } else { |
|
| 596 | $sql .= ' AND m.module_id=0'; |
|
| 597 | } |
|
| 598 | } |
|
| 599 | $sql .= ' AND b.bid IN (' . implode(',', $non_grouped) . ')'; |
|
| 600 | $sql .= ' ORDER BY ' . $orderby; |
|
| 601 | $result = $db->query($sql); |
|
| 602 | while ($myrow = $db->fetchArray($result)) { |
|
| 603 | $block = new XoopsBlock($myrow); |
|
| 604 | $ret[$myrow['bid']] =& $block; |
|
| 605 | unset($block); |
|
| 606 | } |
|
| 607 | } |
|
| 608 | ||
| 609 | return $ret; |
|
| 610 | } |
|
| 611 | ||
| 612 | /** |
|
| 613 | * XoopsBlock::countSimilarBlocks() |
|