Allow marking versions as obsolete

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-09-08 22:52:00 +00:00
committed by WineHQ
parent 4d65a32e17
commit d2a53b510c
4 changed files with 130 additions and 22 deletions

View File

@@ -96,10 +96,15 @@ class Application {
} }
} }
function _internal_retrieve_all_versions() function _internal_retrieve_all_versions($bIncludeObsolete = TRUE)
{ {
if(!$bIncludeObsolete)
$sObsolete = " AND obsoleteBy = '0'";
else
$sObsolete = "";
$sQuery = "SELECT versionId FROM appVersion WHERE $sQuery = "SELECT versionId FROM appVersion WHERE
appId = '?'"; appId = '?'$sObsolete";
$hResult = query_parameters($sQuery, $this->iAppId); $hResult = query_parameters($sQuery, $this->iAppId);
return $hResult; return $hResult;
} }
@@ -986,11 +991,11 @@ class Application {
return $oRow->count; return $oRow->count;
} }
function getVersions() function getVersions($bIncludeObsolete = TRUE)
{ {
$aVersions = array(); $aVersions = array();
$hResult = $this->_internal_retrieve_all_versions(); $hResult = $this->_internal_retrieve_all_versions($bIncludeObsolete);
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
$aVersions[] = new version($oRow->versionId); $aVersions[] = new version($oRow->versionId);
@@ -998,6 +1003,29 @@ class Application {
return $aVersions; return $aVersions;
} }
/* Make a drop-down list of this application's versions. Optionally set the default
versionId, a version to exclude and whether to not show obsolete versions */
function makeVersionDropDownList($sVarName, $iCurrentId = null, $iExclude = null, $bIncludeObsolete = TRUE)
{
$sMsg = "<select name=\"$sVarName\">\n";
foreach($this->getVersions() as $oVersion)
{
if($oVersion->sQueued != "false" || $oVersion->iVersionId == $iExclude ||
(!$bIncludeObsolete && $oVersion->iObsoleteBy))
continue;
$sMsg .= "<option value=\"".$oVersion->iVersionId."\"";
if($oVersion->iVersionId == $iCurrentId)
$sMsg .= " selected=\"selected\"";
$sMsg .= ">".$oVersion->sName."</option>\n";
}
$sMsg .= "</select>\n";
return $sMsg;
}
function objectGetChildren() function objectGetChildren()
{ {
$aChildren = array(); $aChildren = array();

View File

@@ -33,6 +33,8 @@ class version {
var $iSubmitterId; var $iSubmitterId;
var $sQueued; var $sQueued;
var $sLicense; var $sLicense;
var $iObsoleteBy; /* Whether this version is marked as obsolete, and if so which
version its votes should be moved to. */
var $iMaintainerRequest; /* Temporary variable for version submisson. var $iMaintainerRequest; /* Temporary variable for version submisson.
Indicates whether the user wants to become a Indicates whether the user wants to become a
maintainer of the version being submitted. maintainer of the version being submitted.
@@ -71,6 +73,7 @@ class version {
$this->sTestedRating = $oRow->maintainer_rating; $this->sTestedRating = $oRow->maintainer_rating;
$this->sQueued = $oRow->queued; $this->sQueued = $oRow->queued;
$this->sLicense = $oRow->license; $this->sLicense = $oRow->license;
$this->iObsoleteBy = $oRow->obsoleteBy;
} }
} }
@@ -200,6 +203,23 @@ class version {
"$this->sLicense.\n\n"; "$this->sLicense.\n\n";
} }
if($this->iObsoleteBy != $oVersion->iObsoleteBy)
{
if(!query_parameters("UPDATE appVersion SET obsoleteBy = '?' WHERE versionId = '?'",
$this->iObsoleteBy, $this->iVersionId))
if($this->iObsoleteBy)
$sWhatChanged .= "The version was marked as obsolete.\n\n";
else
$sWhatChanged .= "The version is no longer marked as obsolete.\n\n";
if($this->iObsoleteBy)
{
query_parameters("UPDATE appVotes SET versionId = '?' WHERE versionId = '?'",
$this->iObsoleteBy, $this->iVersionId);
}
}
if($sWhatChanged and !$bSilent) if($sWhatChanged and !$bSilent)
$this->SendNotificationMail("edit",$sWhatChanged); $this->SendNotificationMail("edit",$sWhatChanged);
return true; return true;
@@ -460,6 +480,26 @@ class version {
return $aBuglinkIds; return $aBuglinkIds;
} }
/* Makes a frame with title 'Mark as obsolete' and info about what it means, plus
caller-defined content */
function makeObsoleteFrame($sContent = "")
{
$sMsg = html_frame_start("Mark as obsolete", "90%", "", 0);
$sMsg .= "Some applications need to be updated from time to time in order to ";
$sMsg .= "be of any use. An example is online multi-player games, where you need ";
$sMsg .= "to be running a version compatible with the server. ";
$sMsg .= "If this is such an application, and this version is no longer usable, ";
$sMsg .= "you can mark it as obsolete and move its current votes to a usable ";
$sMsg .= "version instead.<br /><br />";
$sMsg .= $sContent;
$sMsg .= html_frame_end();
return $sMsg;
}
/* output html and the current versions information for editing */ /* output html and the current versions information for editing */
/* if $editParentApplication is true that means we need to display fields */ /* if $editParentApplication is true that means we need to display fields */
/* to let the user change the parent application of this version */ /* to let the user change the parent application of this version */
@@ -588,6 +628,32 @@ class version {
echo $oTable->GetString(); echo $oTable->GetString();
echo html_frame_end(); echo html_frame_end();
/* Mark as obsolete */
$oApp = new application($this->iAppId);
$oVersionInDB = new version($this->iVersionId);
if($oVersionInDB->iObsoleteBy)
{
$sObsoleteTxt = "<input type=\"checkbox\" name=\"bObsolete\" value=\"true\" checked=\"checked\" />";
$sObsoleteTxt .= " This version is obsolete";
echo $this->makeObsoleteFrame($sObsoleteTxt);
echo "<input type=\"hidden\" name=\"iObsoleteBy\" value=\"".
$oVersionInDB->iObsoleteBy."\" type=\"hidden\" />\n";
} else if(sizeof($oApp->getVersions(FALSE)) > 1)
{
if($this->iObsoleteBy)
$sObsolete = "checked=\"checked\"";
else
$sObsolete = "";
$sObsoleteTxt = "<input type=\"checkbox\" name=\"bObsolete\" value=\"true\"$sObsolete />";
$sObsoleteTxt .= "Mark as obsolete and move votes to \n";
$sObsoleteTxt .= $oApp->makeVersionDropDownList("iObsoleteBy", $this->iObsoleteBy, $this->iVersionId, FALSE);
echo $this->makeObsoleteFrame($sObsoleteTxt);
}
} else } else
{ {
echo '<input type="hidden" name="sMaintainerRating" value="'.$this->sTestedRating.'" />'; echo '<input type="hidden" name="sMaintainerRating" value="'.$this->sTestedRating.'" />';
@@ -620,6 +686,11 @@ class version {
$this->sTestedRelease = $aValues['sMaintainerRelease']; $this->sTestedRelease = $aValues['sMaintainerRelease'];
$this->sLicense = $aValues['sLicense']; $this->sLicense = $aValues['sLicense'];
$this->iMaintainerRequest = $aValues['iMaintainerRequest']; $this->iMaintainerRequest = $aValues['iMaintainerRequest'];
if($aValues['bObsolete'] == "true")
$this->iObsoleteBy = $aValues['iObsoleteBy'];
else
$this->iObsoleteBy = 0;
} }
function display($iTestingId) function display($iTestingId)

View File

@@ -117,28 +117,36 @@ function vote_menu()
$m = new htmlmenu("Votes","updatevote.php"); $m = new htmlmenu("Votes","updatevote.php");
$votes = vote_get_user_votes(); $oVersion = new version($aClean['iVersionId']);
for($i = 1;$i <= MAX_VOTES; $i++) if($oVersion->iObsoleteBy)
{ {
if(isset($votes[$i])) $m->add("This version is marked as obsolete, so you cannot vote for it.");
$str = Version::fullNameLink($votes[$i]->versionId); } else
else {
$str = "No App Selected"; $votes = vote_get_user_votes();
$m->add("<input type=radio name=iSlot value='$i'> $str"); for($i = 1;$i <= MAX_VOTES; $i++)
{
if(isset($votes[$i]))
$str = Version::fullNameLink($votes[$i]->versionId);
else
$str = "No App Selected";
$m->add("<input type=radio name=iSlot value='$i'> $str");
}
$m->addmisc("&nbsp;");
$m->add("<input type=submit name=sClear value=' Clear Vote ' class=votebutton>");
$m->add("<input type=submit name=sVote value='Vote for App' class=votebutton>");
$m->addmisc("<input type=hidden name=iVersionId value={$aClean['iVersionId']}>");
$m->add("View Results", BASE."votestats.php");
$m->add("Voting Help", BASE."help/?sTopic=voting");
} }
$m->addmisc("&nbsp;");
$m->add("<input type=submit name=sClear value=' Clear Vote ' class=votebutton>");
$m->add("<input type=submit name=sVote value='Vote for App' class=votebutton>");
$m->addmisc("<input type=hidden name=iVersionId value={$aClean['iVersionId']}>");
$m->add("View Results", BASE."votestats.php");
$m->add("Voting Help", BASE."help/?sTopic=voting");
$m->done(1); $m->done(1);
} }

View File

@@ -60,6 +60,7 @@ create table appVersion (
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
queued enum('true','false','rejected') NOT NULL default 'false', queued enum('true','false','rejected') NOT NULL default 'false',
license enum('Retail','Open Source','Freeware','Demo','Shareware'), license enum('Retail','Open Source','Freeware','Demo','Shareware'),
obsoleteBy int(11) NOT NULL default '0',
key(versionId), key(versionId),
index(appId) index(appId)
); );