Code Duplication    Length = 15-15 lines in 2 locations

code/control/PageRaterExtension_Controller.php 1 location

@@ 153-167 (lines=15) @@
150
     * rating for this page ...
151
     * @return ArrayList
152
     */
153
    public function PageRatingResults()
154
    {
155
        $sqlQuery = new SQLQuery();
156
        $sqlQuery->setSelect("AVG(\"PageRating\".\"Rating\") RatingAverage, ParentID");
157
        $sqlQuery->setFrom("\"PageRating\" ");
158
        if ($this->onlyShowApprovedPageRatings()) {
159
            $sqlQuery->setWhere("\"ParentID\" = ".$this->owner->ID." AND \"PageRating\".\"IsApproved\" = 1");
160
        } else {
161
            $sqlQuery->setWhere("\"ParentID\" = ".$this->owner->ID."");
162
        }
163
        $sqlQuery->setOrderBy("RatingAverage DESC");
164
        $sqlQuery->setGroupby("\"ParentID\"");
165
        $sqlQuery->setLimit(1);
166
        return $this->turnPageRaterSQLIntoArrayList($sqlQuery, "PageRatingResults");
167
    }
168
169
    /**
170
     * rating of this page by this user ...

code/model/PageRaterExtension.php 1 location

@@ 159-173 (lines=15) @@
156
     * rating for this page ...
157
     * @return ArrayList
158
     */
159
    public function PageRatingResults()
160
    {
161
        $sqlQuery = new SQLQuery();
162
        $sqlQuery->setSelect("AVG(\"PageRating\".\"Rating\") RatingAverage, ParentID");
163
        $sqlQuery->setFrom("\"PageRating\" ");
164
        if ($this->onlyShowApprovedPageRatings()) {
165
            $sqlQuery->setWhere("\"ParentID\" = ".$this->owner->ID." AND \"PageRating\".\"IsApproved\" = 1");
166
        } else {
167
            $sqlQuery->setWhere("\"ParentID\" = ".$this->owner->ID."");
168
        }
169
        $sqlQuery->setOrderBy("RatingAverage DESC");
170
        $sqlQuery->setGroupby("\"ParentID\"");
171
        $sqlQuery->setLimit(1);
172
        return $this->turnPageRaterSQLIntoArrayList($sqlQuery, "PageRatingResults");
173
    }
174
175
    /**
176
     * rating of this page by this user ...