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  c94004b0dd15c825a18c81b4691a7047aae95123 (commit)
      from  2acd58ca729368012f2dd051e298237a95250ccd (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=c94004b0dd15c825a18c81b4691a7047aae95123

commit c94004b0dd15c825a18c81b4691a7047aae95123
Author: Franck Villaume <franck.villa...@trivialdev.com>
Date:   Sun Sep 18 18:14:40 2016 +0200

    template project: clone tracker, support workflow

diff --git a/src/common/include/Group.class.php 
b/src/common/include/Group.class.php
index b9b9a27..d858827 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -2676,7 +2676,7 @@ class Group extends FFError {
                                        foreach ($oldatf->getArtifactTypes() as 
$o) {
                                                $t = 
artifactType_get_object($id_mappings['tracker'][$o->getID()]);
                                                
$id_mappings['tracker'][$o->getID()] = $t->getID();
-                                               
$t->cloneFieldsFrom($o->getID(), $o->Group->getID());
+                                               
$t->cloneFieldsFrom($o->getID(), $o->Group->getID(), $id_mappings);
                                        }
                                }
                        }
diff --git a/src/common/tracker/ArtifactType.class.php 
b/src/common/tracker/ArtifactType.class.php
index 4069a65..b8be8db 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -655,9 +655,10 @@ class ArtifactType extends FFError {
         *
         * @param       int     $clone_tracker_id       id of the cloned tracker
         * @param       int     $group_id               id of the project 
template to use.
+        * @param       array   $id_mappings            array mapping between 
template objects and new project objects
         * @return      boolean true/false on success
         */
-       function cloneFieldsFrom($clone_tracker_id, $group_id = null) {
+       function cloneFieldsFrom($clone_tracker_id, $group_id = null, 
$id_mappings = array()) {
                if ($group_id) {
                        $g = group_get_object($group_id);
                } else {
@@ -733,9 +734,9 @@ class ArtifactType extends FFError {
                        }
                }
 
-               foreach ($newEFIds as $oldEFId=>$newEFId) {
+               foreach ($newEFIds as $oldEFId => $newEFId) {
                        $oef = new ArtifactExtraField($at, $oldEFId);
-                       $nef = new ArtifactExtraField($this,$newEFId);
+                       $nef = new ArtifactExtraField($this, $newEFId);
                        // update Dependency between extrafield
                        if ($oef->getParent() != 100) {
                                if (!$nef->update($nef->getName(), 
$nef->getAttribute1(), $nef->getAttribute2(), $nef->isRequired(), 
$nef->getAlias(), $nef->getShow100(), $nef->getShow100label(), 
$nef->getDescription(), $nef->getPattern(), $newEFIds[$oef->getParent()], 
$nef->isAutoAssign(), $nef->is_hidden_on_submit(), $nef->is_disabled())) {
@@ -744,7 +745,7 @@ class ArtifactType extends FFError {
                                        return false;
                                }
 
-                               foreach ($newEFElIds[$oldEFId] as 
$oldEFElId=>$newEFElId) {
+                               foreach ($newEFElIds[$oldEFId] as $oldEFElId => 
$newEFElId) {
                                        $oel = new 
ArtifactExtraFieldElement($oef,$oldEFElId);
                                        if ($oel->isError()) {
                                                db_rollback();
@@ -782,13 +783,35 @@ class ArtifactType extends FFError {
                                        $naivs[] = $newEFElIds[$oldEFId][$oaiv];
                                }
                                $natw->saveNextNodes('100', $naivs);
-                               //TODO implement the rest of the workflow...
+
+                               //implement role based of the workflow
+                               if (sizeof($id_mappings) && 
isset($id_mappings['role'])) {
+                                       $oefelements = 
$at->getExtraFieldElements($oldEFId);
+                                       foreach ($oefelements as $oefelement) {
+                                               // retrieve the allowed values 
for the old element
+                                               $onexts = 
$oatw->getNextNodes($oefelement['element_id']);
+                                               $naivs = array();
+                                               foreach ($onexts as $onext) {
+                                                       $naivs[] = 
$newEFElIds[$oldEFId][$onext];
+                                                       //retrieve the allowed 
old roles from old element to old next value
+                                                       $oars = 
$oatw->getAllowedRoles($oefelement['element_id'], $onext);
+                                                       //map old roles into 
new roles id
+                                                       $nar = array();
+                                                       foreach ($oars as $oar) 
{
+                                                               if 
(array_key_exists($oar, $id_mappings['role'])) {
+                                                                       $nar[] 
= $id_mappings['role'][$oar];
+                                                               }
+                                                       }
+                                                       
$natw->saveAllowedRoles($newEFElIds[$oldEFId][$oefelement['element_id']], 
$newEFElIds[$oldEFId][$onext], $nar);
+                                               }
+                                               
$natw->saveNextNodes($newEFElIds[$oldEFId][$oefelement['element_id']], $naivs);
+                                       }
+                               }
                        }
                }
 
                db_commit();
                return true;
-
        }
 
        /**
diff --git a/src/common/tracker/ArtifactWorkflow.class.php 
b/src/common/tracker/ArtifactWorkflow.class.php
index d4fced5..0a26d3f 100644
--- a/src/common/tracker/ArtifactWorkflow.class.php
+++ b/src/common/tracker/ArtifactWorkflow.class.php
@@ -102,6 +102,8 @@ class ArtifactWorkflow extends FFError {
         * When a new element is created, add all the new events in the 
workflow.
         */
        function addNode($element_id) {
+               // reset the cache!
+               $this->ath->fetchData($this->ath->getID());
                $elearray = $this->ath->getExtraFieldElements($this->field_id);
                foreach ($elearray as $e) {
                        if ($element_id !== $e['element_id']) {

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

Summary of changes:
 src/common/include/Group.class.php            |  2 +-
 src/common/tracker/ArtifactType.class.php     | 35 ++++++++++++++++++++++-----
 src/common/tracker/ArtifactWorkflow.class.php |  2 ++
 3 files changed, 32 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
Fusionforge-commits@lists.fusionforge.org
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to