This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  1be39f12907decdfb2898a1f60071667a0f3c0b9 (commit)
      from  4d0c78e4100962414d89b6c30ee9c9c86358e24f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=1be39f12907decdfb2898a1f60071667a0f3c0b9

commit 1be39f12907decdfb2898a1f60071667a0f3c0b9
Author: Stéphane-Eymeric Bredthauer <[email protected]>
Date:   Sat Jun 4 12:48:26 2016 +0200

    Tracker : Add User Type for Custom Extra Field

diff --git a/src/common/tracker/ArtifactExtraField.class.php 
b/src/common/tracker/ArtifactExtraField.class.php
index d7ae56e..4ed7ae4 100644
--- a/src/common/tracker/ArtifactExtraField.class.php
+++ b/src/common/tracker/ArtifactExtraField.class.php
@@ -41,7 +41,8 @@ define('ARTIFACT_EXTRAFIELDTYPE_FORMULA',11);
 /* reserved for Evolvis extension, for merge into FusionForge */
 define('ARTIFACT_EXTRAFIELDTYPE_DATETIME',12);
 /* reserved */
-define('ARTIFACT_EXTRAFIELDTYPE_USER',13);
+define('ARTIFACT_EXTRAFIELDTYPE_DATE',13);
+define('ARTIFACT_EXTRAFIELDTYPE_USER',14);
 
 class ArtifactExtraField extends FFError {
 
@@ -145,8 +146,9 @@ class ArtifactExtraField extends FFError {
                                $this->setError(_('This Tracker already uses 
custom statuses'));
                                return false;
                        }
+               }  elseif ($field_type == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+                       $show100label='nobody';
                }
-
                if ($is_required) {
                        $is_required=1;
                } else {
@@ -376,7 +378,8 @@ class ArtifactExtraField extends FFError {
                        ARTIFACT_EXTRAFIELDTYPE_TEXTAREA => _('Text Area'),
                        ARTIFACT_EXTRAFIELDTYPE_STATUS => _('Status'),
                        ARTIFACT_EXTRAFIELDTYPE_RELATION => _('Relation between 
artifacts'),
-                       ARTIFACT_EXTRAFIELDTYPE_INTEGER => _('Integer')
+                       ARTIFACT_EXTRAFIELDTYPE_INTEGER => _('Integer'),
+                       ARTIFACT_EXTRAFIELDTYPE_USER => _('User Select Box')
                        );
        }
 
diff --git a/src/common/tracker/actions/admin-updates.php 
b/src/common/tracker/actions/admin-updates.php
index 94d5fcc..0537720 100644
--- a/src/common/tracker/actions/admin-updates.php
+++ b/src/common/tracker/actions/admin-updates.php
@@ -292,6 +292,62 @@ if (getStringFromRequest('add_extrafield')) {
        }
 
 //
+//     Update checked elements (add checked, delete uncheked)
+//
+} elseif (getStringFromRequest('update_checked_opt')) {
+       $checkedElts = getStringFromRequest('element');
+       $boxid = getStringFromRequest('boxid');
+       $aef = new ArtifactExtraField($ath,$boxid);
+       if (!$aef || !is_object($aef)) {
+               $error_msg .= _('Unable to create ArtifactExtraField Object');
+       } elseif ($aef->isError()) {
+               $error_msg .= $aef->getErrorMessage();
+       } else {
+               $efValues = $aef->getAvailableValues();
+               $efEltNames = array();
+               foreach ($efValues as $efValue) {
+                       $efEltNames [$efValue['element_id']]= 
$efValue['element_name'];
+               }
+               if (is_array($checkedElts)) {
+                       foreach ($checkedElts as $checkedElt) {
+                               if (!in_array($checkedElt,$efEltNames)) {
+                                       $aefe = new 
ArtifactExtraFieldElement($aef);
+                                       if (!$aefe || !is_object($aefe)) {
+                                               $error_msg .= 'Unable to create 
ArtifactExtraFieldElement Object';
+                                               //              } elseif 
($ao->isError())
+                                               //                      
$error_msg .= $ao->getErrorMessage();
+                                       } else {
+                                               if 
(!$aefe->create($checkedElt)) {
+                                                       $error_msg .= _('Insert 
Error')._(': ').$aefe->getErrorMessage();
+                                                       $aefe->clearError();
+                                               } else {
+                                                       $feedback .= _('Element 
inserted').' ';
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (is_array($efEltNames)) {
+                       foreach ($efEltNames as $efEltId=>$efEltName) {
+                               if (!in_array($efEltName,$checkedElts)) {
+                                       $aefe = new 
ArtifactExtraFieldElement($aef,$efEltId);
+                                       if (!$aefe || !is_object($aefe)) {
+                                               $error_msg .= _('Unable to 
create ArtifactExtraFieldElement Object');
+                                       } else {
+                                               if (!$aefe->delete()) {
+                                                       $error_msg .= _('Error 
deleting an element')._(': ').$aefe->getErrorMessage();
+                                                       $aefe->clearError();
+                                               } else {
+                                                       $feedback .= _('Element 
deleted').' ';
+                                                       $next = 
'add_extrafield';
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       $next = 'add_extrafield';
+//
 //     Clone a tracker's elements to this tracker
 //
 } elseif (getStringFromRequest('clone_tracker')) {
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php 
b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 8ed1e23..91a3387 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -7,6 +7,7 @@
  * Copyright 2011, Franck Villaume - Capgemini
  * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
  * Copyright 2014, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -309,6 +310,8 @@ class ArtifactTypeHtml extends ArtifactType {
                                if ($mode == 'UPDATE') {
                                        $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')"));
                                }
+                       } elseif ($efarr[$i]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_USER) {
+                               $str = 
$this->renderUserField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false,
 $attrs);
                        }
                        $template = 
str_replace('{$PostName:'.$efarr[$i]['field_name'].'}',$post_name,$template);
                        $template = 
str_replace('{$'.$efarr[$i]['field_name'].'}',$str,$template);
@@ -526,7 +529,12 @@ class ArtifactTypeHtml extends ArtifactType {
                                $return .= '
                                        <td style="width:'.(50*$colspan).'%" 
colspan="'.$colspan.'" 
class="top">'.$name.'{$PostName:'.$efarr[$i]['field_name'].'}<br 
/>{$'.$efarr[$i]['field_name'].'}</td>';
 
+                       } elseif ($efarr[$i]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_USER) {
+
+                               $return .= '
+                                       <td class="halfwidth top">'.$name.'<br 
/>{$'.$efarr[$i]['field_name'].'}</td>';
                        }
+
                        $col_count++;
                        //we've done two columns - if there are more to do, 
start a new row
                        if (($col_count == 2) && ($k != $count-1)) {
@@ -574,6 +582,47 @@ class ArtifactTypeHtml extends ArtifactType {
        }
 
        /**
+        * renderUserField - this function builds pop up box with choices.
+        *
+        * @param       int             $extra_field_id The ID of this field.
+        * @param       string          $checked        The item that should be 
checked
+        * @param       bool|string     $show_100       Whether to show the 
'100 row'
+        * @param       string          $text_100       What to call the '100 
row'
+        * @param       bool            $show_any
+        * @param       string          $text_any
+        * @param       bool            $allowed
+        * @param       array           $attrs
+        * @return string HTML code for the box and choices
+        */
+       function renderUserField 
($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any',
 $allowed=false, $attrs = array ()) {
+               if ($text_100 == 'none' || $text_100 == 'nobody'){
+                       $text_100=_('NoBody');
+               }
+               $arr = $this->getExtraFieldElements($extra_field_id);
+               $selectedRolesId = array();
+               for ($i=0; $i<count($arr); $i++) {
+                       $selectedRolesId[$i]=$arr[$i]['element_name'];
+               }
+               $roles = $this->getGroup()->getRoles();
+               $userArray = array();
+               foreach ($roles as $role) {
+                       if (in_array($role->getID(), $selectedRolesId)) {
+                               foreach ($role->getUsers() as $user) {
+                                       $userArray[$user->getID()] = 
$user->getRealName().(($user->getStatus()=='S') ? ' '._('[SUSPENDED]') : '');
+                               }
+                       }
+               }
+               if (!isset($userArray[$checked])) {
+                       $checkedUser = user_get_object($checked);
+                       $userArray[$checkedUser->getID()] = 
$checkedUser->getRealName().' '._('[DELETED]');
+               }
+               asort($userArray,SORT_FLAG_CASE | SORT_STRING);
+               $keys = array_keys($userArray);
+               $vals = array_values($userArray);
+               return html_build_select_box_from_arrays 
($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any,
 $allowed, $attrs);
+       }
+
+       /**
         * renderRadio - this function builds radio buttons.
         *
         * @param       int     $extra_field_id The $int ID of this field.
diff --git a/src/common/tracker/views/form-addextrafield.php 
b/src/common/tracker/views/form-addextrafield.php
index c241b19..e392447 100644
--- a/src/common/tracker/views/form-addextrafield.php
+++ b/src/common/tracker/views/form-addextrafield.php
@@ -47,11 +47,12 @@ if ($rows > 0) {
        $title_arr[]=_('Elements Defined');
        $title_arr[]=_('Add Options');
        echo $HTML->listTableTop($title_arr);
-
+       $rownb = 0;
        for ($k=0; $k < $rows; $k++) {
                $i=$keys[$k];
+               $rownb++;
                $id=str_replace('@','',$efarr[$i]['alias']);
-               echo '<tr id="field-'.$id.'" '. $HTML->boxGetAltRowStyle($i) 
.">\n".
+               echo '<tr id="field-'.$id.'" '. 
$HTML->boxGetAltRowStyle($rownb) .">\n".
                        
'<td>'.$efarr[$i]['field_name'].(($efarr[$i]['is_required']) ? 
utils_requiredField() : '').
                                
util_make_link('/tracker/admin/?update_box=1&id='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
 ' ['._('Edit').']').
                                
util_make_link('/tracker/admin/?deleteextrafield=1&id='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.
 $ath->getID(), ' ['._('Delete').']').
@@ -62,14 +63,26 @@ if ($rows > 0) {
                        List of possible options for a user built Selection Box
                */
                $elearray = 
$ath->getExtraFieldElements($efarr[$i]['extra_field_id']);
+               if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_USER && 
!isset($roles)) {
+                       $rolesarray = array();
+                       $roles = $ath->getGroup()->getRoles();
+                       foreach ($roles as $role) {
+                               $rolesarray[$role->getID()]=$role->getName();
+                       }
+               }
 
                if (!empty($elearray)) {
                        $optrows=count($elearray);
 
                        echo '<td>';
                        for ($j=0; $j <$optrows; $j++) {
-                               echo $elearray[$j]['element_name'];
-                               echo 
util_make_link('/tracker/admin/?update_opt=1&id='.$elearray[$j]['element_id'].'&group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$efarr[$i]['extra_field_id'],
 ' ['._('Edit').']');
+
+                               if ($efarr[$i]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_USER) {
+                                       echo 
$rolesarray[$elearray[$j]['element_name']];
+                               } else {
+                                       echo $elearray[$j]['element_name'];
+                                       echo 
util_make_link('/tracker/admin/?update_opt=1&id='.$elearray[$j]['element_id'].'&group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$efarr[$i]['extra_field_id'],
 ' ['._('Edit').']');
+                               }
                                echo 
util_make_link('/tracker/admin/?delete_opt=1&id='.$elearray[$j]['element_id'].'&group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$efarr[$i]['extra_field_id'],
 ' ['._('Delete').']');
                                echo '<br />';
                        }
@@ -86,6 +99,9 @@ if ($rows > 0) {
                        || $efarr[$i]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_STATUS) {
                        echo 
util_make_link('/tracker/admin/?add_opt=1&boxid='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
 '['._('Add/Reorder choices').']');
                }
+               if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_USER) {
+                                       echo 
util_make_link('/tracker/admin/?add_opt=1&boxid='.$efarr[$i]['extra_field_id'].'&group_id='.$group_id.'&atid='.$ath->getID(),
 '['._('Add/remove roles for user choices').']');
+                               }
                echo "</td>\n";
                echo "</tr>\n";
        }
@@ -101,54 +117,44 @@ echo html_ao('p');
 echo html_e('input', array('type'=>'hidden', 'name'=>'add_extrafield', 
'value'=>'y'));
 
 echo html_e('strong', array(), _('Custom Field 
Name').utils_requiredField()._(':')).html_e('br');
-echo html_e('input', array('type'=>'text', 'name'=>'name', 'value'=>'', 
size=>'15', 'maxlength'=>'30', 'required'=>'required'));
+echo html_e('input', array('type'=>'text', 'name'=>'name', 'value'=>'', 
'size'=>'15', 'maxlength'=>'30', 'required'=>'required'));
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
 echo html_e('strong', array(), _('Field alias')._(':')).html_e('br');
-echo html_e('input', array('type'=>'text', 'name'=>'alias', 'value'=>'', 
size=>'15', 'maxlength'=>'30'));
+echo html_e('input', array('type'=>'text', 'name'=>'alias', 'value'=>'', 
'size'=>'15', 'maxlength'=>'30'));
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
 echo html_e('strong', array(), _('Description')._(':')).html_e('br');
-echo html_e('input', array('type'=>'text', 'name'=>'description', 'value'=>'', 
size=>'50', 'maxlength'=>'255'));
+echo html_e('input', array('type'=>'text', 'name'=>'description', 'value'=>'', 
'size'=>'50', 'maxlength'=>'255'));
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
 echo html_e('strong', array(), _('Type of custom 
field').utils_requiredField()._(':')).html_e('br');
 
-$vals = array(ARTIFACT_EXTRAFIELDTYPE_SELECT , 
ARTIFACT_EXTRAFIELDTYPE_CHECKBOX, ARTIFACT_EXTRAFIELDTYPE_RADIO, 
ARTIFACT_EXTRAFIELDTYPE_TEXT, ARTIFACT_EXTRAFIELDTYPE_MULTISELECT, 
ARTIFACT_EXTRAFIELDTYPE_TEXTAREA, ARTIFACT_EXTRAFIELDTYPE_STATUS, 8, 
ARTIFACT_EXTRAFIELDTYPE_RELATION);
-// 8 = ARTIFACT_EXTRAFIELDTYPE_ASSIGNEE
-// ARTIFACT_EXTRAFIELDTYPE_INTEGER, ARTIFACT_EXTRAFIELDTYPE_FORMULA, 
ARTIFACT_EXTRAFIELDTYPE_DATETIME, ARTIFACT_EXTRAFIELDTYPE_USER
-$texts = array( _('Select Box'), _('Check Box'), _('Radio Buttons'), _('Text 
Field'), _('Multi-Select Box'), _('Text Area'), _('Status'), _('Box type 
technician'), _('Relation between artifacts'));
-
-// ARTIFACT_EXTRAFIELDTYPE_ASSIGNEE not used
-unset($vals[7]);
-unset($texts[7]);
-
 if ($ath->usesCustomStatuses()) {
-       unset($vals[ARTIFACT_EXTRAFIELDTYPE_STATUS-1]);
-       unset($texts[ARTIFACT_EXTRAFIELDTYPE_STATUS-1]);
+       unset($eftypes[ARTIFACT_EXTRAFIELDTYPE_STATUS]);
 }
-// re-index
-$vals = array_values($vals);
-$texts = array_values($texts);
+$vals = array_keys($eftypes);
+$texts = array_values($eftypes);
 
-echo html_build_radio_buttons_from_arrays( $vals, $texts, 'field_type', '', 
false, '', false ,'', array('required'=>'required') );
+echo html_build_radio_buttons_from_arrays($vals, $texts, 'field_type', '', 
false, '', false ,'', array('required'=>'required') );
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
 echo _('Text Fields and Text Areas need to have Size/Maxlength and Rows/Cols 
defined, respectively.').html_e('br');
 echo _('Text Field Size/Text Area Rows');
-echo html_e('input', array('type'=>'text', 'name'=>'attribute1', 
'value'=>'20', size=>'2', 'maxlength'=>'2')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'attribute1', 
'value'=>'20', 'size'=>'2', 'maxlength'=>'2')).html_e('br');
 echo _('Text Field Maxlength/Text Area Columns');
-echo html_e('input', array('type'=>'text', 'name'=>'attribute2', 
'value'=>'80', size=>'2', 'maxlength'=>'2')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'attribute2', 
'value'=>'80', 'size'=>'2', 'maxlength'=>'2')).html_e('br');
 echo _('Text Field Pattern');
-echo html_e('input', array('type'=>'text', 'name'=>'pattern', 'value'=>'', 
size=>'80', 'maxlength'=>'255')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'pattern', 'value'=>'', 
'size'=>'80', 'maxlength'=>'255')).html_e('br');
+
 echo _('Hide the default none value');
 echo html_build_checkbox('hide100','',false).html_e('br');
 echo _('Label for the none value');
-echo html_e('input', array('type'=>'text', 'name'=>'show100label', 
'value'=>_('none'), size=>'30')).html_e('br');
+echo html_e('input', array('type'=>'text', 'name'=>'show100label', 
'value'=>_('none'), 'size'=>'30')).html_e('br');
 echo html_ac(html_ap() - 1);
 
 echo html_ao('p');
diff --git a/src/common/tracker/views/form-addextrafieldoption.php 
b/src/common/tracker/views/form-addextrafieldoption.php
index 342f373..6234a56 100644
--- a/src/common/tracker/views/form-addextrafieldoption.php
+++ b/src/common/tracker/views/form-addextrafieldoption.php
@@ -4,6 +4,7 @@
  *
  * Copyright 2010 (c) FusionForge Team
  * Copyright 2014-2015, Franck Villaume - TrivialDev
+ * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -37,79 +38,95 @@ global $HTML;
                $efearr=$ath->getExtraFieldElements($boxid);
                $title = sprintf(_('Add/Update Custom Field Elements in %s'), 
$ath->getName());
                $ath->adminHeader(array('title'=>$title));
-
-               echo '<h2>'._('Custom Field Name')._(': 
').$ac->getName().'</h2>';
-               $rows=count($efearr);
-               if ($rows > 0) {
-                       echo $HTML->openForm(array('action' => 
'/tracker/admin?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid, 
'method' => 'post'));
-                       $title_arr=array();
-                       $title_arr[]=_('Current / New positions');
-                       if ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
-                               $title_arr[] = _('Mapping');
-                       }
-                       $title_arr[]=_('Up/Down positions');
-                       $title_arr[]=_('Elements Defined');
-                       $title_arr[]='';
-
-                       echo $HTML->listTableTop ($title_arr,false, ' ');
-
-                       for ($i=0; $i < $rows; $i++) {
-                               echo '<tr '. $HTML->boxGetAltRowStyle($i) .'>'.
-                                       '<td class="align-right">'.
-                                       ($i + 1).' --&gt; <input type="text" 
name="order['. $efearr[$i]['element_id'] .']" value="" size="3" maxlength="3" 
/>'.
-                                       "</td>\n";
-                               if ($ac->getType() == 
ARTIFACT_EXTRAFIELDTYPE_STATUS) {
-                                       echo '<td>' .
-                                           
$ath->getStatusName($efearr[$i]['status_id']) .
-                                           "</td>\n";
+               echo html_e('h2', array(), _('Custom Field Name')._(': 
').$ac->getName());
+               $efType = $ac->getType();
+               if ($efType != ARTIFACT_EXTRAFIELDTYPE_USER) {
+                       $rows=count($efearr);
+                       if ($rows > 0) {
+                               echo $HTML->openForm(array('action' => 
'/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid, 
'method' => 'post'));
+                               $title_arr=array();
+                               $title_arr[]=_('Current / New positions');
+                               if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+                                       $title_arr[] = _('Mapping');
+                               }
+                               $title_arr[]=_('Up/Down positions');
+                               $title_arr[]=_('Elements Defined');
+                               $title_arr[]='';
+                               echo $HTML->listTableTop ($title_arr,false, ' 
');
+                               for ($i=0; $i < $rows; $i++) {
+                                       $row_attrs = 
array('class'=>$HTML->boxGetAltRowStyle($i,true));
+                                       $cells = array();
+                                       $content = ($i + 1).' 
--&gt;'.html_e('input', array('type'=>'text', 'name'=>'order['. 
$efearr[$i]['element_id'] .']', 'value'=>'', 'size'=>'3', 'maxlength'=>'3'));
+                                       $cells[] = array($content, 
'class'=>'align-right');
+                                       if ($efType == 
ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+                                               $cells[] = 
array($ath->getStatusName($efearr[$i]['status_id']));
+                                       }
+                                       $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')));
+                                       $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')));
+                                       $cells[] = array($content, 
'class'=>'align-center');
+                                       $cells[] = 
array($efearr[$i]['element_name']);
+                                       $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/forum_edit.gif','37','15',array('alt'=>_('Edit'))));
+                                       $cells[] = array($content, 
'class'=>'align-center');
+                                       echo $HTML->multiTableRow($row_attrs, 
$cells);
                                }
-                               echo '<td class="align-center">'.
-                                       
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"))).
-                                       
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"))).
-                                       
'</td>'."\n".'<td>'.$efearr[$i]['element_name'].
-                                       '</td>'."\n".'<td 
class="align-center">'.
-                                       
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/forum_edit.gif','37','15',array('alt'=>_('Edit')))).
-                                       '</td></tr>'."\n";
+                               $row_attrs = array('class'=>'noborder');
+                               $cells = array();
+                               $content = html_e('input', 
array('type'=>'submit', 'name'=>'post_changes_order', 'value'=>_('Reorder')));
+                               $cells[] = array($content, 
'class'=>'align-right');
+                               $cells[] = array('');
+                               if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+                                       $cells[] = array('');
+                               }
+                               $content = html_e('input', 
array('type'=>'submit', 'name'=>'post_changes_alphaorder', 
'value'=>_('Alphabetical order')));
+                               $cells[] = array($content, 
'class'=>'align-left');
+                               echo $HTML->multiTableRow($row_attrs, $cells);
+                               echo $HTML->listTableBottom();
+                               echo $HTML->closeForm();
+                       } else {
+                               echo html_e('strong', array(), _('You have not 
defined any elements.'));
+                       }
+                       echo html_e('br').html_e('br');
+                       echo $HTML->openForm(array('action' => 
'/tracker/admin/?group_id='.$group_id.'&boxid='.$boxid.'&atid='.$ath->getID(), 
'method' => 'post'));
+                       echo html_e('input', array('type'=>'hidden', 
'name'=>'add_opt', 'value'=>'y'));
+                       echo html_e('label', 
array('for'=>'name'),html_e('strong', array(), _('Add New Element')._(':')));
+                       echo html_e('input', array('type'=>'text', 
'id'=>'name', 'name'=>'name', 'value'=>'', 'size'=>'15', 'maxlength'=>'30'));
+                       // Show a pop-up box to choose the possible statuses 
that this element will map to
+                       if ($efType == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+                               echo html_e('strong', array(), _('Status'));
+                               echo $ath->statusBox('status_id',1,false,false);
                        }
-//                     echo $GLOBALS['HTML']->listTableBottom();
-                       ?>
-                       <tr class="noborder">
-                       <td class="align-right">
-                       <input type="submit" name="post_changes_order" 
value="<?php echo _('Reorder') ?>" />
-                       </td>
-                       <td>
-                       </td>
-                       <td class="align-left">
-                       <input type="submit" name="post_changes_alphaorder" 
value="<?php echo _('Alphabetical order') ?>" />
-                       </td>
-                       </tr>
-                       <?php
-                       echo $HTML->listTableBottom();
+                       echo html_e('input', array( 'type'=>'submit', 
'name'=>'post_changes', 'value'=>_('Submit')));
                        echo $HTML->closeForm();
-
                } else {
-                       echo "\n<strong>"._('You have not defined any 
elements.')."</strong>";
+                       // $efType == ARTIFACT_EXTRAFIELDTYPE_USER
+                       $vals = array();
+                       // specific for user select box
+                       echo html_e('p',array(),_('Choose roles used for the 
user select box'));
+                       $g=$ath->getGroup();
+                       $roles = $g->getRoles();
+                       foreach ($roles as $role) {
+                               $vals[$role->getID()]=$role->getName();
+                       }
+                       // end
+                       asort($vals,SORT_FLAG_CASE);
+                       $rows=count($efearr);
+                       // change by:
+                       // $checked_array = array_column($efearr, 
'element_name');
+                       // for php>=5.5.0
+                       $checked_array = array();
+                       for ($i=0; $i < $rows; $i++) {
+                               $checked_array []= $efearr[$i]['element_name'];
+                       }
+
+                       echo $HTML->openForm(array('action' => 
'/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&boxid='.$boxid, 
'method' => 'post'));
+                       echo html_e('input', array('type'=>'hidden', 
'name'=>'update_checked_opt', 'value'=>'y'));
+                       echo html_build_checkboxes_from_array($vals, 'element', 
$checked_array, true);
+                       echo html_e('input', array('type'=>'submit', 
'name'=>'post_changes', 'value'=>_('Submit')));
+                       echo $HTML->closeForm();
                }
-               echo $HTML->openForm(array('action' => 
'/tracker/admin/?group_id='.$group_id.'&boxid='.$boxid.'&atid='.$ath->getID(), 
'method' => 'post'));
-               ?>
-               <input type="hidden" name="add_opt" value="y" />
-               <br /><br />
-               <label for="name">
-                       <strong><?php echo _('Add New Element')._(':'); 
?></strong>
-               </label>
-               <input type="text" id="name" name="name" value="" size="15" 
maxlength="30" />
-               <!--
-               Show a pop-up box to choose the possible statuses that this 
element will map to
-               -->
-               <?php if ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_STATUS) { ?>
-               <strong><?php echo _('Status'); ?></strong>
-               <?php echo $ath->statusBox('status_id',1,false,false); ?>
-               <?php } ?>
-               <input type="submit" name="post_changes" value="<?php echo 
_('Submit') ?>" />
-               <?php
-               echo $HTML->closeForm();
                $ath->footer();
-       }
+
+}
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"
diff --git a/src/www/include/html.php b/src/www/include/html.php
index 10cdbd2..b9f9291 100644
--- a/src/www/include/html.php
+++ b/src/www/include/html.php
@@ -803,6 +803,42 @@ function html_build_checkbox($name, $value, $checked, 
$attrs=array()) {
 }
 
 /**
+ * html_build_checkboxes_from_array() - Render checkbox control
+ *
+ * @param      string  $name           name of control
+ * @param      string  $value          value of control
+ * @param      bool    $checked        true if control should be checked
+ * @param      array   $attrs          Array of other attributes for this 
element
+ * @return     html code for checkbox control
+ */
+function html_build_checkboxes_from_array($vals, $check_name, 
$checked_array=array(), $checkall=false, $attrs=array()) {
+
+       $title = (empty($attrs['title']) ? array() : array('title' => 
$attrs['title']));
+       if ($checkall) {
+               $javascript = '//<![CDATA[
+                                                       
$(window).load(function(){
+                                                               
$("#checkall_'.$check_name.'").change(function () {
+                                                                       
$("input[id^=\''.$check_name.'\']:checkbox").prop(\'checked\', 
$(this).prop("checked"));
+                                                               });
+                                                       });
+                                               //]]';
+               echo html_e('script', array( 'type'=>'text/javascript'), 
$javascript);
+               echo html_ao('p');
+               echo html_e('input', array_merge( array( 'type' => 'checkbox', 
'name' => 'checkall_'.$check_name, 'id' => 'checkall_'.$check_name ), $attrs));
+               echo html_e('label', array_merge( array( 'for' => 
'checkall_'.$check_name), $title), _('Check all'), false);
+               echo html_ac(html_ap() - 1);
+       }
+       echo html_ao('p');
+       foreach ($vals as $key => $value) {
+               $checked = ((in_array($key, $checked_array)) ? 
array('checked'=>'checked') : array());
+               echo html_e('input', array_merge( array( 'type' => 'checkbox', 
'name' => $check_name.'[]', 'id' => $check_name.$key, 'value' => $key), $attrs, 
$checked));
+               echo html_e('label', array_merge( array( 'for' => 
$check_name.$key), $title), $value, false);
+               echo html_e('br');
+       }
+       echo html_ac(html_ap() - 1);
+}
+
+/**
  * build_priority_select_box() - Wrapper for html_build_priority_select_box()
  *
  * @see html_build_priority_select_box()

-----------------------------------------------------------------------

Summary of changes:
 src/common/tracker/ArtifactExtraField.class.php    |   9 +-
 src/common/tracker/actions/admin-updates.php       |  56 ++++++++
 .../tracker/include/ArtifactTypeHtml.class.php     |  49 +++++++
 src/common/tracker/views/form-addextrafield.php    |  58 ++++----
 .../tracker/views/form-addextrafieldoption.php     | 151 ++++++++++++---------
 src/www/include/html.php                           |  36 +++++
 6 files changed, 263 insertions(+), 96 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to