function cloudflare_form_comment_admin_overview_alter in CloudFlare 6
Same name and namespace in other branches
- 7 cloudflare.module \cloudflare_form_comment_admin_overview_alter()
Implementation of hook_form_FORM_ID_alter().
File
- ./
cloudflare.module, line 57
Code
function cloudflare_form_comment_admin_overview_alter(&$form, $form_state) {
// If cloudflare hasn't been configured, don't display form alterations.
if (!_is_cloudflare_configured()) {
return $form;
}
// Add some additional options to the comment operations list.
$form['options']['operation']['#options']['Cloudflare Actions'] = array(
'cloudflare_spam' => t('Report Spam'),
'cloudflare_spam_delete' => t('Report Spam + Delete'),
'cloudflare_ban_ip' => t('Ban IP'),
'cloudflare_ban_ip_delete' => t('Ban IP + Delete Comment'),
'cloudflare_whitelist_ip' => t('Whitelist IP'),
'cloudflare_whitelist_ip_publish' => t('Whitelist IP + Publish Comment'),
);
// Variable used when detecting a page postback.
$post_parameters = $form['#parameters'];
//dpm($post_parameters);
// Check to see if the count of comments checked is greater than 0.
if (count($post_parameters[1]['post']['comments']) > 0) {
// Loop through each checked comment to perform selected operation.
foreach ($post_parameters[1]['post']['comments'] as $cid) {
switch ($post_parameters[1]['post']['operation']) {
case 'cloudflare_ban_ip':
_cloudflare_ban_comment($cid, FALSE);
break;
case 'cloudflare_ban_ip_delete':
_cloudflare_ban_comment($cid, TRUE);
break;
case 'cloudflare_whitelist_ip':
_cloudflare_whitelist_comment($cid, FALSE);
break;
case 'cloudflare_whitelist_ip_publish':
_cloudflare_whitelist_comment($cid, TRUE);
break;
case 'cloudflare_spam':
_cloudflare_spam_report($cid, FALSE);
break;
case 'cloudflare_spam_delete':
_cloudflare_spam_report($cid, TRUE);
break;
}
}
}
}