Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
608 views
in Q2A Core by

I have written my own plugin (not released) just to see the users who flagged, as well as the posts they flagged.

This is not a fancy thing to do, so I would like to see this in core under /admin/flagged

Basically, the query looks like this:

            $queryRecentFlags = qa_db_query_sub("SELECT postid,userid,flag
                                            FROM `^uservotes`
                                            WHERE `flag` = 1
                                            ORDER BY userid DESC);

 

This will contain all the necessary data...

 

In case you might ask, why this is necessary: From the member that flagged a post as Spam I can see (by time of membership and if I know the name etc.) if the spam flag is serious or just a kid...

@gidgreen: Implementation into core should be done fast.

by
That's nice, mind sharing the plugin?
by
I merged 3 of my plugins into one, it lists duplicates questions, recent closed questions, and flagged questions.

Sharing... of course, give me some time to tidy up. (1 week or so) :)

1 Answer

0 votes
by

plugin code to list all flagged questions with member names.

$queryRecentFlags = qa_db_query_sub("SELECT postid,userid,flag
                                FROM `^uservotes`
                                WHERE `flag` = 1
                                ORDER BY userid DESC;");
                                
// initiate output string
$flaggersList = "<table> <thead><tr><th class='column1'>Post-ID</th> <th class='column2'>Flagged by</th> </tr></thead>";
$flagCount = 0;
while ( ($flagrow = qa_db_read_one_assoc($queryRecentFlags,true)) !== null ) {
    $flagCount++;
    
    // query recent user
    $currentUser = $flagrow['userid'];
    $userrow = qa_db_select_with_pending( qa_db_user_account_selectspec($currentUser, true) );

    // get link to post from postid
    $linkToPost = "";
    $postid = $flagrow['postid'];
    $getPostType = mysql_fetch_array( qa_db_query_sub("SELECT type,parentid FROM `^posts` WHERE `postid` = ".$postid) );
    $postType = $getPostType[0]; // type, and $getPostType[1] is parentid
    if($postType=="A") {
        $getQtitle = mysql_fetch_array( qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = ".$getPostType[1]." LIMIT 1") );
        $qTitle = (isset($getQtitle[0])) ? $getQtitle[0] : "";
        // get correct public URL
        $activity_url = qa_path_html(qa_q_request($getPostType[1], $qTitle), null, qa_opt('site_url'), null, null);
        $linkToPost = $activity_url."?show=".$postid."#a".$postid;
    }
    else if($postType=="C") {
        // get question link from answer
        $getQlink = mysql_fetch_array( qa_db_query_sub("SELECT parentid,type FROM `^posts` WHERE `postid` = '".$getPostType[1]."' LIMIT 1") );
        $linkToQuestion = $getQlink[0];
        if($getQlink[1]=="A") {
            $getQtitle = mysql_fetch_array( qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = '".$getQlink[0]."' LIMIT 1") );
            $qTitle = (isset($getQtitle[0])) ? $getQtitle[0] : "";
            // get correct public URL
            $activity_url = qa_path_html(qa_q_request($linkToQuestion, $qTitle), null, qa_opt('site_url'), null, null);
            $linkToPost = $activity_url."?show=".$postid."#c".$postid;
        }
        else {
            // default: comment on question
            $getQtitle = mysql_fetch_array( qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = '".$getPostType[1]."' LIMIT 1") );
            $qTitle = (isset($getQtitle[0])) ? $getQtitle[0] : "";
            // get correct public URL
            $activity_url = qa_path_html(qa_q_request($getPostType[1], $qTitle), null, qa_opt('site_url'), null, null);
            $linkToPost = $activity_url."?show=".$postid."#c".$postid;
        }
    }
    else {
        // question has correct postid to link
        $getQtitle = mysql_fetch_array( qa_db_query_sub("SELECT title FROM `^posts` WHERE `postid` = ".$postid." LIMIT 1") );
        $qTitle = (isset($getQtitle[0])) ? $getQtitle[0] : "";
        // get correct public URL
        $activity_url = qa_path_html(qa_q_request($postid, $qTitle), null, qa_opt('site_url'), null, null);
        $linkToPost = $activity_url;
    }

                
    // for output
    $flaggersList .= '<tr><td><a target="_blank" href="'.$linkToPost.'">'.$qTitle.'</a></td> <td>'. qa_get_user_avatar_html($userrow['flags'], $userrow['email'], $userrow['handle'], $userrow['avatarblobid'], $userrow['avatarwidth'], $userrow['avatarheight'], qa_opt('avatar_users_size'), false) . ' ' . qa_get_one_user_html($userrow['handle'], false) . '</td></tr>';
}
$flaggersList .= "</table>";


// output into theme
$qa_content['custom'.++$c]='<div class="flaggerslist" style="border-radius:0; padding:0;">';
$qa_content['custom'.++$c]='<h2>Flagged Questions</h2>';
$qa_content['custom'.++$c]= $flaggersList;
$qa_content['custom'.++$c]='</div>';

...