You are here

function flag_abuse_flag in Flag Abuse 6

Same name and namespace in other branches
  1. 6.2 flag_abuse.module \flag_abuse_flag()

Implementation of 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

File

./flag_abuse.module, line 62

Code

function flag_abuse_flag($event, $flag, $content_id, $account) {

  // permmission check instead of a role
  if (user_access('reset abuse flags', $account)) {

    // is this one of our abuse flags
    // @todo: should be dynamic
    if (in_array($flag->name, array(
      'abuse_node',
      'abuse_comment',
      'abuse_user',
    ))) {

      // remove all flag on this content
      $query = db_query("SELECT uid FROM {flag_content} WHERE fid = %d", $flag->fid);
      while ($result = db_fetch_object($query)) {

        // Supposed to pass in a full $account here, let's see if we can fake it
        $flag
          ->flag('unflag', $content_id, $result, TRUE);
      }
    }
  }
}