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 {
36 * ArtifactType() - constructor
38 * @param $group object
39 * @param $artifact_type_id - the id # assigned to this artifact type in the db
41 function ArtifactTypeHtml(&$group,$artifact_type_id=false, $arr=false) {
42 return $this->ArtifactType($group,$artifact_type_id,$arr);
45 function header($params) {
47 if (!forge_get_config('use_tracker')) {
50 $group_id= $this->Group->getID();
52 //required by new site_project_header
53 $params['group']=$group_id;
54 $params['toptab']='tracker';
55 $params['tabtext']=$this->getName();
61 $labels[] = _("View Trackers");
62 $links[] = '/tracker/?group_id='.$group_id;
63 $attr[] = array('title' => _('Get the list of available trackers'), 'class' => 'tabtitle-nw');
64 $labels[] = $this->getName();
65 $links[] = '/tracker/?func=browse&group_id='.$group_id.'&atid='. $this->getID();
66 $attr[] = array('title' => _('Browse this tracker.'), 'class' => 'tabtitle');
67 $labels[] = _('Export CSV');
68 $links[] = '/tracker/?func=csv&group_id='.$group_id.'&atid='. $this->getID();
69 $attr[] = array('title' => _('Download data from this tracker as csv file.'), 'class' => 'tabtitle');
70 if ($this->allowsAnon() || session_loggedin()) {
71 $labels[] = _('Submit New');
72 $links[] = '/tracker/?func=add&group_id='.$group_id.'&atid='. $this->getID();
73 $attr[] = array('title' => _('Add a new issue.'), 'class' => 'tabtitle');
76 if (session_loggedin()) {
77 $labels[] = _('Reporting');
78 $links[] = '/tracker/reporting/?group_id='.$group_id.'&atid='. $this->getID();
79 $attr[] = array('title' => _('Various graph about statistics.'), 'class' => 'tabtitle');
80 if ($this->isMonitoring()) {
81 $labels[] = _('Stop Monitor');
82 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&stop=1';
83 $attr[] = array('title' => _('Remove this tracker from your monitoring.'), 'class' => 'tabtitle');
85 $labels[] = _('Monitor');
86 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&start=1';
87 $attr[] = array('title' => _('Add this tracker from your monitoring.'), 'class' => 'tabtitle');
90 if (forge_check_perm ('tracker', $this->getID(), 'manager')) {
91 $labels[] = _('Administration');
92 $links[] = '/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID();
93 $attr[] = array('title' => _('Global administration for trackers. Create, clone, workflow, fields ...'), 'class' => 'tabtitle');
96 $labels[] = _('Monitor');
97 $links[] = '/tracker/?group_id='.$group_id.'&atid='. $this->getID().'&func=monitor&start=1';
98 $attr[] = array('title' => _('Add this tracker from your monitoring.'), 'class' => 'tabtitle');
101 $params['submenu'] = $HTML->subMenu($labels, $links, $attr);
102 site_project_header($params);
105 plugin_hook("blocks", "tracker_".$this->getName());
109 function footer($params) {
110 site_project_footer($params);
113 function adminHeader($params) {
115 $this->header($params);
116 $group_id= $this->Group->getID();
118 $links_arr[]='/tracker/admin/?group_id='.$group_id;
119 $title_arr[]=_('New Tracker');
121 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&update_type=1';
122 $title_arr[]=_('Update Settings');
124 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_extrafield=1';
125 $title_arr[]=_('Manage Custom Fields');
127 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&workflow=1';
128 $title_arr[]=_('Manage Workflow');
130 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&customize_list=1';
131 $title_arr[]=_('Customize List');
133 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_canned=1';
134 $title_arr[]=_('Add/Update Canned Responses');
136 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&clone_tracker=1';
137 $title_arr[]=_('Clone Tracker');
139 $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&delete=1';
140 $title_arr[]=_('Delete');
142 echo $HTML->printSubMenu($title_arr, $links_arr, false);
145 function adminFooter($params) {
146 echo $this->footer($params);
149 function renderSubmitInstructions() {
150 $msg = $this->getSubmitInstructions();
151 return str_replace("\n","<br />", $msg);
154 function renderBrowseInstructions() {
155 $msg = $this->getBrowseInstructions();
156 return str_replace("\n","<br />", $msg);
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 renderding 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 } else if ($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 } else if ($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());
309 if (forge_check_perm ('tracker_admin', $ah->ArtifactType->Group->getID())) {
315 $totalPercentage = 0;
317 if ($taskcount > 0) {
318 echo '<tr><td colspan="2">';
319 echo '<b>'._("Related Tasks").':</b>'.'<br/>';
320 $title_arr = array();
321 $title_arr[] = _('Task Id');
322 $title_arr[] = _('Task 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 echo '<table cellspacing="0">';
330 for ($i = 0; $i < $taskcount; $i++) {
331 $taskinfo = db_fetch_array($ah->relatedtasks, $i);
332 $totalPercentage += $taskinfo['percent_complete'];
333 $taskid = $taskinfo['project_task_id'];
334 $projectid = $taskinfo['group_project_id'];
335 $groupid = $taskinfo['group_id'];
336 $summary = util_unconvert_htmlspecialchars($taskinfo['summary']);
337 $startdate = date(_('Y-m-d H:i'), $taskinfo['start_date']);
338 $enddate = date(_('Y-m-d H:i'), $taskinfo['end_date']);
339 $status = $taskinfo['status_name'];
341 <td><a href="/pm/task.php?func=detailtask&project_task_id='.$taskid.
342 '&group_id='.$groupid.'&group_project_id='.$projectid.'">[T'.$taskid.'] '.$summary.'</a></td>
343 <td>'.$startdate.'</td>
344 <td>'.$enddate.'</td>
345 <td>'.$status.' ('.$taskinfo['percent_complete'].'%)</td>'.
346 (($is_admin) ? '<td><input type="checkbox" name="remlink[]" value="'.$taskid.'" /></td>' : '').
349 echo $GLOBALS['HTML']->listTableBottom();
351 echo "\n<hr /><p style=\"text-align:right;\">";
352 printf(_('Average completion rate: %d%%'), (int)($totalPercentage/$taskcount));
353 echo "</p>\n"; echo '</td></tr>';
357 function renderFiles($group_id, $ah) {
359 $file_list =& $ah->getFiles();
360 $count=count($file_list);
363 echo '<tr><td colspan="2">';
364 echo '<b>'._("Attachments").':</b>'.'<br/>';
366 $title_arr[] = _('Size');
367 $title_arr[] = _('Name');
368 $title_arr[] = _('Date');
369 $title_arr[] = _('By');
370 $title_arr[] = _('Download');
371 echo $GLOBALS['HTML']->listTableTop($title_arr);
373 foreach ($file_list as $file) {
375 echo '<td>'.human_readable_bytes($file->getSize()).'</td>';
376 echo '<td>'.htmlspecialchars($file->getName()).'</td>';
377 echo '<td>'.date(_('Y-m-d H:i'), $file->getDate()).'</td>';
378 echo '<td>'.$file->getSubmittedUnixName().'</td>';
379 echo '<td><a href="/tracker/download.php/'.$group_id.'/'. $this->getID().'/'. $ah->getID() .'/'.$file->getID().'/'.$file->getName() .'">'. htmlspecialchars($file->getName()) .'</a></td>';
380 // <td><input type="checkbox" name="delete_file[]" value="'. $file->getID() .'">'._("Delete").' </td>
384 echo $GLOBALS['HTML']->listTableBottom();
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 * @return string HTML template.
409 function generateRenderHTML($types=array(), $mode) {
410 $efarr = $this->getExtraFields($types);
411 //each two columns, we'll reset this and start a new row
414 <!-- Start Extra Fields Rendering -->
418 $keys=array_keys($efarr);
420 if ($count == 0) return '';
422 for ($k=0; $k<$count; $k++) {
425 // Do not show the required star in query mode (creating/updating a query).
426 $is_required = ($mode == 'QUERY' || $mode == 'DISPLAY') ? 0 : $efarr[$i]['is_required'];
427 $name = $efarr[$i]['field_name'].($is_required ? utils_requiredField() : '').': ';
428 $name = '<strong>'.$name.'</strong>';
430 if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
433 <td width="50%" valign="top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
435 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
438 <td width="50%" valign="top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
440 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
443 <td width="50%" valign="top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
445 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
446 $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
448 //text fields might be really wide, so need a row to themselves.
449 if (($col_count == 1) && ($efarr[$i]['attribute1'] > 30)) {
459 <td width="'.(50*$colspan).'%" colspan="'.$colspan.'" valign="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br />{$'.$efarr[$i]['field_name'].'}</td>';
461 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
463 //text areas might be really wide, so need a row to themselves.
464 if (($col_count == 1) && ($efarr[$i]['attribute2'] > 30)) {
474 <td width="'.(50*$colspan).'%" colspan="'.$colspan.'" valign="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br />{$'.$efarr[$i]['field_name'].'}</td>';
476 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
479 <td width="50%" valign="top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
481 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
484 <td width="50%" valign="top">'.$name.'<br />{$'.$efarr[$i]['field_name'].'}</td>';
486 } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
488 //text fields might be really wide, so need a row to themselves.
489 if (($col_count == 1) && ($efarr[$i]['attribute1'] > 30)) {
499 <td width="'.(50*$colspan).'%" colspan="'.$colspan.'" valign="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br />{$'.$efarr[$i]['field_name'].'}</td>';
503 //we've done two columns - if there are more to do, start a new row
504 if (($col_count == 2) && ($k != $count-1)) {
511 if ($col_count == 1) {
517 <!-- End Extra Fields Rendering -->';
522 * renderSelect - this function builds pop up
525 * @param int The ID of this field.
526 * @param string The item that should be checked
527 * @param string Whether to show the '100 row'
528 * @param string What to call the '100 row'
529 * @return box and choices
531 function renderSelect ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false) {
532 if ($text_100 == 'none'){
535 $arr = $this->getExtraFieldElements($extra_field_id);
538 for ($i=0; $i<count($arr); $i++) {
539 $keys[$i]=$arr[$i]['element_id'];
540 $vals[$i]=$arr[$i]['element_name'];
542 return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed);
546 * renderRadio - this function builds radio buttons.
548 * @param int The ID of this field.
549 * @param string The item that should be checked
550 * @param string Whether to show the '100 row'
551 * @param string What to call the '100 row'
552 * @return radio buttons
554 function renderRadio ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any') {
555 $arr = $this->getExtraFieldElements($extra_field_id);
558 for ($i=0; $i<count($arr); $i++) {
559 $keys[$i]=$arr[$i]['element_id'];
560 $vals[$i]=$arr[$i]['element_name'];
562 return html_build_radio_buttons_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any);
566 * renderCheckbox - this function builds checkboxes.
568 * @param int The ID of this field.
569 * @param array The items that should be checked
570 * @param string Whether to show the '100 row'
571 * @param string What to call the '100 row'
572 * @return radio buttons
574 function renderCheckbox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
575 if ($text_100 == 'none'){
578 if (!$checked || !is_array($checked)) {
581 $arr = $this->getExtraFieldElements($extra_field_id);
585 <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="100" '.
586 ((in_array(100,$checked)) ? 'checked="checked"' : '').'/> '.$text_100.'<br />';
588 for ($i=0; $i<count($arr); $i++) {
590 <input type="checkbox" name="extra_fields['.$extra_field_id.'][]" value="'.$arr[$i]['element_id'].'" '.
591 ((in_array($arr[$i]['element_id'],$checked)) ? 'checked="checked"' : '').'/> '.$arr[$i]['element_name'].'<br />';
597 * renderMultiSelectBox - this function builds checkboxes.
599 * @param int The ID of this field.
600 * @param array The items that should be checked
601 * @param string Whether to show the '100 row'
602 * @param string What to call the '100 row'
603 * @return radio multiselectbox
605 function renderMultiSelectBox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none') {
606 $arr = $this->getExtraFieldElements($extra_field_id);
610 if (!is_array($checked)) {
611 $checked = explode(',',$checked);
615 $arr = $this->getExtraFieldElements($extra_field_id);
616 for ($i=0; $i<count($arr); $i++) {
617 $keys[]=$arr[$i]['element_id'];
618 $vals[]=$arr[$i]['element_name'];
620 $size = min( count($arr)+1, 15);
621 return html_build_multiple_select_box_from_arrays($keys,$vals,"extra_fields[$extra_field_id][]",$checked,$size,$show_100,$text_100);
625 * renderTextField - this function builds a text field.
627 * @param int The ID of this field.
628 * @param string The data for this field.
629 * @return text area and data.
631 function renderTextField ($extra_field_id,$contents,$size,$maxlength) {
633 <input type="text" name="extra_fields['.$extra_field_id.']" value="'.$contents.'" size="'.$size.'" maxlength="'.$maxlength.'"/>';
637 * renderRelationField - this function builds a relation field.
639 * @param int The ID of this field.
640 * @param string The data for this field.
641 * @return text area and data.
643 function renderRelationField ($extra_field_id,$contents,$size,$maxlength) {
644 $arr = $this->getExtraFieldElements($extra_field_id);
645 for ($i=0; $i<count($arr); $i++) {
646 $keys[$i]=$arr[$i]['element_id'];
647 $vals[$i]=$arr[$i]['element_name'];
649 // Convert artifact id to links.
650 $html_contents = preg_replace('/\b(\d+)\b/e', "_artifactid2url('\\1','title')", $contents);
651 $edit_contents = $this->renderTextField ($extra_field_id,$contents,$size,$maxlength);
652 $edit_tips = '<br/><span class="tips">'._('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)').'</span>';
654 <div id="edit'.$extra_field_id.'" style="display: none;">'.$edit_contents.$edit_tips.'</div>
655 <div id="show'.$extra_field_id.'" style="display: block;">'.$html_contents.'</div>';
659 * renderTextArea - this function builds a text area.
661 * @param int The ID of this field.
662 * @param string The data for this field.
663 * @return text area and data.
665 function renderTextArea ($extra_field_id,$contents,$rows,$cols) {
667 <textarea name="extra_fields['.$extra_field_id.']" rows="'.$rows.'" cols="'.$cols.'">'.$contents.'</textarea>';
670 function technicianBox ($name='assigned_to[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
671 if ($text_100=='none'){
672 $text_100=_('Nobody');
675 $engine = RBACEngine::getInstance () ;
676 $techs = $engine->getUsersByAllowedAction ('tracker', $this->getID(), 'tech') ;
681 sortUserList($techs);
683 foreach ($techs as $tech) {
684 $ids[] = $tech->getID() ;
685 $names[] = $tech->getRealName() ;
688 if ($extra_id != '-1') {
690 $names[]=$extra_name;
694 if (!is_array($checked)) {
695 $checked = explode(',',$checked);
697 $size = min( count($ids)+1, 15);
698 return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,$size,$show_100,$text_100);
700 return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
704 function submitterBox ($name='submitted_by[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
705 if ($text_100=='none'){
706 $text_100=_('Nobody');
708 $result = $this->getSubmitters();
709 $ids =& util_result_column_to_array($result,0);
710 $names =& util_result_column_to_array($result,1);
711 if ($extra_id != '-1') {
713 $names[]=$extra_name;
717 if (!is_array($checked)) {
718 $checked = explode(',',$checked);
720 $size = min( count($ids)+1, 15);
721 return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,$size,$show_100,$text_100);
723 return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
727 function cannedResponseBox ($name='canned_response',$checked='xzxz') {
728 return html_build_select_box ($this->getCannedResponses(),$name,$checked);
732 * statusBox - show the statuses - automatically shows the "custom statuses" if they exist
736 function statusBox ($name='status_id',$checked='xzxz',$show_100=false,$text_100='none') {
737 if ($text_100=='none'){
740 return html_build_select_box($this->getStatuses(),$name,$checked,$show_100,$text_100);
747 // c-file-style: "bsd"