function change_block_visibility($visible) { global $xoopsSecurity; $block_id = rmc_server_var($_POST, 'id', 0); if (!$xoopsSecurity->check(false, false)) { response(__('Block visibility could not be saved!', 'rmcommon'), array('error' => __('Session token expired!', 'rmcommon')), 1, 0); } if ($block_id <= 0) { response(__('Block identifier not specified!', 'rmcommon'), array('error' => ''), 1, 0); } $block = new RMInternalBlock($block_id); if ($block->isNew()) { response(__('Specified block does not exists!', 'rmcommon'), array(), 1, 0); } $block->setVar('visible', $visible); if ($block->save()) { response(sprintf(__('The visibility of the block %s was changed successfully!', 'rmcommon'), $block->getVar('name')), array('visible' => $visible), 0, 0); } else { response(sprintf(__('Visibility for block %s could not be changed!', 'rmcommon'), $block->getVar('name')), array('error' => $block->error()), 1, 0); } }