Commit 117d6504fb2963cf6165496f16a68c2da0ca3bd8
1 parent
6fe18cb2
Remove code from previous conditional metadata framework.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3782 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
0 additions
and
279 deletions
presentation/lookAndFeel/knowledgeTree/administration/docfieldmanagement/conditional/manageConditionals.php
| @@ -72,291 +72,12 @@ class ManageConditionalDispatcher extends KTStandardDispatcher { | @@ -72,291 +72,12 @@ class ManageConditionalDispatcher extends KTStandardDispatcher { | ||
| 72 | return $oTemplate->render($aTemplateData); | 72 | return $oTemplate->render($aTemplateData); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - /** DELETE FROM HERE. */ | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - function do_newMasterConditionSet() { | ||
| 81 | - $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 82 | - | ||
| 83 | - if (empty($fieldset_id)) { | ||
| 84 | - return $this->errorRedirectToMain("No fieldset specified."); | ||
| 85 | - } | ||
| 86 | - $oFieldset = KTFieldset::get($fieldset_id); | ||
| 87 | - if (PEAR::isError($oFieldset)) { | ||
| 88 | - return $this->errorRedirectToMain("Unable to open the specified fieldset."); | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - // now we need to get other fields in this set. | ||
| 93 | - $aOtherFields = DocumentField::getList('parent_fieldset = '.$oFieldset->getId().' AND id != '.$oFieldset->getMasterField()); | ||
| 94 | - if (PEAR::isError($aOtherFields)) { | ||
| 95 | - $this->errorRedirectToMain("Failed to get field list for table."); | ||
| 96 | - } | ||
| 97 | - $oTemplating = new KTTemplating; | ||
| 98 | - | ||
| 99 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/conditional/editsimple"); | ||
| 100 | - $aTemplateData = array( | ||
| 101 | - "fieldset_id" => $fieldset_id, | ||
| 102 | - "other_fields" => $aOtherFields, | ||
| 103 | - ); | ||
| 104 | - return $oTemplate->render($aTemplateData); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - function do_newSubConditionSet() { | ||
| 108 | - global $default; | ||
| 109 | - $default->log->debug('SUBCONDITION CREATION: starting.'); | ||
| 110 | - $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 111 | - $starting_id = KTUtil::arrayGet($_REQUEST, 'starting_field'); // populated elsewhere. | ||
| 112 | - | ||
| 113 | - if (empty($fieldset_id)) { | ||
| 114 | - return $this->errorRedirectToMain("No fieldset specified."); | ||
| 115 | - } | ||
| 116 | - if (empty($starting_id)) { | ||
| 117 | - return $this->errorRedirectToMain("No field specified to start from."); | ||
| 118 | - } | ||
| 119 | - $default->log->debug('SUBCONDITION CREATION: extracted.'); | ||
| 120 | - $oFieldset = KTFieldset::get($fieldset_id); | ||
| 121 | - if (PEAR::isError($oFieldset)) { | ||
| 122 | - return $this->errorRedirectToMain("Unable to open the specified fieldset."); | ||
| 123 | - } | ||
| 124 | - $default->log->debug('SUBCONDITION CREATION: validated.'); | ||
| 125 | - | ||
| 126 | - // now we need to get other fields in this set. | ||
| 127 | - $aOtherFields = DocumentField::getList('parent_fieldset = '.$oFieldset->getId().' AND id != '.$oFieldset->getMasterField().' AND id != '.$starting_id); | ||
| 128 | - if (PEAR::isError($aOtherFields)) { | ||
| 129 | - $this->errorRedirectToMain("Failed to get field list for table."); | ||
| 130 | - } | ||
| 131 | - // FIXME we tableMappings. | ||
| 132 | - $starting_lookup = DBUtil::getResultArray(array('SELECT id, name FROM metadata_lookup WHERE document_field_id = ? ', array($starting_id))); | ||
| 133 | - if (PEAR::isError($starting_lookup)) { | ||
| 134 | - return $this->errorRedirectToMain('invalid starting field.'); | ||
| 135 | - } | ||
| 136 | - $default->log->debug('SUBCONDITION CREATION: rendering.'); | ||
| 137 | - $oTemplating = new KTTemplating; | ||
| 138 | - | ||
| 139 | - $oTemplate = $oTemplating->loadTemplate("ktcore/metadata/conditional/new_subchain"); | ||
| 140 | - $aTemplateData = array( | ||
| 141 | - "fieldset_id" => $fieldset_id, | ||
| 142 | - "starting_field" => $starting_id, | ||
| 143 | - "starting_lookup" => $starting_lookup, | ||
| 144 | - "other_fields" => $aOtherFields, | ||
| 145 | - ); | ||
| 146 | - return $oTemplate->render($aTemplateData); | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - | ||
| 150 | function handleOutput($data) { | 75 | function handleOutput($data) { |
| 151 | global $main; | 76 | global $main; |
| 152 | $main->bFormDisabled = true; | 77 | $main->bFormDisabled = true; |
| 153 | $main->setCentralPayload($data); | 78 | $main->setCentralPayload($data); |
| 154 | $main->render(); | 79 | $main->render(); |
| 155 | } | 80 | } |
| 156 | - | ||
| 157 | - /* create a "master" (or root) condition for a fieldset. | ||
| 158 | - * this _must_ be for a "masterfield". | ||
| 159 | - */ | ||
| 160 | - | ||
| 161 | - function do_createMasterChain() { | ||
| 162 | - global $default; | ||
| 163 | - $default->log->debug("CREATE MASTER CHAIN: starting."); | ||
| 164 | - | ||
| 165 | - | ||
| 166 | - // FIXME: delete EVERYTHING that chains FROM this item. | ||
| 167 | - $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 168 | - $rule_name = KTUtil::arrayGet($_REQUEST, 'rule_name'); | ||
| 169 | - $base_lookup_id = KTUtil::arrayGet($_REQUEST, 'lookup_id'); // we ARE on the master field, this represents that. | ||
| 170 | - | ||
| 171 | - $default->log->debug("CREATE MASTER CHAIN: lookup_id " .print_r($lookup_id, true)); | ||
| 172 | - | ||
| 173 | - $fields_to_attach = KTUtil::arrayGet($_REQUEST, 'fields_to_attach'); // listed as fields_to_attach[], a list. | ||
| 174 | - if (empty($fields_to_attach)) { | ||
| 175 | - return $this->errorRedirectToMain("No fields specified."); | ||
| 176 | - } else { | ||
| 177 | - // get the list of fields, and their "chained" values. | ||
| 178 | - // we key this by field. | ||
| 179 | - $chained_direct_values = array(); | ||
| 180 | - foreach ($fields_to_attach as $field_id) { | ||
| 181 | - $chained_direct_values[$field_id] = array(); | ||
| 182 | - // we now grab the appropriate values from the form. | ||
| 183 | - // these will have been input as "direct_values_{$field_id} | ||
| 184 | - $direct_values = KTUtil::arrayGet($_REQUEST, "direct_values_".$field_id); | ||
| 185 | - if (empty($direct_values)) { | ||
| 186 | - return $this->errorRedirectToMain("Missing input for field ".$field_id); | ||
| 187 | - } else { | ||
| 188 | - foreach ($direct_values as $lookup_id) { | ||
| 189 | - // FIXME use MetaData::get() on these to verify their existence. | ||
| 190 | - $chained_direct_values[$field_id][] = $lookup_id; | ||
| 191 | - } | ||
| 192 | - } | ||
| 193 | - } | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - $default->log->debug("CREATE MASTER CHAIN: lookup_id (2) " .print_r($lookup_id, true)); | ||
| 197 | - $rulesets_to_attach = KTUtil::arrayGet($_REQUEST, 'rulesets_to_attach'); | ||
| 198 | - | ||
| 199 | - $oFieldset = KTFieldset::get($fieldset_id); | ||
| 200 | - if (PEAR::isError($oFieldset)) { | ||
| 201 | - return $this->errorRedirectToMain("Invalid Fieldset."); | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | - $resObj = MDConditionNode::createFromArray(array( | ||
| 205 | - "iFieldId" => $oFieldset->getMasterField(), | ||
| 206 | - "iLookupId" => $base_lookup_id, | ||
| 207 | - "sName" => $rule_name, | ||
| 208 | - )); | ||
| 209 | - | ||
| 210 | - $default->log->debug("CREATE MASTER CHAIN: created master chain node " .print_r($resObj, true)); | ||
| 211 | - | ||
| 212 | - $resObj2 = MDConditionChain::createFromArray(array( | ||
| 213 | - "iParentCondition" => null, // this is a MASTER chain. | ||
| 214 | - "iChildCondition" => $resObj->getId(), | ||
| 215 | - )); | ||
| 216 | - | ||
| 217 | - // the id of this "master rule". | ||
| 218 | - $master_rule_id = $resObj->getId(); | ||
| 219 | - | ||
| 220 | - // walk the connections to make, and ... | ||
| 221 | - // NBM: please make this transactional... | ||
| 222 | - foreach ($chained_direct_values as $field_id => $lookup_ids) { | ||
| 223 | - foreach ($lookup_ids as $lookup_id) { | ||
| 224 | - $lookupCreation = MDConditionNode::createFromArray(array( | ||
| 225 | - "iFieldId" => $field_id, | ||
| 226 | - "iLookupId" => $lookup_id, | ||
| 227 | - )); | ||
| 228 | - if (PEAR::isError($lookupCreation)) { | ||
| 229 | - return $this->errorRedirectToMain("Error creating link to ".$field_id." => ".$lookup_id); | ||
| 230 | - } | ||
| 231 | - $lookupChain = MDConditionChain::createFromArray(array( | ||
| 232 | - "iParentCondition" => $master_rule_id, | ||
| 233 | - "iChildCondition" => $lookupCreation->getId(), | ||
| 234 | - )); | ||
| 235 | - if (PEAR::isError($lookupChain)) { | ||
| 236 | - return $this->errorRedirectToMain("Error creating link to ".$field_id." => ".$lookup_id); | ||
| 237 | - } | ||
| 238 | - } | ||
| 239 | - } | ||
| 240 | - if (!empty($rulesets_to_attach)) { | ||
| 241 | - foreach ($rulesets_to_attach as $child_ruleset) { | ||
| 242 | - $lookupChain = MDConditionChain::createFromArray(array( | ||
| 243 | - "iParentCondition" => $master_rule_id, | ||
| 244 | - "iChildCondition" => $child_ruleset, | ||
| 245 | - )); | ||
| 246 | - if (PEAR::isError($lookupChain)) { | ||
| 247 | - return $this->errorRedirectToMain("Error creating link to ruleset ".$child_ruleset); | ||
| 248 | - } | ||
| 249 | - } | ||
| 250 | - } | ||
| 251 | - $default->log->debug("CREATE MASTER CHAIN: done."); | ||
| 252 | - return $this->errorRedirectToMain("Created ruleset."); | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | - function do_createSubChain() { | ||
| 256 | - global $default; | ||
| 257 | - $default->log->debug("CREATE SB CHAIN: starting."); | ||
| 258 | - | ||
| 259 | - | ||
| 260 | - // FIXME: delete EVERYTHING that chains FROM this item. | ||
| 261 | - $fieldset_id = KTUtil::arrayGet($_REQUEST, 'fieldset_id'); | ||
| 262 | - $starting_id = KTUtil::arrayGet($_REQUEST, 'starting_field'); | ||
| 263 | - $rule_name = KTUtil::arrayGet($_REQUEST, 'rule_name'); | ||
| 264 | - | ||
| 265 | - if (empty($fieldset_id)) { | ||
| 266 | - return $this->errorRedirectToMain('No fieldset specified.'); | ||
| 267 | - } | ||
| 268 | - if (empty($rule_name)) { | ||
| 269 | - return $this->errorRedirectToMain('Sub-rules MUST have a name specified.'); | ||
| 270 | - } | ||
| 271 | - if (empty($starting_id)) { | ||
| 272 | - return $this->errorRedirectToMain('Must indicate which fieldset to start with.'); | ||
| 273 | - } | ||
| 274 | - | ||
| 275 | - $base_lookup_id = KTUtil::arrayGet($_REQUEST, 'lookup_id'); // we NEED TO KNOW which is the "base" element. | ||
| 276 | - | ||
| 277 | - $default->log->debug("CREATE SB CHAIN: lookup_id " .print_r($base_lookup_id, true)); | ||
| 278 | - | ||
| 279 | - // these are the next layers of rules to attach. | ||
| 280 | - $fields_to_attach = KTUtil::arrayGet($_REQUEST, 'fields_to_attach'); // listed as fields_to_attach[], a list. | ||
| 281 | - $default->log->debug("CREATE SB CHAIN: fields_to_attach " .print_r($fields_to_attach, true)); | ||
| 282 | - if (empty($fields_to_attach)) { | ||
| 283 | - return $this->errorRedirectToMain("No fields specified."); | ||
| 284 | - } else { | ||
| 285 | - // get the list of fields, and their "chained" values. | ||
| 286 | - // we key this by field. | ||
| 287 | - $chained_direct_values = array(); | ||
| 288 | - foreach ($fields_to_attach as $field_id) { | ||
| 289 | - $chained_direct_values[$field_id] = array(); | ||
| 290 | - // we now grab the appropriate values from the form. | ||
| 291 | - // these will have been input as "direct_values_{$field_id} | ||
| 292 | - $direct_values = KTUtil::arrayGet($_REQUEST, "direct_values_".$field_id); | ||
| 293 | - if (empty($direct_values)) { | ||
| 294 | - return $this->errorRedirectToMain("Missing input for field ".$field_id); | ||
| 295 | - } else { | ||
| 296 | - foreach ($direct_values as $lookup_id) { | ||
| 297 | - // FIXME use MetaData::get() on these to verify their existence. | ||
| 298 | - $chained_direct_values[$field_id][] = $lookup_id; | ||
| 299 | - } | ||
| 300 | - } | ||
| 301 | - } | ||
| 302 | - } | ||
| 303 | - | ||
| 304 | - $default->log->debug("CREATE SB CHAIN: lookup_id (2) " .print_r($lookup_id, true)); | ||
| 305 | - $rulesets_to_attach = KTUtil::arrayGet($_REQUEST, 'rulesets_to_attach'); | ||
| 306 | - | ||
| 307 | - $oFieldset = KTFieldset::get($fieldset_id); | ||
| 308 | - if (PEAR::isError($oFieldset)) { | ||
| 309 | - return $this->errorRedirectToMain("Invalid Fieldset."); | ||
| 310 | - } | ||
| 311 | - | ||
| 312 | - $resObj = MDConditionNode::createFromArray(array( | ||
| 313 | - "iFieldId" => $starting_id, | ||
| 314 | - "iLookupId" => $base_lookup_id, | ||
| 315 | - "sName" => $rule_name, | ||
| 316 | - )); | ||
| 317 | - | ||
| 318 | - $default->log->debug("CREATE SB CHAIN: created master chain node " .print_r($resObj, true)); | ||
| 319 | - | ||
| 320 | - // WE DON'T CREATE A PARENT-CHAIN ... this one must be picked up by other nodes. | ||
| 321 | - | ||
| 322 | - // the id of this "master rule". | ||
| 323 | - $master_rule_id = $resObj->getId(); | ||
| 324 | - | ||
| 325 | - // walk the connections to make, and ... | ||
| 326 | - // NBM: please make this transactional... | ||
| 327 | - foreach ($chained_direct_values as $field_id => $lookup_ids) { | ||
| 328 | - foreach ($lookup_ids as $lookup_id) { | ||
| 329 | - $lookupCreation = MDConditionNode::createFromArray(array( | ||
| 330 | - "iFieldId" => $field_id, | ||
| 331 | - "iLookupId" => $lookup_id, | ||
| 332 | - )); | ||
| 333 | - if (PEAR::isError($lookupCreation)) { | ||
| 334 | - return $this->errorRedirectToMain("Error creating link to ".$field_id." => ".$lookup_id); | ||
| 335 | - } | ||
| 336 | - $lookupChain = MDConditionChain::createFromArray(array( | ||
| 337 | - "iParentCondition" => $master_rule_id, | ||
| 338 | - "iChildCondition" => $lookupCreation->getId(), | ||
| 339 | - )); | ||
| 340 | - if (PEAR::isError($lookupChain)) { | ||
| 341 | - return $this->errorRedirectToMain("Error creating link to ".$field_id." => ".$lookup_id); | ||
| 342 | - } | ||
| 343 | - } | ||
| 344 | - } | ||
| 345 | - if (!empty($rulesets_to_attach)) { | ||
| 346 | - foreach ($rulesets_to_attach as $child_ruleset) { | ||
| 347 | - $lookupChain = MDConditionChain::createFromArray(array( | ||
| 348 | - "iParentCondition" => $master_rule_id, | ||
| 349 | - "iChildCondition" => $child_ruleset, | ||
| 350 | - )); | ||
| 351 | - if (PEAR::isError($lookupChain)) { | ||
| 352 | - return $this->errorRedirectToMain("Error creating link to ruleset ".$child_ruleset); | ||
| 353 | - } | ||
| 354 | - } | ||
| 355 | - } | ||
| 356 | - $default->log->debug("CREATE SB CHAIN: done."); | ||
| 357 | - return $this->errorRedirectToMain("Created ruleset."); | ||
| 358 | - } | ||
| 359 | - | ||
| 360 | } | 81 | } |
| 361 | 82 | ||
| 362 | $oDispatcher = new ManageConditionalDispatcher(); | 83 | $oDispatcher = new ManageConditionalDispatcher(); |