Code Duplication    Length = 26-26 lines in 2 locations

addTicket.php 1 location

@@ 159-184 (lines=26) @@
156
        }
157
158
        $aFields = array();
159
        foreach($fields as $field){
160
            $values = $field->getVar('fieldvalues');
161
            if ($field->getVar('controltype') == XHELP_CONTROL_YESNO) {
162
                $values = array(1 => _YES, 0 => _NO);
163
            }
164
165
            // Check for values already submitted, and fill those values in
166
            if(array_key_exists($field->getVar('fieldname'), $savedFields)){
167
                $defaultValue = $savedFields[$field->getVar('fieldname')];
168
            } else {
169
                $defaultValue = $field->getVar('defaultvalue');
170
            }
171
172
            $aFields[$field->getVar('id')] =
173
            array('name' => $field->getVar('name'),
174
                      'desc' => $field->getVar('description'),
175
                      'fieldname' => $field->getVar('fieldname'),
176
                      'defaultvalue' => $defaultValue,
177
                      'controltype' => $field->getVar('controltype'),
178
                      'required' => $field->getVar('required'),
179
                      'fieldlength' => ($field->getVar('fieldlength') < 50 ? $field->getVar('fieldlength') : 50),
180
                      'maxlength' => $field->getVar('fieldlength'),
181
                      'weight' => $field->getVar('weight'),
182
                      'fieldvalues' => $values,
183
                      'validation' => $field->getVar('validation'));
184
        }
185
        $xoopsTpl->assign('xhelp_custFields', $aFields);
186
        if(!empty($aFields)){
187
            $xoopsTpl->assign('xhelp_hasCustFields', true);

anon_addTicket.php 1 location

@@ 84-109 (lines=26) @@
81
    }
82
83
    $aFields = array();
84
    foreach($fields as $field){
85
        $values = $field->getVar('fieldvalues');
86
        if ($field->getVar('controltype') == XHELP_CONTROL_YESNO) {
87
            $values = array(1 => _YES, 0 => _NO);
88
        }
89
90
        // Check for values already submitted, and fill those values in
91
        if(array_key_exists($field->getVar('fieldname'), $savedFields)){
92
            $defaultValue = $savedFields[$field->getVar('fieldname')];
93
        } else {
94
            $defaultValue = $field->getVar('defaultvalue');
95
        }
96
97
        $aFields[$field->getVar('id')] =
98
        array('name' => $field->getVar('name'),
99
                  'desc' => $field->getVar('description'),
100
                  'fieldname' => $field->getVar('fieldname'),
101
                  'defaultvalue' => $defaultValue,
102
                  'controltype' => $field->getVar('controltype'),
103
                  'required' => $field->getVar('required'),
104
                  'fieldlength' => $field->getVar('fieldlength'),
105
                  'maxlength' => ($field->getVar('fieldlength') < 50 ? $field->getVar('fieldlength') : 50),
106
                  'weight' => $field->getVar('weight'),
107
                  'fieldvalues' => $values,
108
                  'validation' => $field->getVar('validation'));
109
    }
110
    $xoopsTpl->assign('xhelp_custFields', $aFields);
111
    if(!empty($aFields)){
112
        $xoopsTpl->assign('xhelp_hasCustFields', true);