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; exit;
$oNote = new Note(); $oNote = new Note();
$oNote->GetOutputEditorValues(); $oNote->GetOutputEditorValues($_REQUEST);
if($aClean['sSub'] == "Submit") if($aClean['sSub'] == "Submit")
{ {

View File

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

View File

@@ -29,7 +29,7 @@ if ($aClean['sSub'])
if(is_numeric($aClean['iTestingId'])) if(is_numeric($aClean['iTestingId']))
{ {
$oTest = new testData($aClean['iTestingId']); $oTest = new testData($aClean['iTestingId']);
$oTest->GetOutputEditorValues(); $oTest->GetOutputEditorValues($_REQUEST);
if($aClean['sSub'] == 'Submit') // submit the testing results 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'])) if(!empty($aClean['sSub']))
{ {
$oNote->GetOutputEditorValues(); /* retrieve the updated values */ $oNote->GetOutputEditorValues($_REQUEST); /* retrieve the updated values */
if ($aClean['sSub'] == 'Delete') if ($aClean['sSub'] == 'Delete')
{ {
@@ -45,7 +45,7 @@ if(!empty($aClean['sSub']))
/* if preview is set display the note for review */ /* if preview is set display the note for review */
if($aClean['sPreview']) if($aClean['sPreview'])
{ {
$oNote->GetOutputEditorValues(); /* retrieve the updated values */ $oNote->GetOutputEditorValues($_REQUEST); /* retrieve the updated values */
$oNote->show(true); $oNote->show(true);
} }

View File

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

View File

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

View File

@@ -457,58 +457,40 @@ class Application {
echo html_frame_end(); 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 = ""; $errors = "";
if (empty($aClean['iAppCatId'])) if (empty($aValues['iAppCatId']))
$errors .= "<li>Please enter a category for your application.</li>\n"; $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"; $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"; $errors .= "<li>Please enter an application name.</li>\n";
// No vendor entered, and nothing in the list is selected // 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"; $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"; $errors .= "<li>Please enter a description of your application.</li>\n";
return $errors; return $errors;
} }
/* retrieves values from $_REQUEST that were output by OutputEditor() */ /* 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 $this->iAppId = $aValues['iAppId'];
$this->sName = $aValues['sAppName'];
$aClean['iAppId'] = makeSafe($_REQUEST['iAppId']); $this->sDescription = $aValues['shAppDescription'];
$aClean['iAppVendorId'] = makeSafe($_REQUEST['iAppVendorId']); $this->iCatId = $aValues['iAppCatId'];
$aClean['sAppName'] = makeSafe($_REQUEST['sAppName']); $this->iVendorId = $aValues['iAppVendorId'];
$aClean['shAppDescription'] = makeSafe($_REQUEST['shAppDescription']); $this->sWebpage = $aValues['sAppWebpage'];
$aClean['iAppCatId'] = makeSafe($_REQUEST['iAppCatId']); $this->sKeywords = $aValues['sAppKeywords'];
$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'];
} }
/* display this application */ /* display this application */

View File

@@ -378,20 +378,13 @@ class distribution{
} }
/* retrieves values from $_REQUEST that were output by OutputEditor() */ /* 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)
{ {
$this->iDistributionId = $aValues['iDistributionId'];
$aClean = array(); //array of filtered user input $this->sName = $aValues['sName'];
$this->sUrl = $aValues['sUrl'];
$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'];
} }
} }
/* Make a dropdown list of distributions */ /* Make a dropdown list of distributions */

View File

@@ -245,19 +245,13 @@ class Note {
} }
/* retrieves values from $_REQUEST that were output by OutputEditor() */ /* 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 $this->iVersionId = $aValues['iVersionId'];
$this->iAppId = $aValues['iAppId'];
$aClean['iVersionId'] = makeSafe($_REQUEST['iVersionId']); $this->sTitle = $aValues['sNoteTitle'];
$aClean['iAppId'] = makeSafe( $_REQUEST['iAppId']); $this->sDescription = $aValues['sNoteDesc'];
$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'];
} }
} }
?> ?>

View File

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

View File

@@ -592,11 +592,11 @@ function process_app_version_changes($isVersion)
// commit changes of form to database // commit changes of form to database
if(($_REQUEST['sSubmit'] == "Update Database") && $isVersion) /* is a version */ if(($_REQUEST['sSubmit'] == "Update Database") && $isVersion) /* is a version */
{ {
$oVersion->GetOutputEditorValues(); $oVersion->GetOutputEditorValues($_REQUEST);
$oVersion->update(); $oVersion->update();
} else if(($_REQUEST['sSubmit'] == "Update Database") && !$isVersion) /* is an application */ } else if(($_REQUEST['sSubmit'] == "Update Database") && !$isVersion) /* is an application */
{ {
$oApp->GetOutputEditorValues(); $oApp->GetOutputEditorValues($_REQUEST);
$oApp->update(); $oApp->update();
} else if($_REQUEST['sSubmit'] == "Update URL") } 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 = ""; $errors = "";
if (empty($aClean['sVersionName'])) if (empty($aValues['sVersionName']))
$errors .= "<li>Please enter an application version.</li>\n"; $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"; $errors .= "<li>Please enter a version description.</li>\n";
return $errors; return $errors;
} }
/* retrieves values from $_REQUEST that were output by OutputEditor() */ /* 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 $this->iAppId = $aValues['iAppId'];
$aClean['iAppId'] = makeSafe($_REQUEST['iAppId']); $this->iVersionId = $aValues['iVersionId'];
$aClean['iVersionId'] = makeSafe($_REQUEST['iVersionId']); $this->sName = $aValues['sVersionName'];
$aClean['sVersionName'] = makeSafe($_REQUEST['sVersionName']); $this->sDescription = $aValues['shVersionDescription'];
$aClean['shVersionDescription'] = makeSafe($_REQUEST['shVersionDescription']); $this->sTestedRating = $aValues['sMaintainerRating'];
$aClean['sMaintainerRating'] = makeSafe($_REQUEST['sMaintainerRating']); $this->sTestedRelease = $aValues['sMaintainerRelease'];
$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'];
} }
function display() function display()

View File

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