jblaze commited on 2011-02-07 05:39:05
Showing 3 changed files, with 35 additions and 34 deletions.
... | ... |
@@ -556,7 +556,15 @@ function shd_get_urgency_options($self_ticket = false) |
556 | 556 |
$context['ticket_form']['urgency']['can_change'] = false; |
557 | 557 |
} |
558 | 558 |
|
559 |
-function shd_load_custom_fields($use_roles = false) |
|
559 |
+/** |
|
560 |
+ * Loads any custom fields that are active |
|
561 |
+ * |
|
562 |
+ * @param bool $new_ticket (default true) If a new ticket is being created, this value will make sure that all default values |
|
563 |
+ * are loaded. It also uses role permissions for viewing and editing. |
|
564 |
+ * |
|
565 |
+ * @since 1.1 |
|
566 |
+*/ |
|
567 |
+function shd_load_custom_fields($new_ticket = true) |
|
560 | 568 |
{ |
561 | 569 |
global $context, $smcFunc; |
562 | 570 |
|
... | ... |
@@ -576,11 +584,8 @@ function shd_load_custom_fields($use_roles = false) |
576 | 584 |
// Loop through all fields and figure out where they should be. |
577 | 585 |
while($row = $smcFunc['db_fetch_assoc']($custom_fields)) |
578 | 586 |
{ |
579 |
- // No custom fields? Bah... |
|
580 |
- if (empty($row['id_field'])) |
|
581 |
- return false; |
|
582 |
- |
|
583 |
- $context['ticket_form']['custom_fields'][$row['placement']][$row['id_field']] = array( |
|
587 |
+ // Load up the fields and do some extra parsing |
|
588 |
+ $context['ticket_form']['custom_fields'][$row['id_field']] = array( |
|
584 | 589 |
'id' => $row['id_field'], |
585 | 590 |
'order' => $row['field_order'], |
586 | 591 |
'location' => $row['field_loc'], |
... | ... |
@@ -598,6 +603,7 @@ function shd_load_custom_fields($use_roles = false) |
598 | 603 |
); |
599 | 604 |
} |
600 | 605 |
|
606 |
+ // Send the data back to the template |
|
601 | 607 |
return $context['ticket_form']['custom_fields']; |
602 | 608 |
} |
603 | 609 |
|
... | ... |
@@ -140,53 +140,49 @@ function template_ticket_info() |
140 | 140 |
', shd_profile_link($context['ticket_form']['member']['avatar']['image'], $context['ticket_form']['member']['id']), ' |
141 | 141 |
</div>'; |
142 | 142 |
|
143 |
- // Custom fields |
|
144 |
- template_ticket_custom_fields(1); |
|
145 |
- |
|
146 | 143 |
echo ' |
147 | 144 |
</div>'; |
148 | 145 |
} |
149 | 146 |
|
150 |
-function template_ticket_custom_fields($placement = 2) |
|
147 |
+function template_ticket_custom_fields() |
|
151 | 148 |
{ |
152 | 149 |
global $context, $settings; |
153 | 150 |
|
154 |
- // Custom fields maybe? |
|
155 |
- if ($context['ticket_form']['custom_fields'] != 0) |
|
156 |
- { |
|
157 | 151 |
echo ' |
158 |
- <div class="information shd_customfields"> |
|
159 |
- <ul class="reset">'; |
|
152 |
+ <div class="information shd_customfields">'; |
|
160 | 153 |
|
161 |
- foreach ($context['ticket_form']['custom_fields'][$placement] as $field) |
|
154 |
+ // Loop through each custom field |
|
155 |
+ foreach ($context['ticket_form']['custom_fields'] as $field) |
|
162 | 156 |
{ |
163 | 157 |
echo ' |
164 |
- <li id="field-' . $field['id'] . '"> |
|
158 |
+ <dl class="settings"> |
|
159 |
+ <dt id="field-' . $field['id'] . '"> |
|
165 | 160 |
', !empty($field['icon']) ? '<img src="' . $settings['default_images_url'] . '/simpledesk/cf/' . $field['icon'] . '" alt="" />' : '', ' |
166 |
- <strong>' . $field['name'] . '</strong><br /> |
|
161 |
+ <strong>' . $field['name'] . ': </strong><br /> |
|
167 | 162 |
<span class="smalltext">' . $field['desc'] . '</span> |
168 |
- <br />'; |
|
163 |
+ </dt>'; |
|
169 | 164 |
|
170 | 165 |
// Text |
171 | 166 |
if ($field['type'] == 1) |
172 | 167 |
echo ' |
173 |
- <input type="text" name="field-' . $field['id'] . '" value="' . $field['default_value'] . '" size="50" />'; |
|
168 |
+ <dd><input type="text" name="field-' . $field['id'] . '" value="' . $field['default_value'] . '" size="50" /></dd>'; |
|
174 | 169 |
// Textarea |
175 | 170 |
elseif ($field['type'] == 2) |
176 | 171 |
echo ' |
177 |
- <textarea name="field-' . $field['id'] . '"', !empty($field['default_value']) ? ' rows="' . $field['default_value'][0] . '" cols="' . $field['default_value'][1] . '" ' : '', '> </textarea>'; |
|
172 |
+ <dd><textarea name="field-' . $field['id'] . '"', !empty($field['default_value']) ? ' rows="' . $field['default_value'][0] . '" cols="' . $field['default_value'][1] . '" ' : '', '> </textarea></dd>'; |
|
178 | 173 |
// Integers only |
179 | 174 |
elseif ($field['type'] == 3) |
180 | 175 |
echo ' |
181 |
- <input name="field-' . $field['id'] . '" value="' . $field['default_value'] . ' size="10 />'; |
|
176 |
+ <dd><input name="field-' . $field['id'] . '" value="' . $field['default_value'] . ' size="10 /></dd>'; |
|
182 | 177 |
// Floating numbers |
183 | 178 |
elseif ($field['type'] == 4) |
184 | 179 |
echo ' |
185 |
- <input name="field-' . $field['id'] . '" value="' . $field['default_value'] . ' size="10 />'; |
|
180 |
+ <dd><input name="field-' . $field['id'] . '" value="' . $field['default_value'] . ' size="10 /></dd>'; |
|
186 | 181 |
// Select boxes |
187 | 182 |
elseif ($field['type'] == 5) |
188 | 183 |
{ |
189 | 184 |
echo ' |
185 |
+ <dd> |
|
190 | 186 |
<select name="field-' . $field['id'] . '">'; |
191 | 187 |
|
192 | 188 |
foreach ($field['options'] as $option) |
... | ... |
@@ -196,37 +192,35 @@ function template_ticket_custom_fields($placement = 2) |
196 | 192 |
} |
197 | 193 |
|
198 | 194 |
echo ' |
199 |
- </select>'; |
|
195 |
+ </select> |
|
196 |
+ </dd>'; |
|
200 | 197 |
} |
201 | 198 |
// Checkboxes! |
202 | 199 |
elseif ($field['type'] == 6) |
203 | 200 |
echo ' |
204 |
- <input name="field-' . $field['id'] . '" type="checkbox" ' . $field['default_value'] == 1 ? 'checked="checked"' : '' . '/>'; |
|
201 |
+ <dd><input name="field-' . $field['id'] . '" type="checkbox" ' . $field['default_value'] == 1 ? 'checked="checked"' : '' . '/></dd>'; |
|
205 | 202 |
// Last one, radio buttons |
206 | 203 |
elseif ($field['type'] == 7) |
207 | 204 |
{ |
208 | 205 |
foreach ($field['options'] as $option) |
209 | 206 |
{ |
210 | 207 |
echo ' |
211 |
- <label for="field-' . $field['id'] . '">' . $option . '</label> |
|
212 |
- <input name="field-' . $field['id'] . '" type="radio" value="' . $option . '" />'; |
|
208 |
+ <dd><input name="field-' . $field['id'] . '" type="radio" value="' . $option . '" /> <span>' . $option . '</span></dd>'; |
|
213 | 209 |
} |
214 | 210 |
} |
215 | 211 |
// Default to a text input field |
216 | 212 |
else |
217 | 213 |
echo ' |
218 |
- <input type="text" name="field-' . $field['id'] . '" value="' . $field['default_value'] . '" size="50" />'; |
|
214 |
+ <dd><input type="text" name="field-' . $field['id'] . '" value="' . $field['default_value'] . '" size="50" /></dd>'; |
|
219 | 215 |
|
220 | 216 |
echo ' |
221 |
- </li> |
|
222 |
- ', $placement == 1 ? '' : '<hr />', '<br />'; |
|
217 |
+ </dl> |
|
218 |
+ <hr class="hrcolor" />'; |
|
223 | 219 |
} |
224 | 220 |
|
225 | 221 |
echo ' |
226 |
- </ul> |
|
227 | 222 |
</div>'; |
228 | 223 |
} |
229 |
-} |
|
230 | 224 |
|
231 | 225 |
function template_ticket_posterrors() |
232 | 226 |
{ |
... | ... |
@@ -385,7 +379,7 @@ function template_ticket_postbox() |
385 | 379 |
echo template_control_richedit($context['post_box_name'], 'shd_smileybox', 'shd_bbcbox'); |
386 | 380 |
|
387 | 381 |
// Custom fields |
388 |
- template_ticket_custom_fields(2); |
|
382 |
+ template_ticket_custom_fields(); |
|
389 | 383 |
|
390 | 384 |
// Additional ticket options (attachments, smileys, etc) |
391 | 385 |
template_ticket_additional_options(); |
392 | 386 |