Lets users submit application testing results in a uniform and easy to process manner

This commit is contained in:
Tony Lambregts
2005-10-17 03:59:24 +00:00
committed by WineHQ
parent c1aa7e392e
commit ba6e92d184
13 changed files with 1686 additions and 4 deletions

View File

@@ -0,0 +1,69 @@
<?php
/*******************************************************/
/* code to view and maintain the list of Distributions */
/*******************************************************/
/*
* application environment
*/
include("path.php");
require(BASE."include/incl.php");
require_once(BASE."include/distributions.php");
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage("Insufficient privileges.");
exit;
}
if ($_REQUEST['sub'])
{
if($_REQUEST['sub'] == 'delete')
{
$oDistribution = new distribution($_REQUEST['iDistributionId']);
$oDistribution->delete();
redirect(apidb_fullurl("admin/adminDistributions.php"));
}
} else
{
apidb_header("Admin Distributions");
//get available Distributions
$sQuery = "SELECT distributionId FROM distributions ORDER BY name, distributionId;";
$hResult = query_appdb($sQuery);
// show Distribution list
echo html_frame_start("","90%","",0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
echo "<tr class=color4>\n";
echo " <td>Distribution name</td>\n";
echo " <td>Distribution url</td>\n";
echo " <td>Linked Tests</td>\n";
echo " <td align=\"center\">Action</td>\n";
echo "</tr>\n\n";
$c = 1;
while($ob = mysql_fetch_object($hResult))
{
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
$oDistribution = new distribution($ob->distributionId);
echo "<tr class=\"$bgcolor\">\n";
echo " <td><a href=\"".BASE."distributionView.php?iDistributionId=".$oDistribution->iDistributionId."\">","\n";
echo $oDistribution->sName."</a></td>\n";
echo " <td><a href=\"".$oDistribution->sUrl."\">".$oDistribution->sUrl."</a></td>\n";
echo " <td>".sizeof($oDistribution->aTestingIds)."</td>\n";
echo " <td align=\"center\">";
echo "[<a href='editDistribution.php?iDistributionId=".$oDistribution->iDistributionId."'>edit</a>]";
if(!sizeof($oDistribution->aTestingIds))
echo " &nbsp; [<a href='adminDistributions.php?sub=delete&iDistributionId=".$oDistribution->iDistributionId."'>delete</a>]";
echo " </td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
apidb_footer();
?>

172
admin/adminTestResults.php Normal file
View File

@@ -0,0 +1,172 @@
<?php
/*************************************/
/* code to View and resubmit Apps */
/*************************************/
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/tableve.php");
require(BASE."include/application.php");
require(BASE."include/mail.php");
require_once(BASE."include/testResults.php");
require_once(BASE."include/distributions.php");
if ($_REQUEST['sub'])
{
if (!($_SESSION['current']->hasPriv("admin")) &&
!($_SESSION['current']->hasAppVersionModifyPermission($_REQUEST['iVersionId'])))
{
errorpage("Insufficient privileges.");
exit;
}
if(($_REQUEST['sub'] == 'Submit') || ($_REQUEST['sub'] == 'Save') ||
($_REQUEST['sub'] == 'Reject') || ($_REQUEST['sub'] == 'Delete'))
{
if(is_numeric($_REQUEST['iTestingId']))
{
$oTest = new testData($_REQUEST['iTestingId']);
$oTest->GetOutputEditorValues();
if($_REQUEST['sub'] == 'Submit') // submit the testing results
{
$oTest->update(true);
$oTest->unQueue();
} else if($_REQUEST['sub'] == 'Save') // save the testing results
{
$oTest->update();
} else if($_REQUEST['sub'] == 'Reject') // reject testing results
{
$oTest->update(true);
$oTest->Reject();
} else if($_REQUEST['sub'] == 'Delete') // delete testing results
{
$oTest->delete();
}
redirect($_SERVER['PHP_SELF']);
}
}
if(is_numeric($_REQUEST['iTestingId']))
{
$oTest = new testData($_REQUEST['iTestingId']);
}
if ($_REQUEST['sub'] == 'view')
{
switch($oTest->sQueued)
{
case "new":
apidb_header("Submit new testing results");
$_REQUEST['sTestedDate'] = date('Y-m-d H:i:s');
break;
case "true":
case "rejected":
apidb_header("Edit new testing results");
break;
case "False":
apidb_header("Edit testing results");
break;
}
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
// View Testing Details
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
/*
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the full view of the rejected application. \n";
echo "You need to pick a category before submitting \n";
echo "it into the database.\n";
echo "<p>Click delete to remove the selected item from the queue. An email will automatically be sent to the\n";
echo "submitter to let them know the item was deleted.</p>\n\n";
echo "</td></tr></table></div>\n\n";
*/
$oTest->OutputEditor();
echo '<a href="'.$_SERVER['PHP_SELF'].'">Back</a>';
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
// Submit Buttons
switch($oTest->sQueued)
{
case "false":
echo '<input name="sub" type="submit" value="Submit" class="button" >&nbsp',"\n";
echo '<input name="sub" type="submit" value="Delete" class="button" >',"\n";
break;
case "true":
echo '<input name="sub" type="submit" value="Submit" class="button" >&nbsp',"\n";
echo '<input name="sub" type="submit" value="Reject" class="button" >&nbsp',"\n";
echo '<input name="sub" type="submit" value="Delete" class="button" >',"\n";
break;
case "rejected":
echo '<input name="sub" type="submit" value="Submit" class="button" >&nbsp',"\n";
echo '<input name="sub" type="submit" value="Save" class="button" >&nbsp',"\n";
echo '<input name="sub" type="submit" value="Delete" class="button" >',"\n";
break;
}
echo '</td></tr>',"\n";
echo '</form>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
// error no sub!
addmsg("Internal Routine Not Found!!", "red");
redirect($_SERVER['PHP_SELF']);
}
}
else // if ($_REQUEST['sub']) is not defined, display the Testing results queue page
{
$oTest = new TestData();
apidb_header("Testing Results");
// Get queued testing results.
$hResult = $oTest->getTestingQueue("true");
if(!$hResult)
{
//no apps in queue
echo html_frame_start("Submitted Testing Results","90%");
echo '<p><b>The Submitted Testng Results Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of test results waiting for submition, rejection or deletion.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can Submit it into \n";
echo "the AppDB reject it or delete it.<br>\n";
echo "</td></tr></table></div>\n\n";
$oTest->ShowListofTests($hResult,"Submitted Testing Results");
}
// Get rejected testing results.
$hResult = $oTest->getTestingQueue("rejected");
if(!$hResult || !mysql_num_rows($hResult))
{
//no rejected test results in queue
echo html_frame_start("Rejected Testing Results","90%");
echo '<p><b>The Rejected Testng Results Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of test results that have been rejected for some reason.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can Submit it into \n";
echo "the AppDB, edit and save it or delete it.<br>\n";
echo "</td></tr></table></div>\n\n";
$oTest->ShowListofTests($hResult,"Rejected Testing Results");
}
}
apidb_footer();
?>

View File

@@ -0,0 +1,47 @@
<?php
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/distributions.php");
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage();
exit;
}
$oDistribution = new distribution($_REQUEST['iDistributionId']);
if($_REQUEST['Submit'])
{
$oDistribution->GetOutputEditorValues();
if($oDistribution->iDistributionId)
$oDistribution->update();
else
{
$oDistribution->create();
}
redirect(apidb_fullurl("admin/adminDistributions.php"));
exit;
}
else
{
if ($oDistribution->iDistributionId)
apidb_header("Edit Distribution");
else
apidb_header("Add Distribution");
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
$oDistribution->OutputEditor();
echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
echo '<input name="Submit" type="submit" value="Submit" class="button" >&nbsp',"\n";
echo '</td></tr>',"\n";
echo "</form>";
echo html_frame_end("&nbsp;");
apidb_footer();
}
?>

View File

@@ -21,5 +21,9 @@ table.historyTable { border: 1px;
td.gold { background-color: #fff600; }
td.silver { background-color: silver; }
td.bronze { background-color: #fcba0a; }
td.garbage { background-color: #5c4f2a; }
td.garbage { background-color: #999966; }
tr.gold { background-color: #fff600; }
tr.silver { background-color: silver; }
tr.bronze { background-color: #fcba0a; }
tr.garbage { background-color: #999966; }

View File

@@ -15,6 +15,7 @@ require(BASE."include/category.php");
require(BASE."include/maintainer.php");
require(BASE."include/mail.php");
require(BASE."include/monitor.php");
require_once(BASE."include/testResults.php");
$oApp = new Application($_REQUEST['appId']);
@@ -503,6 +504,17 @@ else if($_REQUEST['versionId'])
// description
echo "<table width='100%' border=0><tr><td width='100%' valign=top> <b>Description</b><br />\n";
echo $oVersion->sDescription;
// Show testing data
$oTest = new TestData($_REQUEST['iTestingId']);
$iCurrentTest = $oTest->ShowTestResult($oTest->iTestingId,$oVersion->iVersionId);
if($iCurrentTest)
$oTest->ShowVersionsTestingTable($oVersion->iVersionId,$iCurrentTest,$_SERVER['PHP_SELF']."?versionId=".$oVersion->iVersionId."&iTestingId=");
echo '<form method=post name=message action=testResults.php?sub=view&iVersionId='.$oVersion->iVersionId.'>';
echo '<input type=submit value="Add Testing Data" class="button" />';
echo '</form>';
echo "</td></tr>";
/* close the table */

83
distributionView.php Normal file
View File

@@ -0,0 +1,83 @@
<?php
/*************************************/
/* code to view distributions */
/*************************************/
/*
* application environment
*/
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/distributions.php");
require(BASE."include/testResults.php");
$oDistribution = new distribution($_REQUEST['iDistributionId']);
//exit with error if no vendor
if(!$oDistribution->iDistributionId)
{
errorpage("No Distribution ID specified!");
exit;
}
else
{
//display page
apidb_header("View Distribution");
echo html_frame_start("Distribution Information",500);
echo "Distribution Name:";
if($oDistribution->sUrl)
echo "<a href='".$oDistribution->sUrl."'>";
echo $oDistribution->sName;
if ($oDistribution->sUrl)
echo " (".$oDistribution->sUrl.")";
echo "</a> <br />\n";
echo "<br />\n";
if($oDistribution->aTestingIds)
{
echo "<br />Testing results for ".$oDistribution->sName."<br /><ol>\n";
echo '<p><span class="title">Testing Results</span><br />',"\n";
echo '<table width="100%" border="1">',"\n";
echo '<thead class="historyHeader">',"\n";
echo '<tr>',"\n";
echo '<td>Submitter</td>',"\n";
echo '<td>Date Submitted</td>',"\n";
echo '<td>Wine version</td>',"\n";
echo '<td>Installs?</td>',"\n";
echo '<td>Runs?</td>',"\n";
echo '<td>Rating</td>',"\n";
echo '</tr></thead>',"\n";
foreach($oDistribution->aTestingIds as $iTestingId)
{
$oTest = new testData($iTestingId);
$oVersion = new version($oTest->iVersionId);
$oApp = new application($oVersion->iAppId);
$oSubmitter = new User($oTest->iSubmitterId);
$bgcolor = $oTest->sTestedRating;
echo '<tr class='.$bgcolor.'>',"\n";
echo ' <td>',"\n";
echo $oSubmitter->sEmail ? "<a href=\"mailto:".$oSubmitter->sEmail."\">":"";
echo $oSubmitter->sRealname;
echo $oSubmitter->sEmail ? "</a>":"";
echo ' </td>',"\n";
echo ' <td>'.date("M d Y", mysqldatetime_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
echo ' <td>'.$oTest->sTestedRelease.'&nbsp</td>',"\n";
echo ' <td>'.$oTest->sInstalls.'&nbsp</td>',"\n";
echo ' <td>'.$oTest->sRuns.'&nbsp</td>',"\n";
echo ' <td>'.$oTest->sTestedRating.'&nbsp</td>',"\n";
echo '</tr>',"\n";
}
echo '</table>',"\n";
}
echo html_frame_end();
echo html_back_link(1);
apidb_footer();
}
?>

396
include/distributions.php Normal file
View File

@@ -0,0 +1,396 @@
<?php
/***************************************/
/* this class represents Distributions */
/***************************************/
require_once(BASE."include/mail.php");
// Testing class for handling Distributions.
class distribution{
var $iDistributionId;
var $sName;
var $sDescription;
var $sUrl;
var $sSubmitTime;
var $iSubmitterId;
var $sQueued;
var $aTestingIds;
// constructor, fetches the data.
function distribution($iDistributionId = null)
{
// we are working on an existing distribution.
if(is_numeric($iDistributionId))
{
// We fetch the data related to this distribution.
if(!$this->$iDistributionId)
{
$sQuery = "SELECT *
FROM distributions
WHERE distributionId = ".$iDistributionId;
if($hResult = query_appdb($sQuery))
{
$oRow = mysql_fetch_object($hResult);
$this->iDistributionId = $iDistributionId;
$this->sName = $oRow->name;
$this->sDescription = $oRow->description;
$this->sUrl = $oRow->url;
$this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId;
$this->sQueued = $oRow->queued;
}
}
/*
* We fetch Test Result Ids.
*/
$sQuery = "SELECT testingId
FROM testResults
WHERE distributionId = ".$iDistributionId;
if($hResult = query_appdb($sQuery))
{
while($oRow = mysql_fetch_object($hResult))
{
$this->aTestingIds[] = $oRow->testingId;
}
}
}
}
// Creates a new distribution.
function create()
{
//Let's not create a duplicate
$sQuery = "SELECT *
FROM distributions
WHERE name LIKE '".$this->sName."'";
$hDuplicate = query_appdb($sQuery, "checking distributions");
if(!mysql_num_rows($hDuplicate) == 0)
{
addmsg("There was an existing Distribution called ".$this->sName.".", "red");
$oRow = mysql_fetch_object($hDuplicate);
$this->iDistributionId = $oRow->distributionId;
return false;
}
// Security, if we are not an administrator the Distributions must be queued.
if(!$_SESSION['current']->hasPriv("admin"))
$this->sQueued = 'true';
else
$this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'name' => $this->sName,
'url' => $this->sUrl,
'submitterId' => $_SESSION['current']->iUserId,
'queued' => $this->sQueued ));
$sFields = "({$aInsert['FIELDS']})";
$sValues = "({$aInsert['VALUES']})";
if(query_appdb("INSERT INTO distributions $sFields VALUES $sValues", "Error while creating Distribution."))
{
$this->iDistributionId = mysql_insert_id();
$this->distribution($this->iDistributionId);
$this->SendNotificationMail();
return true;
}
else
return false;
}
// Update Distribution.
function update()
{
// is the current user allowed to update this Distribution?
if(!$_SESSION['current']->hasPriv("admin") &&
!($_SESSION['current']->iUserId == $this->iSubmitterId))
{
return;
}
$sUpdate = compile_update_string(array( 'name' => $this->sName,
'url' => $this->sUrl ));
if(query_appdb("UPDATE distributions SET ".$sUpdate." WHERE distributionId = ".$this->iDistributionId, "Error while updating Distribution."))
{
$this->SendNotificationMail("edit");
return true;
}
else
return false;
}
// Delete Distributution.
function delete($bSilent=false)
{
// is the current user allowed to delete this Distribution?
if(!$_SESSION['current']->hasPriv("admin") &&
!($_SESSION['current']->iUserId == $this->iSubmitterId))
{
return;
}
// now delete the Distribution
$sQuery = "DELETE FROM distributions
WHERE distributionId = ".$this->iDistributionId."
LIMIT 1";
if(!($hResult = query_appdb($sQuery)))
{
addmsg("Error removing the Distribution!", "red");
}
if(!$bSilent)
$this->SendNotificationMail("delete");
$this->mailSubmitter("delete");
}
// Move Distribution out of the queue.
function unQueue()
{
// is the current user allowed to move this Distribution?
if(!$_SESSION['current']->hasPriv("admin"))
{
return;
}
// If we are not in the queue, we can't move the Distribution out of the queue.
if(!$this->sQueued == 'true')
return false;
$sUpdate = compile_update_string(array('queued' => "false"));
if(query_appdb("UPDATE distribution SET ".$sUpdate." WHERE distributionId = ".$this->iDistributionId, "Error while unqueuing Distribution."))
{
$this->sQueued = 'false';
// we send an e-mail to intersted people
$this->mailSubmitter("unQueue");
$this->SendNotificationMail();
}
}
function Reject($bSilent=false)
{
// is the current user allowed to reject this Distribution?
if(!$_SESSION['current']->hasPriv("admin"))
{
return;
}
// If we are not in the queue, we can't move the Distribution out of the queue.
if(!$this->sQueued == 'true')
return false;
$sUpdate = compile_update_string(array('queued' => "rejected"));
if(query_appdb("UPDATE distribution SET ".$sUpdate." WHERE distributionId = ".$this->iDistributionId, "Error while rejecting Distribution."))
{
$this->sQueued = 'rejected';
// we send an e-mail to intersted people
if(!$bSilent)
{
$this->mailSubmitter("reject");
$this->SendNotificationMail("reject");
}
// the Distribution data has been rejected
}
}
function ReQueue()
{
// is the current user allowed to requeue this data
if(!$_SESSION['current']->hasPriv("admin") &&
!($_SESSION['current']->iUserId == $this->iSubmitterId))
{
return;
}
$sUpdate = compile_update_string(array('queued' => "true"));
if(query_appdb("UPDATE testResults SET ".$sUpdate." WHERE testingId = ".$this->iTestingId))
if(query_appdb("UPDATE distribution SET ".$sUpdate." WHERE distributionId = ".$this->iDistributionId, "Error while requeueing Distribution."))
{
$this->sQueued = 'true';
// we send an e-mail to intersted people
$this->SendNotificationMail();
// the testing data has been resubmitted
addmsg("The Distribution has been resubmitted", "green");
}
}
function mailSubmitter($sAction="add")
{
if($this->iSubmitterId)
{
$oSubmitter = new User($this->iSubmitterId);
switch($sAction)
{
case "add":
{
$sSubject = "Submitted Distribution accepted";
$sMsg = "The Distribution you submitted (".$this->sName.") has been accepted.";
}
break;
case "reject":
{
$sSubject = "Distribution rejected";
$sMsg = "The Distribution you submitted (".$this->sName.") has been rejected.";
$sMsg .= APPDB_ROOT."testingData.php?sub=view&versionId=".$this->iVersionId."\n";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
break;
case "delete":
{
$sSubject = "Submitted Distribution deleted";
$sMsg = "The Distribution you submitted (".$this->sName.") has been deleted.";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
break;
}
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
}
}
function SendNotificationMail($sAction="add",$sMsg=null)
{
switch($sAction)
{
case "add":
if($this->sQueued == "false")
{
$sSubject = "Distribution ".$this->sName." added by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."distributionView.php?iDistributionId=".$this->iDistributionId."\n";
if($this->iSubmitterId)
{
$oSubmitter = new User($this->iSubmitterId);
$sMsg .= "This Distribution has been submitted by ".$oSubmitter->sRealname.".";
$sMsg .= "\n";
$sMsg .= "Appdb admin reply text:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
addmsg("The Distribution was successfully added into the database.", "green");
} else // testing data queued.
{
$sSubject = "Distribution ".$this->sName." submitted by ".$_SESSION['current']->sRealname;
$sMsg .= "This testing data has been queued.";
$sMsg .= "\n";
addmsg("The Distribution you submitted will be added to the database after being reviewed.", "green");
}
break;
case "edit":
$sSubject = "Distribution ".$this->sName." has been modified by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."distributionView.php?iDistributionId=".$this->iDistributionId."\n";
addmsg("Distribution modified.", "green");
break;
case "delete":
$sSubject = "Distribution ".$this->sName." has been deleted by ".$_SESSION['current']->sRealname;
// if replyText is set we should report the reason the data was deleted
if($_REQUEST['replyText'])
{
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
addmsg("Distribution deleted.", "green");
break;
case "reject":
$sSubject = "Distribution '".$this->sName." has been rejected by ".$_SESSION['current']->sRealname;
$sMsg = APPDB_ROOT."distributionView.php?iDistributionId=".$this->iDistributionId."\n";
// if replyText is set we should report the reason the data was rejected
if($_REQUEST['replyText'])
{
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
addmsg("Distribution rejected.", "green");
break;
}
$sEmail = get_notify_email_address_list(null, null);
if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg);
}
function OutputEditor()
{
echo html_frame_start("Distribution Form", "90%", "", 0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
// Name
echo '<tr valign=top><td class="color1" width="20%"><b>Distribution Name</b></td>',"\n";
echo '<td class="color0"><input type=text name="sName" value="'.$this->sName.'" size="50"></td></tr>',"\n";
// Url
echo '<tr valign=top><td class="color1"><b>Distribution Url</b></td>',"\n";
echo '<td class="color0"><input type=text name="sUrl" value="'.$this->sUrl.'" size="50"></td></tr>',"\n";
echo '<input type="hidden" name="iDistributionId" value="'.$this->iDistributionId.'">',"\n";
echo "</table>\n";
echo html_frame_end();
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
{
if(get_magic_quotes_gpc())
{
$this->iDistributionId = stripslashes($_REQUEST['iDistributionId']);
$this->sName = stripslashes($_REQUEST['sName']);
$this->sUrl = stripslashes($_REQUEST['sUrl']);
} else
{
$this->iDistributionId = $_REQUEST['iDistributionId'];
$this->sName = $_REQUEST['sName'];
$this->sUrl = $_REQUEST['sUrl'];
}
}
}
/* Make a dropdown list of distributions */
function make_distribution_list($varname, $cvalue)
{
$query = "SELECT name, distributionId FROM distributions ORDER BY name";
$result = query_appdb($query);
if(!$result) return;
echo "<select name='$varname'>\n";
echo "<option value=\"\">Choose ...</option>\n";
while(list($name, $value) = mysql_fetch_row($result))
{
if($value == $cvalue)
echo "<option value=$value selected>$name\n";
else
echo "<option value=$value>$name\n";
}
echo "</select>\n";
}
/* Get the total number of Distributions in the database */
function getNumberOfDistributions()
{
$hResult = query_appdb("SELECT count(*) as num_dists FROM distributions");
if($hResult)
{
$row = mysql_fetch_object($hResult);
return $row->num_dists;
}
return 0;
}
/* Get the number of Queued Distributions in the database */
function getNumberOfQueuedDistributions()
{
$hResult = query_appdb("SELECT count(*) as num_dists FROM distributions WHERE queued='true';");
if($hResult)
{
$row = mysql_fetch_object($hResult);
return $row->num_dists;
}
return 0;
}
?>

View File

@@ -2,6 +2,8 @@
/*****************/
/* sidebar_admin */
/*****************/
require_once(BASE."include/testResults.php");
require_once(BASE."include/distributions.php");
function global_admin_menu() {
@@ -9,6 +11,7 @@ function global_admin_menu() {
$g->add("Add Category", BASE."admin/addCategory.php");
$g->add("Add Vendor", BASE."admin/addVendor.php");
$g->add("Add Distribution", BASE."admin/editDistribution.php");
$g->addmisc("&nbsp;");
$g->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php");
@@ -17,11 +20,14 @@ function global_admin_menu() {
$g->add("View Maintainer Entries (".getMaintainerCount().")", BASE."admin/adminMaintainers.php");
$g->add("View Vendors (".getVendorCount().")", BASE."admin/adminVendors.php");
$g->add("View Bug Links (".getNumberOfQueuedBugLinks()."/".getNumberOfBugLinks().")", BASE."admin/adminBugs.php");
$g->add("View Test Results Queue (".getNumberOfQueuedTests().")", BASE."admin/adminTestResults.php");
$g->add("View Distributions (".getNumberOfDistributions().")", BASE."admin/adminDistributions.php");
$g->addmisc("&nbsp;");
$g->add("Users Management", BASE."admin/adminUsers.php");
$g->add("Comments Management", BASE."admin/adminCommentView.php");
$g->add("Screenshots Management", BASE."admin/adminScreenshots.php");
$g->done();
}

643
include/testResults.php Normal file
View File

@@ -0,0 +1,643 @@
<?php
/*****************************************/
/* this class represents Testing results */
/*****************************************/
require_once(BASE."include/distributions.php");
// Testing class for handling Testing History.
class testData{
var $iTestingId;
var $iVersionId;
var $sWhatWorks;
var $sWhatDoesnt;
var $sWhatNotTested;
var $sTestedRelease;
var $iDistributionId;
var $sTestedDate;
var $sTestedRelease;
var $sInstalls;
var $sRuns;
var $sTestedRating;
var $sComments;
var $sSubmitTime;
var $iSubmitterId;
var $sQueued;
// constructor, fetches the data.
function testData($iTestingId = null)
{
// we are working on an existing test
if(is_numeric($iTestingId))
{
// We fetch the data related to this test.
if(!$this->iTestingId)
{
$sQuery = "SELECT *
FROM testResults
WHERE testingId = ".$iTestingId;
if($hResult = query_appdb($sQuery))
{
$oRow = mysql_fetch_object($hResult);
$this->iTestingId = $iTestingId;
$this->iVersionId = $oRow->versionId;
$this->sWhatWorks = $oRow->whatWorks;
$this->sWhatDoesnt = $oRow->whatDoesnt;
$this->sWhatNotTested = $oRow->whatNotTested;
$this->sTestedDate = $oRow->testedDate;
$this->iDistributionId = $oRow->distributionId;
$this->sTestedRelease = $oRow->testedRelease;
$this->sInstalls = $oRow->installs;
$this->sRuns = $oRow->runs;
$this->sTestedRating = $oRow->testedRating;
$this->sComments = $oRow->comments;
$this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId;
$this->sQueued = $oRow->queued;
}
}
}
}
// Creates a new Test Results.
function create()
{
// Security, if we are not an administrator or an maintainer the test result must be queued.
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($oTest->iVersionId))
$this->sQueued = 'true';
else
$this->sQueued = 'false';
$aInsert = compile_insert_string(array( 'versionId' => $this->iVersionId,
'whatWorks' => $this->sWhatWorks,
'whatDoesnt' => $this->sWhatDoesnt,
'whatNotTested' => $this->sWhatNotTested,
'testedDate' => $this->sTestedDate,
'distributionId' => $this->iDistributionId,
'testedRelease' => $this->sTestedRelease,
'installs' => $this->sInstalls,
'runs' => $this->sRuns,
'testedRating' => $this->sTestedRating,
'comments' => $this->sComments,
'submitterId' => $_SESSION['current']->iUserId,
'queued' => $this->sQueued ));
$sFields = "({$aInsert['FIELDS']})";
$sValues = "({$aInsert['VALUES']})";
if(query_appdb("INSERT INTO testResults $sFields VALUES $sValues", "Error while creating test results."))
{
$this->iTestingId = mysql_insert_id();
$this->testData($this->iTestingId);
$this->SendNotificationMail();
return true;
}
else
return false;
}
// Update Test Results.
function update($bSilent=false)
{
// is the current user allowed to update this testing result?
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($this->iVersionId) &&
!(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sQueued == 'false')))
{
return;
}
$sUpdate = compile_update_string(array( 'versionId' => $this->iVersionId,
'whatWorks' => $this->sWhatWorks,
'whatDoesnt' => $this->sWhatDoesnt,
'whatNotTested' => $this->sWhatNotTested,
'testedDate' => $this->sTestedDate,
'distributionId' => $this->iDistributionId,
'testedRelease' => $this->sTestedRelease,
'installs' => $this->sInstalls,
'runs' => $this->sRuns,
'testedRating' => $this->sTestedRating,
'comments' => $this->sComments));
if(query_appdb("UPDATE testResults SET ".$sUpdate." WHERE testingId = ".$this->iTestingId, "Error while updating test results."))
{
if(!$bSilent)
$this->SendNotificationMail();
return true;
}
else
return false;
}
// Delete testing results.
function delete($bSilent=false)
{
// is the current user allowed to delete this testing result?
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($this->iVersionId) &&
!(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sQueued == 'false')))
{
return;
}
// now delete the testing data
$sQuery = "DELETE FROM testResults
WHERE testingId = ".$this->iTestingId."
LIMIT 1";
if(!($hResult = query_appdb($sQuery)))
{
addmsg("Error removing the deleted testing data!", "red");
}
if(!$bSilent)
$this->SendNotificationMail("delete");
$this->mailSubmitter("delete");
}
// Move Testing Data out of the queue.
function unQueue()
{
// is the current user allowed to delete this testing data?
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($this->iVersionId))
{
return;
}
// If we are not in the queue, we can't move the testing data out of the queue.
if(!$this->sQueued == 'true')
return false;
$sUpdate = compile_update_string(array('queued' => "false"));
if(query_appdb("UPDATE testResults SET ".$sUpdate." WHERE testingId = ".$this->iTestingId))
{
$this->sQueued = 'false';
// we send an e-mail to intersted people
$this->mailSubmitter("unQueue");
$this->SendNotificationMail();
}
}
function Reject()
{
// is the current user allowed to delete this testing data?
if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($this->iVersionId))
{
return;
}
// If we are not in the queue, we can't move the version out of the queue.
if(!$this->sQueued == 'true')
return false;
$sUpdate = compile_update_string(array('queued' => "rejected"));
if(query_appdb("UPDATE testResults SET ".$sUpdate." WHERE testingId = ".$this->iTestingId))
{
$this->sQueued = 'rejected';
// we send an e-mail to intersted people
$this->mailSubmitter("reject");
$this->SendNotificationMail("reject");
}
}
function ReQueue()
{
// is the current user allowed to requeue this data
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($this->iVersionId) &&
!$_SESSION['current']->iUserId == $this->iSubmitterId)
{
return;
}
$sUpdate = compile_update_string(array('queued' => "true"));
if(query_appdb("UPDATE testResults SET ".$sUpdate." WHERE testingId = ".$this->iTestingId))
{
$this->sQueued = 'true';
// we send an e-mail to intersted people
$this->SendNotificationMail();
}
}
function mailSubmitter($sAction="add")
{
if($this->iSubmitterId)
{
$oSubmitter = new User($this->iSubmitterId);
switch($sAction)
{
case "add":
$sSubject = "Submitted testing data accepted";
$sMsg = "The testing data you submitted (".$oApp->sName." ".$this->sName.") has been accepted.";
$sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."&iTestingId=".$this->iTestingId."\n";
break;
case "reject":
$sSubject = "Submitted testing data rejected";
$sMsg = "The testing data you submitted (".$oApp->sName." ".$this->sName.") has been rejected.";
$sMsg .= APPDB_ROOT."testResults.php?sub=view&iTestingId=".$this->iTestingId."\n";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
break;
case "delete":
$sSubject = "Submitted testing data deleted";
$sMsg = "The testing data you submitted (".$oApp->sName." ".$this->sName.") has been deleted.";
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
break;
}
$sMsg .= $_REQUEST['replyText']."\n";
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
}
}
function SendNotificationMail($sAction="add",$sMsg=null)
{
$oVersion = new Version($this->iVersionId);
$oApp = new Application($oVersion->iAppId);
switch($sAction)
{
case "add":
if($this->sQueued == "false")
{
$sSubject = "Test Results added to version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname;
$sMsg = $sMsg .= APPDB_ROOT."appview.php?versionId=".$this->iVersionId."&iTestingId=".$this->iTestingId."\n";
if($this->iSubmitterId)
{
$oSubmitter = new User($this->iSubmitterId);
$sMsg .= "This Testing data has been submitted by ".$oSubmitter->sRealname.".";
$sMsg .= "\n";
$sMsg .= "Appdb admin reply text:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
addmsg("The testing data was successfully added into the database.", "green");
} else // testing data queued.
{
$sSubject = "Test Results submitted for version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."admin/adminTestResults.php?sub=view&iTestingId=".$this->iTestingId."\n";
$sMsg .= "This testing data has been queued.";
$sMsg .= "\n";
addmsg("The testing data you submitted will be added to the database after being reviewed.", "green");
}
break;
case "edit":
$sSubject = "Test Results modified for version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."admin/adminTestResults.php?sub=view&iTestingId=".$this->iTestingId."\n";
addmsg("testing data modified.", "green");
break;
case "delete":
$sSubject = "Test Results deleted for version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname;
// if replyText is set we should report the reason the data was deleted
if($_REQUEST['replyText'])
{
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
addmsg("testing data deleted.", "green");
break;
case "reject":
$sSubject = "Test Results rejected for version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname;
$sMsg .= APPDB_ROOT."admin/adminTestResults.php?sub=view&iTestingId=".$this->iTestingId."\n";
// if replyText is set we should report the reason the data was rejected
if($_REQUEST['replyText'])
{
$sMsg .= "Reason given:\n";
$sMsg .= $_REQUEST['replyText']."\n"; // append the reply text, if there is any
}
addmsg("testing data rejected.", "green");
break;
}
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
if($sEmail)
mail_appdb($sEmail, $sSubject ,$sMsg);
}
function ShowTestResult($iCurrentTest,$iVersionId)
{
$hResult = query_appdb("SELECT *
FROM testResults
WHERE testingId = '".$iCurrentTest."';");
if(!$hResult || mysql_num_rows($hResult) == 0)
{
echo '<p><b>over hers</b><br />',"\n";
$hResult = query_appdb("SELECT *
FROM testResults
WHERE versionId = '".$iVersionId."'
ORDER BY testedRelease DESC ;");
if(!$hResult || mysql_num_rows($hResult) == 0)
return false;
}
$oRow = mysql_fetch_object($hResult);
echo '<p><b>What works</b><br />',"\n";
echo $oRow->whatWorks;
echo '<p><b>What Doesn\'t</b><br />',"\n";
echo $oRow->whatDoesnt;
echo '<p><b>What wasn\'t tested</b><br />',"\n";
echo $oRow->whatNotTested;
return $oRow->testingId;
}
// Show the Test results for a application version
function ShowVersionsTestingTable($iVersionId, $iCurrentTest, $link)
{
$hResult = query_appdb("SELECT *
FROM testResults
WHERE versionId = '".$iVersionId."'
ORDER BY testedRelease DESC;");
if(!$hResult || mysql_num_rows($hResult) == 0)
return;
echo '<p><span class="title">Testing Results</span><br />',"\n";
echo '<table width="100%" border="1" class="historyTable">',"\n";
echo '<thead class="historyHeader">',"\n";
echo '<tr>',"\n";
echo '<td></td>',"\n";
echo '<td>Distribution</td>',"\n";
echo '<td>Date Submitted</td>',"\n";
echo '<td>Wine version</td>',"\n";
echo '<td>Installs?</td>',"\n";
echo '<td>Runs?</td>',"\n";
echo '<td>Rating</td>',"\n";
echo '</tr></thead>',"\n";
while($oRow = mysql_fetch_object($hResult))
{
$oTest = new testData($oRow->testingId);
$oVersion = new version($oTest->iVersionId);
$oApp = new application($oVersion->iAppId);
$oSubmitter = new User($oTest->iSubmitterId);
$oDistribution = new distribution($oTest->iDistributionId);
$bgcolor = $oTest->sTestedRating;
echo '<tr class='.$bgcolor.'>',"\n";
if ($oTest->iTestingId == $iCurrentTest)
echo ' <td align="center" class="color2"><b>Current</b></td>',"\n";
else
echo ' <td align="center" class="color2">[<a href="'.$link.$oTest->iTestingId.'">Show</a>]</td>',"\n";
echo ' <td>',"\n";
echo '<a href="'.BASE.'distributionView.php?iDistributionId='.$oTest->iDistributionId.'">',"\n";
echo $oDistribution->sName.'</a>',"\n";
echo ' </td>',"\n";
echo ' <td>'.date("M d Y", mysqldatetime_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
echo ' <td>'.$oTest->sTestedRelease.'&nbsp</td>',"\n";
echo ' <td>'.$oTest->sInstalls.'&nbsp</td>',"\n";
echo ' <td>'.$oTest->sRuns.'&nbsp</td>',"\n";
echo ' <td>'.$oTest->sTestedRating.'&nbsp</td>',"\n";
echo '</tr>',"\n";
}
echo '</table>',"\n";
}
// show the fields for editing
function OutputEditor($sDistribution, $bNewDist=false)
{
HtmlAreaLoaderScript(array("Test1", "Test2", "Test3"));
echo html_frame_start("Testing Form", "90%", "", 0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
// What works
echo '<tr valign=top><td class="color0"><b>What Works</b></td>',"\n";
echo '<td class="color0"><p><textarea cols="80" rows="20" id="Test1" name="sWhatWorks">';
echo $this->sWhatWorks.'</textarea></p></td></tr>',"\n";
// What Does not work
echo '<tr valign=top><td class=color1><b>What Does not work</b></td>',"\n";
echo '<td class="color0"><p><textarea cols="80" rows="20" id="Test2" name="sWhatDoesnt">';
echo $this->sWhatDoesnt.'</textarea></p></td></tr>',"\n";
// What was not tested
echo '<tr valign=top><td class=color0><b>What was not tested</b></td>',"\n";
echo '<td class="color0"><p><textarea cols="80" rows="20" id="Test3" name="sWhatNotTested">';
echo $this->sWhatNotTested.'</textarea></p></td></tr>',"\n";
// Date Tested
echo '<tr valign=top><td class="color1"><b>Date Tested </b></td>',"\n";
echo '<td class="color0"><input type=text name="sTestedDate" value="'.$this->sTestedDate.'" size="20"></td></tr>',"\n";
echo '<tr valign=top><td class="color1"></td><td class="color0"><p/>YYYY-MM-DD HH:MM:SS</td></tr>',"\n";
// Distribution
echo '<tr valign=top><td class="color0"><b>Distribution</b></td class="color0">',"\n";
if ($bNewDist)
{
echo '<td class="color0"><input type=text name="sDistribution" value="'.$sDistribution.'" size="20"></td></tr>',"\n";
echo '<tr><td class=color0><b></b></td>',"\n";
}
echo '<td class=color0>',"\n";
make_distribution_list("iDistributionId", $this->iDistributionId);
echo '</td></tr>',"\n";
// Version List
echo '<tr><td class=color1><b>Tested Release</b></td><td class=color0>',"\n";
make_bugzilla_version_list("sTestedRelease", $this->sTestedRelease);
echo '</td></tr>',"\n";
// Installs
echo '<tr><td class=color0><b>Installs?</b></td><td class=color0>',"\n";
make_Installs_list("sInstalls", $this->sInstalls);
echo '</td></tr>',"\n";
// Runs
echo '<tr><td class=color1><b>Runs?</b></td><td class=color0>',"\n";
make_Runs_list("sRuns", $this->sRuns);
echo '</td></tr>',"\n";
// Rating
echo '<tr><td class="color0"><b>Rating</b></td><td class="color0">',"\n";
make_maintainer_rating_list("sTestedRating", $this->sTestedRating);
echo '</td></tr>',"\n";
// extra comments
echo '<tr valign=top><td class="color1"><b>Extra Comments</b></td>',"\n";
echo '<td class="color0"><textarea name="sComments" rows=10 cols=35>';
echo $this->sComments.'</textarea></td></tr>',"\n";
echo '<input type="hidden" name="iVersionId" value="'.$this->iVersionId.'" >';
echo '<input type="hidden" name="iTestingId" value="'.$this->iTestingId.'" >';
echo "</table>\n";
echo html_frame_end();
}
function CheckOutputEditorInput($sDistribution="")
{
$errors = "";
$sWhatWorks = trim($_REQUEST['sWhatWorks']);
$sWhatDoesnt = trim($_REQUEST['sWhatDoesnt']);
$sWhatNotTested = trim($_REQUEST['sWhatNotTested']);
$sDistribution = trim($_REQUEST['sDistribution']);
if (empty($sWhatWorks))
$errors .= "<li>Please enter what worked.</li>\n";
if (empty($sWhatDoesnt))
$errors .= "<li>Please enter what did not work.</li>\n";
if (empty($sWhatNotTested))
$errors .= "<li>Please enter what was not tested.</li>\n";
if (empty($_REQUEST['sTestedDate']))
$errors .= "<li>Please enter the Date and Time that you tested.</li>\n";
if (empty($_REQUEST['sTestedRelease']))
$errors .= "<li>Please enter the version of Wine that you tested with.</li>\n";
// No Distribution entered, and nothing in the list is selected
if (empty($sDistribution) && !$_REQUEST['iDistributionId'])
$errors .= "<li>Please enter a Distribution.</li>\n";
if (empty($_REQUEST['sInstalls']))
$errors .= "<li>Please enter whether this application installs or not.</li>\n";
if (empty($_REQUEST['sRuns']))
$errors .= "<li>Please enter whether this application runs or not.</li>\n";
if (empty($_REQUEST['sTestedRating']))
$errors .= "<li>Please enter a Rating based on how well this application runs.</li>\n";
return $errors;
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
{
if(get_magic_quotes_gpc())
{
$this->iTestingId = stripslashes($_REQUEST['iTestingId']);
$this->iVersionId = stripslashes($_REQUEST['iVersionId']);
$this->sWhatWorks = stripslashes($_REQUEST['sWhatWorks']);
$this->sWhatDoesnt = stripslashes($_REQUEST['sWhatDoesnt']);
$this->sWhatNotTested = stripslashes($_REQUEST['sWhatNotTested']);
$this->sTestedDate = stripslashes($_REQUEST['sTestedDate']);
$this->iDistributionId = stripslashes($_REQUEST['iDistributionId']);
$this->sTestedRelease = stripslashes($_REQUEST['sTestedRelease']);
$this->sInstalls = stripslashes($_REQUEST['sInstalls']);
$this->sRuns = stripslashes($_REQUEST['sRuns']);
$this->sTestedRating = stripslashes($_REQUEST['sTestedRating']);
$this->sComments = stripslashes($_REQUEST['sComments']);
} else
{
$this->iTestingId = $_REQUEST['iTestingId'];
$this->iVersionId = $_REQUEST['iVersionId'];
$this->sWhatWorks = $_REQUEST['sWhatWorks'];
$this->sWhatDoesnt = $_REQUEST['sWhatDoesnt'];
$this->sWhatNotTested = $_REQUEST['sWhatNotTested'];
$this->sTestedDate = $_REQUEST['sTestedDate'];
$this->iDistributionId = $_REQUEST['iDistributionId'];
$this->sTestedRelease = $_REQUEST['sTestedRelease'];
$this->sInstalls = $_REQUEST['sInstalls'];
$this->sRuns = $_REQUEST['sRuns'];
$this->sTestedRating = $_REQUEST['sTestedRating'];
$this->sComments = $_REQUEST['sComments'];
}
}
function getTestingQueue($sQueued='true')
{
if($_SESSION['current']->hasPriv("admin"))
{
$hResult = query_appdb("SELECT *
FROM testResults
WHERE queued = '".$sQueued."';");
if(!$hResult || mysql_num_rows($hResult) == 0)
return;
} else
{
$hResult = query_appdb("SELECT *
FROM testResults
WHERE queued = '".$sQueued."'
AND submitterId = ".$_SESSION['current']->iUserId.";");
if(!$hResult || mysql_num_rows($hResult) == 0)
return;
}
return $hResult;
}
function ShowListofTests($hResult, $heading="")
{
//show applist
echo html_frame_start($heading,"90%","",0);
echo "<table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"0\">
<tr class=color4>
<td>Submission Date</td>
<td>Submitter</td>
<td>Application</td>
<td>Version</td>
<td>Release</td>
<td align=\"center\">Action</td>
</tr>";
$c = 1;
while($oRow = mysql_fetch_object($hResult))
{
$oTest = new testData($oRow->testingId);
$oVersion = new version($oTest->iVersionId);
$oApp = new application($oVersion->iAppId);
$oSubmitter = new User($oTest->iSubmitterId);
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "<tr class=\"$bgcolor\">\n";
echo " <td>".print_date(mysqltimestamp_to_unixtimestamp($oTest->sSubmitTime))."</td>\n";
echo " <td>\n";
echo $oSubmitter->sEmail ? "<a href=\"mailto:".$oSubmitter->sEmail."\">":"";
echo $oSubmitter->sRealname;
echo $oSubmitter->sEmail ? "</a>":"";
echo " </td>\n";
echo " <td>".$oApp->sName."</td>\n";
echo " <td>".$oVersion->sName."</td>\n";
echo " <td>".$oTest->sTestedRelease."</td>\n";
echo " <td align=\"center\">[<a href=".$_SERVER['PHP_SELF']."?sub=view&iTestingId=".$oTest->iTestingId.">process</a>]</td>\n";
echo "</tr>\n\n";
$c++;
}
echo html_frame_end();
}
}
/* Get the number of TestResults in the database */
function getNumberOfQueuedTests()
{
$hResult = query_appdb("SELECT count(*) as num_tests FROM testResults WHERE queued='true';");
if($hResult)
{
$row = mysql_fetch_object($hResult);
return $row->num_tests;
}
return 0;
}
function make_Installs_list($varname, $cvalue)
{
echo "<select name='$varname'>\n";
echo "<option value=\"\">Choose ...</option>\n";
$aRating = array("Yes", "No");
$iMax = count($aRating);
for($i=0; $i < $iMax; $i++)
{
if($aRating[$i] == $cvalue)
echo "<option value=$aRating[$i] selected>$aRating[$i]\n";
else
echo "<option value=$aRating[$i]>$aRating[$i]\n";
}
echo "</select>\n";
}
function make_Runs_list($varname, $cvalue)
{
echo "<select name='$varname'>\n";
echo "<option value=\"\">Choose ...</option>\n";
$aRating = array("Yes", "No", "???");
$iMax = count($aRating);
for($i=0; $i < $iMax; $i++)
{
if($aRating[$i] == $cvalue)
echo "<option value=$aRating[$i] selected>$aRating[$i]\n";
else
echo "<option value=$aRating[$i]>$aRating[$i]\n";
}
echo "</select>\n";
}
?>

18
tables/distributions.sql Normal file
View File

@@ -0,0 +1,18 @@
use apidb;
drop table if exists distributions;
/*
* Distributions table.
*/
create table distributions (
distributionId int not null auto_increment,
name varchar(255) default NULL,
url varchar(255) default NULL,
submitTime timestamp(14) NOT NULL,
submitterId int(11) NOT NULL default '0',
queued enum('true','false','rejected') NOT NULL default 'false',
key(distributionId),
index(name)
);

26
tables/testResults.sql Normal file
View File

@@ -0,0 +1,26 @@
use apidb;
drop table if exists testResults;
drop table if exists TestResults;
/*
* Version Testing results
*/
create table testResults (
testingId int not null auto_increment,
versionId int not null,
whatWorks text,
whatDoesnt text,
whatNotTested text,
testedDate datetime not null,
distributionId int not null,
testedRelease tinytext,
installs enum('Yes','No') NOT NULL default 'Yes',
runs enum('Yes','No','???') NOT NULL default 'Yes',
testedRating tinytext,
comments text,
submitTime timestamp(14) NOT NULL,
submitterId int(11) NOT NULL default '0',
queued enum('true','false','rejected') NOT NULL default 'false',
key(testingId)
);

206
testResults.php Normal file
View File

@@ -0,0 +1,206 @@
<?php
/**************************************************/
/* code to submit, view and resubmit Test Results */
/**************************************************/
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/tableve.php");
require(BASE."include/application.php");
require(BASE."include/mail.php");
require_once(BASE."include/testResults.php");
require_once(BASE."include/distributions.php");
if ($_REQUEST['sub'])
{
$oTest = new testData($_REQUEST['iTestingId']);
if($_REQUEST['iVersionId'])
$oTest->iVersionId = $_REQUEST['iVersionId'];
$errors = "";
// Submit or Resubmit the new testing results
if (($_REQUEST['sub'] == 'Submit') || ($_REQUEST['sub'] == 'Resubmit'))
{
$errors = $oTest->CheckOutputEditorInput();
$oTest->GetOutputEditorValues(); // retrieve the values from the current $_REQUEST
if(empty($errors))
{
$sDistribution = trim($_REQUEST['sDistribution']);
if(!empty($sDistribution))
{
$oDistribution = new distribution();
$oDistribution->sName = $sDistribution;
$oDistribution->create();
$oTest->iDistributionId = $oDistribution->iDistributionId;
}
if($_REQUEST['sub'] == 'Submit')
{
$oTest->create();
} else if($_REQUEST['sub'] == 'Resubmit')
{
$oTest->update(true);
$oTest->ReQueue();
}
redirect($_SERVER['PHP_SELF']);
} else
{
$_REQUEST['sub'] = 'view';
}
}
// Delete testing results
if ($_REQUEST['sub'] == 'Delete')
{
if(is_numeric($_REQUEST['iTestingId']))
{
$oTest = new testData($_REQUEST['iTestingId']);
$oTest->delete();
}
redirect($_SERVER['PHP_SELF']);
}
// is this an old test?
if(is_numeric($_REQUEST['iTestingId']))
{
// make sure the user has permission to view this testing result
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($oTest->iVersionId)&&
!(($_SESSION['current']->iUserId == $oTest->iSubmitterId) && !($oTest->sQueued == 'false')))
{
errorpage("Insufficient privileges.");
exit;
} else
$oVersion = new version($oTest->iVersionId);
} else
{
$oTest->iVersionId = $_REQUEST['iVersionId'];
$oVersion = new version($_REQUEST['iVersionId']);
$oTest->sQueued = "new";
}
if ($_REQUEST['sub'] == 'view')
{
$oApp = new application($oVersion->iAppId);
$sVersionInfo = $oApp->sName." ".$oVersion->sName;
switch($oTest->sQueued)
{
case "new":
apidb_header("Submit new testing results for ".$sVersionInfo);
$oTest->sTestedDate = date('Y-m-d H:i:s');
break;
case "true":
apidb_header("Edit new testing results for ".$sVersionInfo);
break;
case "rejected":
apidb_header("Resubmit testing results for ".$sVersionInfo);
break;
case "False":
apidb_header("Edit testing results for ".$sVersionInfo);
break;
default:
apidb_header("Edit testing results for ");
}
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
//help
echo "<p>This is the Screen for imputting testing information so that others looking at the database will know \n";
echo "what was working or a particular release of Wine.</p>\n";
echo "<p>Please be as detailed as you can.</p>\n";
echo "<p>If you can not find your distribution on the list of existing Distributions please add it add it in the \n";
echo "field provided.</p>\n\n";
if(!empty($errors))
{
echo '<font color="red">',"\n";
echo '<p class="red"> We found the following errors:</p><ul>'.$errors.'</ul>Please correct them.';
echo '</font><br />',"\n";
echo '<p></p>',"\n";
}
// View Testing Details
$oTest->OutputEditor($_REQUEST['sDistribution'],true);
echo '<a href="'.BASE."appview.php?versionId=".$oTest->iVersionId.'">Back to Version</a>';
echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
// Submit Buttons
switch($oTest->sQueued)
{
case "new":
echo '<input name="sub" type="submit" value="Submit" class="button" >&nbsp',"\n";
break;
case "true":
case "rejected":
case "False":
echo '<input name="sub" type="submit" value="Resubmit" class="button" >&nbsp',"\n";
echo '<input name="sub" type="submit" value="Delete" class="button" >',"\n";
break;
}
echo '</td></tr>',"\n";
echo "</form>";
echo html_frame_end("&nbsp;");
}
else
{
// error no sub!
addmsg("Internal Routine Not Found!!", "red");
redirect($_SERVER['PHP_SELF']);
}
}
else // if ($_REQUEST['sub']) is not defined, display the Testing results queue page
{
apidb_header("Testing Results");
// Get queued testing results.
$oTest = new TestData();
$hResult = $oTest->getTestingQueue("true");
if(!$hResult)
{
// no Tests in queue
echo html_frame_start("Submitted Testing Results","90%");
echo '<p><b>The Submitted Testng Results Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
// help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of Test Results waiting for submition, or to be deleted.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can delete or edit and\n";
echo "re-submit it into the AppDB .<br>\n";
echo "</td></tr></table></div>\n\n";
$oTest->ShowListofTests($hResult,"Submitted Testing Results");
}
// Get rejected testing results.
$hResult = $oTest->getTestingQueue("rejected");
if(!$hResult || !mysql_num_rows($hResult))
{
//no Test Results in queue
echo html_frame_start("Rejected Testing Results","90%");
echo '<p><b>The Rejected Testng Results Queue is empty.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of Rejected Test Results waiting for re-submition or deletion.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can delete or edit and re-submit it into \n";
echo "the AppDB .<br>\n";
echo "</td></tr></table></div>\n\n";
$oTest->ShowListofTests($hResult,"Rejected Testing Results");
}
}
apidb_footer();
?>