示例#1
0
/**
 * Delete a set of selected widgets
 */
function delete_block()
{
    global $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        response(__('Session token expired!', 'rmcommon'), array(), 1, 0);
    }
    $block_id = rmc_server_var($_POST, 'id', 0);
    if ($block_id <= 0) {
        response(__('No block has been specified!', 'rmcommon'), array(), 1, 1);
    }
    $block = new RMInternalBlock($block_id);
    if ($block->isNew()) {
        response(__('Specified block does not exists!', 'rmcommon'), array(), 1, 1);
    }
    if (!$block->delete()) {
        response(sprintf(__('The block "%s" could not be deleted!', 'rmcommon'), $block->getVar('name')), array('error' => $block->errors()), 1, 1);
    } else {
        response(sprintf(__('The block "%s" was deleted successfully!', 'rmcommon'), $block->getVar('name')), array(), 0, 1);
    }
}