| 1 |
<?php |
<?php |
| 2 |
// $Id: spam.module,v 1.51.4.1.2.41.2.30.2.15 2009/08/06 21:06:49 jeremy Exp $ |
// $Id: spam.module,v 1.51.4.1.2.41.2.30.2.16 2009/08/10 03:03:11 gnassar Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1066 |
$form['delete'] = array( |
$form['delete'] = array( |
| 1067 |
'#type' => 'submit', |
'#type' => 'submit', |
| 1068 |
'#value' => t('Delete feedback'), |
'#value' => t('Delete feedback'), |
| 1069 |
|
'#submit' => array('spam_admin_feedback_delete_submit'), |
| 1070 |
); |
); |
| 1071 |
$form['cancel'] = array( |
$form['cancel'] = array( |
| 1072 |
'#value' => l(t('Cancel'), 'admin/content/spam/feedback'), |
'#value' => l(t('Cancel'), 'admin/content/spam/feedback'), |
| 1100 |
* Process spam feedback. |
* Process spam feedback. |
| 1101 |
*/ |
*/ |
| 1102 |
function spam_admin_feedback_form_submit($form, &$form_state) { |
function spam_admin_feedback_form_submit($form, &$form_state) { |
| 1103 |
/* TODO The 'op' element in the form values is deprecated. |
$content = unserialize($form_state['values']['content']); |
| 1104 |
Each button can have #validate and #submit functions associated with it. |
// mark the content as not spam |
| 1105 |
Thus, there should be one button that submits the form and which invokes |
$extra['content'] = $content; |
| 1106 |
the normal form_id_validate and form_id_submit handlers. Any additional |
spam_mark_as_not_spam($form_state['values']['type'], $form_state['values']['id'], $extra); |
| 1107 |
buttons which need to invoke different validate or submit functionality |
// publish the content |
| 1108 |
should have button-specific functions. */ |
// TODO: don't execute form if content is already published |
| 1109 |
if ($form_state['values']['op'] == t('Publish content')) { |
// return will contain a url to the new content |
| 1110 |
$content = unserialize($form_state['values']['content']); |
$form = unserialize($form_state['values']['spam_form']); |
| 1111 |
// mark the content as not spam |
$_SESSION['bypass_spam_filter'] = _spam_sign($form['#post']['form_token']); |
| 1112 |
$extra['content'] = $content; |
$form_state = array(); |
| 1113 |
spam_mark_as_not_spam($form_state['values']['type'], $form_state['values']['id'], $extra); |
$return = drupal_process_form($content['form_id'], $form, $form_state); |
| 1114 |
// publish the content |
db_query('DELETE FROM {spam_filters_errors} WHERE bid = %d', $form_state['values']['bid']); |
| 1115 |
// TODO: don't execute form if content is already published |
drupal_set_message(t('Content published.')); |
| 1116 |
// return will contain a url to the new content |
drupal_goto('admin/content/spam/feedback'); |
| 1117 |
$form = unserialize($form_state['values']['spam_form']); |
} |
| 1118 |
$_SESSION['bypass_spam_filter'] = _spam_sign($form['#post']['form_token']); |
|
| 1119 |
$return = drupal_process_form($content['form_id'], unserialize($form_state['values']['spam_form'])); |
function spam_admin_feedback_delete_submit($form, &$form_state) { |
| 1120 |
db_query('DELETE FROM {spam_filters_errors} WHERE bid = %d', $form_state['values']['bid']); |
// TODO: Confirm the delete. |
| 1121 |
drupal_set_message(t('Content published.')); |
db_query('DELETE FROM {spam_filters_errors} WHERE bid = %d', $form_state['values']['bid']); |
| 1122 |
drupal_goto('admin/content/spam/feedback'); |
drupal_set_message(t('Feedback deleted.')); |
| 1123 |
} |
drupal_goto('admin/content/spam/feedback'); |
|
/* TODO The 'op' element in the form values is deprecated. |
|
|
Each button can have #validate and #submit functions associated with it. |
|
|
Thus, there should be one button that submits the form and which invokes |
|
|
the normal form_id_validate and form_id_submit handlers. Any additional |
|
|
buttons which need to invoke different validate or submit functionality |
|
|
should have button-specific functions. */ |
|
|
if ($form_state['values']['op'] == t('Delete feedback')) { |
|
|
// TODO: Confirm the delete. |
|
|
db_query('DELETE FROM {spam_filters_errors} WHERE bid = %d', $form_state['values']['bid']); |
|
|
drupal_set_message(t('Feedback deleted.')); |
|
|
drupal_goto('admin/content/spam/feedback'); |
|
|
} |
|
| 1124 |
} |
} |
| 1125 |
|
|
| 1126 |
function _spam_truncate($text, $length = 64) { |
function _spam_truncate($text, $length = 64) { |
| 1216 |
*/ |
*/ |
| 1217 |
function spam_filter_form_submit($form, &$form_state) { |
function spam_filter_form_submit($form, &$form_state) { |
| 1218 |
$filters = spam_overview_filters(); |
$filters = spam_overview_filters(); |
|
/* TODO The 'op' element in the form values is deprecated. |
|
|
Each button can have #validate and #submit functions associated with it. |
|
|
Thus, there should be one button that submits the form and which invokes |
|
|
the normal form_id_validate and form_id_submit handlers. Any additional |
|
|
buttons which need to invoke different validate or submit functionality |
|
|
should have button-specific functions. */ |
|
| 1219 |
switch ($form_state['values']['op']) { |
switch ($form_state['values']['op']) { |
| 1220 |
case t('Filter'): |
case t('Filter'): |
| 1221 |
case t('Refine'): |
case t('Refine'): |
| 1577 |
* Helper function, generate a link for reporting mis-filtered content. |
* Helper function, generate a link for reporting mis-filtered content. |
| 1578 |
*/ |
*/ |
| 1579 |
function _spam_error_link($text) { |
function _spam_error_link($text) { |
|
// TODO: Finish implementing error reporting functionality. |
|
|
//return t('Unable to generate error link. Please email the site admins.'); |
|
| 1580 |
if (($text) && is_array(unserialize($text))) { |
if (($text) && is_array(unserialize($text))) { |
| 1581 |
return l(t('Report spam filter error.'), "spam/denied/error/" . md5($text) .'/'. _spam_sign($text)); |
return l(t('Report spam filter error.'), "spam/denied/error/" . md5($text) .'/'. _spam_sign($text)); |
| 1582 |
} |
} |