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  90991ce2bd76e739eb89891010bd80464a4c1b2c (commit)
       via  1b7cc8b9406ba8d57ab3189f3d77acffe991350d (commit)
      from  3ba51bd72e7a81069f88811a95a59bb0e61cdcc2 (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=90991ce2bd76e739eb89891010bd80464a4c1b2c

commit 90991ce2bd76e739eb89891010bd80464a4c1b2c
Author: Stéphane-Eymeric Bredthauer <[email protected]>
Date:   Mon May 23 22:40:19 2016 +0200

    Tracker: Add pattern (regex) to custom text fields

diff --git a/src/common/tracker/Artifact.class.php 
b/src/common/tracker/Artifact.class.php
index a489b0a..c8e13c4 100644
--- a/src/common/tracker/Artifact.class.php
+++ b/src/common/tracker/Artifact.class.php
@@ -1340,6 +1340,12 @@ class Artifact extends FFError {
                                        }
                                }
                        }
+
+                       // check pattern for text fields
+                       if ($type == ARTIFACT_EXTRAFIELDTYPE_TEXT && 
!empty($ef[$efid]['pattern']) && !empty($extra_fields[$efid]) && 
!preg_match('/'.$ef[$efid]['pattern'].'/', $extra_fields[$efid])) {
+                               $this->setError(sprintf(_("Field %s doesn't 
match the pattern."), $ef[$efid]['field_name']));
+                               return false;
+                       }
 //
 //     Force each field to have some value if it is a numeric field
 //     text fields will just be purged and skipped
diff --git a/src/common/tracker/ArtifactExtraField.class.php 
b/src/common/tracker/ArtifactExtraField.class.php
index 3a44197..0fe768c 100644
--- a/src/common/tracker/ArtifactExtraField.class.php
+++ b/src/common/tracker/ArtifactExtraField.class.php
@@ -93,17 +93,19 @@ class ArtifactExtraField extends FFError {
         * a tracker.  This function is only used to create rows for boxes
         * configured by the admin.
         *
-        * @param       string  $name           Name of the extra field.
-        * @param       int     $field_type     The type of field - radio, 
select, text, textarea
-        * @param       int     $attribute1     For text (size) and textarea 
(rows)
-        * @param       int     $attribute2     For text (maxlength) and 
textarea (cols)
-        * @param       int     $is_required    True or false whether this is a 
required field or not.
-        * @param       string  $alias          Alias for this extra field 
(optional)
-        * @param       int     $show100        True or false whether the 100 
value is displayed or not
+        * @param       string  $name                   Name of the extra field.
+        * @param       int             $field_type             The type of 
field - radio, select, text, textarea
+        * @param       int             $attribute1             For text (size) 
and textarea (rows)
+        * @param       int             $attribute2             For text 
(maxlength) and textarea (cols)
+        * @param       int             $is_required    True or false whether 
this is a required field or not.
+        * @param       string  $alias                  Alias for this extra 
field (optional)
+        * @param       int             $show100                True or false 
whether the 100 value is displayed or not
         * @param       string  $show100label   The label used for the 100 
value if displayed
+        * @param       string  $description    Description used for help text.
+        * @param       string  $pattern                A regular expression to 
check the field.
         * @return      bool    true on success / false on failure.
         */
-       function create($name, $field_type, $attribute1, $attribute2, 
$is_required = 0, $alias = '', $show100 = true, $show100label = 'none', 
$description = '') {
+       function create($name, $field_type, $attribute1, $attribute2, 
$is_required = 0, $alias = '', $show100 = true, $show100label = 'none', 
$description = '', $pattern='') {
                //
                //      data validation
                //
@@ -156,8 +158,8 @@ class ArtifactExtraField extends FFError {
                }
 
                db_begin();
-               $result = db_query_params ('INSERT INTO 
artifact_extra_field_list (group_artifact_id, field_name, field_type, 
attribute1, attribute2, is_required, alias, show100, show100label, description)
-                       VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)',
+               $result = db_query_params ('INSERT INTO 
artifact_extra_field_list (group_artifact_id, field_name, field_type, 
attribute1, attribute2, is_required, alias, show100, show100label, description, 
pattern)
+                       VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)',
                                           array ($this->ArtifactType->getID(),
                                                          
htmlspecialchars($name),
                                                          $field_type,
@@ -167,7 +169,8 @@ class ArtifactExtraField extends FFError {
                                                          $alias,
                                                          $show100,
                                                          $show100label,
-                                                         $description));
+                                                         $description,
+                                                         $pattern));
 
                if ($result && db_affected_rows($result) > 0) {
                        $this->clearError();
@@ -304,6 +307,15 @@ class ArtifactExtraField extends FFError {
        }
 
        /**
+        * getPattern - get the pattern for text field.
+        *
+        * @return      string  The pattern.
+        */
+       function getPattern() {
+               return $this->data_array['pattern'];
+       }
+
+       /**
         * getShow100 - get the show100 field.
         *
         * @return      int     The show100 attribute.
@@ -406,7 +418,7 @@ class ArtifactExtraField extends FFError {
         * @param       string  $show100label   The label used for the 100 
value if displayed
         * @return      bool    success.
         */
-       function update($name, $attribute1, $attribute2, $is_required = 0, 
$alias = "", $show100 = true, $show100label = 'none', $description = '') {
+       function update($name, $attribute1, $attribute2, $is_required = 0, 
$alias = "", $show100 = true, $show100label = 'none', $description = '', 
$pattern='') {
                if (!forge_check_perm ('tracker_admin', 
$this->ArtifactType->Group->getID())) {
                        $this->setPermissionDeniedError();
                        return false;
@@ -445,9 +457,10 @@ class ArtifactExtraField extends FFError {
                        is_required = $5,
                        alias = $6,
                        show100 = $7,
-                       show100label = $8
-                       WHERE extra_field_id = $9
-                       AND group_artifact_id = $10',
+                       show100label = $8,
+                       pattern = $9,
+                       WHERE extra_field_id = $10
+                       AND group_artifact_id = $11',
                                           array (htmlspecialchars($name),
                                                          $description,
                                                          $attribute1,
@@ -456,6 +469,7 @@ class ArtifactExtraField extends FFError {
                                                          $alias,
                                                          $show100,
                                                          $show100label,
+                                                         $pattern,
                                                          $this->getID(),
                                                          
$this->ArtifactType->getID())) ;
                if ($result && db_affected_rows($result) > 0) {
diff --git a/src/common/tracker/ArtifactType.class.php 
b/src/common/tracker/ArtifactType.class.php
index 2069db2..7fbbadb 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -659,7 +659,7 @@ class ArtifactType extends FFError {
                                        $current_ef_todelete->delete(true,true);
                                }
                        }
-                       if 
(!$nef->create(util_unconvert_htmlspecialchars($ef['field_name']), 
$ef['field_type'], $ef['attribute1'], $ef['attribute2'], $ef['is_required'], 
$ef['alias'], $ef['description'])) {
+                       if 
(!$nef->create(util_unconvert_htmlspecialchars($ef['field_name']), 
$ef['field_type'], $ef['attribute1'], $ef['attribute2'], $ef['is_required'], 
$ef['alias'], $ef['description'], $ef['pattern'])) {
                                $this->setError('Error Creating New Extra 
Field: '.$nef->getErrorMessage());
                                db_rollback();
                                return false;
diff --git a/src/common/tracker/actions/admin-updates.php 
b/src/common/tracker/actions/admin-updates.php
index cd65668..94d5fcc 100644
--- a/src/common/tracker/actions/admin-updates.php
+++ b/src/common/tracker/actions/admin-updates.php
@@ -39,6 +39,7 @@ if (getStringFromRequest('add_extrafield')) {
        $field_type = getStringFromRequest('field_type');
        $attribute1 = getStringFromRequest('attribute1');
        $attribute2 = getStringFromRequest('attribute2');
+       $pattern = getStringFromRequest('pattern');
        $is_required = getStringFromRequest('is_required');
        $alias = getStringFromRequest('alias');
        $hide100 = getStringFromRequest('hide100');
@@ -56,7 +57,7 @@ if (getStringFromRequest('add_extrafield')) {
                } else {
                        $show100 = 1;
                }
-               if (!$ab->create($name, $field_type, $attribute1, $attribute2, 
$is_required, $alias, $show100, $show100label, $description)) {
+               if (!$ab->create($name, $field_type, $attribute1, $attribute2, 
$is_required, $alias, $show100, $show100label, $description, $pattern)) {
                        $error_msg .= _('Error inserting a custom field')._(': 
').$ab->getErrorMessage();
                        $ab->clearError();
                } else {
@@ -232,6 +233,7 @@ if (getStringFromRequest('add_extrafield')) {
        $description = getStringFromRequest('description');
        $attribute1 = getStringFromRequest('attribute1');
        $attribute2 = getStringFromRequest('attribute2');
+       $pattern = getStringFromRequest('pattern');
        $is_required = getStringFromRequest('is_required');
        $alias = getStringFromRequest('alias');
        $hide100 = getStringFromRequest('hide100');
@@ -248,7 +250,7 @@ if (getStringFromRequest('add_extrafield')) {
                } else {
                        $show100 = 1;
                }
-               if (!$ac->update($name, $attribute1, $attribute2, $is_required, 
$alias, $show100, $show100label, $description)) {
+               if (!$ac->update($name, $attribute1, $attribute2, $is_required, 
$alias, $show100, $show100label, $description, $pattern)) {
                        $error_msg .= _('Update failed')._(': 
').$ac->getErrorMessage();
                        $ac->clearError();
                } else {
diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php 
b/src/common/tracker/include/ArtifactTypeHtml.class.php
index 0d3bd1a..8ed1e23 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -265,6 +265,9 @@ class ArtifactTypeHtml extends ArtifactType {
                        } elseif ($efarr[$i]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_TEXT ||
                                        $efarr[$i]['field_type'] == 
ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
 
+                               if (!empty($efarr[$i]['pattern'])) {
+                                       $attrs['pattern'] = 
$efarr[$i]['pattern'];
+                               }
                                $str = 
$this->renderTextField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'],
 $attrs);
                                if ($mode == 'QUERY') {
                                        $post_name =  ' <i>'._('(%% for 
wildcards)').'</i>&nbsp;&nbsp;&nbsp;';
@@ -675,7 +678,7 @@ class ArtifactTypeHtml extends ArtifactType {
         * @return      string  HTML code of corresponding input tag.
         */
        function renderTextField ($extra_field_id, $contents, $size, 
$maxlength, $attrs = array()) {
-               return html_e('input', array_merge(array( 'type'=>'text', 
'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$contents, 'size'=>$size, 
'maxlength'=>$maxlength)));
+               return html_e('input', array_merge(array('type'=>'text', 
'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$contents, 'size'=>$size, 
'maxlength'=>$maxlength), $attrs));
        }
 
        /**()
diff --git a/src/common/tracker/views/form-addextrafield.php 
b/src/common/tracker/views/form-addextrafield.php
index 1d97446..657b9d8 100644
--- a/src/common/tracker/views/form-addextrafield.php
+++ b/src/common/tracker/views/form-addextrafield.php
@@ -143,12 +143,19 @@ 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 _('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 _('Text Field Pattern');
+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_ac(html_ap() - 1);
 
+echo html_ao('p');
+echo html_build_checkbox('is_required','',false);
+echo html_e('label', array('for'=>'is_required'), _('Field is mandatory'));
+echo html_ac(html_ap() - 1);
+
 echo $HTML->warning_msg(_('Warning: this add new custom field'));
 
 echo html_ao('p');
diff --git a/src/common/tracker/views/form-updateextrafield.php 
b/src/common/tracker/views/form-updateextrafield.php
index 2fea886..b9afa9f 100644
--- a/src/common/tracker/views/form-updateextrafield.php
+++ b/src/common/tracker/views/form-updateextrafield.php
@@ -73,6 +73,12 @@ if (!$ac || !is_object($ac)) {
                echo html_ao('p');
                echo html_e('label', array('for'=>'attribute2'), html_e('b', 
array(), _('Text Field Maxlength')).html_e('br'));
                echo html_e('input', array('type'=>'text', 'id'=>'attribute2', 
'name'=>'attribute2', 'value'=>$ac->getAttribute2(), size=>'2', 
'maxlength'=>'2'));
+               if ($ac->getType() == ARTIFACT_EXTRAFIELDTYPE_TEXT) {
+                       echo html_ac(html_ap() - 1);
+                       echo html_ao('p');
+                       echo html_e('label', array('for'=>'pattern'), 
html_e('b', array(), _('Text Field Pattern')).html_e('br'));
+                       echo html_e('input', array('type'=>'text', 
'id'=>'pattern', 'name'=>'pattern', 'value'=>$ac->getPattern(), size=>'80', 
'maxlength'=>'255'));
+               }
        } else {
                echo html_e('input', array('type'=>'hidden', 
'name'=>'attribute1', 'value'=>'0'));
                echo html_e('input', array('type'=>'hidden', 
'name'=>'attribute2', 'value'=>'0'));
diff --git a/src/db/20160522-artifact_extra_field_list-pattern.sql 
b/src/db/20160522-artifact_extra_field_list-pattern.sql
new file mode 100644
index 0000000..871b43a
--- /dev/null
+++ b/src/db/20160522-artifact_extra_field_list-pattern.sql
@@ -0,0 +1,2 @@
+ALTER TABLE artifact_extra_field_list
+   ADD COLUMN pattern text NOT NULL DEFAULT '';
\ No newline at end of file

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

commit 1b7cc8b9406ba8d57ab3189f3d77acffe991350d
Author: Stéphane-Eymeric Bredthauer <[email protected]>
Date:   Mon May 23 16:34:13 2016 +0200

    Tracker: Add description (help text) for custom fields, fix renderTextArea

diff --git a/src/common/tracker/include/ArtifactTypeHtml.class.php 
b/src/common/tracker/include/ArtifactTypeHtml.class.php
index aea1696..0d3bd1a 100644
--- a/src/common/tracker/include/ArtifactTypeHtml.class.php
+++ b/src/common/tracker/include/ArtifactTypeHtml.class.php
@@ -713,7 +713,7 @@ class ArtifactTypeHtml extends ArtifactType {
         * @return      string  text area and data.
         */
        function renderTextArea ($extra_field_id,$contents,$rows,$cols, $attrs 
= array()) {
-               return html_e('textarea', 
array_merge(array('name'=>'extra_fields['.$extra_field_id.']', 'rows'=>$rows, 
'cols'=>$cols), $attrs), $contents);
+               return html_e('textarea', 
array_merge(array('name'=>'extra_fields['.$extra_field_id.']', 'rows'=>$rows, 
'cols'=>$cols), $attrs), $contents, false);
        }
 
        function technicianBox 
($name='assigned_to[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false)
 {

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

Summary of changes:
 src/common/tracker/Artifact.class.php              |  6 +++
 src/common/tracker/ArtifactExtraField.class.php    | 44 ++++++++++++++--------
 src/common/tracker/ArtifactType.class.php          |  2 +-
 src/common/tracker/actions/admin-updates.php       |  6 ++-
 .../tracker/include/ArtifactTypeHtml.class.php     |  7 +++-
 src/common/tracker/views/form-addextrafield.php    |  7 ++++
 src/common/tracker/views/form-updateextrafield.php |  6 +++
 .../20160522-artifact_extra_field_list-pattern.sql |  2 +
 8 files changed, 60 insertions(+), 20 deletions(-)
 create mode 100644 src/db/20160522-artifact_extra_field_list-pattern.sql


hooks/post-receive
-- 
FusionForge

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

Reply via email to