Allow maintainer requests on version submission

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-01-20 17:41:43 +00:00
committed by WineHQ
parent 6a92f95a6d
commit a81ce02877
4 changed files with 104 additions and 19 deletions

View File

@@ -17,6 +17,8 @@ define("SILVER_RATING", "Silver");
define("BRONZE_RATING", "Bronze");
define("GARBAGE_RATING", "Garbage");
define("MAINTAINER_REQUEST", 1);
define("SUPERMAINTAINER_REQUEST", 2);
/**
* Application class for handling applications.
@@ -34,8 +36,8 @@ class Application {
var $sSubmitTime;
var $iSubmitterId;
var $aVersionsIds; // an array that contains the versionId of every version linked to this app.
var $bSuperMaintainerRequest; // Temporary variable used in application submission.
// If the user wants to become a super maintainer for the application
var $iMaintainerRequest; /* Temporary variable for tracking maintainer
requests on app submission. Value denotes type of request */
/**
* constructor, fetches the data.
@@ -133,7 +135,7 @@ class Application {
$this->SendNotificationMail(); // Only administrators will be mailed as no supermaintainers exist for this app.
/* Submit super maintainer request if asked to */
if($this->bSuperMaintainerRequest)
if($this->iMaintainerRequest == SUPERMAINTAINER_REQUEST)
{
$oMaintainer = new Maintainer();
$oMaintainer->iAppId = $this->iAppId;
@@ -309,7 +311,7 @@ class Application {
/* Unqueue matching super maintainer request */
$hResultMaint = query_parameters("SELECT maintainerId FROM appMaintainers WHERE userId = '?' AND appId = '?'", $this->iSubmitterId, $this->iAppId);
if($hResultMaint)
if($hResultMaint && mysql_num_rows($hResultMaint))
{
$oMaintainerRow = mysql_fetch_object($hResultMaint);
$oMaintainer = new Maintainer($oMaintainerRow->maintainerId);
@@ -541,10 +543,25 @@ class Application {
// Allow user to apply as super maintainer if this is a new app
if(!$this->iAppId)
{
if($this->bSuperMaintainerRequest)
$sRequestSuperMaintainerChecked = 'checked="checked"';
echo '<tr valign="top"><td class="color0"><b>Become super maintainer?</b></td>',"\n";
echo '<td><input type="checkbox" '.$sRequestSuperMaintainerChecked.' name="bSuperMaintainerRequest" /> Check this to request being a super maintainer for the application</td></tr>',"\n";
$sMaintainerOptions =
"<input type=\"radio\" name=\"iMaintainerRequest\" value=\"0\" />".
"I would not like to become a maintainer<br />\n".
"<input type=\"radio\" name=\"iMaintainerRequest\" ".
"value=\"".MAINTAINER_REQUEST."\" />".
"I would like to be a maintainer of the new version only<br />\n".
"<input type=\"radio\" name=\"iMaintainerRequest\" ".
"value=\"".SUPERMAINTAINER_REQUEST."\" />".
"I would like to be a maintainer of the entire application<br />\n";
$sMaintainerOptionsSelected = str_replace(
"value=\"$this->iMaintainerRequest\"",
"value=\"$this->iMaintainerRequest\" checked=\"checked\"",
$sMaintainerOptions);
echo html_tr(array(
array("<b>Maintainer options</b>", "class=\"color0\""),
$sMaintainerOptionsSelected),
"", "valign=\"top\"");
}
echo "</table>\n";
@@ -586,7 +603,7 @@ class Application {
$this->iVendorId = $aValues['iAppVendorId'];
$this->sWebpage = $aValues['sAppWebpage'];
$this->sKeywords = $aValues['sAppKeywords'];
$this->bSuperMaintainerRequest = $aValues['bSuperMaintainerRequest'];
$this->iMaintainerRequest = $aValues['iMaintainerRequest'];
}
/* display this application */

View File

@@ -191,19 +191,31 @@ class maintainer
function ObjectGetEntries($bQueued)
{
/* Excluding requests for queued apps, as these will be handled automatically */
/* Excluding requests for queued apps and versions, as these will be
handled automatically */
if($bQueued)
$sQuery = "SELECT maintainerId FROM appMaintainers, user_list, appFamily WHERE appMaintainers.userid = user_list.userid ".
"AND appMaintainers.queued = '?' AND appMaintainers.appId = ".
"appFamily.appId AND appFamily.queued = 'false' ORDER by ". "appMaintainers.submitTime";
$sQuery = "SELECT appMaintainers.submitTime, maintainerId FROM
appMaintainers, user_list, appFamily
WHERE appMaintainers.userid = user_list.userid AND
appMaintainers.queued = '?' AND appMaintainers.appId =
appFamily.appId AND appMaintainers.versionId = '' AND
appFamily.queued = 'false' UNION SELECT
appMaintainers.submitTime, maintainerId FROM
appMaintainers, user_list, appVersion WHERE
user_list.userid = appMaintainers.userid AND
appMaintainers.versionId = appVersion.versionId AND
appVersion.queued = 'false' AND appMaintainers.queued = '?'
ORDER by submitTime";
else
$sQuery = "SELECT maintainerId FROM appMaintainers, user_list WHERE appMaintainers.userid = user_list.userid ".
$sQuery = "SELECT maintainerId FROM appMaintainers, user_list
WHERE appMaintainers.userid = user_list.userid ".
"AND queued = '?' ORDER by realname";
if($bQueued)
{
if($_SESSION['current']->hasPriv("admin"))
return query_parameters($sQuery, $bQueued ? "true" : "false");
return query_parameters($sQuery, $bQueued ? "true" : "false",
$bQueued ? "true" : "false");
else
return NULL;
} else
@@ -256,10 +268,21 @@ class maintainer
function getQueuedMaintainerCount()
{
/* Excluding requests for queued apps, as these are handled automatically */
$sQuery = "SELECT COUNT(*) as queued_maintainers FROM appMaintainers, appFamily WHERE appMaintainers.queued='true' AND appFamily.appId = appMaintainers.appId AND appFamily.queued = 'false'";
$hResult = query_parameters($sQuery);
/* Excluding requests for queued apps and versions, as these are handled
automatically. One SELECT for super maintainers, one for maintainers. */
$sQuery = "SELECT COUNT(DISTINCT maintainerId) as queued_maintainers FROM
appMaintainers, appFamily, appVersion
WHERE appMaintainers.queued='true' AND ((appFamily.appId =
appMaintainers.appId AND appFamily.queued = 'false' AND
appMaintainers.versionId = '') OR (
appVersion.versionId = appMaintainers.versionId
AND appVersion.queued = 'false'))";
if(!($hResult = query_parameters($sQuery)))
return FALSE;
$oRow = mysql_fetch_object($hResult);
return $oRow->queued_maintainers;
}

View File

@@ -26,6 +26,10 @@ class Version {
var $iSubmitterId;
var $sDate;
var $sQueued;
var $iMaintainerRequest; /* Temporary variable for version submisson.
Indicates whether the user wants to become a
maintainer of the version being submitted.
Value denotes type of request. */
/**
* constructor, fetches the data.
@@ -90,6 +94,19 @@ class Version {
$this->iVersionId = mysql_insert_id();
$this->Version($this->iVersionId);
$this->SendNotificationMail();
/* Submit maintainer request if asked to */
if($this->iMaintainerRequest == MAINTAINER_REQUEST)
{
$oMaintainer = new Maintainer();
$oMaintainer->iAppId = $this->iAppId;
$oMaintainer->iVersionId = $this->iVersionId;
$oMaintainer->iUserId = $_SESSION['current']->iUserId;
$oMaintainer->sMaintainReason = "This user submitted the version;".
"auto-queued.";
$oMaintainer->bSuperMaintainer = 0;
$oMaintainer->create();
}
return true;
}
else
@@ -348,6 +365,18 @@ class Version {
// we send an e-mail to interested people
$this->mailSubmitter("unQueue");
$this->SendNotificationMail();
/* Unqueue matching maintainer request */
$hResultMaint = query_parameters("SELECT maintainerId FROM
appMaintainers WHERE userId = '?' AND versionId = '?'",
$this->iSubmitterId, $this->iVersionId);
if($hResultMaint && mysql_num_rows($hResultMaint))
{
$oMaintainerRow = mysql_fetch_object($hResultMaint);
$oMaintainer = new Maintainer($oMaintainerRow->maintainerId);
$oMaintainer->unQueue("OK");
}
}
}
@@ -562,6 +591,21 @@ class Version {
echo $this->sDescription.'</textarea></p></td></tr>',"\n";
/* Allow the user to apply as maintainer if this is a new version.
If it is a new application as well, radio boxes will be displayed
by the application class instead. */
if(!$this->iVersionId && $_REQUEST['iAppId'])
{
if($this->iMaintainerRequest == MAINTAINER_REQUEST)
$sRequestMaintainerChecked = 'checked="checked"';
echo html_tr(array(
array("<b>Become maintainer?</b>", "class=\"color0\""),
"<input type=\"checkbox\" $sRequestMaintainerChecked".
"name=\"iMaintainerRequest\" value=\"".MAINTAINER_REQUEST."\" /> ".
"Check this box to request being a maintainer for this version"),
"","valign=\"top\"");
}
echo '</table>',"\n";
echo html_frame_end();
@@ -608,6 +652,7 @@ class Version {
$this->sDescription = $aValues['shVersionDescription'];
$this->sTestedRating = $aValues['sMaintainerRating'];
$this->sTestedRelease = $aValues['sMaintainerRelease'];
$this->iMaintainerRequest = $aValues['iMaintainerRequest'];
}
function display($iTestingId)

View File

@@ -278,7 +278,7 @@ function test_superMaintainerOnAppSubmit()
$oApp = new Application($iAppId);
/* The user wants to be a super maintainer */
$oApp->bSuperMaintainerRequest = 1;
$oApp->iMaintainerRequest = SUPERMAINTAINER_REQUEST;
/* Make sure the user is not an admin, so the app will be queued */
$oUser->delPriv("admin");