diff --git a/include/application.php b/include/application.php index 0ebda5f..0a09cc1 100644 --- a/include/application.php +++ b/include/application.php @@ -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 - appId = '?'"; + appId = '?'$sObsolete"; $hResult = query_parameters($sQuery, $this->iAppId); return $hResult; } @@ -986,11 +991,11 @@ class Application { return $oRow->count; } - function getVersions() + function getVersions($bIncludeObsolete = TRUE) { $aVersions = array(); - $hResult = $this->_internal_retrieve_all_versions(); + $hResult = $this->_internal_retrieve_all_versions($bIncludeObsolete); while($oRow = mysql_fetch_object($hResult)) $aVersions[] = new version($oRow->versionId); @@ -998,6 +1003,29 @@ class Application { 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 = "\n"; + + return $sMsg; + } + function objectGetChildren() { $aChildren = array(); diff --git a/include/version.php b/include/version.php index d97a9c9..0c0f254 100644 --- a/include/version.php +++ b/include/version.php @@ -33,6 +33,8 @@ class version { var $iSubmitterId; var $sQueued; 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. Indicates whether the user wants to become a maintainer of the version being submitted. @@ -71,6 +73,7 @@ class version { $this->sTestedRating = $oRow->maintainer_rating; $this->sQueued = $oRow->queued; $this->sLicense = $oRow->license; + $this->iObsoleteBy = $oRow->obsoleteBy; } } @@ -200,6 +203,23 @@ class version { "$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) $this->SendNotificationMail("edit",$sWhatChanged); return true; @@ -460,6 +480,26 @@ class version { 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.

"; + + $sMsg .= $sContent; + + $sMsg .= html_frame_end(); + + return $sMsg; + } + /* output html and the current versions information for editing */ /* if $editParentApplication is true that means we need to display fields */ /* to let the user change the parent application of this version */ @@ -588,6 +628,32 @@ class version { echo $oTable->GetString(); echo html_frame_end(); + + /* Mark as obsolete */ + $oApp = new application($this->iAppId); + $oVersionInDB = new version($this->iVersionId); + + if($oVersionInDB->iObsoleteBy) + { + $sObsoleteTxt = ""; + $sObsoleteTxt .= " This version is obsolete"; + echo $this->makeObsoleteFrame($sObsoleteTxt); + + echo "iObsoleteBy."\" type=\"hidden\" />\n"; + } else if(sizeof($oApp->getVersions(FALSE)) > 1) + { + if($this->iObsoleteBy) + $sObsolete = "checked=\"checked\""; + else + $sObsolete = ""; + + $sObsoleteTxt = ""; + $sObsoleteTxt .= "Mark as obsolete and move votes to \n"; + $sObsoleteTxt .= $oApp->makeVersionDropDownList("iObsoleteBy", $this->iObsoleteBy, $this->iVersionId, FALSE); + + echo $this->makeObsoleteFrame($sObsoleteTxt); + } } else { echo ''; @@ -620,6 +686,11 @@ class version { $this->sTestedRelease = $aValues['sMaintainerRelease']; $this->sLicense = $aValues['sLicense']; $this->iMaintainerRequest = $aValues['iMaintainerRequest']; + + if($aValues['bObsolete'] == "true") + $this->iObsoleteBy = $aValues['iObsoleteBy']; + else + $this->iObsoleteBy = 0; } function display($iTestingId) diff --git a/include/vote.php b/include/vote.php index cf3d9ec..814e99d 100644 --- a/include/vote.php +++ b/include/vote.php @@ -117,29 +117,37 @@ function vote_menu() $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])) - $str = Version::fullNameLink($votes[$i]->versionId); - else - $str = "No App Selected"; + $m->add("This version is marked as obsolete, so you cannot vote for it."); + } else + { + $votes = vote_get_user_votes(); - $m->add(" $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(" $str"); + } + + $m->addmisc(" "); + + $m->add(""); + $m->add(""); + + $m->addmisc(""); + + $m->add("View Results", BASE."votestats.php"); + $m->add("Voting Help", BASE."help/?sTopic=voting"); } - - $m->addmisc(" "); - $m->add(""); - $m->add(""); - - $m->addmisc(""); - - $m->add("View Results", BASE."votestats.php"); - $m->add("Voting Help", BASE."help/?sTopic=voting"); - - $m->done(1); + $m->done(1); } diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql index b112f03..d064108 100644 --- a/tables/appdb_tables.sql +++ b/tables/appdb_tables.sql @@ -60,6 +60,7 @@ create table appVersion ( submitterId int(11) NOT NULL default '0', queued enum('true','false','rejected') NOT NULL default 'false', license enum('Retail','Open Source','Freeware','Demo','Shareware'), + obsoleteBy int(11) NOT NULL default '0', key(versionId), index(appId) );