2005-10-17 03:59:24 +00:00
< ? php
/*****************************************/
2006-12-31 19:39:41 +00:00
/* this class represents Test results */
2005-10-17 03:59:24 +00:00
/*****************************************/
2006-07-21 04:21:04 +00:00
require_once ( BASE . " include/distribution.php " );
2006-06-17 06:10:10 +00:00
require_once ( BASE . " include/util.php " );
2006-12-31 19:39:41 +00:00
// Class for handling Test History.
2005-10-17 03:59:24 +00:00
class testData {
var $iTestingId ;
var $iVersionId ;
var $sWhatWorks ;
var $sWhatDoesnt ;
var $sWhatNotTested ;
var $sTestedRelease ;
var $iDistributionId ;
var $sTestedDate ;
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
2006-06-27 19:16:27 +00:00
WHERE testingId = '?' " ;
if ( $hResult = query_parameters ( $sQuery , $iTestingId ))
2005-10-17 03:59:24 +00:00
{
$oRow = mysql_fetch_object ( $hResult );
2006-11-25 17:24:44 +00:00
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 ;
}
2005-10-17 03:59:24 +00:00
}
}
}
}
// Creates a new Test Results.
function create ()
{
2006-12-31 19:39:41 +00:00
// Security, if we are not an administrator or a maintainer the test result must be queued.
2006-01-23 02:10:31 +00:00
$oVersion = new Version ( $oTest -> iVersionId );
2005-10-17 03:59:24 +00:00
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) &&
2006-01-23 02:10:31 +00:00
! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ))
2005-10-17 03:59:24 +00:00
$this -> sQueued = 'true' ;
else
$this -> sQueued = 'false' ;
2006-06-24 04:20:32 +00:00
$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 )
2005-10-17 03:59:24 +00:00
{
$this -> iTestingId = mysql_insert_id ();
$this -> testData ( $this -> iTestingId );
$this -> SendNotificationMail ();
return true ;
}
else
2006-06-24 04:20:32 +00:00
{
addmsg ( " Error while creating test results. " , " red " );
2005-10-17 03:59:24 +00:00
return false ;
2006-06-24 04:20:32 +00:00
}
2005-10-17 03:59:24 +00:00
}
// Update Test Results.
function update ( $bSilent = false )
{
2006-12-31 19:39:41 +00:00
// is the current user allowed to update this test result?
2006-01-23 02:10:31 +00:00
$oVersion = new Version ( $this -> iVersionId );
2005-10-17 03:59:24 +00:00
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) &&
2006-01-23 02:10:31 +00:00
! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ) &&
2005-10-17 03:59:24 +00:00
! (( $_SESSION [ 'current' ] -> iUserId == $this -> iSubmitterId ) && ! ( $this -> sQueued == 'false' )))
{
return ;
}
2006-07-04 03:43:06 +00:00
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 ,
2006-06-27 19:16:27 +00:00
$this -> iTestingId ))
2005-10-17 03:59:24 +00:00
{
if ( ! $bSilent )
$this -> SendNotificationMail ();
return true ;
}
else
2006-06-27 19:16:27 +00:00
{
addmsg ( " Error while updating test results " , " red " );
2005-10-17 03:59:24 +00:00
return false ;
2006-06-27 19:16:27 +00:00
}
2005-10-17 03:59:24 +00:00
}
2006-12-31 19:39:41 +00:00
// Delete test results.
2005-10-17 03:59:24 +00:00
function delete ( $bSilent = false )
{
2006-12-31 19:39:41 +00:00
// is the current user allowed to delete this test result?
2006-01-23 02:10:31 +00:00
$oVersion = new Version ( $this -> iVersionId );
2005-10-17 03:59:24 +00:00
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) &&
2006-01-23 02:10:31 +00:00
! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ) &&
2005-10-17 03:59:24 +00:00
! (( $_SESSION [ 'current' ] -> iUserId == $this -> iSubmitterId ) && ! ( $this -> sQueued == 'false' )))
{
return ;
}
2006-12-31 19:39:41 +00:00
// now delete the test data
2005-10-17 03:59:24 +00:00
$sQuery = " DELETE FROM testResults
2006-06-27 19:16:27 +00:00
WHERE testingId = '?'
2005-10-17 03:59:24 +00:00
LIMIT 1 " ;
2006-06-27 19:16:27 +00:00
if ( ! ( $hResult = query_parameters ( $sQuery , $this -> iTestingId )))
2005-10-17 03:59:24 +00:00
{
2006-12-31 19:39:41 +00:00
addmsg ( " Error removing the deleted test data! " , " red " );
2005-10-17 03:59:24 +00:00
}
if ( ! $bSilent )
$this -> SendNotificationMail ( " delete " );
2006-12-27 03:23:52 +00:00
if ( $this -> iSubmitterId && ( $this -> iSubmitterId != $_SESSION [ 'current' ] -> iUserId ))
$this -> mailSubmitter ( " delete " );
2005-10-17 03:59:24 +00:00
}
2006-12-31 19:39:41 +00:00
// Move Test Data out of the queue.
2005-10-17 03:59:24 +00:00
function unQueue ()
{
2006-12-31 19:39:41 +00:00
// is the current user allowed to delete this test data?
2006-01-23 02:10:31 +00:00
$oVersion = new Version ( $this -> iVersionId );
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) &&
! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ))
2005-10-17 03:59:24 +00:00
{
return ;
}
2006-12-31 19:39:41 +00:00
// If we are not in the queue, we can't move the test data out of the queue.
2005-10-17 03:59:24 +00:00
if ( ! $this -> sQueued == 'true' )
return false ;
2006-06-27 19:16:27 +00:00
if ( query_parameters ( " UPDATE testResults SET queued = '?' WHERE testingId = '?' " ,
" false " , $this -> iTestingId ))
2005-10-17 03:59:24 +00:00
{
$this -> sQueued = 'false' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-10-17 03:59:24 +00:00
$this -> mailSubmitter ( " unQueue " );
$this -> SendNotificationMail ();
}
}
function Reject ()
{
2006-12-31 19:39:41 +00:00
// is the current user allowed to delete this test data?
2006-01-23 02:10:31 +00:00
$oVersion = new Version ( $this -> iVersionId );
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) &&
! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ))
2005-10-17 03:59:24 +00:00
{
return ;
}
// If we are not in the queue, we can't move the version out of the queue.
if ( ! $this -> sQueued == 'true' )
return false ;
2006-06-27 19:16:27 +00:00
if ( query_parameters ( " UPDATE testResults SET queued = '?' WHERE testingId = '?' " ,
" rejected " , $this -> iTestingId ))
2005-10-17 03:59:24 +00:00
{
$this -> sQueued = 'rejected' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-10-17 03:59:24 +00:00
$this -> mailSubmitter ( " reject " );
$this -> SendNotificationMail ( " reject " );
}
}
function ReQueue ()
{
// is the current user allowed to requeue this data
2006-01-23 02:10:31 +00:00
$oVersion = new Version ( $this -> iVersionId );
2005-10-17 03:59:24 +00:00
if ( ! $_SESSION [ 'current' ] -> hasPriv ( " admin " ) &&
2006-01-23 02:10:31 +00:00
! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ) &&
2005-10-17 03:59:24 +00:00
! $_SESSION [ 'current' ] -> iUserId == $this -> iSubmitterId )
{
return ;
}
2006-06-27 19:16:27 +00:00
if ( query_parameters ( " UPDATE testResults SET queued = '?' WHERE testingId = '?' " ,
" true " , $this -> iTestingId ))
2005-10-17 03:59:24 +00:00
{
$this -> sQueued = 'true' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-10-17 03:59:24 +00:00
$this -> SendNotificationMail ();
}
}
function mailSubmitter ( $sAction = " add " )
{
2007-01-04 02:35:01 +00:00
global $aClean ;
2006-06-17 06:10:10 +00:00
2005-10-17 03:59:24 +00:00
if ( $this -> iSubmitterId )
{
$oSubmitter = new User ( $this -> iSubmitterId );
2006-12-27 03:19:43 +00:00
/* 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 " ;
2005-10-17 03:59:24 +00:00
switch ( $sAction )
{
case " add " :
$sSubject = " Submitted testing data accepted " ;
2006-12-27 03:19:43 +00:00
$sMsg = " The testing data you submitted for ' $sName ' has been accepted. " ;
2006-07-06 17:27:54 +00:00
$sMsg .= APPDB_ROOT . " appview.php?iVersionId= " . $this -> iVersionId . " &iTestingId= " . $this -> iTestingId . " \n " ;
2006-02-22 02:20:02 +00:00
$sMsg .= " Administrators Responce: \n " ;
break ;
2005-10-17 03:59:24 +00:00
case " reject " :
$sSubject = " Submitted testing data rejected " ;
2006-12-27 03:19:43 +00:00
$sMsg = " The testing data you submitted for ' $sName ' has been rejected. " ;
2006-07-06 17:27:54 +00:00
$sMsg .= APPDB_ROOT . " testResults.php?sSub=view&iTestingId= " . $this -> iTestingId . " \n " ;
2005-10-17 03:59:24 +00:00
$sMsg .= " Reason given: \n " ;
2006-02-22 02:20:02 +00:00
break ;
2005-10-17 03:59:24 +00:00
case " delete " :
$sSubject = " Submitted testing data deleted " ;
2006-12-27 03:19:43 +00:00
$sMsg = " The testing data you submitted for ' $sName ' has been deleted. " ;
2005-10-17 03:59:24 +00:00
$sMsg .= " Reason given: \n " ;
break ;
}
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ;
2005-10-17 03:59:24 +00:00
$sMsg .= " We appreciate your help in making the Application Database better for all users. " ;
2006-12-27 03:19:43 +00:00
2005-10-17 03:59:24 +00:00
mail_appdb ( $oSubmitter -> sEmail , $sSubject , $sMsg );
}
}
function SendNotificationMail ( $sAction = " add " , $sMsg = null )
{
2007-01-04 02:35:01 +00:00
global $aClean ;
2006-06-17 06:10:10 +00:00
2005-10-17 03:59:24 +00:00
$oVersion = new Version ( $this -> iVersionId );
$oApp = new Application ( $oVersion -> iAppId );
2006-07-06 17:27:54 +00:00
$sBacklink = APPDB_ROOT . " appview.php?iVersionId= " . $this -> iVersionId . " &iTestingId= " . $this -> iTestingId . " \n " ;
2006-06-30 16:38:05 +00:00
2005-10-17 03:59:24 +00:00
switch ( $sAction )
{
case " add " :
if ( $this -> sQueued == " false " )
{
$sSubject = " Test Results added to version " . $oVersion -> sName . " of " . $oApp -> sName . " submitted by " . $_SESSION [ 'current' ] -> sRealname ;
2006-06-30 16:38:05 +00:00
$sMsg .= $sBacklink ;
2005-10-17 03:59:24 +00:00
if ( $this -> iSubmitterId )
{
$oSubmitter = new User ( $this -> iSubmitterId );
2006-12-31 19:39:41 +00:00
$sMsg .= " This Test data has been submitted by " . $oSubmitter -> sRealname . " . " ;
2005-10-17 03:59:24 +00:00
$sMsg .= " \n " ;
2006-02-22 02:20:02 +00:00
}
2006-07-13 18:54:10 +00:00
if ( $aClean [ 'sReplyText' ])
2006-02-22 02:20:02 +00:00
{
2005-10-17 03:59:24 +00:00
$sMsg .= " Appdb admin reply text: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-10-17 03:59:24 +00:00
}
2006-12-31 19:39:41 +00:00
addmsg ( " The test data was successfully added into the database. " , " green " );
} else // test data queued.
2005-10-17 03:59:24 +00:00
{
$sSubject = " Test Results submitted for version " . $oVersion -> sName . " of " . $oApp -> sName . " submitted by " . $_SESSION [ 'current' ] -> sRealname ;
2006-06-30 16:38:05 +00:00
$sMsg .= $sBacklink ;
2006-12-31 19:39:41 +00:00
$sMsg .= " This test data has been queued. " ;
2005-10-17 03:59:24 +00:00
$sMsg .= " \n " ;
2006-12-31 19:39:41 +00:00
addmsg ( " The test data you submitted will be added to the database after being reviewed. " , " green " );
2005-10-17 03:59:24 +00:00
}
break ;
case " edit " :
$sSubject = " Test Results modified for version " . $oVersion -> sName . " of " . $oApp -> sName . " submitted by " . $_SESSION [ 'current' ] -> sRealname ;
2006-06-30 16:38:05 +00:00
$sMsg .= $sBacklink ;
2006-12-31 19:39:41 +00:00
addmsg ( " test data modified. " , " green " );
2005-10-17 03:59:24 +00:00
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
2006-07-13 18:54:10 +00:00
if ( $aClean [ 'sReplyText' ])
2005-10-17 03:59:24 +00:00
{
$sMsg .= " Reason given: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-10-17 03:59:24 +00:00
}
2006-12-31 19:39:41 +00:00
addmsg ( " test data deleted. " , " green " );
2005-10-17 03:59:24 +00:00
break ;
case " reject " :
$sSubject = " Test Results rejected for version " . $oVersion -> sName . " of " . $oApp -> sName . " submitted by " . $_SESSION [ 'current' ] -> sRealname ;
2006-06-30 16:38:05 +00:00
$sMsg .= $sBacklink ;
2005-10-17 03:59:24 +00:00
// if replyText is set we should report the reason the data was rejected
2006-07-13 18:54:10 +00:00
if ( $aClean [ 'sReplyText' ])
2005-10-17 03:59:24 +00:00
{
$sMsg .= " Reason given: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-10-17 03:59:24 +00:00
}
2006-12-31 19:39:41 +00:00
addmsg ( " test data rejected. " , " green " );
2005-10-17 03:59:24 +00:00
break ;
}
2006-06-29 15:54:29 +00:00
$sEmail = User :: get_notify_email_address_list ( null , $this -> iVersionId );
2005-10-17 03:59:24 +00:00
if ( $sEmail )
mail_appdb ( $sEmail , $sSubject , $sMsg );
}
2006-07-10 15:42:00 +00:00
function ShowTestResult ()
2005-10-17 03:59:24 +00:00
{
echo '<p><b>What works</b><br />' , " \n " ;
2006-07-10 15:42:00 +00:00
echo $this -> sWhatWorks ;
2006-05-04 00:24:18 +00:00
echo '<p><b>What does not</b><br />' , " \n " ;
2006-07-10 15:42:00 +00:00
echo $this -> sWhatDoesnt ;
2006-05-04 00:24:18 +00:00
echo '<p><b>What was not tested</b><br />' , " \n " ;
2006-07-10 15:42:00 +00:00
echo $this -> sWhatNotTested ;
2006-07-14 01:48:46 +00:00
echo '<p><b>Additional Comments</b><br />' , " \n " ;
echo $this -> sComments ;
2005-10-17 03:59:24 +00:00
}
// Show the Test results for a application version
2006-07-10 15:42:00 +00:00
function ShowVersionsTestingTable ( $link , $iDisplayLimit )
2005-10-17 03:59:24 +00:00
{
2007-01-04 02:35:01 +00:00
global $aClean ;
2006-06-27 19:16:27 +00:00
/* escape input parameters */
$link = mysql_real_escape_string ( $link );
$iDisplayLimit = mysql_real_escape_string ( $iDisplayLimit );
2006-06-17 06:10:10 +00:00
$showAll = $aClean [ 'showAll' ];
2006-01-28 22:53:28 +00:00
$sQuery = " SELECT *
FROM testResults
2006-07-10 15:42:00 +00:00
WHERE versionId = '".$this->iVersionId."'
2006-01-28 22:53:28 +00:00
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 )
2005-10-17 03:59:24 +00:00
return ;
2006-12-31 19:39:41 +00:00
echo '<p><span class="title">Test Results</span><br />' , " \n " ;
2005-10-17 03:59:24 +00:00
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 " ;
2005-10-28 00:14:46 +00:00
echo '<td>Test date</td>' , " \n " ;
2005-10-17 03:59:24 +00:00
echo '<td>Wine version</td>' , " \n " ;
echo '<td>Installs?</td>' , " \n " ;
echo '<td>Runs?</td>' , " \n " ;
echo '<td>Rating</td>' , " \n " ;
2006-06-30 16:38:05 +00:00
echo '<td>Status</td>' , " \n " ;
2005-10-17 03:59:24 +00:00
echo '</tr></thead>' , " \n " ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oTest = new testData ( $oRow -> testingId );
2006-08-31 02:39:09 +00:00
$oVersion = new Version ( $oTest -> iVersionId );
2006-08-30 22:27:07 +00:00
$oApp = new Application ( $oVersion -> iAppId );
2005-10-17 03:59:24 +00:00
$oSubmitter = new User ( $oTest -> iSubmitterId );
$oDistribution = new distribution ( $oTest -> iDistributionId );
$bgcolor = $oTest -> sTestedRating ;
2006-01-28 22:53:28 +00:00
2006-07-10 15:42:00 +00:00
/* if the test we are displaying is this test then */
/* mark it as the current test */
if ( $oTest -> iTestingId == $this -> iTestingId )
2006-01-28 22:53:28 +00:00
{
2006-07-21 04:34:58 +00:00
echo '<tr class=' . $bgcolor . '>' , " \n " ;
2005-10-17 03:59:24 +00:00
echo ' <td align="center" class="color2"><b>Current</b></td>' , " \n " ;
2006-07-21 04:34:58 +00:00
} else /* make all non-current rows clickable so clicking on them selects the test as current */
2006-01-28 22:53:28 +00:00
{
2006-07-21 19:18:10 +00:00
html_tr_highlight_clickable ( $link . $oTest -> iTestingId , $bgcolor , " " , " color2 " , " underline " );
2006-01-28 22:53:28 +00:00
echo ' <td align="center" class="color2">[<a href="' . $link . $oTest -> iTestingId ;
if ( is_string ( $showAll ))
echo '&showAll=' . $showAll . '">Show</a>]</td>' , " \n " ;
else
echo '">Show</a>]</td>' , " \n " ;
}
2006-06-30 16:38:05 +00:00
switch ( $oTest -> sQueued )
{
case " false " :
$sStatus = " Checked " ;
break ;
case " true " :
$sStatus = " Queued " ;
break ;
case " rejected " :
$sStatus = " Rejected " ;
break ;
}
2005-10-17 03:59:24 +00:00
echo ' <td>' , " \n " ;
echo '<a href="' . BASE . 'distributionView.php?iDistributionId=' . $oTest -> iDistributionId . '">' , " \n " ;
echo $oDistribution -> sName . '</a>' , " \n " ;
echo ' </td>' , " \n " ;
2005-10-28 00:21:37 +00:00
echo ' <td>' . date ( " M d Y " , mysqldatetime_to_unixtimestamp ( $oTest -> sTestedDate )) . '</td>' , " \n " ;
2005-10-17 03:59:24 +00:00
echo ' <td>' . $oTest -> sTestedRelease . ' </td>' , " \n " ;
echo ' <td>' . $oTest -> sInstalls . ' </td>' , " \n " ;
echo ' <td>' . $oTest -> sRuns . ' </td>' , " \n " ;
echo ' <td>' . $oTest -> sTestedRating . ' </td>' , " \n " ;
2006-06-30 16:38:05 +00:00
echo ' <td>' . $sStatus . ' </td>' , " \n " ;
2006-07-04 02:52:39 +00:00
if ( $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $oVersion ))
2006-04-03 03:51:26 +00:00
{
2006-07-06 17:27:54 +00:00
echo '<td><a href="' . BASE . 'admin/adminTestResults.php?sSub=view&iTestingId=' . $oTest -> iTestingId . '">' , " \n " ;
2006-04-03 03:51:26 +00:00
echo 'Edit</a></td>' , " \n " ;
}
2005-10-17 03:59:24 +00:00
echo '</tr>' , " \n " ;
}
echo '</table>' , " \n " ;
2006-01-28 22:53:28 +00:00
echo '<form method=get action="' . $PHP_SELF . '">' ;
2006-07-10 15:42:00 +00:00
echo '<input name="iVersionId" type=hidden value="' , $this -> iVersionId , '" />' ;
2006-01-28 22:53:28 +00:00
if ( $rowsUsed >= $iDisplayLimit && ! is_string ( $showAll ))
echo '<input class="button" name="showAll" type=submit value="Show All Tests" />' ;
if ( is_string ( $showAll ))
{
echo '<input class="button" name="hideAll" type=submit value="Limit to ' . $iDisplayLimit . ' Tests" />' ;
}
echo '</form>' ;
2005-10-17 03:59:24 +00:00
}
2006-01-28 22:53:28 +00:00
2006-07-10 15:42:00 +00:00
/* 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 ;
}
2005-10-17 03:59:24 +00:00
// show the fields for editing
2006-06-24 05:02:56 +00:00
function OutputEditor ( $sDistribution = " " , $bNewDist = false )
2005-10-17 03:59:24 +00:00
{
HtmlAreaLoaderScript ( array ( " Test1 " , " Test2 " , " Test3 " ));
2006-12-31 19:39:41 +00:00
echo html_frame_start ( " Test Form " , " 90% " , " " , 0 );
2005-10-17 03:59:24 +00:00
echo " <table width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
// What works
2006-05-04 00:24:18 +00:00
echo '<tr valign=top><td class="color0"><b>What works</b></td>' , " \n " ;
2005-10-17 03:59:24 +00:00
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
2006-05-04 00:24:18 +00:00
echo '<tr valign=top><td class=color1><b>What does not work</b></td>' , " \n " ;
2005-10-17 03:59:24 +00:00
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
2006-05-04 00:24:18 +00:00
echo '<tr valign=top><td class="color1"><b>Date tested </b></td>' , " \n " ;
2005-10-17 03:59:24 +00:00
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 " ;
2006-07-11 17:02:35 +00:00
distribution :: make_distribution_list ( " iDistributionId " , $this -> iDistributionId );
2005-10-17 03:59:24 +00:00
echo '</td></tr>' , " \n " ;
// Version List
2006-05-04 00:24:18 +00:00
echo '<tr><td class=color1><b>Tested release</b></td><td class=color0>' , " \n " ;
2005-10-17 03:59:24 +00:00
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 " ;
2006-07-10 15:39:21 +00:00
testData :: make_Installs_list ( " sInstalls " , $this -> sInstalls );
2005-10-17 03:59:24 +00:00
echo '</td></tr>' , " \n " ;
// Runs
echo '<tr><td class=color1><b>Runs?</b></td><td class=color0>' , " \n " ;
2006-07-10 15:39:21 +00:00
testData :: make_Runs_list ( " sRuns " , $this -> sRuns );
2005-10-17 03:59:24 +00:00
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 );
2006-07-06 17:27:54 +00:00
echo '<a href="' . BASE . '/help/?sTopic=maintainer_ratings" target="_blank">Rating definitions</a></td></tr>' , " \n " ;
2005-10-17 03:59:24 +00:00
// extra comments
2006-05-04 00:24:18 +00:00
echo '<tr valign=top><td class="color1"><b>Extra comments</b></td>' , " \n " ;
2005-10-17 03:59:24 +00:00
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 ();
}
2007-01-04 02:35:01 +00:00
/* $aValues can be $aValues or any array with the values from OutputEditor() */
2006-07-08 22:06:28 +00:00
function CheckOutputEditorInput ( $aValues , $sDistribution = " " )
{
$errors = " " ;
if ( empty ( $aValues [ 'sWhatWorks' ]))
2005-10-17 03:59:24 +00:00
$errors .= " <li>Please enter what worked.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sWhatDoesnt' ]))
2005-10-17 03:59:24 +00:00
$errors .= " <li>Please enter what did not work.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sWhatNotTested' ]))
2005-10-17 03:59:24 +00:00
$errors .= " <li>Please enter what was not tested.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sTestedDate' ]))
2006-05-04 00:24:18 +00:00
$errors .= " <li>Please enter the date and time when you tested.</li> \n " ;
2005-10-17 03:59:24 +00:00
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sTestedRelease' ]))
2005-10-17 03:59:24 +00:00
$errors .= " <li>Please enter the version of Wine that you tested with.</li> \n " ;
// No Distribution entered, and nothing in the list is selected
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sDistribution' ]) && ! $aValues [ 'iDistributionId' ])
2006-05-04 00:24:18 +00:00
$errors .= " <li>Please enter a distribution.</li> \n " ;
2005-10-17 03:59:24 +00:00
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sInstalls' ]))
2005-10-17 03:59:24 +00:00
$errors .= " <li>Please enter whether this application installs or not.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sRuns' ]))
2005-10-17 03:59:24 +00:00
$errors .= " <li>Please enter whether this application runs or not.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sTestedRating' ]))
2006-05-04 00:24:18 +00:00
$errors .= " <li>Please enter a rating based on how well this application runs.</li> \n " ;
2006-11-27 02:32:22 +00:00
// Basic checking of rating logic to ensure that the users test results
// are consistent
if (( $aValues [ 'sRuns' ] != " Yes " ) && ( $aValues [ 'sTestedRating' ] != GARBAGE_RATING ))
$errors .= " <li>Applications that do not run should be rated ‘Garbage’.</li> \n " ;
if (( $aValues [ 'sInstalls' ] == " No " ) && ( $aValues [ 'sTestedRating' ] == PLATINUM_RATING ))
$errors .= " <li>An application can only get a Platinum rating if it installs and runs ‘out of the box’.</li> \n " ;
2005-10-17 03:59:24 +00:00
return $errors ;
}
2007-01-04 02:35:01 +00:00
/* retrieves values from $aValues that were output by OutputEditor() */
2006-07-08 22:06:28 +00:00
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function GetOutputEditorValues ( $aValues )
2005-10-17 03:59:24 +00:00
{
2006-07-08 22:06:28 +00:00
$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' ];
2005-10-17 03:59:24 +00:00
}
function getTestingQueue ( $sQueued = 'true' )
{
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
{
2006-06-27 19:16:27 +00:00
$hResult = query_parameters ( " SELECT *
2005-10-17 03:59:24 +00:00
FROM testResults
2006-06-27 19:16:27 +00:00
WHERE queued = '?' " , $sQueued );
2005-10-17 03:59:24 +00:00
if ( ! $hResult || mysql_num_rows ( $hResult ) == 0 )
return ;
} else
{
2006-06-27 19:16:27 +00:00
$hResult = query_parameters ( " SELECT *
2005-10-17 03:59:24 +00:00
FROM testResults
2006-06-27 19:16:27 +00:00
WHERE queued = '?'
AND submitterId = '?' " ,
$sQueued , $_SESSION [ 'current' ] -> iUserId );
2005-10-17 03:59:24 +00:00
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 >
2006-07-10 03:46:48 +00:00
< td > Rating </ td >
2005-10-17 03:59:24 +00:00
< td align = \ " center \" >Action</td>
</ tr > " ;
2006-07-10 03:46:48 +00:00
2005-10-17 03:59:24 +00:00
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oTest = new testData ( $oRow -> testingId );
2006-08-31 02:39:09 +00:00
$oVersion = new Version ( $oTest -> iVersionId );
2006-12-31 19:39:41 +00:00
// don't show test results of versions that are still queued.
2006-01-17 02:34:58 +00:00
if ( $oVersion -> sQueued == 'false' )
{
2006-08-30 22:27:07 +00:00
$oApp = new Application ( $oVersion -> iAppId );
2006-01-17 02:34:58 +00:00
$oSubmitter = new User ( $oTest -> iSubmitterId );
2006-07-10 03:46:48 +00:00
$bgcolor = $oTest -> sTestedRating ;
echo '<tr class=' . $bgcolor . '>' , " \n " ;
2006-01-17 02:34:58 +00:00
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 " ;
2006-07-14 01:32:04 +00:00
echo ' <td><a href="' . BASE . 'appview.php?iAppId=' . $oApp -> iAppId . '">' . $oApp -> sName . '</a></td>' ;
echo ' <td><a href="' . BASE . 'appview.php?iVersionId=' . $oVersion -> iVersionId . '&iTestingId=' . $oTest -> iTestingId . '">' . $oVersion -> sName . '</a></td>' ;
2006-01-17 02:34:58 +00:00
echo " <td> " . $oTest -> sTestedRelease . " </td> \n " ;
2006-07-10 03:46:48 +00:00
echo " <td> " . $oTest -> sTestedRating . " </td> \n " ;
2006-07-06 17:27:54 +00:00
echo " <td align= \" center \" >[<a href= " . $_SERVER [ 'PHP_SELF' ] . " ?sSub=view&iTestingId= " . $oTest -> iTestingId . " >process</a>]</td> \n " ;
2006-01-17 02:34:58 +00:00
echo " </tr> \n \n " ;
}
2005-10-17 03:59:24 +00:00
}
2006-01-17 02:34:58 +00:00
echo " </table> " , " \n " ;
2005-10-17 03:59:24 +00:00
echo html_frame_end ();
}
2006-07-10 15:39:21 +00:00
/* Get the number of TestResults in the database */
function getNumberOfQueuedTests ()
{
$sQuery = " SELECT count(*) as num_tests
2006-01-17 02:34:58 +00:00
FROM testResults , appVersion
WHERE appVersion . versionId = testResults . versionId
and appVersion . queued = 'false'
and testResults . queued = 'true' ; " ;
2006-07-10 15:39:21 +00:00
$hResult = query_parameters ( $sQuery );
if ( $hResult )
{
$oRow = mysql_fetch_object ( $hResult );
return $oRow -> num_tests ;
}
return 0 ;
2005-10-17 03:59:24 +00:00
}
2006-07-10 15:39:21 +00:00
function make_Installs_list ( $sVarname , $sSelectedValue )
2005-10-17 03:59:24 +00:00
{
2006-07-10 15:39:21 +00:00
echo " <select name=' $sVarname '> \n " ;
echo " <option value= \" \" >Choose ...</option> \n " ;
$aRating = array ( " Yes " , " No " , " N/A " );
$iMax = count ( $aRating );
2005-10-17 03:59:24 +00:00
2006-07-10 15:39:21 +00:00
for ( $i = 0 ; $i < $iMax ; $i ++ )
{
if ( $aRating [ $i ] == $sSelectedValue )
echo " <option value=' " . $aRating [ $i ] . " ' selected> " . $aRating [ $i ] . " \n " ;
else
echo " <option value=' " . $aRating [ $i ] . " '> " . $aRating [ $i ] . " \n " ;
}
echo " </select> \n " ;
}
2005-10-17 03:59:24 +00:00
2006-07-10 15:39:21 +00:00
function make_Runs_list ( $sVarname , $sSelectedValue )
2005-10-17 03:59:24 +00:00
{
2006-07-10 15:39:21 +00:00
echo " <select name=' $sVarname '> \n " ;
echo " <option value= \" \" >Choose ...</option> \n " ;
$aRating = array ( " Yes " , " No " , " Not Installable " );
$iMax = count ( $aRating );
for ( $i = 0 ; $i < $iMax ; $i ++ )
{
if ( $aRating [ $i ] == $sSelectedValue )
echo " <option value=' " . $aRating [ $i ] . " ' selected> " . $aRating [ $i ] . " \n " ;
else
echo " <option value=' " . $aRating [ $i ] . " '> " . $aRating [ $i ] . " \n " ;
}
echo " </select> \n " ;
2005-10-17 03:59:24 +00:00
}
2006-12-27 03:26:16 +00:00
/* 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 (
" <a href= \" " . BASE . " appview.php?iVersionId= $oRow->versionId\ " > $oRow -> appName : $oRow -> versionName </ a > " ,
$oRow -> testedRating ,
$oRow -> testedRelease ,
print_date ( mysqltimestamp_to_unixtimestamp ( $oRow -> submitTime ))),
$oRow -> testedRating );
$sReturn .= html_table_end ();
return $sReturn ;
}
2005-10-17 03:59:24 +00:00
}
?>