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) { $hResult = query_appdb("SELECT * FROM testResults WHERE versionId = '".$iVersionId."' ORDER BY testedDate DESC ;"); if(!$hResult || mysql_num_rows($hResult) == 0) return false; } $oRow = mysql_fetch_object($hResult); echo '
What works
',"\n";
echo $oRow->whatWorks;
echo '
What Doesn\'t
',"\n";
echo $oRow->whatDoesnt;
echo '
What wasn\'t tested
',"\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 testedDate DESC;");
if(!$hResult || mysql_num_rows($hResult) == 0)
return;
echo '
Testing Results
',"\n";
echo '
| ',"\n"; echo ' | Distribution | ',"\n"; echo 'Test date | ',"\n"; echo 'Wine version | ',"\n"; echo 'Installs? | ',"\n"; echo 'Runs? | ',"\n"; echo 'Rating | ',"\n"; echo '|
| Current | ',"\n"; else echo '[Show] | ',"\n"; echo '',"\n"; echo '',"\n"; echo $oDistribution->sName.'',"\n"; echo ' | ',"\n"; echo ''.date("M d Y", mysqltimestamp_to_unixtimestamp($oTest->sTestedDate)).' | ',"\n"; echo ''.$oTest->sTestedRelease.'  | ',"\n"; echo ''.$oTest->sInstalls.'  | ',"\n"; echo ''.$oTest->sRuns.'  | ',"\n"; echo ''.$oTest->sTestedRating.'  | ',"\n"; echo '
| What Works | ',"\n"; echo '|
| What Does not work | ',"\n"; echo '|
| What was not tested | ',"\n"; echo '|
| Date Tested | ',"\n"; echo '|
| YYYY-MM-DD HH:MM:SS | |
| Distribution | ',"\n"; if ($bNewDist) { echo '|
| ',"\n"; } echo ' | ',"\n"; make_distribution_list("iDistributionId", $this->iDistributionId); echo ' |
| Tested Release | ',"\n"; make_bugzilla_version_list("sTestedRelease", $this->sTestedRelease); echo ' |
| Installs? | ',"\n"; make_Installs_list("sInstalls", $this->sInstalls); echo ' |
| Runs? | ',"\n"; make_Runs_list("sRuns", $this->sRuns); echo ' |
| Rating | ',"\n"; make_maintainer_rating_list("sTestedRating", $this->sTestedRating); echo ' |
| Extra Comments | ',"\n"; echo '
| Submission Date | Submitter | Application | Version | Release | Action |
| ".print_date(mysqltimestamp_to_unixtimestamp($oTest->sSubmitTime))." | \n"; echo "\n"; echo $oSubmitter->sEmail ? "sEmail."\">":""; echo $oSubmitter->sRealname; echo $oSubmitter->sEmail ? "":""; echo " | \n"; echo "".$oApp->sName." | \n"; echo "".$oVersion->sName." | \n"; echo "".$oTest->sTestedRelease." | \n"; echo "[iTestingId.">process] | \n"; echo "