29
There is a hack involved in the blocks..
You need to do the following.. in /class/xoopsblocks.php
This is an example from the 2.3.4 build of Multisite for XOOPS Lite edition.
function getAllBlocksByGroup($groupid, $asobject = true, $side = null, $visible = null, $orderby = "b.weight,b.bid", $isactive = 1)
{
global $multisite_module;
$db = &XoopsDatabaseFactory::getDatabaseConnection();
$ret = array();
if (! $asobject) {
$sql = 'SELECT b.bid ';
} else {
$sql = 'SELECT b.* ';
}
$sql .= "FROM " . $db->prefix("newblocks") . " b LEFT JOIN " . $db->prefix("group_permission") . " l ON l.gperm_itemid=b.bid WHERE gperm_name = 'block_read' AND gperm_modid = 1";
if (is_array($groupid)) {
$sql .= " AND (l.gperm_groupid=" . $groupid[0] . "";
$size = count($groupid);
if ($size > 1) {
for($i = 1; $i < $size; $i ++) {
$sql .= " OR l.gperm_groupid=" . $groupid[$i] . "";
}
}
$sql .= ")";
} else {
$sql .= " AND l.gperm_groupid=" . $groupid . "";
}
$sql .= " AND b.isactive=" . $isactive;
if (isset($side)) {
// get both sides in sidebox? (some themes need this)
if ($side == XOOPS_SIDEBLOCK_BOTH) {
$side = "(b.side=0 OR b.side=1)";
} elseif ($side == XOOPS_CENTERBLOCK_ALL) {
$side = "(b.side=3 OR b.side=4 OR b.side=5 OR b.side=7 OR b.side=8 OR b.side=9 )";
} else {
$side = "b.side=" . $side;
}
$sql .= " AND " . $side;
}
if (isset($visible)) {
$sql .= " AND b.visible=$visible";
}
if ($multisite_module->isActive())
$sql .= " AND (b.domains like '|all%' or b.domains like '%|".str_replace('www.','',strtolower($_SERVER['HTTP_HOST']))."%')";
$sql .= " ORDER BY $orderby";
$result = $db->query($sql);
$added = array();
while ($myrow = $db->fetchArray($result)) {
if (! in_array($myrow['bid'], $added)) {
if (! $asobject) {
$ret[] = $myrow['bid'];
} else {
$ret[] = new XoopsBlock($myrow);
}
array_push($added, $myrow['bid']);
}
}
return $ret;
}
/**
* XoopsBlock::getAllBlocks()
*
* @param string $rettype
* @param mixed $side
* @param mixed $visible
* @param string $orderby
* @param integer $isactive
* @return
*/
function getAllBlocks($rettype = "object", $side = null, $visible = null, $orderby = "side,weight,bid", $isactive = 1)
{
global $multisite_module;
$db = &XoopsDatabaseFactory::getDatabaseConnection();
$ret = array();
$where_query = " WHERE isactive=" . $isactive;
if (isset($side)) {
// get both sides in sidebox? (some themes need this)
if ($side == 2) {
$side = "(side=0 OR side=1)";
} elseif ($side == 6) {
$side = "(side=3 OR side=4 OR side=5 OR side=7 OR side=8 OR side=9)";
} else {
$side = "side=" . $side;
}
$where_query .= " AND " . $side;
}
if (isset($visible)) {
$where_query .= " AND visible=.". $visible;
}
if ($multisite_module->isActive())
$sql .= " AND (domains like '|all%' or domains like '%|".str_replace('www.','',strtolower($_SERVER['HTTP_HOST']))."%')";
$where_query .= " ORDER BY ".$orderby;
switch ($rettype) {
case "object":
$sql = "SELECT * FROM " . $db->prefix("newblocks") . "" . $where_query;
$result = $db->query($sql);
while ($myrow = $db->fetchArray($result)) {
$ret[] = new XoopsBlock($myrow);
}
break;
case "list":
$sql = "SELECT * FROM " . $db->prefix("newblocks") . "" . $where_query;
$result = $db->query($sql);
while ($myrow = $db->fetchArray($result)) {
$block = new XoopsBlock($myrow);
$title = $block->getVar("title");
$title = empty($title) ? $block->getVar("name") : $title;
$ret[$block->getVar("bid")] = $title;
}
break;
case "id":
$sql = "SELECT bid FROM " . $db->prefix("newblocks") . "" . $where_query;
$result = $db->query($sql);
while ($myrow = $db->fetchArray($result)) {
$ret[] = $myrow['bid'];
}
break;
}
//echo $sql;
return $ret;
}
/**
* XoopsBlock::getByModule()
*
* @param mixed $moduleid
* @param mixed $asobject
* @return
*/
function getByModule($moduleid, $asobject = true)
{
global $multisite_module;
$moduleid = intval($moduleid);
$db = &XoopsDatabaseFactory::getDatabaseConnection();
if ($asobject == true) {
$sql = $sql = "SELECT * FROM " . $db->prefix("newblocks") . " WHERE mid=" . $moduleid;
} else {
$sql = "SELECT bid FROM " . $db->prefix("newblocks") . " WHERE mid=" . $moduleid;
}
if ($multisite_module->isActive())
$sql .= " AND (domains like '|all%' or domains like '%|".str_replace('www.','',strtolower($_SERVER['HTTP_HOST']))."%')";
$result = $db->query($sql);
$ret = array();
while ($myrow = $db->fetchArray($result)) {
if ($asobject) {
$ret[] = new XoopsBlock($myrow);
} else {
$ret[] = $myrow['bid'];
}
}
return $ret;
}
the part that needs to be added is:
$sql .= " AND (b.domains like '|all%' or b.domains like '%|".str_replace('www.','',strtolower($_SERVER['HTTP_HOST']))."
You will see where this is added (If you are doing a production machine the all you have to do is add this line where you see in the first code example.