Commit e81b2ccf by Scott

Fetch duplicate posts, add to question when hidden

parent b7cb0a56
......@@ -46,7 +46,7 @@
}
function qa_page_q_load_c_follows($question, $childposts, $achildposts)
function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplicateposts=array())
/*
Given a $question, its $childposts and its answers $achildposts from the database,
return a list of comments or follow-on questions for that question or its answers
......@@ -74,6 +74,10 @@
break;
}
foreach ($duplicateposts as $postid => $post) {
$commentsfollows[$postid] = $post;
}
return $commentsfollows;
}
......@@ -185,9 +189,10 @@
// Now make any changes based on the child posts
if (isset($childposts))
foreach ($childposts as $childpost)
if (isset($childposts)) {
foreach ($childposts as $childpost) {
if ($childpost['parentid']==$post['postid']) {
// this post has comments
$rules['deleteable']=false;
if (($childpost['basetype']=='A') && qa_post_is_by_user($childpost, $userid, $cookieid)) {
......@@ -199,6 +204,13 @@
}
}
if ($childpost['closedbyid'] == $post['postid']) {
// other questions are closed as duplicates of this one
$rules['deleteable'] = false;
}
}
}
// Return the resulting rules
return $rules;
......@@ -679,9 +691,13 @@
$showcomments=array();
foreach ($commentsfollows as $commentfollowid => $commentfollow)
if (($commentfollow['parentid']==$parentid) && $commentfollow['viewable'] && ($commentfollowid!=$formpostid) )
$showcomments[$commentfollowid]=$commentfollow;
foreach ($commentsfollows as $commentfollowid => $commentfollow) {
$showcomment = $commentfollow['parentid'] == $parentid && $commentfollow['viewable'] && $commentfollowid != $formpostid;
$showduplicate = $question['hidden'] && $commentfollow['closedbyid'] == $question['postid'];
if ($showcomment || $showduplicate) {
$showcomments[$commentfollowid] = $commentfollow;
}
}
$countshowcomments=count($showcomments);
......
......@@ -41,12 +41,13 @@
// Get information about this question
list($question, $childposts, $achildposts, $parentquestion, $closepost, $extravalue, $categories, $favorite)=qa_db_select_with_pending(
list($question, $childposts, $achildposts, $parentquestion, $closepost, $duplicateposts, $extravalue, $categories, $favorite) = qa_db_select_with_pending(
qa_db_full_post_selectspec($userid, $questionid),
qa_db_full_child_posts_selectspec($userid, $questionid),
qa_db_full_a_child_posts_selectspec($userid, $questionid),
qa_db_post_parent_q_selectspec($questionid),
qa_db_post_close_post_selectspec($questionid),
qa_db_post_duplicates_selectspec($questionid),
qa_db_post_meta_selectspec($questionid, 'qa_q_extra'),
qa_db_category_nav_selectspec($questionid, true, true, true),
isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_QUESTION, $questionid) : null
......@@ -66,9 +67,9 @@
$question['extra']=$extravalue;
$answers=qa_page_q_load_as($question, $childposts);
$commentsfollows=qa_page_q_load_c_follows($question, $childposts, $achildposts);
$commentsfollows=qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplicateposts);
$question=$question+qa_page_q_post_rules($question, null, null, $childposts); // array union
$question=$question+qa_page_q_post_rules($question, null, null, $childposts+$duplicateposts); // array union
if ($question['selchildid'] && (@$answers[$question['selchildid']]['type']!='A'))
$question['selchildid']=null; // if selected answer is hidden or somehow not there, consider it not selected
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment