iTestingId) { $sQuery = "SELECT * FROM testResults WHERE testingId = '?'"; if($hResult = query_parameters($sQuery, $iTestingId)) { $oRow = mysql_fetch_object($hResult); if($oRow) { $this->iTestingId = $oRow->testingId; $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 a maintainer the test result must be queued. $oVersion = new Version($oTest->iVersionId); if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion)) $this->sQueued = 'true'; else $this->sQueued = 'false'; $hResult = query_parameters("INSERT INTO testResults (versionId, whatWorks, whatDoesnt,". "whatNotTested, testedDate, distributionId, testedRelease,". "installs, runs, testedRating, comments, submitterId, queued)". " VALUES('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?',". "'?', '?')", $this->iVersionId, $this->sWhatWorks, $this->sWhatDoesnt, $this->sWhatNotTested, $this->sTestedDate, $this->iDistributionId, $this->sTestedRelease, $this->sInstalls, $this->sRuns, $this->sTestedRating, $this->sComments, $_SESSION['current']->iUserId, $this->sQueued); if($hResult) { $this->iTestingId = mysql_insert_id(); $this->testData($this->iTestingId); $this->SendNotificationMail(); return true; } else { addmsg("Error while creating test results.", "red"); return false; } } // Update Test Results. function update($bSilent=false) { // is the current user allowed to update this test result? $oVersion = new Version($this->iVersionId); if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion) && !(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sQueued == 'false'))) { return; } if(query_parameters("UPDATE testResults SET versionId = '?', whatWorks = '?', whatDoesnt = '?', whatNotTested = '?', testedDate = '?', distributionId = '?', testedRelease = '?', installs = '?', runs = '?', testedRating = '?', comments = '?' WHERE testingId = '?'", $this->iVersionId, $this->sWhatWorks, $this->sWhatDoesnt, $this->sWhatNotTested, $this->sTestedDate, $this->iDistributionId, $this->sTestedRelease, $this->sInstalls, $this->sRuns, $this->sTestedRating, $this->sComments, $this->iTestingId)) { if(!$bSilent) $this->SendNotificationMail(); return true; } else { addmsg("Error while updating test results", "red"); return false; } } // Delete test results. function delete($bSilent=false) { // is the current user allowed to delete this test result? $oVersion = new Version($this->iVersionId); if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion) && !(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sQueued == 'false'))) { return; } // now delete the test data $sQuery = "DELETE FROM testResults WHERE testingId = '?' LIMIT 1"; if(!($hResult = query_parameters($sQuery, $this->iTestingId))) { addmsg("Error removing the deleted test data!", "red"); } if(!$bSilent) $this->SendNotificationMail("delete"); if($this->iSubmitterId && ($this->iSubmitterId != $_SESSION['current']->iUserId)) $this->mailSubmitter("delete"); } // Move Test Data out of the queue. function unQueue() { // is the current user allowed to delete this test data? $oVersion = new Version($this->iVersionId); if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion)) { return; } // If we are not in the queue, we can't move the test data out of the queue. if(!$this->sQueued == 'true') return false; if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", "false", $this->iTestingId)) { $this->sQueued = 'false'; // we send an e-mail to interested people $this->mailSubmitter("unQueue"); $this->SendNotificationMail(); } } function Reject() { // is the current user allowed to delete this test data? $oVersion = new Version($this->iVersionId); if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion)) { return; } // If we are not in the queue, we can't move the version out of the queue. if(!$this->sQueued == 'true') return false; if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", "rejected", $this->iTestingId)) { $this->sQueued = 'rejected'; // we send an e-mail to interested people $this->mailSubmitter("reject"); $this->SendNotificationMail("reject"); } } function ReQueue() { // is the current user allowed to requeue this data $oVersion = new Version($this->iVersionId); if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->hasAppVersionModifyPermission($oVersion) && !$_SESSION['current']->iUserId == $this->iSubmitterId) { return; } if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'", "true", $this->iTestingId)) { $this->sQueued = 'true'; // we send an e-mail to interested people $this->SendNotificationMail(); } } function mailSubmitter($sAction="add") { global $aClean; if($this->iSubmitterId) { $oSubmitter = new User($this->iSubmitterId); /* Get the full app/version name to display */ $oVersion = new Version($this->iVersionId); $sAppName = application::lookup_name($oVersion->iAppId); $sVersionName = version::lookup_name($oVersion->iVersionId); $sName = "$sAppName: $sVersionName"; switch($sAction) { case "add": $sSubject = "Submitted testing data accepted"; $sMsg = "The testing data you submitted for '$sName' has been accepted."; $sMsg .= APPDB_ROOT."appview.php?iVersionId=".$this->iVersionId."&iTestingId=".$this->iTestingId."\n"; $sMsg .= "Administrators Responce:\n"; break; case "reject": $sSubject = "Submitted testing data rejected"; $sMsg = "The testing data you submitted for '$sName' has been rejected."; $sMsg .= APPDB_ROOT."testResults.php?sSub=view&iTestingId=".$this->iTestingId."\n"; $sMsg .= "Reason given:\n"; break; case "delete": $sSubject = "Submitted testing data deleted"; $sMsg = "The testing data you submitted for '$sName' has been deleted."; $sMsg .= "Reason given:\n"; break; } $sMsg .= $aClean['sReplyText']."\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) { global $aClean; $oVersion = new Version($this->iVersionId); $oApp = new Application($oVersion->iAppId); $sBacklink = APPDB_ROOT."appview.php?iVersionId=".$this->iVersionId."&iTestingId=".$this->iTestingId."\n"; 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 .= $sBacklink; if($this->iSubmitterId) { $oSubmitter = new User($this->iSubmitterId); $sMsg .= "This Test data has been submitted by ".$oSubmitter->sRealname."."; $sMsg .= "\n"; } if($aClean['sReplyText']) { $sMsg .= "Appdb admin reply text:\n"; $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any } addmsg("The test data was successfully added into the database.", "green"); } else // test data queued. { $sSubject = "Test Results submitted for version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname; $sMsg .= $sBacklink; $sMsg .= "This test data has been queued."; $sMsg .= "\n"; addmsg("The test 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 .= $sBacklink; addmsg("test 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($aClean['sReplyText']) { $sMsg .= "Reason given:\n"; $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any } addmsg("test data deleted.", "green"); break; case "reject": $sSubject = "Test Results rejected for version ".$oVersion->sName." of ".$oApp->sName." submitted by ".$_SESSION['current']->sRealname; $sMsg .= $sBacklink; // if replyText is set we should report the reason the data was rejected if($aClean['sReplyText']) { $sMsg .= "Reason given:\n"; $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any } addmsg("test data rejected.", "green"); break; } $sEmail = User::get_notify_email_address_list(null, $this->iVersionId); if($sEmail) mail_appdb($sEmail, $sSubject ,$sMsg); } function ShowTestResult() { echo '

What works
',"\n"; echo $this->sWhatWorks; echo '

What does not
',"\n"; echo $this->sWhatDoesnt; echo '

What was not tested
',"\n"; echo $this->sWhatNotTested; echo '

Additional Comments
',"\n"; echo $this->sComments; } // Show the Test results for a application version function ShowVersionsTestingTable($link, $iDisplayLimit) { global $aClean; /* escape input parameters */ $link = mysql_real_escape_string($link); $iDisplayLimit = mysql_real_escape_string($iDisplayLimit); $showAll = $aClean['showAll']; $sQuery = "SELECT * FROM testResults WHERE versionId = '".$this->iVersionId."' ORDER BY testedDate DESC"; if(!$showAll) $sQuery.=" LIMIT 0,".$iDisplayLimit; $hResult = query_appdb($sQuery); if(!$hResult) return; $rowsUsed = mysql_num_rows($hResult); if($rowsUsed == 0) return; echo '

Test Results
',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\n"; echo '',"\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; /* if the test we are displaying is this test then */ /* mark it as the current test */ if ($oTest->iTestingId == $this->iTestingId) { echo '',"\n"; echo ' ',"\n"; } else /* make all non-current rows clickable so clicking on them selects the test as current */ { html_tr_highlight_clickable($link.$oTest->iTestingId, $bgcolor, "", "color2", "underline"); echo ' ',"\n"; else echo '">Show]',"\n"; } switch($oTest->sQueued) { case "false": $sStatus = "Checked"; break; case "true": $sStatus = "Queued"; break; case "rejected": $sStatus = "Rejected"; break; } echo ' ',"\n"; echo ' ',"\n"; echo ' ',"\n"; echo ' ',"\n"; echo ' ',"\n"; echo ' ',"\n"; echo ' ',"\n"; if ($_SESSION['current']->hasAppVersionModifyPermission($oVersion)) { echo '',"\n"; } echo '',"\n"; } echo '
DistributionTest dateWine versionInstalls?Runs?RatingStatus
Current[Show]',"\n"; echo '',"\n"; echo $oDistribution->sName.'',"\n"; echo ' '.date("M d Y", mysqldatetime_to_unixtimestamp($oTest->sTestedDate)).''.$oTest->sTestedRelease.' '.$oTest->sInstalls.' '.$oTest->sRuns.' '.$oTest->sTestedRating.' '.$sStatus.' ',"\n"; echo 'Edit
',"\n"; echo '

'; echo ''; if($rowsUsed >= $iDisplayLimit && !is_string($showAll)) echo ''; if(is_string($showAll)) { echo ''; } echo '
'; } /* retrieve the latest test result for a given version id */ function get_test_for_versionid($iVersionId) { $sQuery = "SELECT testingId from testResults where versionId = '?' ORDER BY testedDate DESC limit 1"; $hResult = query_parameters($sQuery, $iVersionId); if(!$hResult) return 0; $oRow = mysql_fetch_object($hResult); return $oRow->testingId; } // show the fields for editing function OutputEditor($sDistribution="", $bNewDist=false) { HtmlAreaLoaderScript(array("Test1", "Test2", "Test3")); echo html_frame_start("Test Form", "90%", "", 0); echo "\n"; // What works echo '',"\n"; echo '',"\n"; // What Does not work echo '',"\n"; echo '',"\n"; // What was not tested echo '',"\n"; echo '',"\n"; // Date Tested echo '',"\n"; echo '',"\n"; echo '',"\n"; // Distribution echo '',"\n"; if ($bNewDist) { echo '',"\n"; echo '',"\n"; } echo '',"\n"; // Version List echo '',"\n"; // Installs echo '',"\n"; // Runs echo '',"\n"; // Rating echo '',"\n"; // extra comments echo '',"\n"; echo '',"\n"; echo ''; echo ''; echo "
What works

What does not work

What was not tested

Date tested

YYYY-MM-DD HH:MM:SS

Distribution
',"\n"; distribution::make_distribution_list("iDistributionId", $this->iDistributionId); echo '
Tested release',"\n"; make_bugzilla_version_list("sTestedRelease", $this->sTestedRelease); echo '
Installs?',"\n"; testData::make_Installs_list("sInstalls", $this->sInstalls); echo '
Runs?',"\n"; testData::make_Runs_list("sRuns", $this->sRuns); echo '
Rating',"\n"; make_maintainer_rating_list("sTestedRating", $this->sTestedRating); echo 'Rating definitions
Extra comments
\n"; echo html_frame_end(); } /* $aValues can be $aValues or any array with the values from OutputEditor() */ function CheckOutputEditorInput($aValues, $sDistribution="") { $errors = ""; if (empty($aValues['sWhatWorks'])) $errors .= "
  • Please enter what worked.
  • \n"; if (empty($aValues['sWhatDoesnt'])) $errors .= "
  • Please enter what did not work.
  • \n"; if (empty($aValues['sWhatNotTested'])) $errors .= "
  • Please enter what was not tested.
  • \n"; if (empty($aValues['sTestedDate'])) $errors .= "
  • Please enter the date and time when you tested.
  • \n"; if (empty($aValues['sTestedRelease'])) $errors .= "
  • Please enter the version of Wine that you tested with.
  • \n"; // No Distribution entered, and nothing in the list is selected if (empty($aValues['sDistribution']) && !$aValues['iDistributionId']) $errors .= "
  • Please enter a distribution.
  • \n"; if (empty($aValues['sInstalls'])) $errors .= "
  • Please enter whether this application installs or not.
  • \n"; if (empty($aValues['sRuns'])) $errors .= "
  • Please enter whether this application runs or not.
  • \n"; if (empty($aValues['sTestedRating'])) $errors .= "
  • Please enter a rating based on how well this application runs.
  • \n"; // Basic checking of rating logic to ensure that the users test results // are consistent if (($aValues['sRuns'] != "Yes") && ($aValues['sTestedRating'] != GARBAGE_RATING)) $errors .= "
  • Applications that do not run should be rated ‘Garbage’.
  • \n"; if (($aValues['sInstalls'] == "No") && ($aValues['sTestedRating'] == PLATINUM_RATING)) $errors .= "
  • An application can only get a Platinum rating if it installs and runs ‘out of the box’.
  • \n"; return $errors; } /* retrieves values from $aValues that were output by OutputEditor() */ /* $aValues can be $_REQUEST or any array with the values from OutputEditor() */ function GetOutputEditorValues($aValues) { $this->iTestingId = $aValues['iTestingId']; $this->iVersionId = $aValues['iVersionId']; $this->sWhatWorks = $aValues['sWhatWorks']; $this->sWhatDoesnt = $aValues['sWhatDoesnt']; $this->sWhatNotTested = $aValues['sWhatNotTested']; $this->sTestedDate = $aValues['sTestedDate']; $this->iDistributionId = $aValues['iDistributionId']; $this->sTestedRelease = $aValues['sTestedRelease']; $this->sInstalls = $aValues['sInstalls']; $this->sRuns = $aValues['sRuns']; $this->sTestedRating = $aValues['sTestedRating']; $this->sComments = $aValues['sComments']; } function getTestingQueue($sQueued='true') { if($_SESSION['current']->hasPriv("admin")) { $hResult = query_parameters("SELECT * FROM testResults WHERE queued = '?'", $sQueued); if(!$hResult || mysql_num_rows($hResult) == 0) return; } else { $hResult = query_parameters("SELECT * FROM testResults WHERE queued = '?' AND submitterId = '?'", $sQueued, $_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 ""; while($oRow = mysql_fetch_object($hResult)) { $oTest = new testData($oRow->testingId); $oVersion = new Version($oTest->iVersionId); // don't show test results of versions that are still queued. if ($oVersion->sQueued == 'false') { $oApp = new Application($oVersion->iAppId); $oSubmitter = new User($oTest->iSubmitterId); $bgcolor = $oTest->sTestedRating; echo '',"\n"; echo " \n"; echo " \n"; echo ' '; echo ' '; echo " \n"; echo " \n"; echo " \n"; echo "\n\n"; } } echo "
    Submission Date Submitter Application Version Release Rating Action
    ".print_date(mysqltimestamp_to_unixtimestamp($oTest->sSubmitTime))."\n"; echo $oSubmitter->sEmail ? "sEmail."\">":""; echo $oSubmitter->sRealname; echo $oSubmitter->sEmail ? "":""; echo " '.$oApp->sName.''.$oVersion->sName.'".$oTest->sTestedRelease."".$oTest->sTestedRating."[iTestingId.">process]
    ","\n"; echo html_frame_end(); } /* Get the number of TestResults in the database */ function getNumberOfQueuedTests() { $sQuery = "SELECT count(*) as num_tests FROM testResults, appVersion WHERE appVersion.versionId=testResults.versionId and appVersion.queued='false' and testResults.queued='true';"; $hResult = query_parameters($sQuery); if($hResult) { $oRow = mysql_fetch_object($hResult); return $oRow->num_tests; } return 0; } function make_Installs_list($sVarname, $sSelectedValue) { echo "\n"; } function make_Runs_list($sVarname, $sSelectedValue) { echo "\n"; } /* List test data submitted by a given user. Ignore test results for queued applications/versions */ function listSubmittedBy($iUserId, $bQueued = true) { $hResult = query_parameters("SELECT testResults.versionId, testResults.testedDate, testResults.testedRelease, testResults.testedRating, testResults.submitTime, appFamily.appName, appVersion.versionName from testResults, appFamily, appVersion WHERE testResults.versionId = appVersion.versionId AND appVersion.appId = appFamily.appId AND (appFamily.queued = '?' OR appVersion.queued = '?') AND testResults.submitterId = '?' AND testResults.queued = '?' ORDER BY testResults.testingId", "false", "false", $iUserId, $bQueued ? "true" : "false"); if(!$hResult || !mysql_num_rows($hResult)) return false; $sReturn = html_table_begin("width=\"100%\" align=\"center\""); $sReturn .= html_tr(array( "Version", "Rating", "Wine version", "Submission Date"), "color4"); for($i = 1; $oRow = mysql_fetch_object($hResult); $i++) $sReturn .= html_tr(array( "versionId\">$oRow->appName: $oRow->versionName", $oRow->testedRating, $oRow->testedRelease, print_date(mysqltimestamp_to_unixtimestamp($oRow->submitTime))), $oRow->testedRating); $sReturn .= html_table_end(); return $sReturn; } } ?>