3 * FusionForge Generic Tracker facility
5 * Copyright 1999-2001 (c) VA Linux Systems - Sourceforge
6 * Copyright 2010 (c) Fusionforge Team
7 * Copyright 2011, Franck Villaume - Capgemini
8 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once $gfcommon.'tracker/ArtifactType.class.php';
28 require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
29 require_once $gfcommon.'tracker/ArtifactExtraFieldElement.class.php';
30 require_once $gfcommon.'tracker/ArtifactWorkflow.class.php';
31 require_once $gfcommon.'include/utils_crossref.php';
33 class ArtifactTypeHtml extends ArtifactType {
35 function header($params) {
37 if (!forge_get_config('use_tracker')) {
40 $group_id= $this->Group->getID();
42 //required by new site_project_header
43 $params['group']=$group_id;
44 $params['toptab']='tracker';
45 $params['tabtext']=$this->getName();
51 $labels[] = _("View Trackers");
52 $links[] = '/tracker/?group_id='.$group_id;
53 $attr[] = array('title' => _('Get the list of available trackers'), 'class' => 'tabtitle-nw');
54 $labels[] = $this->getName();
55 $links[] = '/tracker/?func=browse&group_id='.$group_id.'&atid='. $this->getID();
56 $attr[] = array('title' => _('Browse this tracker.'), 'class' => 'tabtitle');
57 $labels[] = _('Export CSV');
58 $links[] = '/tracker/?func=csv&group_id='.$group_id.'&atid='. $this->getID();
59 $attr[] = array('title' => _('Download data from this tracker as csv file.'), 'class' => 'tabtitle');
60 if (forge_check_perm ('tracker',$this->getID(),'submit')) {
61 $labels[] = _('Submit New');
62 $links[] = '/tracker/?func=add&group_id='.$group_id.'&atid='. $this->getID();
63 $attr[] = array('title' => _('Add a new issue.'), 'class' => 'tabtitle');
66 if (session_loggedin()) {
67 $labels[] = _('Reporting');
68 $links[] = '/tracker/reporting/?group_id='.$group_id.'&atid='. $this->getID();
69 $attr[] = array('title' => _('Various graph about statistics.'), 'class' => 'tabtitle');
70 if ($this->isMonitoring()) {
71 $labels[] = _('Stop Monitor');
72 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&stop=1';
73 $attr[] = array('title' => _('Remove this tracker from your monitoring.'), 'class' => 'tabtitle');
75 $labels[] = _('Monitor');
76 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&start=1';
77 $attr[] = array('title' => _('Add this tracker from your monitoring.'), 'class' => 'tabtitle');
80 if (forge_check_perm ('tracker', $this->getID(), 'manager')) {
81 $labels[] = _('Administration');
82 $links[] = '/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID();
83 $attr[] = array('title' => _('Global administration for trackers. Create, clone, workflow, fields ...'), 'class' => 'tabtitle');
86 $labels[] = _('Monitor');
87 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&start=1';
88 $attr[] = array('title' => _('Add this tracker from your monitoring.'), 'class' => 'tabtitle');
91 $params['submenu'] = $HTML->subMenu($labels, $links, $attr);
92 site_project_header($params);
95 plugin_hook("blocks", "tracker_".$this->getName());
99 function footer($params) {
100 site_project_footer($params);
103 function adminHeader($params) {
105 $this->header($params);
106 $group_id= $this->Group->getID();
108 $links_arr[]='/tracker/admin/?group_id='.$group_id;
109 $title_arr[]=_('New Tracker');
111 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&update_type=1';
112 $title_arr[]=_('Update Settings');
114 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_extrafield=1';
115 $title_arr[]=_('Manage Custom Fields');
117 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&workflow=1';
118 $title_arr[]=_('Manage Workflow');
120 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&customize_list=1';
121 $title_arr[]=_('Customize List');
123 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_canned=1';
124 $title_arr[]=_('Add/Update Canned Responses');
126 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&clone_tracker=1';
127 $title_arr[]=_('Clone Tracker');
129 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&delete=1';
130 $title_arr[]=_('Delete');
132 echo $HTML->printSubMenu($title_arr, $links_arr, false);
135 function adminFooter($params) {
136 $this->footer($params);
139 function renderSubmitInstructions() {
140 $msg = $this->getSubmitInstructions();
141 return str_replace("\n","<br />", $msg);
144 function renderBrowseInstructions() {
145 $msg = $this->getBrowseInstructions();
146 return str_replace("\n","<br />", $msg);
150 * @param array $selected
151 * @param bool $show_100
152 * @param string $text_100
153 * @param bool $show_any
154 * @param string $text_any
155 * @param array $types
156 * @param bool $status_show_100
157 * @param string $mode
159 function renderExtraFields($selected=array(),$show_100=false,$text_100='none',$show_any=false,$text_any='Any',$types=array(),$status_show_100=false,$mode='') {
160 $efarr = $this->getExtraFields($types);
161 //each two columns, we'll reset this and start a new row
163 $template = $this->getRenderHTML($types, $mode);
165 if ($mode=='QUERY') {
166 $keys=array_keys($efarr);
167 for ($k=0; $k<count($keys); $k++) {
169 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT ||
170 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX ||
171 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO ||
172 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS ||
173 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
174 $efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_MULTISELECT;
176 $efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_TEXT;
181 // 'DISPLAY' mode is for rendering in 'read-only' mode (for detail view).
182 if ($mode === 'DISPLAY') {
183 $keys=array_keys($efarr);
184 for ($k=0; $k<count($keys); $k++) {
187 if (!isset($selected[$efarr[$i]['extra_field_id']]))
188 $selected[$efarr[$i]['extra_field_id']] = '';
190 $value = @$selected[$efarr[$i]['extra_field_id']];
192 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT ||
193 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX ||
194 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO ||
195 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS ||
196 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
200 $arr = $this->getExtraFieldElements($efarr[$i]['extra_field_id']);
202 // Convert the values (ids) to names in the ids order.
204 for ($j=0; $j<count($arr); $j++) {
205 if (is_array($value)) {
206 if (in_array($arr[$j]['element_id'],$value))
207 $new[]= $arr[$j]['element_name'];
208 } elseif ($arr[$j]['element_id'] === $value) {
209 $new[] = $arr[$j]['element_name'];
212 $value = join('<br />', $new);
214 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
215 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
216 $value = preg_replace('/((http|https|ftp):\/\/\S+)/',
217 "<a href=\"\\1\" target=\"_blank\">\\1</a>", $value);
218 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
219 // Convert artifact id to links.
220 $value = preg_replace('/\b(\d+)\b/e', "_artifactid2url('\\1')", $value);
222 $template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}',$post_name,$template);
223 $template = str_replace('{$'.$efarr[$i]['field_name'].'}',$value,$template);
229 $keys=array_keys($efarr);
230 for ($k=0; $k<count($keys); $k++) {
234 if (!isset($selected[$efarr[$i]['extra_field_id']]))
235 $selected[$efarr[$i]['extra_field_id']] = '';
237 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
238 $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100,$show_any,$text_any);
240 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
242 $str = $this->renderCheckbox($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100);
244 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
246 $str = $this->renderRadio($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100,$show_any,$text_any);
248 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
249 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
251 $str = $this->renderTextField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
252 if ($mode == 'QUERY') {
253 $post_name = ' <i>'._('(%% for wildcards)').'</i> ';
256 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
258 $str = $this->renderTextArea($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
259 if ($mode == 'QUERY') {
260 $post_name = ' <i>'._('(%% for wildcards)').'</i> ';
263 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
265 $str = $this->renderMultiSelectBox ($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$show_100,$text_100);
267 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
269 // Get the allowed values from the workflow.
270 $atw = new ArtifactWorkflow($this, $efarr[$i]['extra_field_id']);
272 // Special treatement for the initial step (Submit).
273 // In this case, the initial value is the first value.
274 if ($selected === true) {
275 $selected_node = 100;
276 } elseif (isset($selected[$efarr[$i]['extra_field_id']]) && $selected[$efarr[$i]['extra_field_id']]) {
277 $selected_node = $selected[$efarr[$i]['extra_field_id']];
279 $selected_node = 100;
282 $allowed = $atw->getNextNodes($selected_node);
283 $allowed[] = $selected_node;
284 $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected_node,$status_show_100,$text_100,$show_any,$text_any, $allowed);
286 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
288 $str = $this->renderRelationField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2']);
289 if ($mode == 'UPDATE') {
290 $post_name = html_image('ic/forum_edit.gif','37','15',array('title'=>"Click to edit", 'alt'=>"Click to edit", 'onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
293 $template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}',$post_name,$template);
294 $template = str_replace('{$'.$efarr[$i]['field_name'].'}',$str,$template);
296 if($template != NULL){
301 function renderRelatedTasks($group, $ah) {
303 if (!$group->usesPM()) {
307 $taskcount = db_numrows($ah->getRelatedTasks());
308 db_result_reset($ah->getRelatedTasks());
310 if (forge_check_perm ('tracker_admin', $ah->ArtifactType->Group->getID())) {
316 $totalPercentage = 0;
318 if ($taskcount > 0) {
319 echo '<tr><td colspan="2">';
320 echo '<b>'._("Related Tasks").':</b>'.'<br/>';
321 $title_arr = array();
322 $title_arr[] = _('Task Id and Summary');
323 $title_arr[] = _('Start Date');
324 $title_arr[] = _('End Date');
325 $title_arr[] = _('Status');
326 (($is_admin) ? $title_arr[]=_('Remove Relation') : '');
327 echo $GLOBALS['HTML']->listTableTop($title_arr);
329 for ($i = 0; $i < $taskcount; $i++) {
330 $taskinfo = db_fetch_array($ah->relatedtasks, $i);
331 $totalPercentage += $taskinfo['percent_complete'];
332 $taskid = $taskinfo['project_task_id'];
333 $projectid = $taskinfo['group_project_id'];
334 $groupid = $taskinfo['group_id'];
335 $summary = util_unconvert_htmlspecialchars($taskinfo['summary']);
336 $startdate = date(_('Y-m-d H:i'), $taskinfo['start_date']);
337 $enddate = date(_('Y-m-d H:i'), $taskinfo['end_date']);
338 $status = $taskinfo['status_name'];
340 <td><a href="/pm/task.php?func=detailtask&project_task_id='.$taskid.'&group_id='.$groupid.'&group_project_id='.$projectid.'">[T'.$taskid.'] '.$summary.'</a></td>
341 <td>'.$startdate.'</td>
342 <td>'.$enddate.'</td>
343 <td>'.$status.' ('.$taskinfo['percent_complete'].'%)</td>'.
344 (($is_admin) ? '<td><input type="checkbox" name="remlink[]" value="'.$taskid.'" /></td>' : '').
347 echo $GLOBALS['HTML']->listTableBottom();
349 echo "\n<hr /><p style=\"text-align:right;\">";
350 printf(_('Average completion rate: %d%%'), (int)($totalPercentage/$taskcount));
351 echo "</p>\n"; echo '</td></tr>';
355 function renderFiles($group_id, $ah) {
357 $file_list =& $ah->getFiles();
358 $count=count($file_list);
361 echo '<tr><td colspan="2">';
362 echo '<b>'._("Attachments").':</b>'.'<br/>';
364 $title_arr[] = _('Size');
365 $title_arr[] = _('Name');
366 $title_arr[] = _('Date');
367 $title_arr[] = _('By');
368 $title_arr[] = _('Download');
369 echo $GLOBALS['HTML']->listTableTop($title_arr);
371 foreach ($file_list as $file) {
373 echo '<td>'.human_readable_bytes($file->getSize()).'</td>';
374 echo '<td>'.htmlspecialchars($file->getName()).'</td>';
375 echo '<td>'.date(_('Y-m-d H:i'), $file->getDate()).'</td>';
376 echo '<td>'.$file->getSubmittedUnixName().'</td>';
377 echo '<td><a href="/tracker/download.php/'.$group_id.'/'. $this->getID().'/'. $ah->getID() .'/'.$file->getID().'/'.$file->getName() .'">'. htmlspecialchars($file->getName()) .'</a></td>';
378 // <td><input type="checkbox" name="delete_file[]" value="'. $file->getID() .'">'._("Delete").' </td>
382 echo $GLOBALS['HTML']->listTableBottom();
390 * @param array $types
391 * @param string $mode
392 * @return string HTML template.
394 function getRenderHTML($types=array(), $mode='') {
395 // Use template only for the browse (not for query or mass update)
396 if (($mode === 'DISPLAY' || $mode === 'DETAIL' || $mode === 'UPDATE')
397 && $this->data_array['custom_renderer']) {
398 return preg_replace('/<!--(\S+.*?)-->/','{$\\1}',$this->data_array['custom_renderer']);
400 return $this->generateRenderHTML($types, $mode);
407 * @param array $types
408 * @param string $mode Display mode (QUERY OR DISPLAY)
409 * @return string HTML template.
411 function generateRenderHTML($types=array(), $mode) {
412 $efarr = $this->getExtraFields($types);
413 //each two columns, we'll reset this and start a new row
416 <!-- Start Extra Fields Rendering -->
420 $keys=array_keys($efarr);
422 if ($count == 0) return '';
424 for ($k=0; $k<$count; $k++) {
427 // Do not show the required star in query mode (creating/updating a query).
428 $is_required = ($mode == 'QUERY' || $mode == 'DISPLAY') ? 0 : $efarr[$i]['is_required'];
429 $name = $efarr[$i]['field_name'].($is_required ? utils_requiredField() : '').': ';
430 $name = '<strong>'.$name.'</strong>';
432 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
435 <td class="halfwidth top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
437 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
440 <td class="halfwidth top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
442 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
445 <td class="halfwidth top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
447 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
448 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
450 //text fields might be really wide, so need a row to themselves.
451 if (($col_count == 1) && ($efarr[$i]['attribute1'] > 30)) {
461 <td style="width:'.(50*$colspan).'%" colspan="'.$colspan.'" class="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br />{$'.$efarr[$i]['field_name'].'}</td>';
463 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
465 //text areas might be really wide, so need a row to themselves.
466 if (($col_count == 1) && ($efarr[$i]['attribute2'] > 30)) {
476 <td style="width:'.(50*$colspan).'%" colspan="'.$colspan.'" class="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br />{$'.$efarr[$i]['field_name'].'}</td>';
478 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
481 <td class="halfwidth top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
483 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
486 <td class="halfwidth top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
488 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
490 //text fields might be really wide, so need a row to themselves.
491 if (($col_count == 1) && ($efarr[$i]['attribute1'] > 30)) {
501 <td style="width:'.(50*$colspan).'%" colspan="'.$colspan.'" class="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br />{$'.$efarr[$i]['field_name'].'}</td>';
505 //we've done two columns - if there are more to do, start a new row
506 if (($col_count == 2) && ($k != $count-1)) {
513 if ($col_count == 1) {
519 <!-- End Extra Fields Rendering -->';
524 * renderSelect - this function builds pop up box with choices.
526 * @param int $extra_field_id The ID of this field.
527 * @param string $checked The item that should be checked
528 * @param bool|string $show_100 Whether to show the '100 row'
529 * @param string $text_100 What to call the '100 row'
530 * @param bool $show_any
531 * @param string $text_any
532 * @param bool $allowed
533 * @return string HTML code for the box and choices
535 function renderSelect ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false) {
536 if ($text_100 == 'none'){
539 $arr = $this->getExtraFieldElements($extra_field_id);
542 for ($i=0; $i<count($arr); $i++) {
543 $keys[$i]=$arr[$i]['element_id'];
544 $vals[$i]=$arr[$i]['element_name'];
546 return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed);
550 * renderRadio - this function builds radio buttons.
552 * @param int $extra_field_id The $int ID of this field.
553 * @param string $checked The $string item that should be checked
554 * @param bool $show_100 Whether $string to show the '100 row'
555 * @param string $text_100 What $string to call the '100 row'
556 * @param bool $show_any
557 * @param string $text_any
558 * @return string HTML code using radio buttons
560 function renderRadio ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any') {
561 $arr = $this->getExtraFieldElements($extra_field_id);
564 for ($i=0; $i<count($arr); $i++) {
565 $keys[$i]=$arr[$i]['element_id'];
566 $vals[$i]=$arr[$i]['element_name'];
568 return html_build_radio_buttons_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any);
572 * renderCheckbox - this function builds checkboxes.
574 * @param int $extra_field_id The ID of this field.
575 * @param array $checked The items that should be checked
576 * @param bool|string $show_100 Whether to show the '100 row'
577 * @param string $text_100 What to call the '100 row'
578 * @return string radio buttons
580 function renderCheckbox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
581 if ($text_100 == 'none'){
584 if (!$checked || !is_array($checked)) {
587 $arr = $this->getExtraFieldElements($extra_field_id);
591 <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="100" '.
592 ((in_array(100,$checked)) ? 'checked="checked"' : '').'/> '.$text_100.'<br />';
594 for ($i=0; $i<count($arr); $i++) {
596 <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="'.$arr[$i]['element_id'].'" '.
597 ((in_array($arr[$i]['element_id'],$checked)) ? 'checked="checked"' : '').'/> '.$arr[$i]['element_name'].'<br />';
603 * renderMultiSelectBox - this function builds checkboxes.
605 * @param int $extra_field_id The ID of this field.
606 * @param array $checked The items that should be checked
607 * @param bool|string $show_100 Whether to show the '100 row'
608 * @param string $text_100 What to call the '100 row'
609 * @return string radio multiselectbox
611 function renderMultiSelectBox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
615 if (!is_array($checked)) {
616 $checked = explode(',',$checked);
620 $arr = $this->getExtraFieldElements($extra_field_id);
621 for ($i=0; $i<count($arr); $i++) {
622 $keys[]=$arr[$i]['element_id'];
623 $vals[]=$arr[$i]['element_name'];
625 $size = min( count($arr)+1, 15);
626 return html_build_multiple_select_box_from_arrays($keys,$vals,"extra_fields[$extra_field_id][]",$checked,$size,$show_100,$text_100);
630 * renderTextField - this function builds a text field.
632 * @param int $extra_field_id The ID of this field.
633 * @param string $contents The data for this field.
634 * @param string $size
635 * @param string $maxlength
636 * @return string HTML code of corresponding input tag.
638 function renderTextField ($extra_field_id, $contents, $size, $maxlength) {
640 <input type="text" name="extra_fields['.$extra_field_id.']" value="'.$contents.'" size="'.$size.'" maxlength="'.$maxlength.'"/>';
644 * renderRelationField - this function builds a relation field.
646 * @param int $extra_field_id The ID of this field.
647 * @param string $contents The data for this field.
648 * @param string $size
649 * @param string $maxlength
650 * @return string text area and data.
652 function renderRelationField ($extra_field_id,$contents,$size,$maxlength) {
653 $arr = $this->getExtraFieldElements($extra_field_id);
654 for ($i=0; $i<count($arr); $i++) {
655 $keys[$i]=$arr[$i]['element_id'];
656 $vals[$i]=$arr[$i]['element_name'];
658 // Convert artifact id to links.
659 $html_contents = preg_replace('/\b(\d+)\b/e', "_artifactid2url('\\1','title')", $contents);
660 $edit_contents = $this->renderTextField ($extra_field_id,$contents,$size,$maxlength);
661 $edit_tips = '<br/><span class="tips">'._('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)').'</span>';
663 <div id="edit'.$extra_field_id.'" style="display: none;">'.$edit_contents.$edit_tips.'</div>
664 <div id="show'.$extra_field_id.'" style="display: block;">'.$html_contents.'</div>';
668 * renderTextArea - this function builds a text area.
670 * @param int $extra_field_id The ID of this field.
671 * @param string $contents The data for this field.
672 * @param string $rows
673 * @param string $cols
674 * @return string text area and data.
676 function renderTextArea ($extra_field_id,$contents,$rows,$cols) {
678 <textarea name="extra_fields['.$extra_field_id.']" rows="'.$rows.'" cols="'.$cols.'">'.$contents.'</textarea>';
681 function technicianBox ($name='assigned_to[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
682 if ($text_100=='none'){
683 $text_100=_('Nobody');
686 $engine = RBACEngine::getInstance () ;
687 $techs = $engine->getUsersByAllowedAction ('tracker', $this->getID(), 'tech') ;
692 sortUserList($techs);
694 foreach ($techs as $tech) {
695 $ids[] = $tech->getID() ;
696 $names[] = $tech->getRealName() ;
699 if ($extra_id != '-1') {
701 $names[]=$extra_name;
705 if (!is_array($checked)) {
706 $checked = explode(',',$checked);
708 $size = min( count($ids)+1, 15);
709 return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,$size,$show_100,$text_100);
711 return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
715 function submitterBox ($name='submitted_by[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
716 if ($text_100=='none'){
717 $text_100=_('Nobody');
719 $result = $this->getSubmitters();
720 $ids =& util_result_column_to_array($result,0);
721 $names =& util_result_column_to_array($result,1);
722 if ($extra_id != '-1') {
724 $names[]=$extra_name;
728 if (!is_array($checked)) {
729 $checked = explode(',',$checked);
731 $size = min( count($ids)+1, 15);
732 return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,$size,$show_100,$text_100);
734 return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
738 function cannedResponseBox ($name='canned_response',$checked='xzxz') {
739 return html_build_select_box ($this->getCannedResponses(),$name,$checked);
743 * statusBox - show the statuses - automatically shows the "custom statuses" if they exist
747 function statusBox ($name='status_id',$checked='xzxz',$show_100=false,$text_100='none') {
748 if ($text_100=='none'){
751 return html_build_select_box($this->getStatuses(),$name,$checked,$show_100,$text_100);
758 // c-file-style: "bsd"