public function sort_prepare($pl, &$rows, $sorter) { $this->_sortinfo = $sortinfo = "_score_sort_info." . $this->score . $sorter->score; $this->_avginfo = $avginfo = "_score_sort_avg." . $this->score; $reviewer = $pl->reviewer_cid(); $field = $this->form_field; foreach ($rows as $row) { if (($scores = $row->viewable_scores($field, $pl->contact, null)) !== null) { $scoreinfo = new ScoreInfo($scores); $row->{$sortinfo} = $scoreinfo->sort_data($sorter->score, $reviewer); $row->{$avginfo} = $scoreinfo->mean(); } else { $row->{$sortinfo} = ScoreInfo::empty_sort_data($sorter->score); $row->{$avginfo} = -1; } } $this->_textual_sort = ScoreInfo::sort_by_strcmp($sorter->score); }
function _sort($rows) { global $Conf; switch ($this->sortField) { case self::FIELD_EMAIL: usort($rows, array($this, "_sortEmail")); break; case self::FIELD_AFFILIATION: case self::FIELD_AFFILIATION_ROW: usort($rows, array($this, "_sortAffiliation")); break; case self::FIELD_LASTVISIT: usort($rows, array($this, "_sortLastVisit")); break; case self::FIELD_REVIEWS: usort($rows, array($this, "_sortReviews")); break; case self::FIELD_LEADS: usort($rows, array($this, "_sortLeads")); break; case self::FIELD_SHEPHERDS: usort($rows, array($this, "_sortShepherds")); break; case self::FIELD_REVIEW_RATINGS: usort($rows, array($this, "_sortReviewRatings")); break; case self::FIELD_PAPERS: case self::FIELD_REVIEW_PAPERS: usort($rows, array($this, "_sortPapers")); break; default: if ($f = ReviewForm::field($this->sortField)) { $fieldId = $this->sortField; $scoreMax = $this->scoreMax[$fieldId]; $scoresort = $Conf->session("scoresort", "A"); if ($scoresort != "A" && $scoresort != "V" && $scoresort != "D") { $scoresort = "A"; } Contact::$allow_nonexistent_properties = true; foreach ($rows as $row) { $scoreinfo = new ScoreInfo(@$row->{$fieldId}); $row->_sort_info = $scoreinfo->sort_data($scoresort); $row->_sort_avg = $scoreinfo->mean(); } usort($rows, array($this, "_sortScores")); Contact::$allow_nonexistent_properties = false; } break; } if ($this->reverseSort) { return array_reverse($rows); } else { return $rows; } }