From f25e6fd24825a504e9b17b85b99953c540e52c4a Mon Sep 17 00:00:00 2001
From: kevin_fourie
Date: Thu, 7 Jun 2007 16:24:58 +0000
Subject: [PATCH] Merged in from DEV trunk...
---
plugins/ktcore/KTCorePlugin.php | 1 +
plugins/ktcore/KTWidgets.php | 5 +++++
plugins/ktcore/admin/workflow/newworkflow.inc.php | 39 ++++++++++++++++++++++++++++++++++++---
templates/ktcore/forms/widgets/hidden.smarty | 1 +
templates/ktcore/workflow/admin/new_wizard_step2.smarty | 2 +-
5 files changed, 44 insertions(+), 4 deletions(-)
create mode 100644 templates/ktcore/forms/widgets/hidden.smarty
diff --git a/plugins/ktcore/KTCorePlugin.php b/plugins/ktcore/KTCorePlugin.php
index faf96e8..d053e31 100644
--- a/plugins/ktcore/KTCorePlugin.php
+++ b/plugins/ktcore/KTCorePlugin.php
@@ -138,6 +138,7 @@ class KTCorePlugin extends KTPlugin {
$this->registerWorkflowTrigger('ktcore.workflowtriggers.copyaction', 'CopyActionTrigger', 'KTWorkflowTriggers.inc.php');
// widgets
+ $this->registerWidget('KTCoreHiddenWidget', 'ktcore.widgets.hidden', 'KTWidgets.php');
$this->registerWidget('KTCoreStringWidget', 'ktcore.widgets.string', 'KTWidgets.php');
$this->registerWidget('KTCoreSelectionWidget', 'ktcore.widgets.selection', 'KTWidgets.php');
$this->registerWidget('KTCoreEntitySelectionWidget', 'ktcore.widgets.entityselection', 'KTWidgets.php');
diff --git a/plugins/ktcore/KTWidgets.php b/plugins/ktcore/KTWidgets.php
index 9cbe478..215ff42 100644
--- a/plugins/ktcore/KTWidgets.php
+++ b/plugins/ktcore/KTWidgets.php
@@ -37,6 +37,11 @@ class KTCoreStringWidget extends KTWidget {
var $sTemplate = 'ktcore/forms/widgets/string';
}
+class KTCoreHiddenWidget extends KTWidget {
+ var $sNamespace = 'ktcore.widgets.hidden';
+ var $sTemplate = 'ktcore/forms/widgets/hidden';
+}
+
class KTCoreFileWidget extends KTWidget {
var $sNamespace = 'ktcore.widgets.file';
var $sTemplate = 'ktcore/forms/widgets/file';
diff --git a/plugins/ktcore/admin/workflow/newworkflow.inc.php b/plugins/ktcore/admin/workflow/newworkflow.inc.php
index eec9fb3..afc5e84 100644
--- a/plugins/ktcore/admin/workflow/newworkflow.inc.php
+++ b/plugins/ktcore/admin/workflow/newworkflow.inc.php
@@ -87,6 +87,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
'required' => false,
'name' => 'transitions',
)),
+ array('ktcore.widgets.hidden',array(
+ 'required' => false,
+ 'name' => 'fWizardKey',
+ 'value' => KTUtil::randomString()
+ )),
));
$oForm->setValidators(array(
@@ -95,6 +100,10 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
'output' => 'workflow_name',
)),
array('ktcore.validators.string', array(
+ 'test' => 'fWizardKey',
+ 'output' => 'fWizardKey',
+ )),
+ array('ktcore.validators.string', array(
'test' => 'states',
'output' => 'states',
'max_length' => 9999,
@@ -122,6 +131,14 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
}
function do_process_step1() {
+
+ $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
+ if (!empty($fWizardKey))
+ {
+ $this->errorRedirectToMain(_kt("Could not create workflow.") );
+ exit;
+ }
+
$oForm =& $this->form_step1();
$res = $oForm->validate();
$data = $res['results'];
@@ -191,7 +208,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
}
// store the data for a while.
- $fWizardKey = KTUtil::randomString();
+
$wiz_data = (array) $_SESSION['_wiz_data'];
$wiz_data[$fWizardKey] = $data;
$_SESSION['_wiz_data'] =& $wiz_data;
@@ -200,11 +217,16 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
return $this->finalise(); // finish and go.
}
- $this->successRedirectTo("step2",_kt("Initial data stored."), sprintf('fWizardKey=%s', $fWizardKey));
+ $this->successRedirectTo("step2",_kt("Initial data stored."));
}
function do_step2() {
- $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
+ $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
+ if (!empty($fWizardKey))
+ {
+ $this->errorRedirectToMain(_kt("Could not create workflow.") );
+ exit;
+ }
$wiz_data = (array) $_SESSION['_wiz_data'][$fWizardKey];
if (empty($wiz_data)) {
@@ -218,6 +240,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
$oTemplate->setData(array(
'context' => $this,
+ 'fWizardKey'=>$fWizardKey,
'args' => $args,
'transitions' => $wiz_data['transitions'],
'states' => $wiz_data['states'],
@@ -227,6 +250,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
function do_process_step2() {
$fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
+ if (!empty($fWizardKey))
+ {
+ $this->errorRedirectToMain(_kt("Could not create workflow.") );
+ exit;
+ }
$wiz_data = $_SESSION['_wiz_data'][$fWizardKey];
if (empty($wiz_data)) {
$this->errorRedirectToMain(_kt("Unable to locate stored data. Please try again."));
@@ -272,6 +300,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
function finalise() {
$fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
+ if (!empty($fWizardKey))
+ {
+ $this->errorRedirectToMain(_kt("Could not create workflow.") );
+ exit;
+ }
$wiz_data = $_SESSION['_wiz_data'][$fWizardKey];
// gather all our data. we're sure this is all good and healthy.
diff --git a/templates/ktcore/forms/widgets/hidden.smarty b/templates/ktcore/forms/widgets/hidden.smarty
new file mode 100644
index 0000000..bdee3db
--- /dev/null
+++ b/templates/ktcore/forms/widgets/hidden.smarty
@@ -0,0 +1 @@
+
diff --git a/templates/ktcore/workflow/admin/new_wizard_step2.smarty b/templates/ktcore/workflow/admin/new_wizard_step2.smarty
index 36725de..48b15c2 100644
--- a/templates/ktcore/workflow/admin/new_wizard_step2.smarty
+++ b/templates/ktcore/workflow/admin/new_wizard_step2.smarty
@@ -8,7 +8,7 @@ states. Use the table below to configure this behaviour.{/i18n}
{foreach from=$args key=k item=v}
{/foreach}
-
+