Commit b2a0fc95366e50c4cc1e7b533b6c301729af4e24

Authored by conradverm
1 parent 96e89c4e

"KTS-1526"

"A Required field not being marked as such leads to a DB error: 'DB Error: null value violates not-null constraint'"
Fixed. Added a hidden widget for forms and created the key for the workflow reference on the first page.

Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6724 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktcore/admin/workflow/newworkflow.inc.php
@@ -87,6 +87,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -87,6 +87,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
87 'required' => false, 87 'required' => false,
88 'name' => 'transitions', 88 'name' => 'transitions',
89 )), 89 )),
  90 + array('ktcore.widgets.hidden',array(
  91 + 'required' => false,
  92 + 'name' => 'fWizardKey',
  93 + 'value' => KTUtil::randomString()
  94 + )),
90 )); 95 ));
91 96
92 $oForm->setValidators(array( 97 $oForm->setValidators(array(
@@ -95,6 +100,10 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -95,6 +100,10 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
95 'output' => 'workflow_name', 100 'output' => 'workflow_name',
96 )), 101 )),
97 array('ktcore.validators.string', array( 102 array('ktcore.validators.string', array(
  103 + 'test' => 'fWizardKey',
  104 + 'output' => 'fWizardKey',
  105 + )),
  106 + array('ktcore.validators.string', array(
98 'test' => 'states', 107 'test' => 'states',
99 'output' => 'states', 108 'output' => 'states',
100 'max_length' => 9999, 109 'max_length' => 9999,
@@ -122,6 +131,14 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -122,6 +131,14 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
122 } 131 }
123 132
124 function do_process_step1() { 133 function do_process_step1() {
  134 +
  135 + $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
  136 + if (!empty($fWizardKey))
  137 + {
  138 + $this->errorRedirectToMain(_kt("Could not create workflow.") );
  139 + exit;
  140 + }
  141 +
125 $oForm =& $this->form_step1(); 142 $oForm =& $this->form_step1();
126 $res = $oForm->validate(); 143 $res = $oForm->validate();
127 $data = $res['results']; 144 $data = $res['results'];
@@ -191,7 +208,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -191,7 +208,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
191 } 208 }
192 209
193 // store the data for a while. 210 // store the data for a while.
194 - $fWizardKey = KTUtil::randomString(); 211 +
195 $wiz_data = (array) $_SESSION['_wiz_data']; 212 $wiz_data = (array) $_SESSION['_wiz_data'];
196 $wiz_data[$fWizardKey] = $data; 213 $wiz_data[$fWizardKey] = $data;
197 $_SESSION['_wiz_data'] =& $wiz_data; 214 $_SESSION['_wiz_data'] =& $wiz_data;
@@ -200,11 +217,16 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -200,11 +217,16 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
200 return $this->finalise(); // finish and go. 217 return $this->finalise(); // finish and go.
201 } 218 }
202 219
203 - $this->successRedirectTo("step2",_kt("Initial data stored."), sprintf('fWizardKey=%s', $fWizardKey)); 220 + $this->successRedirectTo("step2",_kt("Initial data stored."));
204 } 221 }
205 222
206 function do_step2() { 223 function do_step2() {
207 - $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey'); 224 + $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
  225 + if (!empty($fWizardKey))
  226 + {
  227 + $this->errorRedirectToMain(_kt("Could not create workflow.") );
  228 + exit;
  229 + }
208 $wiz_data = (array) $_SESSION['_wiz_data'][$fWizardKey]; 230 $wiz_data = (array) $_SESSION['_wiz_data'][$fWizardKey];
209 231
210 if (empty($wiz_data)) { 232 if (empty($wiz_data)) {
@@ -218,6 +240,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -218,6 +240,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
218 240
219 $oTemplate->setData(array( 241 $oTemplate->setData(array(
220 'context' => $this, 242 'context' => $this,
  243 + 'fWizardKey'=>$fWizardKey,
221 'args' => $args, 244 'args' => $args,
222 'transitions' => $wiz_data['transitions'], 245 'transitions' => $wiz_data['transitions'],
223 'states' => $wiz_data['states'], 246 'states' => $wiz_data['states'],
@@ -227,6 +250,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -227,6 +250,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
227 250
228 function do_process_step2() { 251 function do_process_step2() {
229 $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey'); 252 $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
  253 + if (!empty($fWizardKey))
  254 + {
  255 + $this->errorRedirectToMain(_kt("Could not create workflow.") );
  256 + exit;
  257 + }
230 $wiz_data = $_SESSION['_wiz_data'][$fWizardKey]; 258 $wiz_data = $_SESSION['_wiz_data'][$fWizardKey];
231 if (empty($wiz_data)) { 259 if (empty($wiz_data)) {
232 $this->errorRedirectToMain(_kt("Unable to locate stored data. Please try again.")); 260 $this->errorRedirectToMain(_kt("Unable to locate stored data. Please try again."));
@@ -272,6 +300,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { @@ -272,6 +300,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher {
272 300
273 function finalise() { 301 function finalise() {
274 $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey'); 302 $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey');
  303 + if (!empty($fWizardKey))
  304 + {
  305 + $this->errorRedirectToMain(_kt("Could not create workflow.") );
  306 + exit;
  307 + }
275 $wiz_data = $_SESSION['_wiz_data'][$fWizardKey]; 308 $wiz_data = $_SESSION['_wiz_data'][$fWizardKey];
276 309
277 // gather all our data. we're sure this is all good and healthy. 310 // gather all our data. we're sure this is all good and healthy.