function multiblock_add_form_submit in MultiBlock 5
Same name and namespace in other branches
- 6 multiblock.module \multiblock_add_form_submit()
- 7 multiblock.module \multiblock_add_form_submit()
Add block instance to database from "Add Block Instance" form.
File
- ./
multiblock.module, line 242
Code
function multiblock_add_form_submit($form_id, $form_values) {
if (isset($form_values['instance'])) {
db_query("UPDATE {multiblock} SET title='%s' WHERE delta=%d", $form_values['title'], $form_values['instance']);
return 'admin/build/block/instances';
}
// Get the original block info.
$orig_block = multiblock_blockinfo_from_form($form_values['block']);
// Check whether this module is multiblock enabled.
$mb_enabled = (int) (module_invoke($orig_block['module'], 'block', 'mb_enabled') == 'mb_enabled');
// Create block instance information.
$orig_block = (object) $orig_block;
$instance = (object) array(
'title' => $form_values['title'],
'mb_enabled' => $mb_enabled,
);
// Add the block instance.
multiblock_add($orig_block, $instance);
drupal_set_message(t('Block instance %instance created.', array(
'%instance' => $form_values['title'],
)));
}