function cpn_block_submit in Code per Node 6
Same name and namespace in other branches
- 7 cpn.module \cpn_block_submit()
Block submit callback.
1 string reference to 'cpn_block_submit'
- cpn_form_alter in ./
cpn.module - Implemenation of hook_form_alter().
File
- ./
cpn.module, line 364 - Primary hook implementations.
Code
function cpn_block_submit($form, &$form_state) {
if (isset($form_state['values']['cpn'])) {
$module = $form_state['values']['module'];
$delta = $form_state['values']['delta'];
// "Block" block was just created; get delta from "boxes" table.
if (empty($delta) and $module == 'block') {
$delta = db_result(db_query("SELECT bid FROM {boxes} ORDER BY bid DESC LIMIT 1"));
}
// Save in database.
db_query("UPDATE {blocks} SET css = '%s', js = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['cpn']['css'], $form_state['values']['cpn']['js'], $module, $delta);
foreach (array(
'css',
'js',
) as $type) {
if (!empty($form_state['values']['cpn'][$type])) {
// Delete the existing file.
cpn_delete_file($module . '-' . $delta . '.' . $type);
// Add the global wrapper code.
$output = cpn_wrap_output($form_state['values']['cpn'][$type], 'block', $type);
// Output the file.
if (!empty($output)) {
cpn_save_file($output, $module . '-' . $delta . '.' . $type);
}
}
}
}
}