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 c8b1277f682a12046105074ee53ae2d1b76978ab (commit)
via 331300f9a49719aceaa26eb14627a4a032ba388e (commit)
from d015868f813f5624b6e8a5a8ab06ebada30ba1f6 (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=c8b1277f682a12046105074ee53ae2d1b76978ab
commit c8b1277f682a12046105074ee53ae2d1b76978ab
Author: Franck Villaume <[email protected]>
Date: Sun Feb 26 13:16:09 2017 +0100
forge cli: support docmanDump to export complete settings & tree of the
docman tool of a dedicated group
diff --git a/src/bin/forge b/src/bin/forge
index 867825b..699d7c0 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -25,6 +25,7 @@
require (dirname(__FILE__).'/../common/include/env.inc.php');
require_once $gfcommon.'include/pre.php';
+require_once $gfcommon.'tracker/ArtifactFactory.class.php';
class CliActions {
function help($method = null) {
@@ -43,16 +44,14 @@ class CliActions {
echo "to deactivate the <pluginName> plugin\n";
break;
case 'trackerDump':
- echo "Use: .../forge trackerDump <atid>
[setup|artifacts|both] [json|raw]\n";
+ echo "Use: .../forge trackerDump <atid>
[setup|artifacts] [json|raw]\n";
echo "to dump a tracker from a specific
project.\n";
echo "the following functions are available:\n";
echo " - setup: (default option)\n";
echo " use it to dump the full configuration
of the tracker\n";
echo " - artifacts:\n";
echo " use it to dump all the artifacts of
the tracker\n";
- echo " - both:\n";
- echo " use it to dump the full configuration
of the tracker and the artifacts\n";
-// echo " - full:\n";
+// echo " - all:\n";
// echo " use it to dump the full configuration
of the tracker and the artifacts + any attachements if any\n";
echo "the following output formats are
available:\n";
echo " - json:\n";
@@ -60,6 +59,22 @@ class CliActions {
echo " - raw: (default)\n";
echo " standard PHP array print_r format\n";
break;
+ case 'docmanDump':
+ echo "Use: .../forge trackerDump <groupid>
[setup|tree|all] [json|raw]\n";
+ echo "to dump docman from a specific
project.\n";
+ echo "the following functions are available:\n";
+ echo " - setup: (default option)\n";
+ echo " use it to dump the full configuration
of the document management tool\n";
+ echo " - tree:\n";
+ echo " use it to dump the complete tree of
the document management tool\n";
+ echo " - all:\n";
+ echo " use it to dump the full configuration
and the tree\n";
+ echo "the following output formats are
available:\n";
+ echo " - json:\n";
+ echo " pretty json formated string output\n";
+ echo " - raw: (default)\n";
+ echo " standard PHP array print_r format\n";
+ break;
default:
echo "Usage: .../forge ($methods)
[arguments...]\n" ;
echo "Get more info use: .../forge help help\n";
@@ -85,12 +100,9 @@ class CliActions {
$trackerDump = array();
if ($at && is_object($at) && !$at->isError()) {
switch ($params[0]) {
- case 'full':
- //TODO: how to identify files to
retrieve and generate a zip file?
- case 'both':
+ case 'all':
$trackerDump['setup'] =
$at->getSettings();
case 'artifacts':
- require_once
$gfcommon.'tracker/ArtifactFactory.class.php';
$af = new ArtifactFactory($at);
if ($af && is_object($af) &&
!$at->isError()) {
$af->setup(0, '', '', 0,
'overwrite', false, false, array(), false);
@@ -124,17 +136,66 @@ class CliActions {
} else {
$format = 'raw';
}
+ $this->print_result($trackerDump, $format);
+ }
+
+ function docmanDump($group_id, $params = array('setup', 'json')) {
+ $group = group_get_object($group_id);
+ if ($group && is_object($group) && !$group->isError()) {
+ if ($group->usesDocman()) {
+ $dm = new DocumentManager($group);
+ $docmanDump = array();
+ if ($dm && is_object($dm) && !$dm->isError()) {
+ switch ($params[0]) {
+ case 'all':
+ $docmanDump['setup'] =
$dm->getSettings();
+ case 'tree':
+ $tree = $dm->getTree();
+ $docmanDump['tree'] =
$tree;
+ break;
+ case 'setup':
+ $docmanDump['setup'] =
$dm->getSettings();
+ break;
+ default:
+ $docmanDump['error'][]
= _('Unknown function');
+ break;
+ }
+ } else {
+ $docmanDump['error'][] = _('Unable to
get document manager for group id')._(': ').$group_id;
+ }
+ } else {
+ $docmanDump['error'][] = _('Document manager
not enabled for group id')._(': ').$group_id;
+ }
+ } else {
+ $docmanDump['error'][] = _('Unable to get group
id')._(': ').$group_id;
+ }
+ if (isset($params[1])) {
+ if (in_array($params[1], array('json', 'raw'))) {
+ $format = $params[1];
+ } else {
+ $docmanDump['error'][] = _('Unknown format.
Fallback to raw');
+ }
+ } else {
+ $format = 'raw';
+ }
+ $this->print_result($docmanDump, $format);
+ }
+
+ function print_result($arrayDump, $format) {
+
switch ($format) {
case 'json':
- echo json_encode($trackerDump,
JSON_PRETTY_PRINT)."\n";
+ echo json_encode($arrayDump,
JSON_PRETTY_PRINT)."\n";
break;
case 'raw':
default:
- print_r($trackerDump);
+ print_r($arrayDump);
}
}
}
+session_set_admin();
+
if (count($argv) >= 3) {
$action = $argv[1];
$name = $argv[2];
diff --git a/src/common/docman/DocumentFactory.class.php
b/src/common/docman/DocumentFactory.class.php
index 2ec130d..1ef3326 100644
--- a/src/common/docman/DocumentFactory.class.php
+++ b/src/common/docman/DocumentFactory.class.php
@@ -7,7 +7,7 @@
* Copyright 2009, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2016, Franck Villaume - TrivialDev
+ * Copyright 2012-2017, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -28,6 +28,7 @@
require_once $gfcommon.'include/FFError.class.php';
require_once $gfcommon.'docman/Document.class.php';
+require_once $gfcommon.'docman/DocumentVersionFactory.class.php';
class DocumentFactory extends FFError {
@@ -335,6 +336,21 @@ class DocumentFactory extends FFError {
return $return;
}
+ function getDocumentsWithVersions() {
+ $return = null;
+ $docs = $this->getDocuments(1);
+ if (is_array($docs)) {
+ foreach ($docs as $doc) {
+ $dvf = new DocumentVersionFactory($doc);
+ $docArr = array();
+ $docArr['docid'] = $doc->getID();
+ $docArr['versions'] = $dvf->getVersions();
+ $return[] = $docArr;
+ }
+ }
+ return $return;
+ }
+
private function ValidDocumentGroups() {
$this->validdocumentgroups = array();
// recursive query to find if documentgroups are visible thru
the tree of documentgroups
diff --git a/src/common/docman/DocumentGroup.class.php
b/src/common/docman/DocumentGroup.class.php
index e5a07d4..86d2c4c 100644
--- a/src/common/docman/DocumentGroup.class.php
+++ b/src/common/docman/DocumentGroup.class.php
@@ -7,7 +7,7 @@
* Copyright 2009, Roland Mas
* Copyright 2010, Franck Villaume - Capgemini
* Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2016, Franck Villaume - TrivialDev
+ * Copyright 2012-2017, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
diff --git a/src/common/docman/DocumentManager.class.php
b/src/common/docman/DocumentManager.class.php
index 307ad78..cdbe394 100644
--- a/src/common/docman/DocumentManager.class.php
+++ b/src/common/docman/DocumentManager.class.php
@@ -2,7 +2,7 @@
/**
* FusionForge Documentation Manager
*
- * Copyright 2011-2014,2016, Franck Villaume - TrivialDev
+ * Copyright 2011-2014,2016-2017, Franck Villaume - TrivialDev
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
* Copyright 2013, French Ministry of National Education
* http://fusionforge.org
@@ -249,6 +249,45 @@ class DocumentManager extends FFError {
}
/**
+ * getTree - retrieve the tree structure into an organized array
+ *
+ * @param int $docGroupId the doc_group to start: default 0
+ */
+ function getTree($docGroupId = 0) {
+ $dg = new DocumentGroup($this->Group);
+ $stateid = array(1, 2, 3, 4, 5);
+ $tree = $dg->getSubgroup($docGroupId, $stateid);
+ if (sizeof($tree)) {
+ foreach ($tree as $key => $value) {
+ $tree[$key] =
(array)documentgroup_get_object($value, $this->Group->getID());
+ unset($tree[$key]['Group']);
+ $tree[$key]['subdocgroups'] =
$this->getTree($value);
+ $df = new DocumentFactory($this->Group);
+ $df->setDocGroupID($value);
+ $df->setStateID($stateid);
+ $df->setOrder(array('docid'));
+ $tree[$key]['files'] =
(array)$df->getDocumentsWithVersions();
+ }
+ }
+ return $tree;
+ }
+
+ /**
+ * getSettings - return the configuration flags of the docman
+ *
+ */
+ function getSettings() {
+ $settingsArr = array();
+ $settingsArr['new_doc_address'] =
$this->Group->data_array['new_doc_address'];
+ $settingsArr['send_all_docs'] =
$this->Group->data_array['send_all_docs'];
+ $settingsArr['use_docman_search'] =
$this->Group->data_array['use_docman_search'];
+ $settingsArr['force_docman_reindex'] =
$this->Group->data_array['force_docman_reindex'];
+ $settingsArr['use_webdav'] =
$this->Group->data_array['use_webdav'];
+ $settingsArr['use_docman_create_online'] =
$this->Group->data_array['use_docman_create_online'];
+ return $settingsArr;
+ }
+
+ /**
* getStatusNameList - get all status for documents
*
* @param string $format format of the return values.
json returns : { name: id, }. Default is DB object.
diff --git a/src/common/docman/DocumentVersionFactory.class.php
b/src/common/docman/DocumentVersionFactory.class.php
index 4c28a41..a135875 100644
--- a/src/common/docman/DocumentVersionFactory.class.php
+++ b/src/common/docman/DocumentVersionFactory.class.php
@@ -2,7 +2,7 @@
/**
* FusionForge Documentation Manager
*
- * Copyright 2016, Franck Villaume - TrivialDev
+ * Copyright 2016-2017, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -51,13 +51,13 @@ class DocumentVersionFactory extends FFError {
}
/**
- * getVersions - retrieve a limited number of version of a document
+ * getHTMLVersions - retrieve a limited number of version of a document
*
* @param int $limit the number of versions to retrieve.
Default is 0 = No limit
* @param int $start Paging the retrieve. Start point.
Default is 0.
* @return array Array of enriched version datas from database.
*/
- function getVersions($limit = 0, $start = 0) {
+ function getHTMLVersions($limit = 0, $start = 0) {
global $HTML;
$versions = array();
// everything but data_words! Too much memory consumption.
@@ -101,6 +101,21 @@ class DocumentVersionFactory extends FFError {
return $versions;
}
+ function getVersions() {
+ $versions = array();
+ // everything but data_words! Too much memory consumption.
+ $res = db_query_params('SELECT serial_id, version as version,
docid, current_version, title, updatedate, createdate, created_by, description,
filename, filetype, filesize, vcomment FROM doc_data_version WHERE docid = $1
ORDER by version DESC',
+ array($this->Document->getID()));
+ if ($res) {
+ $numrows = db_numrows($res);
+ while ($arr = db_fetch_array($res)) {
+ $versions[] = $arr;
+ }
+ }
+ db_free_result($res);
+ return $versions;
+ }
+
function getSerialIDs() {
$serialids = array();
$res = db_query_params('SELECT serial_id FROM doc_data_version
WHERE docid = $1', array($this->Document->getID()));
diff --git a/src/common/docman/actions/getdocversions.php
b/src/common/docman/actions/getdocversions.php
index dfff656..1495cf7 100644
--- a/src/common/docman/actions/getdocversions.php
+++ b/src/common/docman/actions/getdocversions.php
@@ -2,7 +2,7 @@
/**
* FusionForge Documentation Manager
*
- * Copyright 2016, Franck Villaume - TrivialDev
+ * Copyright 2016-2017, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -44,7 +44,7 @@ if ($docid) {
if ($documentObject && !$documentObject->isError()) {
$dvf = new DocumentVersionFactory($documentObject);
if ($dvf && !$dvf->isError()) {
- $result = $dvf->getVersions($limit, $start);
+ $result = $dvf->getHTMLVersions($limit, $start);
} else {
$result['html'] = $HTML->warning_msg(_('Cannot retrieve
versions')._(': ').$docid);
}
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=331300f9a49719aceaa26eb14627a4a032ba388e
commit 331300f9a49719aceaa26eb14627a4a032ba388e
Author: Franck Villaume <[email protected]>
Date: Sat Feb 25 18:49:57 2017 +0100
rename getTree -> getHTMLTree
diff --git a/src/common/docman/DocumentManager.class.php
b/src/common/docman/DocumentManager.class.php
index cba60c8..307ad78 100644
--- a/src/common/docman/DocumentManager.class.php
+++ b/src/common/docman/DocumentManager.class.php
@@ -158,13 +158,13 @@ class DocumentManager extends FFError {
}
/**
- * getTree - display recursively the content of the doc_group. Only
doc_groups within doc_groups.
+ * getHTMLTree - display recursively the content of the doc_group.
Only doc_groups within doc_groups.
*
* @param int $selecteddir the selected directory
* @param string $linkmenu the type of link in the menu
* @param int $docGroupId the doc_group to start: default 0
*/
- function getTree($selecteddir, $linkmenu, $docGroupId = 0) {
+ function getHTMLTree($selecteddir, $linkmenu, $docGroupId = 0) {
global $g; // the master group of all the groups .... anyway.
Needed to support projects-hierarchy plugin
$dg = new DocumentGroup($this->Group);
switch ($linkmenu) {
@@ -240,7 +240,7 @@ class DocumentManager extends FFError {
}
if ($dg->getSubgroup($subGroupIdValue,
$doc_group_stateid)) {
echo html_ao('ul', array('class' =>
'simpleTreeMenu'));
- $this->getTree($selecteddir, $linkmenu,
$subGroupIdValue);
+ $this->getHTMLTree($selecteddir,
$linkmenu, $subGroupIdValue);
echo html_ac(html_ap() - 1);
}
echo html_ac(html_ap() -1);
diff --git a/src/common/docman/views/tree.php b/src/common/docman/views/tree.php
index 203ae4c..8d1f1d7 100644
--- a/src/common/docman/views/tree.php
+++ b/src/common/docman/views/tree.php
@@ -42,7 +42,7 @@ if (!forge_check_perm('docman', $group_id, 'read')) {
echo html_ao('div', array('id' => 'documenttree'));
echo html_ao('ul', array('id' => $g->getUnixName().'-tree'));
-$dm->getTree($dirid, $linkmenu);
+$dm->getHTMLTree($dirid, $linkmenu);
echo html_ac(html_ap() - 1);
echo html_ao('script', array('type' => 'text/javascript'));
echo '//<![CDATA[
@@ -66,7 +66,7 @@ if (isset($projectIDsArray) && is_array($projectIDsArray)) {
echo html_e('h5', array(), _('Child project')._(':
').util_make_link('/docman/?group_id='.$groupObject->getID(),$groupObject->getPublicName(),
array('title'=>_('Browse document manager for this project.'))), false);
$dmc = new DocumentManager($groupObject);
echo html_ao('ul', array('id' =>
$groupObject->getUnixName().'-tree'));
- $dmc->getTree($dirid, $linkmenu);
+ $dmc->getHTMLTree($dirid, $linkmenu);
echo html_ac(html_ap() - 1);
echo html_ao('script', array('type' =>
'text/javascript'));
echo '//<![CDATA[
-----------------------------------------------------------------------
Summary of changes:
src/bin/forge | 81 +++++++++++++++++++---
src/common/docman/DocumentFactory.class.php | 18 ++++-
src/common/docman/DocumentGroup.class.php | 2 +-
src/common/docman/DocumentManager.class.php | 47 +++++++++++--
src/common/docman/DocumentVersionFactory.class.php | 21 +++++-
src/common/docman/actions/getdocversions.php | 4 +-
src/common/docman/views/tree.php | 4 +-
7 files changed, 154 insertions(+), 23 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits