objectManager: check editor values
This commit is contained in:
committed by
WineHQ
parent
f11a4cf77f
commit
ac978bfad7
@@ -116,7 +116,7 @@ class ObjectManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* display the entry for editing */
|
/* display the entry for editing */
|
||||||
function display_entry_for_editing($sBackLink)
|
function display_entry_for_editing($sBackLink, $sErrors)
|
||||||
{
|
{
|
||||||
$this->checkMethods(array("outputEditor", "getOutputEditorValues",
|
$this->checkMethods(array("outputEditor", "getOutputEditorValues",
|
||||||
"update", "create"));
|
"update", "create"));
|
||||||
@@ -124,9 +124,17 @@ class ObjectManager
|
|||||||
// link back to the previous page
|
// link back to the previous page
|
||||||
echo html_back_link(1, $sBackLink);
|
echo html_back_link(1, $sBackLink);
|
||||||
|
|
||||||
echo '<form name="sQform" action="'.BASE.'objectManager.php?sClass='.
|
$oObject = new $this->sClass($this->iId);
|
||||||
$this->sClass."&bIsQueue=".($this->bIsQueue ? "true" : "false").
|
|
||||||
' method="post" enctype="multipart/form-data">',"\n";
|
/* Display errors, if any, and fetch form data */
|
||||||
|
if($this->displayErrors($sErrors))
|
||||||
|
{
|
||||||
|
global $aClean;
|
||||||
|
$oObject->getOutputEditorValues($aClean);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<form name="sQform" action="'.$this->makeUrl("edit", $this->iId).
|
||||||
|
'" method="post" enctype="multipart/form-data">',"\n";
|
||||||
|
|
||||||
echo '<input type="hidden" name="sClass" value="'.$this->sClass.'" />';
|
echo '<input type="hidden" name="sClass" value="'.$this->sClass.'" />';
|
||||||
echo '<input type="hidden" name="sTitle" value="'.$this->sTitle.'" />';
|
echo '<input type="hidden" name="sTitle" value="'.$this->sTitle.'" />';
|
||||||
@@ -136,8 +144,6 @@ class ObjectManager
|
|||||||
echo '<input type="hidden" name="bIsRejected" '.
|
echo '<input type="hidden" name="bIsRejected" '.
|
||||||
'value='.($this->bIsRejected ? "true" : "false").' />';
|
'value='.($this->bIsRejected ? "true" : "false").' />';
|
||||||
|
|
||||||
$oObject = new $this->sClass($this->iId);
|
|
||||||
|
|
||||||
$oObject->outputEditor();
|
$oObject->outputEditor();
|
||||||
|
|
||||||
/* if this is a queue add a dialog for replying to the submitter of the
|
/* if this is a queue add a dialog for replying to the submitter of the
|
||||||
@@ -215,13 +221,24 @@ class ObjectManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Display screen for submitting a new entry of given type */
|
/* Display screen for submitting a new entry of given type */
|
||||||
function add_entry($sBackLink)
|
function add_entry($sBackLink, $sErrors = "")
|
||||||
{
|
{
|
||||||
$this->checkMethods(array("outputEditor", "getOutputEditorValues",
|
$this->checkMethods(array("outputEditor", "getOutputEditorValues",
|
||||||
"update", "create"));
|
"update", "create"));
|
||||||
|
|
||||||
|
|
||||||
$oObject = new $this->sClass();
|
$oObject = new $this->sClass();
|
||||||
|
|
||||||
|
/* Display help if it is exists */
|
||||||
|
if(method_exists(new $this->sClass, "objectDisplayAddItemHelp"))
|
||||||
|
$oObject->objectDisplayAddItemHelp();
|
||||||
|
|
||||||
|
/* Display errors, if any, and fetch form data */
|
||||||
|
if($this->displayErrors($sErrors))
|
||||||
|
{
|
||||||
|
global $aClean;
|
||||||
|
$oObject->getOutputEditorValues($aClean);
|
||||||
|
}
|
||||||
echo "<form method=\"post\">\n";
|
echo "<form method=\"post\">\n";
|
||||||
|
|
||||||
$oObject->outputEditor();
|
$oObject->outputEditor();
|
||||||
@@ -272,6 +289,14 @@ class ObjectManager
|
|||||||
|
|
||||||
$oObject->getOutputEditorValues($aClean);
|
$oObject->getOutputEditorValues($aClean);
|
||||||
|
|
||||||
|
/* Check input, if necessary */
|
||||||
|
if(method_exists(new $this->sClass, "checkOutputEditorInput"))
|
||||||
|
{
|
||||||
|
$sErrors = $oObject->checkOutputEditorInput($aClean);
|
||||||
|
if($sErrors)
|
||||||
|
return $sErrors;
|
||||||
|
}
|
||||||
|
|
||||||
switch($aClean['sSubmit'])
|
switch($aClean['sSubmit'])
|
||||||
{
|
{
|
||||||
case "Submit":
|
case "Submit":
|
||||||
@@ -299,12 +324,16 @@ class ObjectManager
|
|||||||
$this->delete_entry();
|
$this->delete_entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->bIsQueue)
|
/* Displaying the entire un-queued list for a class is not a good idea,
|
||||||
$sAction = "view";
|
so only do so for queued data */
|
||||||
|
if($this->bIsQueue)
|
||||||
|
$sRedirectLink = $this->makeUrl("view", false, "$this->sClass list");
|
||||||
else
|
else
|
||||||
$sAction = false;
|
$sRedirectLink = APPDB_ROOT;
|
||||||
|
|
||||||
util_redirect_and_exit($this->makeUrl($sAction, false, "$this->sClass list"));
|
util_redirect_and_exit($sRedirectLink);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make an objectManager URL based on the object and optional parameters */
|
/* Make an objectManager URL based on the object and optional parameters */
|
||||||
@@ -362,6 +391,18 @@ class ObjectManager
|
|||||||
|
|
||||||
return $sQueueString;
|
return $sQueueString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayErrors($sErrors)
|
||||||
|
{
|
||||||
|
if($sErrors)
|
||||||
|
{
|
||||||
|
echo "<font color=\"red\">\n";
|
||||||
|
echo "The following errors were found<br />\n";
|
||||||
|
echo "<ul>$sErrors</ul>\n";
|
||||||
|
echo "</font><br />";
|
||||||
|
} else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -40,8 +40,12 @@ if($aClean['bIsRejected'] == 'true')
|
|||||||
|
|
||||||
$oOtherObject = new $oObject->sClass($oObject->iId);
|
$oOtherObject = new $oObject->sClass($oObject->iId);
|
||||||
|
|
||||||
/* Certain actions must be performed before the header is set */
|
/* Certain actions must be performed before the header is set
|
||||||
$oObject->processForm($aClean);
|
processForm return TRUE on success, or a user-readable list of errors
|
||||||
|
on failure */
|
||||||
|
$sErrors = $oObject->processForm($aClean);
|
||||||
|
if($sErrors === TRUE)
|
||||||
|
$sErrors = "";
|
||||||
|
|
||||||
if($oObject->iId && $aClean['sAction'] == "delete")
|
if($oObject->iId && $aClean['sAction'] == "delete")
|
||||||
$oObject->delete_entry();
|
$oObject->delete_entry();
|
||||||
@@ -58,7 +62,7 @@ if($oObject->iId)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "edit":
|
case "edit":
|
||||||
$oObject->display_entry_for_editing($REQUEST_URI);
|
$oObject->display_entry_for_editing($REQUEST_URI, $sErrors);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -66,7 +70,7 @@ if($oObject->iId)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if ($aClean['sAction'] == "add")
|
} else if ($aClean['sAction'] == "add")
|
||||||
$oObject->add_entry($REQUEST_URI);
|
$oObject->add_entry($REQUEST_URI, $sErrors);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if displaying a queue display the help for the given queue
|
// if displaying a queue display the help for the given queue
|
||||||
|
|||||||
Reference in New Issue
Block a user