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  543584ac05623b5596abe92f54575137874ffc54 (commit)
      from  07d8ae3124da92f8d3735e7ca37a377f413dd3d0 (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=543584ac05623b5596abe92f54575137874ffc54

commit 543584ac05623b5596abe92f54575137874ffc54
Author: Franck Villaume <[email protected]>
Date:   Tue Nov 22 10:30:20 2016 +0100

    rewrite setAsDefault

diff --git a/src/common/tracker/ArtifactExtraFieldElement.class.php 
b/src/common/tracker/ArtifactExtraFieldElement.class.php
index 9334244..2a5e8aa 100644
--- a/src/common/tracker/ArtifactExtraFieldElement.class.php
+++ b/src/common/tracker/ArtifactExtraFieldElement.class.php
@@ -307,35 +307,45 @@ class ArtifactExtraFieldElement extends FFError {
         * @return      boolean
         */
        function setAsDefault($is_default) {
-               if ($this->isDefault() && !$is_default) {
-                       $result = db_query_params ('DELETE FROM 
artifact_extra_field_default WHERE extra_field_id = $1 AND default_value = $2',
-                                       array 
($this->ArtifactExtraField->getID(), $this->getID()));
-                       if (!$result) {
-                               $this->setError(db_error());
-                               return false;
-                       }
-                       return true;
-               } elseif (!$this->isDefault() && $is_default) {
-                       if (in_array($this->ArtifactExtraField->getType(), 
unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_SINGLECHOICE))) {
-                               $result = db_query_params ('DELETE FROM 
artifact_extra_field_default WHERE extra_field_id = $1',
-                                               array 
($this->ArtifactExtraField->getID()));
+               if ($is_default) {
+                       if ($this->isDefault()) {
+                               //nothing to do
+                               return true;
+                       } else {
+                               // inject it!
+                               if 
(in_array($this->ArtifactExtraField->getType(), 
unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_SINGLECHOICE))) {
+                                       $result = db_query_params ('DELETE FROM 
artifact_extra_field_default WHERE extra_field_id = $1',
+                                                               array 
($this->ArtifactExtraField->getID()));
+                                       if (!$result) {
+                                               $this->setError(db_error());
+                                               $return = false;
+                                       }
+                               }
+                               $result = db_query_params ('INSERT INTO 
artifact_extra_field_default (extra_field_id, default_value) VALUES ($1,$2)',
+                                                               array 
($this->ArtifactExtraField->getID(), $this->getID()));
                                if (!$result) {
                                        $this->setError(db_error());
-                                       $return = false;
+                                       return false;
                                }
+                               return true;
                        }
-                       $result = db_query_params ('INSERT INTO 
artifact_extra_field_default (extra_field_id, default_value) VALUES ($1,$2)',
-                                       array 
($this->ArtifactExtraField->getID(), $this->getID()));
-                       if (!$result) {
-                               $this->setError(db_error());
-                               return false;
+               } else {
+                       if ($this->isDefault()) {
+                               // remove it!
+                               $result = db_query_params ('DELETE FROM 
artifact_extra_field_default WHERE extra_field_id = $1 AND default_value = $2',
+                                                       array 
($this->ArtifactExtraField->getID(), $this->getID()));
+                               if (!$result) {
+                                       $this->setError(db_error());
+                                       return false;
+                               }
+                               return true;
+                       } else {
+                               //nothing to do
+                               return true;
                        }
-                       return true;
                }
-               return false;
        }
 
-
        /**
         * getChildrenElements - return the array of the elements of children 
fields who depend on current element
         *

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

Summary of changes:
 .../tracker/ArtifactExtraFieldElement.class.php    | 52 +++++++++++++---------
 1 file changed, 31 insertions(+), 21 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