function authcache_example_block_form_submit in Authenticated User Page Caching (Authcache) 7
Same name and namespace in other branches
- 6 modules/authcache_example/authcache_example.module \authcache_example_block_form_submit()
User updated their block
File
- modules/
authcache_example/ authcache_example.module, line 92 - authcache_example.module
Code
function authcache_example_block_form_submit($form, &$form_state) {
$account = $form_state['build_info']['args'][0];
$record = array(
'uid' => $account->uid,
'block_text' => $form_state['values']['block_text'],
);
if ($form_state['storage']['authcache_block']) {
// Update
$res = drupal_write_record('authcache_example', $record, array(
'uid',
));
}
else {
// Save new block
$res = drupal_write_record('authcache_example', $record);
}
if (!$res) {
form_set_error('authcache_example', 'An error occurred. Please consult the logs.');
}
// Invalidate browser cache by modify our cache cookie time
setcookie('authcache_example', REQUEST_TIME, 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
drupal_set_message(t("Your block has been updated."));
}