BUG 5357 The Trigger Wizard doesn't check whether the user... SOLVED

- No validation is performed.
- Was add validation in the Trigger Wizard.
This commit is contained in:
Marco Antonio Nina
2012-09-28 12:07:28 -04:00
parent e31c8d2651
commit d2ac677428
8 changed files with 84 additions and 57 deletions

View File

@@ -113,19 +113,15 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<input type="hidden" name="PMFUNTION_NAME" <input type="hidden" id="FIELDS_REQUIRED" name="FIELDS_REQUIRED" value="{FIELDS_REQUIRED}">
value="{PMFUNTION}"> <input type="hidden" name="PMFUNTION_NAME" value="{PMFUNTION}">
<input type="hidden" name="LIBRARY_CLASS" <input type="hidden" name="LIBRARY_CLASS" value="{LIBRARY_CLASS}">
value="{LIBRARY_CLASS}">
<input type="hidden" id="PRO_UID" name="PRO_UID" value="{PRO_UID}"> <input type="hidden" id="PRO_UID" name="PRO_UID" value="{PRO_UID}">
<input type="hidden" id="ALLFUNCTION" name="ALLFUNCTION" <input type="hidden" id="ALLFUNCTION" name="ALLFUNCTION" value="{ALLFUNCTION}">
value="{ALLFUNCTION}"> <input type="hidden" name="PAGED_TABLE_ID" id="PAGED_TABLE_ID" value="{PAGED_TABLE_ID}">
<input type="hidden" name="PAGED_TABLE_ID" <input type="hidden" name="LIBRARY_NAME" id="LIBRARY_NAME" value="{LIBRARY_NAME}">
id="PAGED_TABLE_ID" value="{PAGED_TABLE_ID}"> <input type="hidden" name="PMFUNTION_LABEL" id="PMFUNTION_LABEL" value="{PMFUNTION_LABEL}">
<input type="hidden" name="LIBRARY_NAME"
id="LIBRARY_NAME" value="{LIBRARY_NAME}">
<input type="hidden" name="PMFUNTION_LABEL"
id="PMFUNTION_LABEL" value="{PMFUNTION_LABEL}">
<td class="FormButton" colspan="2" align=""><input <td class="FormButton" colspan="2" align=""><input
style="" class='module_app_button___gray ' id="savek" style="" class='module_app_button___gray ' id="savek"
name="savek" type='button' value="{ID_SAVE}" name="savek" type='button' value="{ID_SAVE}"

View File

@@ -61,15 +61,21 @@ try {
$methodreturnDescription = (trim(strtoupper($methodreturnA[3])) == strtoupper(G::LoadTranslation('ID_NONE'))) $methodreturnDescription = (trim(strtoupper($methodreturnA[3])) == strtoupper(G::LoadTranslation('ID_NONE')))
? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA[3]; ? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA[3];
$methodReturnLabel = isset ( $methodreturnA[3] ) ? $methodreturnDescription : $methodReturn; $methodReturnLabel = isset ( $methodreturnA[3] ) ? $methodreturnDescription : $methodReturn;
$fieldRequired = array ();
if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) if ( (isset($methodreturnA[0]) && isset($methodreturnA[1]))
&& (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) {
$methodReturnLabelRequired = (trim( $methodreturnA[1] ) != "" ) if (trim( $methodreturnA[1] ) != "") {
? G::LoadTranslation ( "ID_REQUIRED_FIELD" ) : $methodreturnA[1]; $methodReturnLabelRequired = G::LoadTranslation ( "ID_REQUIRED_FIELD" );
$fieldRequired[] = 'TRI_ANSWER';
} else {
$methodReturnLabelRequired = $methodreturnA[1];
}
$methodReturnLabel .= "<br>" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]); $methodReturnLabel .= "<br>" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]);
} else { } else {
$bReturnValue = false; $bReturnValue = false;
$displayMode = 'display:none'; $displayMode = 'display:none';
} }
$aParametersFun = $methodParameters; $aParametersFun = $methodParameters;
$triggerWizardTemplate = PATH_TPL . 'triggers' . PATH_SEP . 'triggers_CreateWizard.html'; $triggerWizardTemplate = PATH_TPL . 'triggers' . PATH_SEP . 'triggers_CreateWizard.html';
$template = new TemplatePower ( $triggerWizardTemplate ); $template = new TemplatePower ( $triggerWizardTemplate );
@@ -112,6 +118,7 @@ try {
$sPMfunction = $sNameFun . " ("; $sPMfunction = $sNameFun . " (";
$methodParametersOnlyNames = array (); $methodParametersOnlyNames = array ();
if (count ( $aParametersFun ) > 0) { if (count ( $aParametersFun ) > 0) {
$template->newBlock ( 'paremetersTriggersGroup' ); $template->newBlock ( 'paremetersTriggersGroup' );
$template->assign ( 'PARAMETERS_LABEL', G::LoadTranslation ( 'ID_PARAMETERS' ) ); $template->assign ( 'PARAMETERS_LABEL', G::LoadTranslation ( 'ID_PARAMETERS' ) );
@@ -145,16 +152,19 @@ try {
str_replace ( "'", "", str_replace ( '"', '', $paramDefaultValue ) ) ); str_replace ( "'", "", str_replace ( '"', '', $paramDefaultValue ) ) );
$fieldDescription = ($paramDescription!="")?$paramDescription . "<br>":""; $fieldDescription = ($paramDescription!="")?$paramDescription . "<br>":"";
$fieldDescription .= $paramDefaultValue != "" if ($paramDefaultValue != "") {
? $paramDefaultValue . " | " . $paramType $fieldDescription .= $paramDefaultValue . " | " . $paramType;
: G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType; } else {
$fieldDescription .= G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType;
$fieldRequired[] = trim (str_replace ("$", "", $paramName));
}
$template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription ); $template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription );
$nrows ++; $nrows ++;
} }
} }
} }
$template->gotoBlock ( '_ROOT' ); $template->gotoBlock ( '_ROOT' );
$template->assign ('FIELDS_REQUIRED', implode ( ",", $fieldRequired ));
$template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) ); $template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) );
$sPMfunction .= ");"; $sPMfunction .= ");";
$content = $template->getOutputContent (); $content = $template->getOutputContent ();

View File

@@ -120,18 +120,14 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<input type="hidden" name="PMFUNTION_NAME" <input type="hidden" id="FIELDS_REQUIRED" name="FIELDS_REQUIRED" value="{FIELDS_REQUIRED}">
value="{PMFUNTION}"> <input type="hidden" name="PMFUNTION_NAME" value="{PMFUNTION}">
<input type="hidden" name="LIBRARY_CLASS" <input type="hidden" name="LIBRARY_CLASS" value="{LIBRARY_CLASS}">
value="{LIBRARY_CLASS}">
<input type="hidden" id="PRO_UID" name="PRO_UID" value="{PRO_UID}"> <input type="hidden" id="PRO_UID" name="PRO_UID" value="{PRO_UID}">
<input type="hidden" id="ALLFUNCTION" name="ALLFUNCTION" value="{ALLFUNCTION}"> <input type="hidden" id="ALLFUNCTION" name="ALLFUNCTION" value="{ALLFUNCTION}">
<input type="hidden" name="PAGED_TABLE_ID" <input type="hidden" name="PAGED_TABLE_ID" id="PAGED_TABLE_ID" value="{PAGED_TABLE_ID}">
id="PAGED_TABLE_ID" value="{PAGED_TABLE_ID}"> <input type="hidden" name="LIBRARY_NAME" id="LIBRARY_NAME" value="{LIBRARY_NAME}">
<input type="hidden" name="LIBRARY_NAME" <input type="hidden" name="PMFUNTION_LABEL" id="PMFUNTION_LABEL" value="{PMFUNTION_LABEL}">
id="LIBRARY_NAME" value="{LIBRARY_NAME}">
<input type="hidden" name="PMFUNTION_LABEL"
id="PMFUNTION_LABEL" value="{PMFUNTION_LABEL}">
<td class="FormButton" colspan="2" align=""><input <td class="FormButton" colspan="2" align=""><input
style="" class='module_app_button___gray ' id="savek" style="" class='module_app_button___gray ' id="savek"
name="savek" type='button' value="{ID_SAVE}" name="savek" type='button' value="{ID_SAVE}"

View File

@@ -54,6 +54,7 @@ try {
$bReturnValue = true; $bReturnValue = true;
$displayMode = 'display:block'; $displayMode = 'display:block';
$methodreturnDescription = ""; $methodreturnDescription = "";
$fieldRequired = array ();
if (isset($methodreturnA[3])) { if (isset($methodreturnA[3])) {
$methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ('ID_NONE'))) $methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ('ID_NONE')))
? G::LoadTranslation ( 'ID_NOT_REQUIRED') ? G::LoadTranslation ( 'ID_NOT_REQUIRED')
@@ -62,8 +63,12 @@ try {
$methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn;
if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) if ( (isset($methodreturnA[0]) && isset($methodreturnA[1]))
&& (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) {
$methodReturnLabelRequired = (trim( $methodreturnA[1] ) != "" ) if (trim( $methodreturnA[1] ) != "") {
? G::LoadTranslation ( "ID_REQUIRED_FIELD" ) : $methodreturnA[1]; $methodReturnLabelRequired = G::LoadTranslation ( "ID_REQUIRED_FIELD" );
$fieldRequired[] = 'TRI_ANSWER';
} else {
$methodReturnLabelRequired = $methodreturnA[1];
}
$methodReturnLabel .= "<br>" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]); $methodReturnLabel .= "<br>" . trim( $methodReturnLabelRequired ) . " | " . trim($methodreturnA[0]);
} else { } else {
$bReturnValue = false; $bReturnValue = false;
@@ -148,10 +153,14 @@ try {
// str_replace ( '"', '', $paramDefaultValue ) ) ); // str_replace ( '"', '', $paramDefaultValue ) ) );
$paramValue = $_GET[trim( str_replace( "$", "", $paramName ) )]; $paramValue = $_GET[trim( str_replace( "$", "", $paramName ) )];
$template->assign ( 'ADD_TRI_VALUE', str_replace("\'", "&apos;", $paramValue) ); $template->assign ( 'ADD_TRI_VALUE', str_replace("\'", "&apos;", $paramValue) );
$fieldDescription = ($paramDescription!="")?$paramDescription . "<br>":""; if ($paramDefaultValue != "") {
$fieldDescription .= $paramDefaultValue != "" $fieldDescription = $paramDescription . "<br>";
? $paramDefaultValue . " | " . $paramType $fieldDescription .= $paramDefaultValue . " | " . $paramType;
: G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType; } else {
$fieldDescription = "";
$fieldDescription .= G::LoadTranslation ( "ID_REQUIRED_FIELD" ) . " | " . $paramType;
$fieldRequired[] = trim (str_replace ("$", "", $paramName));
}
$template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription ); $template->assign ( 'ADD_TRI_DESCRIPTION', $fieldDescription );
$nrows ++; $nrows ++;
@@ -160,6 +169,7 @@ try {
} }
$template->gotoBlock ( '_ROOT' ); $template->gotoBlock ( '_ROOT' );
$template->assign ('FIELDS_REQUIRED', implode ( ",", $fieldRequired ));
$template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) ); $template->assign ( 'ALLFUNCTION', implode ( ",", $methodParametersOnlyNames ) );
$sPMfunction .= ");"; $sPMfunction .= ");";
$content = $template->getOutputContent (); $content = $template->getOutputContent ();

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<dynaForm name="triggersProperties" type="xmlform" width="100%" labelWidth="20%" enableTemplate="1"> <dynaForm name="triggersProperties" type="xmlform" width="100%" labelWidth="20%" enableTemplate="1">
<PRO_UID type="hidden"/> <PRO_UID type="hidden"/>
<FIELDS_REQUIRED type="hidden"/>
<TITLE type="title" group="1"> <TITLE type="title" group="1">

View File

@@ -7,6 +7,7 @@
<td valign="top"> <td valign="top">
<input class="notValidateThisFields" name="__notValidateThisFields__" id="__notValidateThisFields__" value="" type="hidden"> <input class="notValidateThisFields" name="__notValidateThisFields__" id="__notValidateThisFields__" value="" type="hidden">
<input name="DynaformRequiredFields" id="DynaformRequiredFields" value="{$form_objectRequiredFields}" type="hidden"> <input name="DynaformRequiredFields" id="DynaformRequiredFields" value="{$form_objectRequiredFields}" type="hidden">
<input name="FIELDS_REQUIRED" id="FIELDS_REQUIRED" value="{$FIELDS_REQUIRED}" type="hidden">
<table border="0" cellpadding="0" cellspacing="0" width="100%"> <table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr style="display: none;"> <tbody><tr style="display: none;">
<td colspan="2">{$form.TRI_UID}{$form.PRO_UID}</td> <td colspan="2">{$form.TRI_UID}{$form.PRO_UID}</td>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<dynaForm name="triggersProperties" type="xmlform" width="100%" labelWidth="20%" enableTemplate="1"> <dynaForm name="triggersProperties" type="xmlform" width="100%" labelWidth="20%" enableTemplate="1">
<PRO_UID type="hidden"/> <PRO_UID type="hidden"/>
<FIELDS_REQUIRED type="hidden"/>
<TITLE type="title" group="1"> <TITLE type="title" group="1">
<en>Trigger Information</en> <en>Trigger Information</en>
</TITLE> </TITLE>

View File

@@ -9,6 +9,7 @@
<PRO_UID type="private"/> <PRO_UID type="private"/>
<FIELDS_REQUIRED type="private"/>
<triggersEdit type="private" defaultValue="../triggers/triggers_Edit"/> <triggersEdit type="private" defaultValue="../triggers/triggers_Edit"/>
@@ -94,11 +95,21 @@
if(document.getElementById('TRI_UID')) { if(document.getElementById('TRI_UID')) {
var triUid = document.getElementById('TRI_UID').value; var triUid = document.getElementById('TRI_UID').value;
} }
if(triUid==''){
var triTitle =document.getElementById('TRI_TITLE').value; var triTitle =document.getElementById('TRI_TITLE').value;
if(triTitle==''){ if(triTitle==''){
alert(G_STRINGS.ID_REQUIRED_NAME_TRIGGERS);return false; alert(G_STRINGS.ID_REQUIRED_NAME_TRIGGERS);return false;
} }
var fieldsRequired = document.getElementById('FIELDS_REQUIRED').value;
fieldsRequired = fieldsRequired.split(",");
for (i=0; i<fieldsRequired.length; i++)
{
var field = document.getElementById(fieldsRequired[i]).value;
if (field == '') {
alert(_('ID_REQUIRED_FIELDS_ERROR'));return false;
}
}
if(triUid==''){
reqName=ajax_function("../triggers/triggers_Save",'lookforNameTrigger','NAMETRIGGER='+encodeURIComponent(triTitle)+'&proUid='+(document.getElementById('PRO_UID').value),'POST') ; reqName=ajax_function("../triggers/triggers_Save",'lookforNameTrigger','NAMETRIGGER='+encodeURIComponent(triTitle)+'&proUid='+(document.getElementById('PRO_UID').value),'POST') ;
if(!reqName){ if(!reqName){
alert(G_STRINGS.ID_EXIST_TRIGGERS);return false; alert(G_STRINGS.ID_EXIST_TRIGGERS);return false;
@@ -108,6 +119,7 @@
@#PAGED_TABLE_ID.refresh(); @#PAGED_TABLE_ID.refresh();
} }
}else{ }else{
ajax_post(form.action, form, 'POST'); ajax_post(form.action, form, 'POST');
currentPopupWindow.remove(); currentPopupWindow.remove();
@#PAGED_TABLE_ID.refresh(); @#PAGED_TABLE_ID.refresh();