Pass input arrays into GetOutputEditoValues() and CheckOutputEditorInput(). We don't want

classes to be hardcoded to read directly from $_REQUEST
This commit is contained in:
Chris Morgan
2006-07-08 22:06:28 +00:00
committed by WineHQ
parent 4708101f01
commit f05c05864e
13 changed files with 85 additions and 153 deletions

View File

@@ -37,7 +37,7 @@ else
exit;
$oNote = new Note();
$oNote->GetOutputEditorValues();
$oNote->GetOutputEditorValues($_REQUEST);
if($aClean['sSub'] == "Submit")
{

View File

@@ -184,12 +184,12 @@ if ($aClean['sSub'])
{
$oVersion = new Version($aClean['iVersionId']);
$oTest = new testData($aClean['iTestingId']);
$oVersion->GetOutputEditorValues();
$oTest->GetOutputEditorValues();
$oVersion->GetOutputEditorValues($_REQUEST);
$oTest->GetOutputEditorValues($_REQUEST);
if ($aClean['sAppType'] == "application") // application
{
$oApp = new Application($aClean['iAppId']);
$oApp->GetOutputEditorValues(); // load the values from $_REQUEST
$oApp->GetOutputEditorValues($_REQUEST); // load the values from $_REQUEST
// add new vendor
if($aClean['sAppVendorName'] and !$aClean['iAppVendorId'])
{
@@ -263,12 +263,12 @@ if ($aClean['sSub'])
{
$oVersion = new Version($aClean['iVersionId']);
$oTest = new testData($aClean['iTestingId']);
$oVersion->GetOutputEditorValues();
$oTest->GetOutputEditorValues();
$oVersion->GetOutputEditorValues($_REQUEST);
$oTest->GetOutputEditorValues($_REQUEST);
if ($aClean['sAppType'] == "application") // application
{
$oApp = new Application($aClean['iAppId']);
$oApp->GetOutputEditorValues(); // load the values from $_REQUEST
$oApp->GetOutputEditorValues($_REQUEST); // load the values from $_REQUEST
$oApp->update(true);
$oApp->reject();
}

View File

@@ -29,7 +29,7 @@ if ($aClean['sSub'])
if(is_numeric($aClean['iTestingId']))
{
$oTest = new testData($aClean['iTestingId']);
$oTest->GetOutputEditorValues();
$oTest->GetOutputEditorValues($_REQUEST);
if($aClean['sSub'] == 'Submit') // submit the testing results
{

View File

@@ -26,7 +26,7 @@ if(!$_SESSION['current']->hasPriv("admin") && !$_SESSION['current']->isMaintaine
if(!empty($aClean['sSub']))
{
$oNote->GetOutputEditorValues(); /* retrieve the updated values */
$oNote->GetOutputEditorValues($_REQUEST); /* retrieve the updated values */
if ($aClean['sSub'] == 'Delete')
{
@@ -45,7 +45,7 @@ if(!empty($aClean['sSub']))
/* if preview is set display the note for review */
if($aClean['sPreview'])
{
$oNote->GetOutputEditorValues(); /* retrieve the updated values */
$oNote->GetOutputEditorValues($_REQUEST); /* retrieve the updated values */
$oNote->show(true);
}

View File

@@ -15,7 +15,7 @@ if(!$_SESSION['current']->hasPriv("admin"))
$oDistribution = new distribution($aClean['iDistributionId']);
if($aClean['sSubmit'])
{
$oDistribution->GetOutputEditorValues();
$oDistribution->GetOutputEditorValues($_REQUEST);
if($oDistribution->iDistributionId)
$oDistribution->update();

View File

@@ -158,15 +158,15 @@ if ($aClean['sSub'])
$errors = "";
$oVersion = new Version($aClean['iVersionId']);
$oTest = new testData($aClean['iTestingId']);
$errors .= $oVersion->CheckOutputEditorInput();
$errors .= $oTest->CheckOutputEditorInput();
$oVersion->GetOutputEditorValues();
$oTest->GetOutputEditorValues();
$errors .= $oVersion->CheckOutputEditorInput($_REQUEST);
$errors .= $oTest->CheckOutputEditorInput($_REQUEST);
$oVersion->GetOutputEditorValues($_REQUEST);
$oTest->GetOutputEditorValues($_REQUEST);
if ($aClean['sAppType'] == "application") // application
{
$oApp = new Application($aClean['iAppId']);
$errors .= $oApp->CheckOutputEditorInput();
$oApp->GetOutputEditorValues(); // load the values from $_REQUEST
$errors .= $oApp->CheckOutputEditorInput($_REQUEST);
$oApp->GetOutputEditorValues($_REQUEST); // load the values from $_REQUEST
if(empty($errors))
{

View File

@@ -457,58 +457,40 @@ class Application {
echo html_frame_end();
}
function CheckOutputEditorInput()
function CheckOutputEditorInput($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['iAppCatId'] = makeSafe($_REQUEST['iAppCatId']);
$aClean['sAppName'] = makeSafe($_REQUEST['sAppName']);
$aClean['sAppVendorName'] = makeSafe($_REQUEST['sAppVendorName']);
$aClean['iAppVendorId'] = makeSafe($_REQUEST['iAppVendorId']);
$aClean['shAppDescription'] = makeSafe($_REQUEST['shAppDescription']);
$errors = "";
if (empty($aClean['iAppCatId']))
if (empty($aValues['iAppCatId']))
$errors .= "<li>Please enter a category for your application.</li>\n";
if (strlen($aClean['sAppName']) > 200 )
if (strlen($aValues['sAppName']) > 200 )
$errors .= "<li>Your application name is too long.</li>\n";
if (empty($aClean['sAppName']))
if (empty($aValues['sAppName']))
$errors .= "<li>Please enter an application name.</li>\n";
// No vendor entered, and nothing in the list is selected
if (empty($aClean['sAppVendorName']) && !$aClean['iAppVendorId'])
if (empty($aValues['sAppVendorName']) && !$aValues['iAppVendorId'])
$errors .= "<li>Please enter a vendor.</li>\n";
if (empty($aClean['shAppDescription']))
if (empty($aValues['shAppDescription']))
$errors .= "<li>Please enter a description of your application.</li>\n";
return $errors;
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function GetOutputEditorValues($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['iAppId'] = makeSafe($_REQUEST['iAppId']);
$aClean['iAppVendorId'] = makeSafe($_REQUEST['iAppVendorId']);
$aClean['sAppName'] = makeSafe($_REQUEST['sAppName']);
$aClean['shAppDescription'] = makeSafe($_REQUEST['shAppDescription']);
$aClean['iAppCatId'] = makeSafe($_REQUEST['iAppCatId']);
$aClean['sAppWebpage'] = makeSafe($_REQUEST['sAppWebpage']);
$aClean['sAppKeywords'] = makeSafe($_REQUEST['sAppKeywords']);
$this->iAppId = $aClean['iAppId'];
$this->sName = $aClean['sAppName'];
$this->sDescription = $aClean['shAppDescription'];
$this->iCatId = $aClean['iAppCatId'];
$this->iVendorId = $aClean['iAppVendorId'];
$this->sWebpage = $aClean['sAppWebpage'];
$this->sKeywords = $aClean['sAppKeywords'];
$this->iAppId = $aValues['iAppId'];
$this->sName = $aValues['sAppName'];
$this->sDescription = $aValues['shAppDescription'];
$this->iCatId = $aValues['iAppCatId'];
$this->iVendorId = $aValues['iAppVendorId'];
$this->sWebpage = $aValues['sAppWebpage'];
$this->sKeywords = $aValues['sAppKeywords'];
}
/* display this application */

View File

@@ -378,20 +378,13 @@ class distribution{
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function GetOutputEditorValues($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['iDistributionId'] = makeSafe($_REQUEST['iDistributionId']);
$aClean['sName'] = makeSafe($_REQUEST['sName']);
$aClean['sUrl'] = makeSafe($_REQUEST['sUrl']);
$this->iDistributionId = $aClean['iDistributionId'];
$this->sName = $aClean['sName'];
$this->sUrl = $aClean['sUrl'];
$this->iDistributionId = $aValues['iDistributionId'];
$this->sName = $aValues['sName'];
$this->sUrl = $aValues['sUrl'];
}
}
/* Make a dropdown list of distributions */

View File

@@ -245,19 +245,13 @@ class Note {
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function GetOutputEditorValues($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['iVersionId'] = makeSafe($_REQUEST['iVersionId']);
$aClean['iAppId'] = makeSafe( $_REQUEST['iAppId']);
$aClean['sNoteTitle'] = makeSafe($_REQUEST['sNoteTitle']);
$aClean['sNoteDesc'] = makeSafe($_REQUEST['sNoteDesc']);
$this->iVersionId = $aClean['iVersionId'];
$this->iAppId = $aClean['iAppId'];
$this->sTitle = $aClean['sNoteTitle'];
$this->sDescription = $aClean['sNoteDesc'];
$this->iVersionId = $aValues['iVersionId'];
$this->iAppId = $aValues['iAppId'];
$this->sTitle = $aValues['sNoteTitle'];
$this->sDescription = $aValues['sNoteDesc'];
}
}
?>

View File

@@ -547,48 +547,37 @@ class testData{
echo html_frame_end();
}
function CheckOutputEditorInput($sDistribution="")
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function CheckOutputEditorInput($aValues, $sDistribution="")
{
$aClean = array(); //array of filtered user input
$aClean['sWhatWorks'] = trim(makeSafe($_REQUEST['sWhatWorks']));
$aClean['sWhatDoesnt'] = trim(makeSafe($_REQUEST['sWhatDoesnt']));
$aClean['sWhatNotTested'] = trim(makeSafe($_REQUEST['sWhatNotTested']));
$aClean['sDistribution'] = makeSafe($_REQUEST['sDistribution']);
$aClean['sTestedDate'] = makeSafe($_REQUEST['sTestedDate']);
$aClean['sTestedRelease'] = makeSafe($_REQUEST['sTestedRelease']);
$aClean['iDistributionId'] = makeSafe($_REQUEST['iDistributionId']);
$aClean['sInstalls'] = makeSafe($_REQUEST['sInstalls']);
$aClean['sRuns'] = makeSafe($_REQUEST['sRuns']);
$aClean['sTestedRating'] = makeSafe($_REQUEST['sTestedRating']);
$errors = "";
if (empty($aClean['sWhatWorks']))
$errors = "";
if (empty($aValues['sWhatWorks']))
$errors .= "<li>Please enter what worked.</li>\n";
if (empty($aClean['sWhatDoesnt']))
if (empty($aValues['sWhatDoesnt']))
$errors .= "<li>Please enter what did not work.</li>\n";
if (empty($aClean['sWhatNotTested']))
if (empty($aValues['sWhatNotTested']))
$errors .= "<li>Please enter what was not tested.</li>\n";
if (empty($aClean['sTestedDate']))
if (empty($aValues['sTestedDate']))
$errors .= "<li>Please enter the date and time when you tested.</li>\n";
if (empty($aClean['sTestedRelease']))
if (empty($aValues['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($aClean['sDistribution']) && !$aClean['iDistributionId'])
if (empty($aValues['sDistribution']) && !$aValues['iDistributionId'])
$errors .= "<li>Please enter a distribution.</li>\n";
if (empty($aClean['sInstalls']))
if (empty($aValues['sInstalls']))
$errors .= "<li>Please enter whether this application installs or not.</li>\n";
if (empty($aClean['sRuns']))
if (empty($aValues['sRuns']))
$errors .= "<li>Please enter whether this application runs or not.</li>\n";
if (empty($aClean['sTestedRating']))
if (empty($aValues['sTestedRating']))
$errors .= "<li>Please enter a rating based on how well this application runs.</li>\n";
return $errors;
@@ -596,35 +585,21 @@ class testData{
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function GetOutputEditorValues($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['iTestingId'] = makeSafe($_REQUEST['iTestingId']);
$aClean['iVersionId'] = makeSafe($_REQUEST['iVersionId']);
$aClean['sWhatWorks'] = makeSafe($_REQUEST['sWhatWorks']);
$aClean['sWhatDoesnt'] = makeSafe($_REQUEST['sWhatDoesnt']);
$aClean['sWhatNotTested'] = makeSafe($_REQUEST['sWhatNotTested']);
$aClean['sTestedDate'] = makeSafe($_REQUEST['sTestedDate']);
$aClean['iDistributionId'] = makeSafe($_REQUEST['iDistributionId']);
$aClean['sTestedRelease'] = makeSafe($_REQUEST['sTestedRelease']);
$aClean['sInstalls'] = makeSafe($_REQUEST['sInstalls']);
$aClean['sRuns'] = makeSafe($_REQUEST['sRuns']);
$aClean['sTestedRating'] = makeSafe($_REQUEST['sTestedRating']);
$aClean['sComments'] = makeSafe($_REQUEST['sComments']);
$this->iTestingId = $aClean['iTestingId'];
$this->iVersionId = $aClean['iVersionId'];
$this->sWhatWorks = $aClean['sWhatWorks'];
$this->sWhatDoesnt = $aClean['sWhatDoesnt'];
$this->sWhatNotTested = $aClean['sWhatNotTested'];
$this->sTestedDate = $aClean['sTestedDate'];
$this->iDistributionId = $aClean['iDistributionId'];
$this->sTestedRelease = $aClean['sTestedRelease'];
$this->sInstalls = $aClean['sInstalls'];
$this->sRuns = $aClean['sRuns'];
$this->sTestedRating = $aClean['sTestedRating'];
$this->sComments = $aClean['sComments'];
$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'];
}

View File

@@ -592,11 +592,11 @@ function process_app_version_changes($isVersion)
// commit changes of form to database
if(($_REQUEST['sSubmit'] == "Update Database") && $isVersion) /* is a version */
{
$oVersion->GetOutputEditorValues();
$oVersion->GetOutputEditorValues($_REQUEST);
$oVersion->update();
} else if(($_REQUEST['sSubmit'] == "Update Database") && !$isVersion) /* is an application */
{
$oApp->GetOutputEditorValues();
$oApp->GetOutputEditorValues($_REQUEST);
$oApp->update();
} else if($_REQUEST['sSubmit'] == "Update URL")
{

View File

@@ -578,41 +578,29 @@ class Version {
}
}
function CheckOutputEditorInput()
function CheckOutputEditorInput($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['sVersionName'] = makeSafe($_REQUEST['sVersionName']);
$aClean['shVersionDescription'] = makeSafe($_REQUEST['shVersionDescription']);
$errors = "";
if (empty($aClean['sVersionName']))
if (empty($aValues['sVersionName']))
$errors .= "<li>Please enter an application version.</li>\n";
if (empty($aClean['shVersionDescription']))
if (empty($aValues['shVersionDescription']))
$errors .= "<li>Please enter a version description.</li>\n";
return $errors;
}
/* retrieves values from $_REQUEST that were output by OutputEditor() */
function GetOutputEditorValues()
/* $aValues can be $_REQUEST or any array with the values from OutputEditor() */
function GetOutputEditorValues($aValues)
{
$aClean = array(); //array of filtered user input
$aClean['iAppId'] = makeSafe($_REQUEST['iAppId']);
$aClean['iVersionId'] = makeSafe($_REQUEST['iVersionId']);
$aClean['sVersionName'] = makeSafe($_REQUEST['sVersionName']);
$aClean['shVersionDescription'] = makeSafe($_REQUEST['shVersionDescription']);
$aClean['sMaintainerRating'] = makeSafe($_REQUEST['sMaintainerRating']);
$aClean['sMaintainerRelease'] = makeSafe($_REQUEST['sMaintainerRelease']);
$this->iAppId = $aClean['iAppId'];
$this->iVersionId = $aClean['iVersionId'];
$this->sName = $aClean['sVersionName'];
$this->sDescription = $aClean['shVersionDescription'];
$this->sTestedRating = $aClean['sMaintainerRating'];
$this->sTestedRelease = $aClean['sMaintainerRelease'];
$this->iAppId = $aValues['iAppId'];
$this->iVersionId = $aValues['iVersionId'];
$this->sName = $aValues['sVersionName'];
$this->sDescription = $aValues['shVersionDescription'];
$this->sTestedRating = $aValues['sMaintainerRating'];
$this->sTestedRelease = $aValues['sMaintainerRelease'];
}
function display()

View File

@@ -29,8 +29,8 @@ if ($aClean['sSub'])
// Submit or Resubmit the new testing results
if (($aClean['sSub'] == 'Submit') || ($aClean['sSub'] == 'Resubmit'))
{
$errors = $oTest->CheckOutputEditorInput();
$oTest->GetOutputEditorValues(); // retrieve the values from the current $_REQUEST
$errors = $oTest->CheckOutputEditorInput($_REQUEST);
$oTest->GetOutputEditorValues($_REQUEST); // retrieve the values from the current $_REQUEST
if(empty($errors))
{
if(!$aClean['iDistributionId'])