Commit 28b53c8c by Scott Vivian

Merge branch 'pupi1985-patch-22' into dev

parents 350ccf51 0e2c1029
...@@ -922,46 +922,48 @@ ...@@ -922,46 +922,48 @@
{ {
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
require_once QA_INCLUDE_DIR.'qa-util-sort.php'; require_once QA_INCLUDE_DIR . 'qa-util-sort.php';
foreach ($questions as $key => $question) { // collect information about action referenced by each $question foreach ($questions as $key => $question) { // collect information about action referenced by each $question
if (isset($question['opostid'])) { if (isset($question['opostid'])) {
$questions[$key]['_time']=$question['otime']; $questions[$key]['_time'] = $question['otime'];
$questions[$key]['_type']=$question['obasetype']; $questions[$key]['_type'] = $question['obasetype'];
$questions[$key]['_userid']=@$question['ouserid']; $questions[$key]['_userid'] = @$question['ouserid'];
} else { } else {
$questions[$key]['_time']=$question['created']; $questions[$key]['_time'] = $question['created'];
$questions[$key]['_type']='Q'; $questions[$key]['_type'] = 'Q';
$questions[$key]['_userid']=$question['userid']; $questions[$key]['_userid'] = $question['userid'];
} }
$questions[$key]['sort']=-$questions[$key]['_time']; $questions[$key]['sort'] = -$questions[$key]['_time'];
} }
qa_sort_by($questions, 'sort'); qa_sort_by($questions, 'sort');
$keepquestions=array(); // now remove duplicate references to same question $keepquestions = array(); // now remove duplicate references to same question
foreach ($questions as $question) { // going in order from most recent to oldest foreach ($questions as $question) { // going in order from most recent to oldest
$laterquestion=@$keepquestions[$question['postid']]; $laterquestion = @$keepquestions[$question['postid']];
if ( if (isset($laterquestion)) {
(!isset($laterquestion)) // keep this reference if there is no more recent one if (
|| // or ... (abs($laterquestion['_time'] - $question['_time']) < 300) // the two events were within 5 minutes of each other
( &&
(@$laterquestion['oupdatetype']) && // the more recent reference was an edit (
(!@$question['oupdatetype']) && // this is not an edit (@$laterquestion['oupdatetype']) && // the more recent reference was an edit
($laterquestion['_type']==$question['_type']) && // the same part (Q/A/C) is referenced here (!@$question['oupdatetype']) && // this is not an edit
($laterquestion['_userid']==$question['_userid']) && // the same user made the later edit ($laterquestion['_type'] == $question['_type']) && // the same part (Q/A/C) is referenced here
(abs($laterquestion['_time']-$question['_time'])<300) // the edit was within 5 minutes of creation ($laterquestion['_userid'] == $question['_userid']) // the same user made the later edit
) )
|| // or ... || // or ...
( (
(@$question['opersonal']) && // this question (in an update list) is personal to the user (@$question['opersonal']) && // this question (in an update list) is personal to the user
(!@$laterquestion['opersonal']) && // the other one was not personal (!@$laterquestion['opersonal']) // the other one was not personal
(abs($laterquestion['_time']-$question['_time'])<300) // the two events were within 5 minutes of each other )
) ) {
) unset($keepquestions[$question['postid']]); // Remove any previous instance of the post to force a new position
$keepquestions[$question['postid']]=$question; $keepquestions[$question['postid']] = $question;
}
} else // keep this reference if there is no more recent one
$keepquestions[$question['postid']] = $question;
} }
return $keepquestions; return $keepquestions;
......
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