/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { global $wgOut, $wgUser; $wgOut->setPageTitle('Update Edit Counts'); // Check permissions -- we must be allowed to access this special page // before we can run any database queries if (!$wgUser->isAllowed('updatepoints')) { throw new ErrorPageError('error', 'badaccess'); } // And obviously the database needs to be writable before we start // running INSERT/UPDATE queries against it... if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } $dbw = wfGetDB(DB_MASTER); $this->updateMainEditsCount(); global $wgUserLevels; $wgUserLevels = ''; $res = $dbw->select('user_stats', array('stats_user_id', 'stats_user_name', 'stats_total_points'), array(), __METHOD__, array('ORDER BY' => 'stats_user_name')); $out = ''; $x = 0; foreach ($res as $row) { $x++; $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name); $stats->updateTotalPoints(); } $out = "Updated stats for <b>{$x}</b> users"; $wgOut->addHTML($out); }
function wfCommentVote($comment_id, $vote_value, $vg, $page_id) { global $wgUser; // Blocked users cannot vote, obviously if ($wgUser->isBlocked()) { return ''; } if (is_numeric($comment_id) && is_numeric($vote_value)) { $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('Comments', array('comment_page_id', 'comment_user_id', 'comment_username'), array('CommentID' => $comment_id), __METHOD__); $row = $dbr->fetchObject($res); if ($row) { $PageID = $row->comment_page_id; $comment = new Comment($PageID); $comment->CommentID = $comment_id; $comment->setCommentVote($vote_value); $comment->setVoting($vg); $comment->addVote(); $out = $comment->getCommentScore(); if (class_exists('UserStatsTrack')) { $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName()); // Must update stats for user doing the voting if ($vote_value == 1) { $stats->incStatField('comment_give_plus'); } if ($vote_value == -1) { $stats->incStatField('comment_give_neg'); } // Also must update the stats for user receiving the vote $stats_comment_owner = new UserStatsTrack($row->comment_user_id, $row->comment_username); $stats_comment_owner->updateCommentScoreRec($vote_value); $stats_comment_owner->updateTotalPoints(); if ($vote_value === 1) { $stats_comment_owner->updateWeeklyPoints($stats_comment_owner->point_values['comment_plus']); $stats_comment_owner->updateMonthlyPoints($stats_comment_owner->point_values['comment_plus']); } } return $out; } } }
/** * Show the special page * * @param $par Mixed: parameter passed to the page or null */ public function execute($par) { $out = $this->getOutput(); // Check permissions -- we must be allowed to access this special page // before we can run any database queries if (!$this->getUser()->isAllowed('updatepoints')) { throw new ErrorPageError('error', 'badaccess'); } // And obviously the database needs to be writable before we start // running INSERT/UPDATE queries against it... if (wfReadOnly()) { $out->readOnlyPage(); return; } // Set the page title, robot policies, etc. $this->setHeaders(); $dbw = wfGetDB(DB_MASTER); $this->updateMainEditsCount(); global $wgUserLevels; $wgUserLevels = ''; $res = $dbw->select('user_stats', array('stats_user_id', 'stats_user_name', 'stats_total_points'), array(), __METHOD__, array('ORDER BY' => 'stats_user_name')); $x = 0; foreach ($res as $row) { $x++; $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name); $stats->updateTotalPoints(); } $out->addWikiMsg('updateeditcounts-updated', $x); }