diff --git a/flag_abuse.module b/flag_abuse.module index 8d6edfc..9c1c3bc 100644 --- a/flag_abuse.module +++ b/flag_abuse.module @@ -43,84 +43,6 @@ function flag_abuse_views_api() { } /** - * Implements hook_permission(). - */ -function flag_abuse_permission() { - return array( - 'reset abuse flags' => array( - 'title' => t('reset abuse flags'), - 'description' => t('Allow the resetting of all flags on a particular node, comment or user.'), - ), - ); -} - -/** - * Implements hook_preprocess_flag(). - * - * Here we change our flag event/action to 'reset'. - */ -function flag_abuse_preprocess_flag(&$vars) { - // Ensure the user has permissions and this is an abuse flag. - if (user_access('reset abuse flags') && flag_abuse_is_abuse_flag($vars['flag']->name)) { - $vars['action'] = 'reset'; - $vars['link_text'] = t('Reset flags'); - $vars['link_title'] = t('Remove all flags on this content'); - } -} - -/** - * Implements hook_flag(). - * - * If a user with appropriate permission/role flags this content from our view - * we want to remove all flags. http://drupal.org/node/327901#comment-1085685 - * - * @todo: When $flag->access() goes in, use this to limit access to a flag that - * an administrator has already acted upon. http://drupal.org/node/322034 - */ -function flag_abuse_flag($event, $flag, $content_id, $account) { - // Ensure the user has permissions and this is an abuse flag. - if (user_access('reset abuse flags', $account) && flag_abuse_is_abuse_flag($flag->name)) { - // remove all flags on this content - $rows = flag_reset_flag($flag, $content_id); - if ($rows) { - // This user actually flags the content as well, so it may confuse the - // user if they reset what they thought was one flag and we report two. - $rows--; - drupal_set_message(t('Reset !rows flags.', array('!rows' => $rows))); - variable_set($flag->name . '-' . $content_id, TRUE); - } - } -} - -/** - * Implements hook_flag_access(). - */ -function flag_abuse_flag_access($flag, $content_id, $action, $account) { - if (flag_abuse_is_abuse_flag($flag->name)) { - // Check to see if this flag has already been reset. - if (variable_get($flag->name . '-' . $content_id, FALSE)) { - return FALSE; - } - } -} - -/** - * Implements hook_form_FORM_ID_alter(). - */ -function flag_abuse_form_flag_confirm_alter(&$form, &$form_state) { - // Ensure the user has permission. - if (user_access('reset abuse flags')) { - $flag_name = $form['flag_name']['#value']; - // Is this one of our abuse flags? - if (flag_abuse_is_abuse_flag($flag_name)) { - drupal_set_title(t('Flag reset')); - $form['description']['#value'] = t('Are you sure you want to reset all offensive flag on this content? Once doing so, users will not be able to flag this content again.'); - $form['actions']['submit']['#value'] = t('Reset flags'); - } - } -} - -/** * Implements hook_features_pipe_flag_alter(). */ function flag_abuse_features_pipe_flag_alter(&$pipe, $data, $export) { diff --git a/includes/flag_abuse.flag_default.inc b/includes/flag_abuse.flag_default.inc index aa16d4e..0ac50fb 100644 --- a/includes/flag_abuse.flag_default.inc +++ b/includes/flag_abuse.flag_default.inc @@ -1,19 +1,13 @@ 'node', - 'name' => 'abuse_node', 'title' => 'Node Abuse', 'global' => 0, 'types' => array( - 0 => 'story', - ), - 'events' => array( - 0 => 'flag', - 1 => 'unflag', - 2 => 'reset', ), 'flag_short' => 'Flag as offensive', 'flag_long' => 'Flag this content as offensive.', @@ -31,40 +25,33 @@ function _flag_abuse_abuse_node_flags(&$flags) { 0 => '2', ), ), - 'show_on_page' => TRUE, - 'show_on_teaser' => FALSE, - 'show_on_form' => FALSE, + 'weight' => 0, + 'show_on_form' => 0, 'access_author' => '', + 'show_on_page' => 1, + 'show_on_teaser' => 0, + 'show_contextual_link' => FALSE, 'i18n' => 0, 'flag_confirmation' => 'Are you sure you want to flag this content as offensive?', 'unflag_confirmation' => 'Are you sure you want to flag this content as non-offensive?', - 'reset_short' => 'Reset flags', - 'reset_long' => 'Reset all flags on this content', - 'reset_confirmation' => 'Are you sure you want to reset all flags on this content?', - 'status' => FALSE, + 'module' => 'flag_abuse', 'locked' => array( 'name' => 'name', 'global' => 'global', ), - 'module' => 'flag_abuse', 'api_version' => 2, ); return $flags; } function _flag_abuse_abuse_comment_flags(&$flags) { + $flags = array(); // Exported flag: "Comment Abuse". - $flags[] = array( + $flags['abuse_comment'] = array( 'content_type' => 'comment', - 'name' => 'abuse_comment', 'title' => 'Comment Abuse', 'global' => 0, 'types' => array( - 0 => 'story', - ), - 'events' => array( - 0 => 'flag', - 1 => 'unflag', ), 'flag_short' => 'Flag as offensive', 'flag_long' => 'Flag this content as offensive.', @@ -82,38 +69,31 @@ function _flag_abuse_abuse_comment_flags(&$flags) { 0 => '2', ), ), + 'weight' => 0, + 'show_on_form' => 0, 'access_author' => '', - 'show_on_comment' => TRUE, + 'show_on_comment' => 1, 'flag_confirmation' => 'Are you sure you want to flag this content as offensive?', 'unflag_confirmation' => 'Are you sure you want to flag this content as non-offensive?', - 'reset_short' => 'Reset flags', - 'reset_long' => 'Reset all flags on this commnet', - 'reset_confirmation' => 'Are you sure you want to reset all flags on this comment?', - 'status' => FALSE, - 'show_on_teaser' => FALSE, + 'module' => 'flag_abuse', 'locked' => array( 'name' => 'name', 'global' => 'global', ), - 'module' => 'flag_abuse', 'api_version' => 2, ); - return $flags; +return $flags; + } function _flag_abuse_abuse_user_flags(&$flags) { + $flags = array(); // Exported flag: "User Abuse". - $flags[] = array( + $flags['abuse_user'] = array( 'content_type' => 'user', - 'name' => 'abuse_user', 'title' => 'User Abuse', 'global' => 0, - 'types' => array( - ), - 'events' => array( - 0 => 'flag', - 1 => 'unflag', - ), + 'types' => array(), 'flag_short' => 'Report User', 'flag_long' => 'Report this user as offensive.', 'flag_message' => '', @@ -130,20 +110,18 @@ function _flag_abuse_abuse_user_flags(&$flags) { 0 => '2', ), ), - 'show_on_profile' => TRUE, + 'weight' => 0, + 'show_on_form' => 0, + 'access_author' => '', + 'show_on_profile' => 1, 'access_uid' => '', 'flag_confirmation' => 'Are you sure you want to report this user as offensive?', 'unflag_confirmation' => 'Are you sure you want to remove your report of this user?', - 'reset_short' => 'Reset flags', - 'reset_long' => 'Reset all flags on this user', - 'reset_confirmation' => 'Are you sure you want to reset all flags on this user?', - 'status' => FALSE, - 'show_on_teaser' => FALSE, + 'module' => 'flag_abuse', 'locked' => array( 'name' => 'name', 'global' => 'global', ), - 'module' => 'flag_abuse', 'api_version' => 2, ); return $flags; diff --git a/includes/flag_abuse.views_default.inc b/includes/flag_abuse.views_default.inc index 779e7b6..44e3997 100644 --- a/includes/flag_abuse.views_default.inc +++ b/includes/flag_abuse.views_default.inc @@ -42,7 +42,7 @@ function _flag_abuse_views_default_abuse_comment(&$views, $flags) { $handler = $view->new_display('default', 'Defaults', 'default'); $handler->display->display_options['title'] = 'Comment Abuse'; $handler->display->display_options['access']['type'] = 'perm'; - $handler->display->display_options['access']['perm'] = 'reset abuse flags'; + $handler->display->display_options['access']['perm'] = 'administer_nodes'; $handler->display->display_options['cache']['type'] = 'none'; $handler->display->display_options['query']['type'] = 'views_query'; $handler->display->display_options['exposed_form']['type'] = 'basic'; @@ -240,7 +240,6 @@ function _flag_abuse_views_default_abuse_comment(&$views, $flags) { t('Comment Abuse'), t('more'), t('Apply'), - t('Reset'), t('Sort By'), t('Asc'), t('Desc'),