Exemplo n.º 1
0
 function order_block($bid, $weight, $visible, $side)
 {
     $myblock = new XoopsBlock($bid);
     $myblock->setVar('weight', $weight);
     $myblock->setVar('visible', $visible);
     $myblock->setVar('side', $side);
     $myblock->store();
 }
Exemplo n.º 2
0
function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options = array())
{
    global $xoopsConfig;
    if (empty($bmodule)) {
        xoops_cp_header();
        xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
        xoops_cp_footer();
        exit;
    }
    $myblock = new XoopsBlock($bid);
    // $myblock->setVar('side', $bside); GIJ -
    if ($bside >= 0) {
        $myblock->setVar('side', $bside);
    }
    // GIJ +
    $myblock->setVar('weight', $bweight);
    $myblock->setVar('visible', $bvisible);
    $myblock->setVar('title', $btitle);
    $myblock->setVar('content', $bcontent);
    $myblock->setVar('bcachetime', $bcachetime);
    if (isset($options) && count($options) > 0) {
        $options = implode('|', $options);
        $myblock->setVar('options', $options);
    }
    if ($myblock->getVar('block_type') == 'C') {
        switch ($bctype) {
            case 'H':
                $name = _AM_CUSTOMHTML;
                break;
            case 'P':
                $name = _AM_CUSTOMPHP;
                break;
            case 'S':
                $name = _AM_CUSTOMSMILE;
                break;
            default:
                $name = _AM_CUSTOMNOSMILE;
                break;
        }
        $myblock->setVar('name', $name);
        $myblock->setVar('c_type', $bctype);
    } else {
        $myblock->setVar('c_type', 'H');
    }
    $msg = _AM_DBUPDATED;
    if ($myblock->store() != false) {
        $db =& Database::getInstance();
        $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
        $db->query($sql);
        foreach ($bmodule as $bmid) {
            $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid));
            $db->query($sql);
        }
        include_once XOOPS_ROOT_PATH . '/class/template.php';
        $xoopsTpl = new XoopsTpl();
        $xoopsTpl->xoops_setCaching(2);
        if ($myblock->getVar('template') != '') {
            if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'))) {
                if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'))) {
                    $msg = 'Unable to clear cache for block ID' . $bid;
                }
            }
        } else {
            if ($xoopsTpl->is_cached('db:system_dummy.html', 'block' . $bid)) {
                if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block' . $bid)) {
                    $msg = 'Unable to clear cache for block ID' . $bid;
                }
            }
        }
    } else {
        $msg = 'Failed update of block. ID:' . $bid;
    }
    // redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg);
    // exit(); GIJ -
    return $msg;
    // GIJ +
}
Exemplo n.º 3
0
function order_block($bid, $weight, $visible, $side, $title, $bmodule, $bcachetime)
{
    $myblock = new XoopsBlock($bid);
    $myblock->setVar('title', $title);
    $myblock->setVar('weight', $weight);
    $myblock->setVar('visible', $visible);
    $myblock->setVar('side', $side);
    $myblock->setVar('bcachetime', $bcachetime);
    $myblock->store();
    $db =& Database::getInstance();
    $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
    $db->queryF($sql);
    foreach ($bmodule as $bmid) {
        $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid));
        $db->queryF($sql);
    }
}
 function do_edit($bid)
 {
     $bid = intval($bid);
     if ($bid <= 0) {
         // new custom block
         $new_block = new XoopsBlock();
         $new_block->setNew();
         $new_block->setVar('name', $this->get_blockname_from_ctype('C'));
         $new_block->setVar('block_type', 'C');
         $new_block->setVar('func_num', 0);
         $bid = $new_block->store();
         $request = $this->fetchRequest4Block(0);
         // permission copy
         foreach ($GLOBALS['xoopsUser']->getGroups() as $gid) {
             $sql = "INSERT INTO " . $this->db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ({$gid}, {$bid}, 1, 'block_read')";
             $this->db->query($sql);
         }
     } else {
         $request = $this->fetchRequest4Block($bid);
     }
     // update the block by the request
     $msg = $this->update_block($bid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array());
     // block_module_link update
     $this->updateBlockModuleLink($bid, $request['bmodule']);
     // group_permission update
     $this->updateBlockReadGroupPerm($bid, $request['bgroup']);
     return $msg;
 }
Exemplo n.º 5
0
             $name = _AM_CUSTOMPHP;
             break;
         case 'S':
             $name = _AM_CUSTOMSMILE;
             break;
         default:
             $name = _AM_CUSTOMNOSMILE;
             break;
     }
     $myblock->setVar('name', $name);
     $myblock->setVar('c_type', $bctype);
 } else {
     $myblock->setVar('c_type', 'H');
 }
 $msg = _AM_DBUPDATED;
 if ($myblock->store() != false) {
     $db =& Database::getInstance();
     $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
     $db->query($sql);
     foreach ($_POST['bmodule'] as $bmid) {
         $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid));
         $db->query($sql);
     }
     include_once XOOPS_ROOT_PATH . '/class/template.php';
     $xoopsTpl = new XoopsTpl();
     $xoopsTpl->xoops_setCaching(2);
     if ($myblock->getVar('template') != '') {
         if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'), 'blk_' . $myblock->getVar('bid'))) {
             if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'), 'blk_' . $myblock->getVar('bid'))) {
                 $msg = 'Unable to clear cache for block ID ' . $bid;
             }
 /**
  * set block position
  *
  * @access public
  * @param int $bid block id
  * @param bool $visible visible flag
  * @param int $side
  *        0: sideblock - left
  *        1: sideblock - right
  *        2: sideblock - left and right
  *        3: centerblock - left
  *        4: centerblock - right
  *        5: centerblock - center
  *        6: centerblock - left, right, center
  * @param int $weight weight
  * @return bool false if failure
  */
 function setBlockPosition($bid, $visible, $side, $weight)
 {
     $block = new XoopsBlock();
     $block->load($bid);
     if (!is_null($visible)) {
         $block->setVar('visible', $visible ? 1 : 0, true);
         // not gpc
     }
     if (!is_null($side)) {
         $block->setVar('side', $side, true);
         // not gpc
     }
     if (!is_null($weight)) {
         $block->setVar('weight', $weight, true);
         // not gpc
     }
     return $block->store();
 }