View source
<?php
include_once 'commons_content_moderation.features.inc';
function commons_content_moderation_action_info() {
return array(
'commons_content_moderation_delete_node_block_user' => array(
'type' => 'node',
'label' => t("Delete content and block author's account."),
'configurable' => FALSE,
'behavior' => array(
'',
),
'triggers' => array(
'',
),
),
'commons_content_moderation_delete_comment_block_user' => array(
'type' => 'comment',
'label' => t("Delete comment and block author's account."),
'configurable' => FALSE,
'behavior' => array(
'',
),
'triggers' => array(
'',
),
),
);
}
function commons_content_moderation_delete_node_block_user($node, $context = array()) {
if ($node->uid > 1) {
$author = user_load($node->uid);
if ($author->status) {
$author = user_save($author, array(
'status' => 0,
));
watchdog('commons_content_moderation', 'Blocked user %name.', array(
'%name' => format_username($author),
));
}
}
if (module_exists('mollom') && _mollom_flag_access('node', $node)) {
mollom_data_report('node', $node->nid, 'spam');
}
node_delete($node->nid);
watchdog('commons_content_moderation', 'Deleted @type %title.', array(
'@type' => node_type_get_name($node),
'%title' => $node->title,
));
}
function commons_content_moderation_delete_comment_block_user($comment, $context = array()) {
if ($comment->uid > 1) {
$author = user_load($comment->uid);
if ($author->status) {
$author = user_save($author, array(
'status' => 0,
));
watchdog('commons_content_moderation', 'Blocked user %name.', array(
'%name' => format_username($author),
));
}
}
if (module_exists('mollom') && _mollom_flag_access('comment', $comment)) {
mollom_data_report('comment', $comment->cid, 'spam');
}
comment_delete($comment->cid);
watchdog('commons_content_moderation', 'Deleted comment %title.', array(
'%title' => $comment->title,
));
}
function commons_content_moderation_flag_default_flags_alter(&$flags) {
foreach (array(
'abuse_user',
'abuse_comment',
'abuse_node',
'abuse_whitelist_comment',
'abuse_whitelist_node',
'abuse_whitelist_user',
) as $flag_name) {
if (!empty($flags[$flag_name])) {
$flags[$flag_name]['status'] = FALSE;
}
}
}
function commons_content_moderation_views_default_views_alter(&$views) {
foreach (array(
'all_flag_abuse_node',
'all_flag_abuse_comment',
) as $view_name) {
if (!empty($views[$view_name])) {
$views[$view_name]->disabled = TRUE;
}
}
}
function commons_content_moderation_views_pre_build(&$view) {
if ($view->name == 'commons_content_moderation_reported_nodes' && !module_exists('actions_permissions') && (!user_access('administer nodes') || !user_access('administer users'))) {
unset($view->field['views_bulk_operations']);
unset($view->display_handler->handlers['field']['views_bulk_operations']);
}
}
function commons_content_moderation_views_bulk_operations_form_alter(&$form, $form_state, $vbo) {
if (!isset($vbo->options['vbo_operations']['action::commons_content_moderation_delete_node_block_user'])) {
return;
}
if ($form_state['step'] == 'views_form_views_form' && $vbo->options['vbo_operations']['action::commons_content_moderation_delete_node_block_user']['selected'] == 1) {
if (module_exists('mollom') && _mollom_access('report to mollom')) {
$form['mollom_text'] = array(
'#markup' => '<p>' . t('Deleted content will be reported to Mollom.') . '</p>',
);
}
}
}