Skip to content

Commit

Permalink
On the my reviews page, show a list of pages I own
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed May 3, 2010
1 parent da65db0 commit 0dd7364
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions MyReviews_body.php
Expand Up @@ -207,15 +207,15 @@ function showViewerAdditions()
}

# Reviews this user has given
function reviewsIGave($userid) {
$selectquery =<<<EOSQL
function reviewsIGave() {
$selectquery = <<<EOSQL
SELECT
review_score.display_as, page.page_namespace, page.page_title, review.*
FROM
review_score INNER JOIN (
review INNER JOIN page ON review.page_id = page.page_id
) ON review.review_score_id = review_score.id
WHERE user_id = '{$userid}';
WHERE user_id = '{$this->userID}';
EOSQL;
$dbr = wfGetDB(DB_SLAVE);
$given = $dbr->query($selectquery);
Expand Down Expand Up @@ -249,7 +249,7 @@ function reviewsIGave($userid) {
}

# Reviews given to this user
function reviewsIReceive($userid) {
function reviewsIReceive() {
# Explanation of this SQL: We want to get page/review information (along
# with the displayable name of the review) for all pages that this user
# owns
Expand Down Expand Up @@ -293,13 +293,35 @@ function reviewsIReceive($userid) {
return $takenReviews;
}

function ownedPages() {
$selectquery = <<<EOT
SELECT
page.page_namespace, page.page_title
FROM page, page_owner
WHERE page_owner.user_id = '{$this->userID}'
AND page_owner.page_id = page.page_id
EOT;
$dbr = wfGetDB(DB_SLAVE);
$pages = $dbr->query($selectquery);
$pagehtml = "";
while ($row = $dbr->fetchObject($pages)) {
$pagename = $this->getNamespaceNameFromId($row->page_namespace) . $row->page_title;
$page = Title::newFromText($pagename);
$pagehref = $page->getFullURL();
$talkhref = $page->getTalkPage()->getFullURL();
$pagehtml .= "<p><a href='$pagehref'>$pagename</a> (<a href='$talkhref'>Talk</a>)</p>";
}
return $pagehtml;
}

# Show the basic main page
function showMainPage() {
global $wgRequest, $wgOut;

$this->showViewerAdditions();
$givenReviews = $this->reviewsIGave($this->userID);
$takenReviews = $this->reviewsIReceive($this->userID);
$givenReviews = $this->reviewsIGave();
$takenReviews = $this->reviewsIReceive();
$ownedpages = $this->ownedPages();

# TODO: Show a list of all pages I own
$html = <<<EOT
Expand All @@ -313,6 +335,8 @@ function showMainPage() {
<td id="PeerReview-MyReviews-given-side" valign="top">
<h3>Reviews given by {$this->username}</h3>
{$givenReviews}
<h3>Pages owned by {$this->username}</h3>
{$ownedpages}
</td>
</tr>
</table>
Expand Down

0 comments on commit 0dd7364

Please sign in to comment.