5 * Copyright 2010 (c) FusionForge Team
6 * Copyright 2014-2015, Franck Villaume - TrivialDev
7 * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 // FORM TO ADD ELEMENTS TO EXTRA FIELD
31 $boxid = getIntFromRequest('boxid');
32 $ac = new ArtifactExtraField($ath,$boxid);
33 if (!$ac || !is_object($ac)) {
34 exit_error(_('Unable to create ArtifactExtraField Object'),'tracker');
35 } elseif ($ac->isError()) {
36 exit_error($ac->getErrorMessage(),'tracker');
38 // $efearr=$ath->getExtraFieldElements($boxid);
39 $efType = $ac->getType();
40 $efearr=$ac->getAvailableValues();
42 case ARTIFACT_EXTRAFIELDTYPE_USER:
43 $title = sprintf(_('Add/Update Roles for user choices in %s'), $ath->getName());
45 case ARTIFACT_EXTRAFIELDTYPE_RELEASE:
46 $title = sprintf(_('Add/Update Packages for user choices in %s'), $ath->getName());
49 $title = sprintf(_('Add/Update Custom Field Elements in %s'), $ath->getName());
51 $ath->adminHeader(array('title'=>$title, 'modal'=>1));
52 echo html_e('h2', array(), _('Custom Field Name')._(': ').$ac->getName());
54 case ARTIFACT_EXTRAFIELDTYPE_USER:
56 // specific for user select box
57 echo html_e('p',array(),_('Choose roles used for the user select box'));
59 $roles = $g->getRoles();
60 foreach ($roles as $role) {
61 if (!in_array(get_class($role), array('RoleLoggedIn','RoleAnonymous'))) {
62 $vals[$role->getID()]=$role->getName();
66 asort($vals,SORT_FLAG_CASE);
69 // $checked_array = array_column($efearr, 'element_name');
71 $checked_array = array();
72 for ($i=0; $i < $rows; $i++) {
73 $checked_array []= $efearr[$i]['element_name'];
75 echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid, 'method' => 'post'));
76 echo html_e('input', array('type'=>'hidden', 'name'=>'update_checked_opt', 'value'=>'y'));
77 echo html_build_checkboxes_from_array($vals, 'element', $checked_array, true, false);
78 echo html_e('input', array('type'=>'submit', 'name'=>'post_changes', 'value'=>_('Submit')));
79 echo $HTML->closeForm();
84 echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid, 'method' => 'post'));
86 $title_arr[]=_('Current/New positions');
87 if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
88 $title_arr[] = _('Mapping');
90 $title_arr[]=_('Up/Down positions');
91 $title_arr[]=_('Elements Defined');
92 if (in_array($efType, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_CHOICE))) {
93 $title_arr[]=_('Default');
96 echo $HTML->listTableTop($title_arr);
97 if (in_array($efType, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_CHOICE))) {
100 $cells[] = array('', 'class'=>'align-right');
101 if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
102 $cells[] = array('');
104 $cells[] = array('', 'class'=>'align-center');
105 $cells[] = array(_('None'));
106 if (in_array($efType, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_MULTICHOICE))) {
107 $defaultValues = $ac->getDefaultValues();
108 if (is_array($defaultValues)) {
109 if (in_array('100', $defaultValues)) {
110 $content = html_build_checkbox('is_default[100]', false, true);
112 $content = html_build_checkbox('is_default[100]', false, false);
115 if ($defaultValues == 100) {
116 $content = html_build_checkbox('is_default[100]', false, true);
118 $content = html_build_checkbox('is_default[100]', false, false);
121 } elseif (in_array($efType, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_SINGLECHOICE))) {
122 $defaultValues = $ac->getDefaultValues();
123 if ($defaultValues == 100) {
124 $content = html_build_radio_button('is_default', 100, true);
126 $content = html_build_radio_button('is_default', 100, false);
129 $cells[] = array($content, 'class'=>'align-center');
130 $cells[] = array('', 'class'=>'align-center');
131 echo $HTML->multiTableRow($row_attrs, $cells);
133 for ($i=0; $i < $rows; $i++) {
134 $row_attrs = array();
136 $content = ($i + 1).' -->'.html_e('input', array('type'=>'text', 'name'=>'order['. $efearr[$i]['element_id'] .']', 'value'=>'', 'size'=>'3', 'maxlength'=>'3'));
137 $cells[] = array($content, 'class'=>'align-right');
138 if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
139 $cells[] = array($ath->getStatusName($efearr[$i]['status_id']));
141 $content = util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid.'&id='.$efearr[$i]['element_id'].'&updownorder_opt=1&new_pos='.(($i == 0)? $i + 1 : $i), html_image('ic/btn_up.png','19','18',array('alt'=>'Up', 'title'=>_('Move Up this custom field element'))));
142 $content .= util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid.'&id='.$efearr[$i]['element_id'].'&updownorder_opt=1&new_pos='.(($i == $rows - 1)? $i + 1 : $i + 2), html_image('ic/btn_down.png','19','18',array('alt'=>'Down', 'title'=>_('Move Down this custom field element'))));
143 $cells[] = array($content, 'class'=>'align-center');
144 $cells[] = array($efearr[$i]['element_name']);
145 if (in_array($efType, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_MULTICHOICE))) {
146 $content = html_build_checkbox('is_default['. $efearr[$i]['element_id'] .']', false, $efearr[$i]['is_default']);
147 $cells[] = array($content, 'class'=>'align-center');
149 $content = html_build_radio_button('is_default', $efearr[$i]['element_id'], $efearr[$i]['is_default']);
150 $cells[] = array($content, 'class'=>'align-center');
152 $content = util_make_link('/tracker/admin/?update_opt=1&id='.$efearr[$i]['element_id'].'&boxid='.$boxid.'&group_id='.$group_id.'&atid='. $ath->getID(), html_image('ic/configure.png','22','22',array('alt'=>_('Edit'), 'title'=>_('Edit custom field element'))));
153 $cells[] = array($content, 'class'=>'align-center');
154 echo $HTML->multiTableRow($row_attrs, $cells);
156 $row_attrs = array('class'=>'noborder');
158 $content = html_e('input', array('type'=>'submit', 'name'=>'post_changes_order', 'value'=>_('Reorder')));
159 $cells[] = array($content, 'class'=>'align-right');
160 $cells[] = array('');
161 if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
162 $cells[] = array('');
164 $content = html_e('input', array('type'=>'submit', 'name'=>'post_changes_alphaorder', 'value'=>_('Alphabetical order')));
165 $cells[] = array($content, 'class'=>'align-left');
166 if (in_array($efType, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_CHOICE))) {
167 $content = html_e('input', array('type'=>'submit', 'name'=>'post_changes_default', 'value'=>_('Update default')));
168 $cells[] = array($content, 'class'=>'align-center');
170 $cells[] = array('');
171 echo $HTML->multiTableRow($row_attrs, $cells);
172 echo $HTML->listTableBottom();
173 echo $HTML->closeForm();
175 echo html_e('strong', array(), _('You have not defined any elements.'));
177 echo html_e('br').html_e('br');
178 echo $HTML->openForm(array('action' => '/tracker/admin/?group_id='.$group_id.'&boxid='.$boxid.'&atid='.$ath->getID(), 'method' => 'post'));
179 echo html_e('input', array('type'=>'hidden', 'name'=>'add_opt', 'value'=>'y'));
180 echo html_e('label', array('for'=>'name'),html_e('strong', array(), _('Add New Element')._(':')));
181 echo html_e('input', array('type'=>'text', 'id'=>'name', 'name'=>'name', 'value'=>'', 'size'=>'15', 'maxlength'=>'30', 'required'=>'required'));
182 // Show a pop-up box to choose the possible statuses that this element will map to
183 if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
184 echo html_e('strong', array(), _('Status'));
185 echo $ath->statusBox('status_id',1,false,false);
187 echo html_e('input', array('type'=>'submit', 'name'=>'post_changes', 'value'=>_('Submit')));
188 echo $HTML->closeForm();
190 if ($efType != ARTIFACT_EXTRAFIELDTYPE_USER) {} else {}
196 // c-file-style: "bsd"