function save_block_config() { global $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check($XOOPS_TOKEN_REQUEST)) { response(__('Session token expired. Please try again.', 'rmcommon'), array(), 1, 0); } if ($bid <= 0) { response(__('You must provide a block ID!', 'rmcommon'), array(), 1, 1); } $block = new RMInternalBlock($bid); if ($block->isNew()) { response(__('Specified block does not exists!', 'rmcommon'), array(), 1, 1); } if (isset($options)) { $block->setVar('options', serialize($options)); } $block->setVar('name', $bk_name); $block->setVar('canvas', $bk_pos); $block->setVar('weight', $bk_weight); $block->setVar('visible', $bk_visible); $block->setVar('bcachetime', $bk_cache); if (isset($bk_content)) { $block->setVar('content', $bk_content); $block->setVar('content_type', $bk_ctype); } // Set modules $block->sections($bk_mod); // Set Groups $block->setReadGroups($bk_groups); if (!$block->save()) { response(sprintf(__('Settings for the block "%s" could not be saved!', 'rmcommon'), $block->getVar('name')), array('error' => $block->errors()), 1, 1); } RMEvents::get()->run_event('rmcommon.block.saved', $block); $ret = array('id' => $block->id(), 'canvas' => $block->getVar('canvas'), 'visible' => $block->getVar('visible'), 'weight' => $block->getVar('weight')); response(sprintf(__('Settings for block "%s" were saved successfully!', 'rmcommon'), $block->getVar('name')), $ret, 0, 1); die; }
function save_block_config() { global $xoopsSecurity; foreach ($_POST as $k => $v) { ${$k} = $v; } if (!$xoopsSecurity->check($XOOPS_TOKEN_REQUEST)) { response(array('message' => __('Session token expired. Please try again.', 'rmcommon')), 1, 0); die; } if ($bid <= 0) { response(array('message' => __('You must provide a block ID!', 'rmcommon')), 1, 1); die; } $block = new RMInternalBlock($bid); if ($block->isNew()) { response(array('message' => __('Specified block does not exists!', 'rmcommon')), 1, 1); die; } if (isset($options)) { $block->setVar('options', serialize($options)); } $block->setVar('name', $bk_name); $block->setVar('canvas', $bk_pos); $block->setVar('weight', $bk_weight); $block->setVar('visible', $bk_visible); $block->setVar('bcachetime', $bk_cache); if (isset($bk_content)) { $block->setVar('content', $bk_content); $block->setVar('content_type', $bk_ctype); } // Set modules $block->sections($bk_mod); // Set Groups $block->setReadGroups($bk_groups); if ($block->save()) { response(array('message' => __('Block updated successfully!', 'rmcommon')), 0, 1); } die; }