function spam_admin_overview_submit in Spam 6
Same name and namespace in other branches
- 5.3 spam.module \spam_admin_overview_submit()
Submit the spam administration update form. Reusable for content submodules. This should probably be a TODO for going into the API docs, and replacing some custom submits. Submodules will need to define #spam_submit_valuetype and #spam_submit_itemtype in their forms. Should also specify their wanted callbacks as a subset of spam_spam_operations() (see spam_admin_overview for example).
1 string reference to 'spam_admin_overview_submit'
- comment_spamapi_form_alter in content/
spam_content_comment.inc - Form alter gets its own function so we can reference &$form without causing errors in PHP4 installations. (If we use spamapi, we have to set a default, which PHP4 doesn't support.)
File
- ./
spam.module, line 1392 - Spam module, v3 Copyright(c) 2006-2008 Jeremy Andrews <jeremy@tag1consulting.com>. All rights reserved.
Code
function spam_admin_overview_submit($form, &$form_state) {
$operations = module_invoke_all('spam_operations');
if ($operations[$form_state['values']['operation']]) {
$operation = $operations[$form_state['values']['operation']];
if (!($valuetype = $form['#spam_submit_valuetype'])) {
$valuetype = "spam";
}
// Filter out unchecked nodes
//$spam = array_filter($form_state['values'][$valuetype]);
if ($form['#spam_submit_itemtype']) {
foreach ($form_state['values'][$valuetype] as $item => $content) {
$spam["{$form['#spam_submit_itemtype']}-{$item}"] = "{$form['#spam_submit_itemtype']}-{$item}";
}
}
else {
$spam = $form_state['values'][$valuetype];
}
if ($function = $operation['callback']) {
// Add in callback arguments if present.
if (isset($operation['callback arguments'])) {
$args = array_merge(array(
$spam,
), $operation['callback arguments']);
}
else {
$args = array(
$spam,
);
}
call_user_func_array($function, $args);
cache_clear_all();
drupal_set_message(t('The update has been performed.'));
}
}
}