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>';