Code Duplication    Length = 28-28 lines in 2 locations

addTicket.php 1 location

@@ 365-392 (lines=28) @@
362
        $fields =& $hFieldDept->fieldsByDepartment($dept_id, true);
363
        $aFields = array();
364
365
        foreach($fields as $field){
366
            $values = $field->getVar('fieldvalues');
367
            if ($field->getVar('controltype') == XHELP_CONTROL_YESNO) {
368
                $values = array(1 => _YES, 0 => _NO);
369
            }
370
            $fieldname = $field->getVar('fieldname');
371
372
            if($field->getVar('controltype') != XHELP_CONTROL_FILE) {
373
                $checkField = $_POST[$fieldname];
374
            } else {
375
                $checkField = $_FILES[$fieldname];
376
            }
377
378
            $v[$fieldname][] = new ValidateRegex($checkField, $field->getVar('validation'), $field->getVar('required'));
379
380
            $aFields[$field->getVar('id')] =
381
            array('name' => $field->getVar('name'),
382
                      'desc' => $field->getVar('description'),
383
                      'fieldname' => $field->getVar('fieldname'),
384
                      'defaultvalue' => $field->getVar('defaultvalue'),
385
                      'controltype' => $field->getVar('controltype'),
386
                      'required' => $field->getVar('required'),
387
                      'fieldlength' => $field->getVar('fieldlength'),
388
                      'maxlength' => ($field->getVar('fieldlength') < 50 ? $field->getVar('fieldlength') : 50),
389
                      'weight' => $field->getVar('weight'),
390
                      'fieldvalues' => $values,
391
                      'validation' => $field->getVar('validation'));
392
        }
393
394
        _saveTicket($aFields);      // Save ticket information in a session
395

anon_addTicket.php 1 location

@@ 219-246 (lines=28) @@
216
    $fields =& $hFieldDept->fieldsByDepartment($dept_id, true);
217
    $aFields = array();
218
219
    foreach($fields as $field){
220
        $values = $field->getVar('fieldvalues');
221
        if ($field->getVar('controltype') == XHELP_CONTROL_YESNO) {
222
            $values = array(1 => _YES, 0 => _NO);
223
        }
224
        $fieldname = $field->getVar('fieldname');
225
226
        if($field->getVar('controltype') != XHELP_CONTROL_FILE) {
227
            $checkField = $_POST[$fieldname];
228
        } else {
229
            $checkField = $_FILES[$fieldname];
230
        }
231
232
        $v[$fieldname][] = new ValidateRegex($checkField, $field->getVar('validation'), $field->getVar('required'));
233
234
        $aFields[$field->getVar('id')] =
235
        array('name' => $field->getVar('name'),
236
                  'desc' => $field->getVar('description'),
237
                  'fieldname' => $field->getVar('fieldname'),
238
                  'defaultvalue' => $field->getVar('defaultvalue'),
239
                  'controltype' => $field->getVar('controltype'),
240
                  'required' => $field->getVar('required'),
241
                  'fieldlength' => $field->getVar('fieldlength'),
242
                  'maxlength' => ($field->getVar('fieldlength') < 50 ? $field->getVar('fieldlength') : 50),
243
                  'weight' => $field->getVar('weight'),
244
                  'fieldvalues' => $values,
245
                  'validation' => $field->getVar('validation'));
246
    }
247
248
    $_xhelpSession->set('xhelp_ticket',
249
    array('uid' => 0,