diff --git a/include/version.php b/include/version.php
index ae0bc3e..b2c1798 100644
--- a/include/version.php
+++ b/include/version.php
@@ -870,6 +870,14 @@ class version {
else
$shVoteLink = '';
+ // Allow admins to see which users have voted, in order to identify
+ // bogus votes
+ if($_SESSION['current']->hasPriv('admin'))
+ {
+ $oMVoteInspector = new objectManager('voteInspector', 'Vote inspector');
+ $shVoteLink .= ' Inspect';
+ }
+
$shVoteText = vote_count_version_total($this->iVersionId).$shVoteLink;
} else
{
diff --git a/include/vote.php b/include/vote.php
index 36367e3..193c3b8 100644
--- a/include/vote.php
+++ b/include/vote.php
@@ -227,6 +227,95 @@ class voteManager
}
}
+/**
+ * used by admins to check whether votes for a version are legit
+ */
+class voteInspector
+{
+ private $iVersionId;
+
+ function voteInspector($iVersionId = null)
+ {
+ if(is_numeric($iVersionId))
+ $this->iVersionId = $iVersionId;
+ }
+
+ public function objectGetId()
+ {
+ return $this->iVersionId;
+ }
+
+ public function objectGetState()
+ {
+ return 'accepted';
+ }
+
+ public function display()
+ {
+ $oVersion = new version($this->iVersionId);
+
+ echo 'Inspecting votes for ' . version::fullNameLink($this->iVersionId);
+ echo '
';
+
+ $hResult = query_parameters("SELECT userId, COUNT(userId) as count FROM appVotes WHERE
+ versionId = '?'
+ GROUP BY userId", $this->iVersionId);
+
+ if(!$hResult)
+ {
+ echo 'Failed to get list of votes';
+ return;
+ }
+
+ if(mysql_num_rows($hResult) == 0)
+ {
+ echo 'There are no votes for this version';
+ return;
+ }
+
+ $oTable = new Table();
+ $oTable->setCellPadding(3);
+
+ $oTableRow = new TableRow();
+ $oTableRow->setClass('color4');
+ $oTableRow->AddTextCell('User');
+ $oTableRow->AddTextCell('ID');
+ $oTableRow->AddTextCell('Created');
+ $oTableRow->AddTextCell('Votes');
+ $oTableRow->AddTextCell('Privileges');
+ $oTable->AddRow($oTableRow);
+
+ for($i = 0; $oRow = mysql_fetch_object($hResult); $i++)
+ {
+ $oVoter = new user($oRow->userId);
+ $oTableRow = new TableRow();
+ $oTableRow->setClass(($i % 2) ? 'color0' : 'color1');
+ $oTableRow->AddTextCell($oVoter->objectMakeLink());
+ $oTableRow->AddTextCell($oVoter->iUserId);
+ $oTableRow->AddTextCell($oVoter->sDateCreated);
+ $oTableRow->AddTextCell($oRow->count);
+
+ $sPrivs = '';
+ if($oVoter->hasPriv('admin'))
+ $sPrivs .= 'Admin
';
+
+ if($oVoter->isMaintainer($this->iVersionId))
+ $sPrivs .= 'Maintainer of this version
';
+
+ if($oVoter->isMaintainer())
+ {
+ $oM = new objectManager('maintainerView', 'View maintainership info');
+ $sPrivs .= 'Maintainer (other entries)
';
+ }
+
+ $oTableRow->AddTextCell($sPrivs);
+ $oTable->AddRow($oTableRow);
+ }
+
+ echo $oTable->getString();
+ }
+}
+
/**
* count the number of votes for appId by userId
*/