Commit b2a0fc95366e50c4cc1e7b533b6c301729af4e24
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
Showing
1 changed file
with
36 additions
and
3 deletions
plugins/ktcore/admin/workflow/newworkflow.inc.php
| ... | ... | @@ -87,6 +87,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 87 | 87 | 'required' => false, |
| 88 | 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 | 97 | $oForm->setValidators(array( |
| ... | ... | @@ -95,6 +100,10 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 95 | 100 | 'output' => 'workflow_name', |
| 96 | 101 | )), |
| 97 | 102 | array('ktcore.validators.string', array( |
| 103 | + 'test' => 'fWizardKey', | |
| 104 | + 'output' => 'fWizardKey', | |
| 105 | + )), | |
| 106 | + array('ktcore.validators.string', array( | |
| 98 | 107 | 'test' => 'states', |
| 99 | 108 | 'output' => 'states', |
| 100 | 109 | 'max_length' => 9999, |
| ... | ... | @@ -122,6 +131,14 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 122 | 131 | } |
| 123 | 132 | |
| 124 | 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 | 142 | $oForm =& $this->form_step1(); |
| 126 | 143 | $res = $oForm->validate(); |
| 127 | 144 | $data = $res['results']; |
| ... | ... | @@ -191,7 +208,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 191 | 208 | } |
| 192 | 209 | |
| 193 | 210 | // store the data for a while. |
| 194 | - $fWizardKey = KTUtil::randomString(); | |
| 211 | + | |
| 195 | 212 | $wiz_data = (array) $_SESSION['_wiz_data']; |
| 196 | 213 | $wiz_data[$fWizardKey] = $data; |
| 197 | 214 | $_SESSION['_wiz_data'] =& $wiz_data; |
| ... | ... | @@ -200,11 +217,16 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 200 | 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 | 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 | 230 | $wiz_data = (array) $_SESSION['_wiz_data'][$fWizardKey]; |
| 209 | 231 | |
| 210 | 232 | if (empty($wiz_data)) { |
| ... | ... | @@ -218,6 +240,7 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 218 | 240 | |
| 219 | 241 | $oTemplate->setData(array( |
| 220 | 242 | 'context' => $this, |
| 243 | + 'fWizardKey'=>$fWizardKey, | |
| 221 | 244 | 'args' => $args, |
| 222 | 245 | 'transitions' => $wiz_data['transitions'], |
| 223 | 246 | 'states' => $wiz_data['states'], |
| ... | ... | @@ -227,6 +250,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 227 | 250 | |
| 228 | 251 | function do_process_step2() { |
| 229 | 252 | $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey'); |
| 253 | + if (!empty($fWizardKey)) | |
| 254 | + { | |
| 255 | + $this->errorRedirectToMain(_kt("Could not create workflow.") ); | |
| 256 | + exit; | |
| 257 | + } | |
| 230 | 258 | $wiz_data = $_SESSION['_wiz_data'][$fWizardKey]; |
| 231 | 259 | if (empty($wiz_data)) { |
| 232 | 260 | $this->errorRedirectToMain(_kt("Unable to locate stored data. Please try again.")); |
| ... | ... | @@ -272,6 +300,11 @@ class KTNewWorkflowWizard extends KTAdminDispatcher { |
| 272 | 300 | |
| 273 | 301 | function finalise() { |
| 274 | 302 | $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey'); |
| 303 | + if (!empty($fWizardKey)) | |
| 304 | + { | |
| 305 | + $this->errorRedirectToMain(_kt("Could not create workflow.") ); | |
| 306 | + exit; | |
| 307 | + } | |
| 275 | 308 | $wiz_data = $_SESSION['_wiz_data'][$fWizardKey]; |
| 276 | 309 | |
| 277 | 310 | // gather all our data. we're sure this is all good and healthy. | ... | ... |