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  0c6137117ea00002c5a97a414dbb1f8b28594d40 (commit)
      from  87c9c37ef651562da35af368a795f441ddd3da09 (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=0c6137117ea00002c5a97a414dbb1f8b28594d40

commit 0c6137117ea00002c5a97a414dbb1f8b28594d40
Author: Franck Villaume <[email protected]>
Date:   Sat Apr 29 18:42:37 2017 +0200

    forge cli: docgroupImport support multiple sub docgroups injection

diff --git a/src/bin/forge b/src/bin/forge
index 6f0acd3..fe8bdbb 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -498,14 +498,26 @@ class CliActions {
                if ($group && is_object($group) && !$group->isError() && 
$group->usesDocman()) {
                        db_begin();
                        $dg = new DocumentGroup($group);
-                       $parent_doc_group = 
$this->getMappingId($stream['data_array']['parent_doc_group'], 'doc_group');
+                       $parent_doc_group = 
(int)$this->getMappingId($stream['data_array']['parent_doc_group'], 
'doc_group');
                        if (!$dg->create($stream['data_array']['groupname'], 
$parent_doc_group, $stream['data_array']['stateid'], 
$stream['data_array']['createdate'])) {
                                echo $dg->getErrorMessage()."\n";
                                db_rollback();
                                return false;
                        }
-                       db_commit();
                        
$importRefMapping['doc_group'][$stream['data_array']['doc_group']] = 
$dg->getID();
+                       if (isset($stream['subdocgroups']) && 
is_array($stream['subdocgroups'])) {
+                               foreach ($stream['subdocgroups'] as 
$subdocgroup) {
+                                       $filename = 
'docgroupDump-'.$subdocgroup['data_array']['doc_group'].'.'.$format;
+                                       $this->createSubfile($filename, 
$subdocgroup, $format);
+                                       if (!$this->docgroupImport($filename, 
$format)) {
+                                               echo _('Unable to inject child 
docgroup')."\n";
+                                               db_rollback();
+                                               return false;
+                                       }
+                                       @unlink($filename);
+                               }
+                       }
+                       db_commit();
                        echo _('Document Group injected')."\n";
                        return true;
                } else {
@@ -637,6 +649,7 @@ class CliActions {
        }
 
        function getMappingId($idtofind, $objecttofind) {
+               global $importRefMapping;
                if (isset($importRefMapping[$objecttofind][$idtofind])) {
                        return $importRefMapping[$objecttofind][$idtofind];
                } else {
@@ -644,6 +657,15 @@ class CliActions {
                        return $idtofind;
                }
        }
+
+       function createSubfile($filename, $data, $format) {
+               if ($format == 'json') {
+                       $stream = json_encode($data, JSON_PRETTY_PRINT);
+               } else {
+                       $stream = $data;
+               }
+               file_put_contents($filename, $stream);
+       }
 }
 
 session_set_admin();

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

Summary of changes:
 src/bin/forge | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 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