Commit f25e6fd24825a504e9b17b85b99953c540e52c4a
1 parent
e9447f4f
Merged in from DEV trunk...
"KTS-1526" "A Required field not being marked as such leads to a DB error: 'DB Error: null value violates not-null constraint'" Fixed. Made the workflowid part of the form post. Reviewed By: Kevin Fourie "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. Reviewed By: Kevin Fourie "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. Reviewed By: Kevin Fourie "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. Reviewed By: Kevin Fourie "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/STABLE/trunk@6725 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
5 changed files
with
44 additions
and
4 deletions
plugins/ktcore/KTCorePlugin.php
| ... | ... | @@ -138,6 +138,7 @@ class KTCorePlugin extends KTPlugin { |
| 138 | 138 | $this->registerWorkflowTrigger('ktcore.workflowtriggers.copyaction', 'CopyActionTrigger', 'KTWorkflowTriggers.inc.php'); |
| 139 | 139 | |
| 140 | 140 | // widgets |
| 141 | + $this->registerWidget('KTCoreHiddenWidget', 'ktcore.widgets.hidden', 'KTWidgets.php'); | |
| 141 | 142 | $this->registerWidget('KTCoreStringWidget', 'ktcore.widgets.string', 'KTWidgets.php'); |
| 142 | 143 | $this->registerWidget('KTCoreSelectionWidget', 'ktcore.widgets.selection', 'KTWidgets.php'); |
| 143 | 144 | $this->registerWidget('KTCoreEntitySelectionWidget', 'ktcore.widgets.entityselection', 'KTWidgets.php'); | ... | ... |
plugins/ktcore/KTWidgets.php
| ... | ... | @@ -37,6 +37,11 @@ class KTCoreStringWidget extends KTWidget { |
| 37 | 37 | var $sTemplate = 'ktcore/forms/widgets/string'; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | +class KTCoreHiddenWidget extends KTWidget { | |
| 41 | + var $sNamespace = 'ktcore.widgets.hidden'; | |
| 42 | + var $sTemplate = 'ktcore/forms/widgets/hidden'; | |
| 43 | +} | |
| 44 | + | |
| 40 | 45 | class KTCoreFileWidget extends KTWidget { |
| 41 | 46 | var $sNamespace = 'ktcore.widgets.file'; |
| 42 | 47 | var $sTemplate = 'ktcore/forms/widgets/file'; | ... | ... |
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. | ... | ... |
templates/ktcore/forms/widgets/hidden.smarty
0 → 100644
| 1 | + <input type="hidden" name="{$name}" {if $has_id}id="{$id}"{/if} {if $has_value}value="{$value}"{/if}/> | ... | ... |
templates/ktcore/workflow/admin/new_wizard_step2.smarty
| ... | ... | @@ -8,7 +8,7 @@ states. Use the table below to configure this behaviour.{/i18n}</p> |
| 8 | 8 | {foreach from=$args key=k item=v} |
| 9 | 9 | <input type="hidden" name="{$k}" value="{$v}" /> |
| 10 | 10 | {/foreach} |
| 11 | - | |
| 11 | + <input type="hidden" name="fWizardKey" value="{$fWizardKey}" /> | |
| 12 | 12 | <table class="kt_collection" cellspacing="0"> |
| 13 | 13 | <thead> |
| 14 | 14 | <tr> | ... | ... |