function sharedblocks_subscribe_form_submit in Shared Blocks 7
Same name and namespace in other branches
- 6 sharedblocks.module \sharedblocks_subscribe_form_submit()
Submit callback for subscription block add/edit form.
File
- ./
sharedblocks.module, line 316
Code
function sharedblocks_subscribe_form_submit($form, &$form_state) {
$values = $form_state['values'];
// Fetch the block from the publishing site.
$block_data = sharedblocks_fetch_block($values['url']);
if (empty($block_data)) {
form_set_error('url', t('Block information not received: Please check your URL.'));
}
else {
// Specify to drupal_write_record() whether we're doing an insert or update.
if (!isset($values['id'])) {
$update = array();
}
else {
$update = array(
'id',
);
$record['id'] = $values['id'];
}
// Prep our values for the database.
$record['name'] = $values['name'];
$record['url'] = $values['url'];
$record['update_interval'] = (int) $values['update_interval'];
$record['block_data'] = serialize($block_data);
$record['description'] = $block_data['subject'];
$record['last_update'] = REQUEST_TIME;
$record['expiration'] = REQUEST_TIME + $values['update_interval'];
// Populate the table with values.
drupal_write_record('sharedblocks', $record, $update);
// Redirect back to the listing page.
$form_state['redirect'] = 'admin/structure/sharedblocks/subscribe';
drupal_set_message(t('Your subscription block has been saved.'));
}
}