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 b49fe6bb69c9566e5e187cda5f58486001d9a1cb (commit)
from bce5ab392a160b315dc9bb16d2c6050604eea9cc (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=b49fe6bb69c9566e5e187cda5f58486001d9a1cb
commit b49fe6bb69c9566e5e187cda5f58486001d9a1cb
Author: Franck Villaume <[email protected]>
Date: Sun Feb 14 17:53:04 2016 +0100
docman: support private folder
diff --git a/src/CHANGES b/src/CHANGES
index 5087d90..bd3290f 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -10,6 +10,7 @@ FusionForge 6.X:
* Docman: searchengine: DocsAll & Docs unified. (TrivialDev)
* Docman: searchengine: add edit file action on result. (TrivialDev)
* Docman: notify users on document. (TrivialDev)
+* Docman: support private directory. (TrivialDev)
* Plugin AuthBuiltin: add captcha after 3 attempts with the same login [#795]
(TrivialDev)
FusionForge 6.0.4:
diff --git a/src/common/docman/Document.class.php
b/src/common/docman/Document.class.php
index 6c5d7e3..2f7a63a 100644
--- a/src/common/docman/Document.class.php
+++ b/src/common/docman/Document.class.php
@@ -6,7 +6,7 @@
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2011-2015, Franck Villaume - TrivialDev
+ * Copyright 2011-2016, Franck Villaume - TrivialDev
* Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
* http://fusionforge.org
*
@@ -1069,6 +1069,26 @@ class Document extends Error {
$this->setError(_('Error updating document group')._(':
').$localDg->getErrorMessage());
return false;
}
+ for ($i = 0; $i < count($colArr); $i++) {
+ switch ($colArr[$i]) {
+ case 'filesize':
+ case 'data_words':
+ case 'reserved':
+ case 'reserved_by':
+ case 'title':
+ case 'description':
+ case 'filetype':
+ case 'filename':
+ case 'updatedate':
+ case 'stateid':
+ case 'doc_group':
+ case 'locked':
+ case 'locked_by':
+ case 'lockdate': {
+ $this->data_array[$colArr[$i]] =
$valArr[$i];
+ }
+ }
+ }
$this->sendNotice(false);
return true;
}
diff --git a/src/common/docman/DocumentFactory.class.php
b/src/common/docman/DocumentFactory.class.php
index 85c51af..978bf5a 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-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -79,12 +79,21 @@ class DocumentFactory extends Error {
var $limit = 0;
/**
+ * The docgroupstate
+ * @var int Contains the valid state of documentgroups to retrieve
documents using getDocuments.
+ * Default value is 1 which means public any
+ */
+ var $docgroupstate = 1;
+
+ /**
* The offset
* @var integer Contains the offset of the query used to retrive
documents using getDocuments.
* Default value is 0 which means NO OFFSET
*/
var $offset = 0;
+ var $validdocumentgroups = array();
+
/**
* Constructor.
*
@@ -267,6 +276,17 @@ class DocumentFactory extends Error {
}
/**
+ * setDocGroupState - call this before getDocuments() to setup correct
permission settings for retrieve authorized documents.
+ * default value is 1 which means : no limit.
+ *
+ * @param array $state The array of valid state of
documentgroups
+ * @access public
+ */
+ function setDocGroupState($state) {
+ $this->docgroupstate = $state;
+ }
+
+ /**
* setOffset - call this before getDocuments() if you want to move to
the offset in the query used to retrieve documents.
* default value is 0 which means : no offset.
*
@@ -292,7 +312,7 @@ class DocumentFactory extends Error {
$return = array();
- // limit scope to the doc_group_id if any. Useful when you
retrieve all documents
+ // limit scope to the doc_group_id if any. Useful when you
retrieve all documents in cache then filter
if ($this->docgroupid) {
$keys = array($this->docgroupid);
} else {
@@ -303,28 +323,9 @@ class DocumentFactory extends Error {
if (!array_key_exists($key, $this->Documents))
continue; // Should not happen
$count = count($this->Documents[$key]);
-
for ($i=0; $i < $count; $i++) {
- $valid = true;
// do we need to return this document?
$doc =& $this->Documents[$key][$i];
-
- if (!count($this->stateidArr)) {
- $perm =& $this->Group->getPermission();
- if (!$perm || !is_object($perm)) {
- if ($doc->getStateID() != 1) {
- $valid = false;
- }
- if ($perm->isDocEditor()) {
- $valid = true;
- }
- }
- } else {
- if (!in_array($doc->getStateID(),
$this->stateidArr)) {
- $valid = false;
- }
- }
-
- if ($valid) {
+ if (in_array($doc->getStateID(),
$this->stateidArr)) {
$return[] =& $doc;
}
}
@@ -339,6 +340,27 @@ class DocumentFactory extends Error {
return $return;
}
+ private function ValidDocumentGroups() {
+ $this->validdocumentgroups = array();
+ // recursive query to find if documentgroups are visible thru
the tree of documentgroups
+ $qpa = db_construct_qpa(false, 'WITH RECURSIVE
doc_groups_parent(parent_doc_group, doc_group, stateid, group_id) AS
+ ( (SELECT parent_doc_group as
anc, doc_group as desc, stateid as desc_stateid, group_id FROM doc_groups)
+ UNION
+ (select
doc_groups_parent.parent_doc_group as anc, doc_groups.doc_group as desc,
doc_groups_parent.stateid as desc_stateid, doc_groups.group_id
+ FROM doc_groups_parent,
doc_groups
+ WHERE
doc_groups_parent.doc_group = doc_groups.parent_doc_group ))
+ select max(stateid), doc_group
from doc_groups_parent where group_id = $1 group by doc_group having
max(stateid) <= $2',
+ array($this->Group->getID(),
$this->docgroupstate));
+ $result = db_query_qpa($qpa);
+ if (!$result) {
+ $this->setError('getFromStorage:'.db_error());
+ return false;
+ }
+ while ($arr = db_fetch_array($result)) {
+ $this->validdocumentgroups[] = $arr['doc_group'];
+ }
+ }
+
/**
* getFromStorage - Retrieve documents from storage (database for all
informations).
* you can limit query to speed up: warning, once $this->documents is
retrieve, it's cached.
@@ -348,13 +370,20 @@ class DocumentFactory extends Error {
*/
private function getFromStorage() {
$this->Documents = array();
- $qpa = db_construct_qpa(false, 'SELECT * FROM docdata_vw WHERE
group_id = $1 ',
- array($this->Group->getID()));
+
+ $qpa = db_construct_qpa(false, 'SELECT docdata_vw.* from
docdata_vw, doc_groups
+ WHERE docdata_vw.doc_group =
doc_groups.doc_group
+ and docdata_vw.group_id = $1 ',
array($this->Group->getID()));
if ($this->docgroupid) {
- $qpa = db_construct_qpa($qpa, 'AND doc_group = $1 ',
array($this->docgroupid));
+ $qpa = db_construct_qpa($qpa, 'AND docdata_vw.doc_group
= $1 ', array($this->docgroupid));
+ } else {
+ $this->ValidDocumentGroups();
+ $qpa = db_construct_qpa($qpa, 'AND docdata_vw.doc_group
= ANY ($1) ',array(db_int_array_to_any_clause($this->validdocumentgroups)));
}
+ $qpa = db_construct_qpa($qpa, 'AND docdata_vw.stateid = ANY
($1) ', array(db_int_array_to_any_clause($this->stateidArr)));
+
$qpa = db_construct_qpa($qpa, 'ORDER BY ');
for ($i=0; $i<count($this->order); $i++) {
$qpa = db_construct_qpa($qpa, $this->order[$i]);
diff --git a/src/common/docman/DocumentGroup.class.php
b/src/common/docman/DocumentGroup.class.php
index 991d9e1..cd73459 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-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -108,11 +108,15 @@ class DocumentGroup extends Error {
$this->data_array = null;
return;
}
- return;
} else {
$this->fetchData($data);
}
}
+ if ($this->getState() == 5 && !forge_check_perm('docman',
$this->Group->getID(), 'approve')) {
+ $this->data_array = null;
+ $this->setError(_('Permission refused'));
+ return;
+ }
}
/**
@@ -124,7 +128,7 @@ class DocumentGroup extends Error {
* @return boolean true on success / false on failure.
* @access public
*/
- function create($name, $parent_doc_group = 0) {
+ function create($name, $parent_doc_group = 0, $state = 1) {
//
// data validation
//
@@ -168,7 +172,7 @@ class DocumentGroup extends Error {
array ($this->Group->getID(),
htmlspecialchars($name),
$parent_doc_group,
- '1',
+ $state,
time(),
$user_id)
);
@@ -189,7 +193,7 @@ class DocumentGroup extends Error {
if ($parent_doc_group) {
/* update the parent */
$parentDg = documentgroup_get_object($parent_doc_group,
$this->Group->getID());
- $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1);
+ $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1, $parentDg->getState());
}
$this->sendNotice(true);
return true;
@@ -226,9 +230,11 @@ class DocumentGroup extends Error {
return false;
}
- /* update the parent */
- $parentDg = documentgroup_get_object($this->getParentID(),
$this->Group->getID());
- $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1);
+ /* update the parent if any */
+ if ($this->getParentID()) {
+ $parentDg =
documentgroup_get_object($this->getParentID(), $this->Group->getID());
+ $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1);
+ }
/* is there any subdir ? */
$subdir = db_query_params('select doc_group from doc_groups
where parent_doc_group = $1 and group_id = $2',
array($doc_groupid, $project_group_id));
@@ -470,7 +476,7 @@ class DocumentGroup extends Error {
* @return boolean success or not
* @access public
*/
- function update($name, $parent_doc_group = 0, $metadata = 0) {
+ function update($name, $parent_doc_group = 0, $metadata = 0, $state =
1) {
$perm =& $this->Group->getPermission();
if (!$perm || !$perm->isDocEditor()) {
$this->setPermissionDeniedError();
@@ -506,12 +512,12 @@ class DocumentGroup extends Error {
}
$user_id = ((session_loggedin()) ? user_getid() : 100);
- $colArr = array('groupname', 'parent_doc_group', 'updatedate',
'created_by', 'locked', 'locked_by');
- $valArr = array(htmlspecialchars($name), $parent_doc_group,
time(), $user_id, 0, NULL);
+ $colArr = array('groupname', 'parent_doc_group', 'updatedate',
'created_by', 'locked', 'locked_by', 'stateid');
+ $valArr = array(htmlspecialchars($name), $parent_doc_group,
time(), $user_id, 0, NULL, $state);
if ($this->setValueinDB($colArr, $valArr)) {
$parentDg = new DocumentGroup($this->Group,
$parent_doc_group);
if ($parentDg->getParentID())
- $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1);
+ $parentDg->update($parentDg->getName(),
$parentDg->getParentID(), 1, $parentDg->getState());
$this->fetchData($this->getID());
$this->sendNotice(false);
@@ -546,10 +552,20 @@ class DocumentGroup extends Error {
if (array_key_exists($doc_group_id, $result[$stateid]))
return $result[$stateid][$doc_group_id];
+
+ $stateIdDg = 1;
+ if (forge_check_perm('docman',
$document_factory->Group->getID(), 'approve')) {
+ $stateIdDg = 5;
+ }
+ $document_factory->setDocGroupID($doc_group_id);
+ $document_factory->setDocGroupState($stateIdDg);
// check if it has documents
if ($stateid) {
- $document_factory->setStateID($stateid);
+ $document_factory->setStateID(array($stateid));
+ } else {
+ $document_factory->setStateID(array(1, 4, 5));
}
+
$document_factory->setDocGroupID($doc_group_id);
$docs = $document_factory->getDocuments();
if (is_array($docs) && count($docs) > 0) { // this
group has documents
@@ -614,13 +630,13 @@ class DocumentGroup extends Error {
* getSubgroup - Return the ids of any sub folders (first level only)
in specific folder
*
* @param int $docGroupId ID of the specific folder
- * @param int $stateId the state id of this specific
folder (default is 1)
+ * @param array $stateId the state ids of this specific
folder (default is 1)
* @return array the ids of any sub folders
*/
- function getSubgroup($docGroupId, $stateId = 1) {
+ function getSubgroup($docGroupId, $stateId = array(1)) {
$returnArr = array();
- $res = db_query_params('SELECT doc_group from doc_groups where
parent_doc_group = $1 and stateid = $2 and group_id = $3 order by groupname',
- array($docGroupId,
$stateId, $this->Group->getID()));
+ $res = db_query_params('SELECT doc_group from doc_groups where
parent_doc_group = $1 and stateid = ANY ($2) and group_id = $3 order by
groupname',
+ array($docGroupId,
db_int_array_to_any_clause($stateId), $this->Group->getID()));
if (!$res) {
return $returnArr;
}
@@ -637,15 +653,30 @@ class DocumentGroup extends Error {
*
* @param boolean $url does path is url clickable
(default is false)
* @param boolean $includename does path include this document
group name ? (default is true)
- * @return string the complete_path
+ * @return string|boolean the complete_path or false if
user has not proper access to this path.
* @access public
*/
function getPath($url = false, $includename = true) {
-
+ if ($this->getState() != 1 && !forge_check_perm('docman',
$this->Group->getID(), 'approve')) {
+ return false;
+ }
$returnPath = '';
if ($this->getParentID()) {
$parentDg =
documentgroup_get_object($this->getParentID(), $this->Group->getID());
+ if ($parentDg->isError()) {
+ $this->setError = $parentDg->getErrorMessage();
+ return false;
+ }
+ //need to check if user has access to this path. If
not, return false.
+ if ($parentDg->getState() != 1) {
+ if (!forge_check_perm('docman',
$this->Group->getID(), 'approve')) {
+ return false;
+ }
+ }
$returnPath = $parentDg->getPath($url);
+ if (!$returnPath) {
+ return false;
+ }
}
if ($includename) {
if ($url) {
@@ -659,6 +690,7 @@ class DocumentGroup extends Error {
$returnPath .= '/'.$this->getName();
}
}
+
if (!strlen($returnPath))
$returnPath = '/';
@@ -683,7 +715,12 @@ class DocumentGroup extends Error {
if ($dgf->isError())
exit_error($dgf->getErrorMessage(), 'docman');
- $nested_groups =& $dgf->getNested($this->getState());
+ if ($stateid == 2) {
+ $stateidArr = array(2);
+ } else {
+ $stateidArr = array(1, 5);
+ }
+ $nested_groups =& $dgf->getNested($stateidArr);
$df->setDocGroupID($this->getID());
$d_arr =& $df->getDocuments();
@@ -948,7 +985,7 @@ class DocumentGroup extends Error {
$this->data_array['locked'] = $stateLock;
$this->data_array['locked_by'] = $userid;
$this->data_array['lockdate'] = $thistime;
- $subGroupArray = $this->getSubgroup($this->getID(),
$this->getState());
+ $subGroupArray = $this->getSubgroup($this->getID(),
array($this->getState()));
foreach ($subGroupArray as $docgroupId) {
$ndg = documentgroup_get_object($docgroupId,
$this->Group->getID());
$ndg->setLock($stateLock, $userid, $thistime);
@@ -1003,6 +1040,20 @@ class DocumentGroup extends Error {
$this->setOnUpdateError(db_error());
return false;
}
+ for ($i = 0; $i < count($colArr); $i++) {
+ switch ($colArr[$i]) {
+ case 'groupname':
+ case 'parent_doc_group':
+ case 'updatedate':
+ case 'created_by':
+ case 'locked':
+ case 'locked_by':
+ case 'stateid':
+ case 'lockdate': {
+ $this->data_array[$colArr[$i]] =
$valArr[$i];
+ }
+ }
+ }
return true;
}
}
diff --git a/src/common/docman/DocumentGroupFactory.class.php
b/src/common/docman/DocumentGroupFactory.class.php
index e453e93..44205af 100644
--- a/src/common/docman/DocumentGroupFactory.class.php
+++ b/src/common/docman/DocumentGroupFactory.class.php
@@ -6,7 +6,7 @@
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
* Copyright 2010, Franck Villaume - Capgemini
- * Copyright 2012-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2014,2016, Franck Villaume - TrivialDev
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
* http://fusionforge.org
*
@@ -67,16 +67,16 @@ class DocumentGroupFactory extends Error {
/**
* getNested - Return an array of DocumentGroup objects arranged for
nested views.
*
- * @param int $stateid The stateid of DocumentGroup :
default is public (1).
+ * @param array $stateid The array of stateid of
DocumentGroup : default is public (1).
* @return array The array of DocumentGroup.
*/
- function &getNested($stateid = 1) {
+ function &getNested($stateid = array(1)) {
if ($this->nested_groups) {
return $this->nested_groups;
}
- $result = db_query_params('SELECT * FROM doc_groups WHERE
group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
- array($this->Group->getID(),
$stateid));
+ $result = db_query_params('SELECT * FROM doc_groups WHERE
group_id=$1 AND stateid = ANY ($2) ORDER BY groupname ASC',
+ array($this->Group->getID(),
db_int_array_to_any_clause($stateid)));
if (!$result) {
$this->setError(_('No Documents Folder Found').'
'.db_error());
@@ -98,18 +98,18 @@ class DocumentGroupFactory extends Error {
/**
* getDocumentGroups - Return an array of DocumentGroup objects.
*
- * @param int $stateid The stateid of DocumentGroups :
default is public (1).
+ * @param int $stateid The array of stateid of
DocumentGroups : default is public (1).
* @return array The array of DocumentGroup.
*/
- function &getDocumentGroups($stateid = 1) {
+ function &getDocumentGroups($stateid = array(1)) {
if ($this->flat_groups) {
return $this->flat_groups;
}
$this->flat_groups = array();
- $result = db_query_params('SELECT * FROM doc_groups WHERE
group_id=$1 AND stateid=$2 ORDER BY groupname ASC',
- array($this->Group->getID(),
$stateid));
+ $result = db_query_params('SELECT * FROM doc_groups WHERE
group_id = $1 AND stateid = ANY ($2) ORDER BY groupname ASC',
+ array($this->Group->getID(),
db_int_array_to_any_clause($stateid)));
$rows = db_numrows($result);
if (!$result || $rows < 1) {
diff --git a/src/common/docman/DocumentManager.class.php
b/src/common/docman/DocumentManager.class.php
index 74f2b79..d000390 100644
--- a/src/common/docman/DocumentManager.class.php
+++ b/src/common/docman/DocumentManager.class.php
@@ -2,7 +2,7 @@
/**
* FusionForge document manager
*
- * Copyright 2011-2015, Franck Villaume - TrivialDev
+ * Copyright 2011-2016, Franck Villaume - TrivialDev
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
* Copyright 2013, French Ministry of National Education
* http://fusionforge.org
@@ -173,14 +173,19 @@ class DocumentManager extends Error {
switch ($linkmenu) {
case 'listtrashfile': {
$stateId = 2;
+ $doc_group_stateid = array(2);
break;
}
default: {
$stateId = 1;
+ $doc_group_stateid = array(1);
+ if (forge_check_perm('docman',
$this->Group->getID(), 'approve')) {
+ $doc_group_stateid = array(1, 3, 4, 5);
+ }
break;
}
}
- $subGroupIdArr = $dg->getSubgroup($docGroupId, $stateId);
+ $subGroupIdArr = $dg->getSubgroup($docGroupId,
$doc_group_stateid);
if (sizeof($subGroupIdArr)) {
foreach ($subGroupIdArr as $subGroupIdValue) {
$localDg =
documentgroup_get_object($subGroupIdValue, $this->Group->getID());
@@ -227,11 +232,15 @@ class DocumentManager extends Error {
}
$lititle .= _('Last
Modified')._(': ').relative_date($localDg->getLastModifyDate());
}
- echo html_ao('li', array('id' =>
'leaf-'.$subGroupIdValue, 'class' => $liclass)).util_make_link($link,
$localDg->getName(), array('title'=>$lititle)).$nbDocsLabel;
+ $linkname = $localDg->getName();
+ if ($localDg->getState() == 5) {
+ $linkname .= ' '._('(private)');
+ }
+ echo html_ao('li', array('id' =>
'leaf-'.$subGroupIdValue, 'class' => $liclass)).util_make_link($link,
$linkname, array('title'=>$lititle)).$nbDocsLabel;
} else {
echo html_ao('li', array('id' =>
'leaf-'.$subGroupIdValue, 'class' => $liclass)).util_make_link($link,
$localDg->getName()).$nbDocsLabel;
}
- if ($dg->getSubgroup($subGroupIdValue,
$stateId)) {
+ if ($dg->getSubgroup($subGroupIdValue,
$doc_group_stateid)) {
echo html_ao('ul', array('class' =>
'simpleTreeMenu'));
$this->getTree($selecteddir, $linkmenu,
$subGroupIdValue);
echo html_ac(html_ap() - 1);
@@ -354,6 +363,12 @@ class DocumentManager extends Error {
} else {
$df = new
DocumentFactory($doc_group->getGroup());
$df->setDocGroupID($doc_group->getID());
+ $stateidArr = array(1);
+ if (forge_check_perm('docman',
$this->getGroup()->getID(), 'approve')) {
+ $stateIdDg = 5;
+ }
+ $df->setStateID(array(1, 4, 5));
+ $df->setDocGroupState($stateIdDg);
$docs = $df->getDocuments();
if (is_array($docs)) {
foreach ($docs as $doc) {
diff --git a/src/common/docman/actions/addsubdocgroup.php
b/src/common/docman/actions/addsubdocgroup.php
index f64180f..93ae2de 100644
--- a/src/common/docman/actions/addsubdocgroup.php
+++ b/src/common/docman/actions/addsubdocgroup.php
@@ -5,7 +5,7 @@
* Copyright 2000, Quentin Cregan/Sourceforge
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2011,2015, Franck Villaume - TrivialDev
+ * Copyright 2011,2016, Franck Villaume - TrivialDev
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
* http://fusionforge.org
*
@@ -35,11 +35,7 @@ global $error_msg;
global $warning_msg;
global $childgroup_id; // id of child group if any
-if ($dirid) {
- $urlredirect = '/docman/?group_id='.$group_id.'&dirid='.$dirid;
-} else {
- $urlredirect = '/docman/?group_id='.$group_id;
-}
+$urlredirect = '/docman/?group_id='.$group_id.'&dirid='.$dirid;
// plugin projects-hierarchy support
if ($childgroup_id) {
@@ -53,10 +49,11 @@ if (!forge_check_perm('docman', $g->getID(), 'approve')) {
}
$groupname = trim(getStringFromRequest('groupname'));
+$stateid = getIntFromRequest('stateid');
$dg = new DocumentGroup($g);
-if ($dg->isError() || !$dg->create($groupname, $dirid)) {
+if ($dg->isError() || !$dg->create($groupname, $dirid, $stateid)) {
$error_msg = $dg->getErrorMessage();
session_redirect($urlredirect);
}
diff --git a/src/common/docman/actions/editdocgroup.php
b/src/common/docman/actions/editdocgroup.php
index 65b02df..e2a7408 100644
--- a/src/common/docman/actions/editdocgroup.php
+++ b/src/common/docman/actions/editdocgroup.php
@@ -5,7 +5,7 @@
* Copyright 2000, Quentin Cregan/Sourceforge
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2013-2014, Franck Villaume - TrivialDev
+ * Copyright 2013-2014,2016 Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -46,6 +46,8 @@ if (!forge_check_perm('docman', $g->getID(), 'approve')) {
$groupname = getStringFromRequest('groupname');
$parent_dirid = getIntFromRequest('parent_dirid');
+$stateid = getIntFromRequest('stateid');
+
$dg = documentgroup_get_object($dirid, $g->getID());
if ($dg->isError()) {
$error_msg = $dg->getErrorMessage();
@@ -53,7 +55,7 @@ if ($dg->isError()) {
}
$currentParentID = $dg->getParentID();
-if (!$dg->update($groupname, $parent_dirid)) {
+if (!$dg->update($groupname, $parent_dirid, 1, $stateid)) {
$error_msg = $dg->getErrorMessage();
session_redirect($urlredirect);
}
diff --git a/src/common/docman/include/utils.php
b/src/common/docman/include/utils.php
index 09929c1..9e5184a 100644
--- a/src/common/docman/include/utils.php
+++ b/src/common/docman/include/utils.php
@@ -7,7 +7,7 @@
* Copyright 2002-2004, GForge Team
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2014,2016 Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -30,9 +30,10 @@
* tooling library
*/
-function doc_get_state_box($checkedval = 'xzxz', $removedval = '') {
- if (!empty($removedval)) {
- $res_states = db_query_params('select * from doc_states where
stateid not in ($1)', array($removedval));
+function doc_get_state_box($checkedval = 'xzxz', $removedval = array()) {
+ if (count($removedval)) {
+ //TODO: find an easier way to get != ANY($1)
+ $res_states = db_query_params('select * from doc_states where
stateid NOT IN (select stateid from doc_states where stateid = ANY($1))',
array(db_int_array_to_any_clause($removedval)));
} else {
$res_states = db_query_params('select * from doc_states',
array());
}
@@ -63,7 +64,15 @@ function docman_fill_zip($zip, $nested_groups,
$document_factory, $docgroup = 0,
return false;
}
+ $stateidArr = array(1);
+ $stateIdDg = 1;
+ if (forge_check_perm('docman',
$document_factory->Group->getID(), 'approve')) {
+ $stateidArr = array(1, 4, 5);
+ $stateIdDg = 5;
+ }
$document_factory->setDocGroupID($dg->getID());
+ $document_factory->setStateID($stateidArr);
+ $document_factory->setDocGroupState($stateIdDg);
$docs = $document_factory->getDocuments(1); // no
caching
if (is_array($docs) && count($docs)) {
foreach ($docs as $doc) {
diff --git a/src/common/docman/include/webdav.php
b/src/common/docman/include/webdav.php
index 99f0f26..8ce9387 100644
--- a/src/common/docman/include/webdav.php
+++ b/src/common/docman/include/webdav.php
@@ -3,7 +3,7 @@
* FusionForge Documentation Manager
*
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2012,2014, Franck Villaume - TrivialDev
+ * Copyright 2012,2014,2016 Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -105,8 +105,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
if ($analysed_path['isdir']) {
$i = 0;
$path = rtrim($options['path'], '/');
- $res = db_query_params('select * from doc_groups where
group_id = $1 and doc_group = $2 and stateid = 1',
- array($group_id,
$analysed_path['doc_group']));
+ $res = db_query_params('select * from doc_groups where
group_id = $1 and doc_group = $2 and stateid = ANY ($3)',
+ array($group_id,
$analysed_path['doc_group'], db_int_array_to_any_clause(array(1, 5))));
if (!$res)
return '404';
@@ -126,8 +126,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
$files['files'][$i]['props'][] =
$this->mkprop('ishidden', false);
$files['files'][$i]['props'][] =
$this->mkprop('resourcetype', 'collection');
$files['files'][$i]['props'][] =
$this->mkprop('getcontenttype', 'httpd/unix-directory');
- $res = db_query_params('select * from doc_groups where
group_id = $1 and parent_doc_group = $2 and stateid = 1',
- array($group_id,
$analysed_path['doc_group']));
+ $res = db_query_params('select * from doc_groups where
group_id = $1 and parent_doc_group = $2 and stateid = ANY ($3)',
+ array($group_id,
$analysed_path['doc_group'], db_int_array_to_any_clause(array(1, 5))));
if (!$res)
return '404';
@@ -243,8 +243,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
$back_url = substr($options['path'], 0,
strrpos($options['path'], strrchr($lastpath,'/')));
echo util_make_link($back_url, '..');
}
- $res = db_query_params('select groupname from
doc_groups where group_id = $1 and parent_doc_group = $2 and stateid = 1',
- array($group_id,
$analysed_path['doc_group']));
+ $res = db_query_params('select groupname from
doc_groups where group_id = $1 and parent_doc_group = $2 and stateid = ANY
($3)',
+ array($group_id,
$analysed_path['doc_group'], db_int_array_to_any_clause(array(1, 5))));
if (!$res) {
exit_error(_('webdav db error')._(':
').db_error(),'docman');
}
@@ -254,8 +254,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
while ($arr = db_fetch_array($res)) {
echo
'<li>'.util_make_link('/docman/view.php/'.$group_id.'/webdav'.$subpath.$arr['groupname'],
$arr['groupname']).'</li>';
}
- $res = db_query_params('select filename, filetype from
doc_data where group_id = $1 and doc_group = $2 and stateid = 1',
- array($group_id,
$analysed_path['doc_group']));
+ $res = db_query_params('select filename, filetype from
doc_data where group_id = $1 and doc_group = $2 and stateid = ANY ($3)',
+ array($group_id,
$analysed_path['doc_group'], db_int_array_to_any_clause(array(1, 5))));
if (!$res) {
exit_error(_('webdav db error')._(':
').db_error(),'docman');
}
@@ -562,8 +562,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
}
function findPdgIdFromPath($name, $parent_doc_group, $group_id) {
- $res = db_query_params('select doc_group from doc_groups where
group_id = $1 and groupname = $2 and stateid = 1 and parent_doc_group = $3',
- array($group_id, $name,
$parent_doc_group));
+ $res = db_query_params('select doc_group from doc_groups where
group_id = $1 and groupname = $2 and stateid = ANY ($3) and parent_doc_group =
$4',
+ array($group_id, $name,
db_int_array_to_any_clause(array(1, 5)), $parent_doc_group));
if (!$res) {
exit_error(_('webdav db error')._(':
').db_error(),'docman');
}
@@ -607,8 +607,8 @@ class HTTP_WebDAV_Server_Docman extends HTTP_WebDAV_Server {
*/
function whatIsIt($string, $group_id, $path_array) {
$return_path_array['isdir'] = false;
- $res = db_query_params('select doc_group from doc_groups where
group_id = $1 and groupname = $2 and parent_doc_group = $3 and stateid = 1',
- array($group_id,
$string, $path_array['doc_group']));
+ $res = db_query_params('select doc_group from doc_groups where
group_id = $1 and groupname = $2 and parent_doc_group = $3 and stateid = ANY
($4)',
+ array($group_id,
$string, $path_array['doc_group'], db_int_array_to_any_clause(array(1, 5))));
if (!$res) {
exit_error(_('webdav db error')._(':
').db_error(),'docman');
}
diff --git a/src/common/docman/views/addfile.php
b/src/common/docman/views/addfile.php
index fcfe9c9..5e0a748 100644
--- a/src/common/docman/views/addfile.php
+++ b/src/common/docman/views/addfile.php
@@ -7,7 +7,7 @@
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright 2011, Roland Mas
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -77,7 +77,11 @@ jQuery(document).ready(function() {
<?php
echo html_ac(html_ap() - 1);
echo html_ao('div', array('class' => 'docmanDivIncluded'));
-if ($dgf->getNested() == NULL) {
+$stateidArr = array(1);
+if (forge_check_perm('docman', $group_id, 'approve')) {
+ $stateidArr[] = 5;
+}
+if ($dgf->getNested($stateidArr) == NULL) {
$dg = new DocumentGroup($g);
if ($dg->isError()) {
@@ -176,13 +180,13 @@ if ($dgf->getNested() == NULL) {
} else {
$cells = array();
$cells[][] = _('Documents folder that document belongs in');
- $cells[][] = $dm->showSelectNestedGroups($dgf->getNested(),
'doc_group', false, $dirid);
+ $cells[][] =
$dm->showSelectNestedGroups($dgf->getNested($stateidArr), 'doc_group', false,
$dirid);
echo $HTML->multiTableRow(array(), $cells);
}
if (forge_check_perm('docman', $group_id, 'approve')) {
$cells = array();
$cells[][] = _('Status of that document');
- $cells[][] = doc_get_state_box('xzxz', 2); /** no direct
deleted status */
+ $cells[][] = doc_get_state_box('xzxz', array(2)); /** no direct
deleted status */
echo $HTML->multiTableRow(array(), $cells);
}
echo $HTML->listTableBottom();
diff --git a/src/common/docman/views/addsubdocgroup.php
b/src/common/docman/views/addsubdocgroup.php
index e77a65b..b819c3a 100644
--- a/src/common/docman/views/addsubdocgroup.php
+++ b/src/common/docman/views/addsubdocgroup.php
@@ -6,7 +6,7 @@
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013-2015, Franck Villaume - TrivialDev
+ * Copyright 2013-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -67,6 +67,7 @@ if ($dirid) {
}
echo html_e('span', array(), $folderMessage.utils_requiredField(), false);
echo html_e('input', array('required' => 'required', 'type' => 'text', 'name'
=> 'groupname', 'size' => 40, 'maxlength' => 255, 'placeholder' =>
$folderMessage));
+echo html_e('span', array(),
_('Status').utils_requiredField().doc_get_state_box('xzxz', array(2)), false);
echo html_e('input', array('id' => 'submitaddsubgroup', 'type' => 'button',
'value' => _('Create'), 'onclick' => 'javascript:doItAddSubGroup()'));
echo $HTML->closeForm();
echo html_ac(html_ap() -1);
diff --git a/src/common/docman/views/editdocgroup.php
b/src/common/docman/views/editdocgroup.php
index 7ed12ae..ae1b579 100644
--- a/src/common/docman/views/editdocgroup.php
+++ b/src/common/docman/views/editdocgroup.php
@@ -1,5 +1,4 @@
<?php
-
/**
* FusionForge Documentation Manager
*
@@ -7,7 +6,7 @@
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013-2015, Franck Villaume - TrivialDev
+ * Copyright 2013-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -63,13 +62,16 @@ echo $HTML->listTableTop();
$cells[][] = _('Folder Name');
$cells[][] = '<input required="required" type="text" name="groupname"
value="'.$dg->getName().'" />';
$cells[][] = ' ';
+$cells[][] = _('Status');
+$cells[][] = doc_get_state_box($dg->getState(), array(2, 3, 4)); /** no direct
deleted, pending, hidden status */
+$cells[][] = ' ';
$cells[][] = _('belongs to');
if ($dg->getState() == 2) {
$newdgf = new DocumentGroupFactory($g);
- $cells[][] = $dm->showSelectNestedGroups($newdgf->getNested(),
'parent_dirid', true, false);
+ $cells[][] = $dm->showSelectNestedGroups($newdgf->getNested(array(1,
5)), 'parent_dirid', true, false);
$labelSubmit = _('Restore');
} else {
- $cells[][] = $dm->showSelectNestedGroups($dgf->getNested(),
'parent_dirid', true, $dg->getParentId(), array($dg->getID()));
+ $cells[][] = $dm->showSelectNestedGroups($dgf->getNested(array(1, 5)),
'parent_dirid', true, $dg->getParentId(), array($dg->getID()));
$labelSubmit = _('Edit');
}
$cells[][] = '<input type="submit" value="'.$labelSubmit.'" name="submit" />';
diff --git a/src/common/docman/views/listfile.php
b/src/common/docman/views/listfile.php
index 26f4a05..fe1b403 100644
--- a/src/common/docman/views/listfile.php
+++ b/src/common/docman/views/listfile.php
@@ -1,4 +1,3 @@
-
<?php
/**
* FusionForge Documentation Manager
@@ -8,7 +7,7 @@
* Copyright (C) 2010 Alcatel-Lucent
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -82,28 +81,38 @@ $dgf = new DocumentGroupFactory($g);
if ($dgf->isError())
exit_error($dgf->getErrorMessage(), 'docman');
+$stateidArr = array(1);
+$stateIdDg = 1;
+if (forge_check_perm('docman', $g->getID(), 'approve')) {
+ $stateidArr[] = 5;
+ $stateIdDg = 5;
+}
+
$df->setLimit($paging);
$df->setOffset($start);
$df->setDocGroupID($dirid);
-
//active, hidden & private state ids
$df->setStateID(array(1, 4, 5));
+$df->setDocGroupState($stateIdDg);
$d_arr =& $df->getDocuments();
-
-$nested_groups = $dgf->getNested();
+$nested_groups = $dgf->getNested($stateidArr);
$nested_docs = array();
$DocGroupName = 0;
if ($dirid) {
$ndg = documentgroup_get_object($dirid, $g->getID());
+ if ($ndg->isError()) {
+ $error_msg = $ndg->getErrorMessage();
+ session_redirect($baseredirecturl);
+ }
$DocGroupName = $ndg->getName();
$dgpath = $ndg->getPath(true, false);
if (!$DocGroupName) {
$error_msg = $g->getErrorMessage();
session_redirect($baseredirecturl);
}
- if ($ndg->getState() != 1) {
+ if (($ndg->getState() != 1 && $ndg->getState() != 5) || !$dgpath) {
$error_msg = _('Invalid folder');
session_redirect($baseredirecturl.'&view=listfile');
}
@@ -207,10 +216,7 @@ if ($DocGroupName) {
}
}
- $numFiles = $ndg->getNumberOfDocuments(1);
- if (forge_check_perm('docman', $group_id, 'approve'))
- $numPendingFiles = $ndg->getNumberOfDocuments(3);
- if ($numFiles || (isset($numPendingFiles) && $numPendingFiles))
+ if ($ndg->hasDocuments($nested_groups, $df))
echo
util_make_link('/docman/view.php/'.$ndg->Group->getID().'/zip/full/'.$dirid,
html_image('docman/download-directory-zip.png', 22, 22, array('alt' =>
'downloadaszip')), array('title' => _('Download this folder as a ZIP')));
if (session_loggedin()) {
diff --git a/src/common/docman/views/listtrashfile.php
b/src/common/docman/views/listtrashfile.php
index 8087a4b..16639ed 100644
--- a/src/common/docman/views/listtrashfile.php
+++ b/src/common/docman/views/listtrashfile.php
@@ -5,7 +5,7 @@
* Copyright 2000, Quentin Cregan/Sourceforge
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2011-2015, Franck Villaume - TrivialDev
+ * Copyright 2011-2016, Franck Villaume - TrivialDev
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
* http://fusionforge.org
*
@@ -66,6 +66,7 @@ if ($dgf->isError())
// deleted state id
$df->setStateID(array(2));
+$df->setDocGroupState(2);
$d_arr =& $df->getDocuments();
@@ -190,7 +191,7 @@ if (isset($nested_docs[$dirid]) &&
is_array($nested_docs[$dirid])) {
$editfileaction .= '&group_id='.$GLOBALS['group_id'];
$nextcell = '';
$nextcell .=
util_make_link($redirecturl.'&action=delfile&fileid='.$d->getID(),
$HTML->getRemovePic(_('Delete permanently this document.'), 'delfile'));
- $nextcell .= util_make_link('#',
html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))),
array('onclick' =>
'javascript:controllerListTrash.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\',
lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).'
,id:'.$d->getID().', groupId:'.$d->Group->getID().',
docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().',
statusDict:'.$dm->getStatusNameList('json','2').',
docgroupDict:'.$dm->getDocGroupList($newdgf->getNested(), 'json').',
title:\''.addslashes($d->getName()).'\',
filename:\''.addslashes($d->getFilename()).'\',
description:\''.addslashes($d->getDescription()).'\',
isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\',
useCreateOnline:'.$d->Group->useCreateOnline().',
docManURL:\''.util_make_uri("docman").'\'})', 'title' => _('Edit this
document')), true);
+ $nextcell .= util_make_link('#',
html_image('docman/edit-file.png',22,22,array('alt'=>_('Edit this document'))),
array('onclick' =>
'javascript:controllerListTrash.toggleEditFileView({action:\''.util_make_uri($editfileaction).'\',
lockIntervalDelay: 60000, childGroupId: '.util_ifsetor($childgroup_id, 0).'
,id:'.$d->getID().', groupId:'.$d->Group->getID().',
docgroupId:'.$d->getDocGroupID().', statusId:'.$d->getStateID().',
statusDict:'.$dm->getStatusNameList('json','2').',
docgroupDict:'.$dm->getDocGroupList($newdgf->getNested(array(1, 5)), 'json').',
title:\''.addslashes($d->getName()).'\',
filename:\''.addslashes($d->getFilename()).'\',
description:\''.addslashes($d->getDescription()).'\',
isURL:\''.$d->isURL().'\', isText:\''.$d->isText().'\',
useCreateOnline:'.$d->Group->useCreateOnline().',
docManURL:\''.util_make_uri("docman").'\'})', 'title' => _('Edit this
document')), true);
$cells[][] = $nextcell;
echo $HTML->multiTableRow(array(), $cells);
}
diff --git a/src/common/docman/views/movefile.php
b/src/common/docman/views/movefile.php
index 32be6cb..4aa4f5c 100644
--- a/src/common/docman/views/movefile.php
+++ b/src/common/docman/views/movefile.php
@@ -2,7 +2,7 @@
/**
* FusionForge Documentation Manager
*
- * Copyright 2014-2015, Franck Villaume - TrivialDev
+ * Copyright 2014-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -48,7 +48,7 @@ echo html_ao('div', array('class' => 'docmanDivIncluded'));
echo $HTML->openForm(array('name' => 'movefile', 'action' =>
util_make_uri($actionurl), 'method' => 'post'));
echo html_e('input', array('type' => 'hidden', 'name' => 'fileid', 'id' =>
'movefileinput'));
echo html_e('p', array(), _('Move files to').
- $dm->showSelectNestedGroups($dgf->getNested(),
'moveto_dirid', false).
+ $dm->showSelectNestedGroups($dgf->getNested(array(1,
5)), 'moveto_dirid', false).
html_e('input', array('type' => 'submit', 'value' =>
_('Go'), 'name' => 'submit')));
echo $HTML->closeForm();
echo html_ac(html_ap() - 1);
diff --git a/src/common/frs/views/docmanfile.php
b/src/common/frs/views/docmanfile.php
index 18b0602..65068b5 100644
--- a/src/common/frs/views/docmanfile.php
+++ b/src/common/frs/views/docmanfile.php
@@ -2,7 +2,7 @@
/**
* FusionForge FRS : docman include view
*
- * Copyright 2014 Franck Villaume - TrivialDev
+ * Copyright 2014, 2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -29,4 +29,8 @@ global $content;
$content .= html_e('p', array(), _('Alternatively, you can pick a file
available in the Documents Management tool.'), false);
$dm = new DocumentManager($g);
$dgf = new DocumentGroupFactory($g);
-$content .= $dm->showSelectNestedGroups($dgf->getNested(), 'docman_fileid',
true, 0, array(), true);
+$stateidArr = array(1);
+if (forge_check_perm('docman', $g->getID(), 'approve')) {
+ $stateidArr[] = 5;
+}
+$content .= $dm->showSelectNestedGroups($dgf->getNested($stateidArr),
'docman_fileid', true, 0, array(), true);
diff --git a/src/common/include/Group.class.php
b/src/common/include/Group.class.php
index 7f4d130..d16d94c 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -6,7 +6,7 @@
* Copyright 2009-2013, Roland Mas
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* Copyright 2013, French Ministry of National Education
* http://fusionforge.org
*
@@ -2571,7 +2571,7 @@ class Group extends Error {
$olddgf = new
DocumentGroupFactory($template);
// First pass: create all docgroups
$id_mappings['docman_docgroup'][0] = 0;
- foreach ($olddgf->getDocumentGroups()
as $o) {
+ foreach
($olddgf->getDocumentGroups(array(1, 5)) as $o) {
$ndgf = new
DocumentGroup($this);
// .trash is a reserved
directory
if ($o->getName() != '.trash'
&& $o->getParentID() == 0) {
@@ -2579,12 +2579,12 @@ class Group extends Error {
$id_mappings['docman_docgroup'][$o->getID()] = $ndgf->getID();
}
}
- // Second pass: restore hierarchy links
- foreach ($olddgf->getDocumentGroups()
as $o) {
+ // Second pass: restore hierarchy links
& stateid
+ foreach
($olddgf->getDocumentGroups(array(1, 5)) as $o) {
$ndgf = new
DocumentGroup($this);
if ($o->getName() != '.trash'
&& $o->getParentID() == 0) {
$ndgf->fetchData($id_mappings['docman_docgroup'][$o->getID()]);
-
$ndgf->update($ndgf->getName(),
$id_mappings['docman_docgroup'][$o->getParentID()]);
+
$ndgf->update($ndgf->getName(),
$id_mappings['docman_docgroup'][$o->getParentID()],
$id_mappings['docman_docgroup'][$o->getState()]);
}
}
}
diff --git a/src/common/widget/Widget_MyProjectsLastDocuments.class.php
b/src/common/widget/Widget_MyProjectsLastDocuments.class.php
index 0d51195..c4c0ee9 100644
--- a/src/common/widget/Widget_MyProjectsLastDocuments.class.php
+++ b/src/common/widget/Widget_MyProjectsLastDocuments.class.php
@@ -2,7 +2,7 @@
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights
reserved
* Copyright 2010, Franck Villaume - Capgemini
- * Copyright 2011-2014, Franck Villaume - TrivialDev
+ * Copyright 2011-2014,2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is a part of FusionForge.
@@ -22,7 +22,7 @@
*/
require_once 'Widget.class.php';
-include $gfcommon.'docman/DocumentFactory.class.php';
+require_once $gfcommon.'docman/DocumentFactory.class.php';
/**
* Widget_MyProjectsLastDocuments
@@ -69,9 +69,14 @@ class Widget_MyProjectsLastDocuments extends Widget {
$hide_docmanproject = null;
}
+ $stateIdDg = 1;
+ if (forge_check_perm('docman',
$g->getID(), 'approve')) {
+ $stateIdDg = 5;
+ }
$df = new DocumentFactory($g);
+ $df->setDocGroupState($stateIdDg);
$df->setLimit(5);
-
$df->setOrder(array('updatedate','createdate'));
+ $df->setOrder(array('updatedate',
'createdate'));
$df->setSort('DESC');
$df->getDocuments();
diff --git a/src/common/widget/Widget_ProjectLatestDocuments.class.php
b/src/common/widget/Widget_ProjectLatestDocuments.class.php
index e990f53..a42bd90 100644
--- a/src/common/widget/Widget_ProjectLatestDocuments.class.php
+++ b/src/common/widget/Widget_ProjectLatestDocuments.class.php
@@ -2,7 +2,7 @@
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights
reserved
* Copyright 2010, Franck Villaume - Capgemini
- * Copyright 2012-2013, Franck Villaume - TrivialDev
+ * Copyright 2012-2013,2016, Franck Villaume - TrivialDev
* Copyright 2013, French Ministry of National Education
*
* This file is a part of Fusionforge.
@@ -22,6 +22,7 @@
*/
require_once 'Widget.class.php';
+require_once $gfcommon.'docman/DocumentFactory.class.php';
/**
* Widget_ProjectLatestDocuments
@@ -51,22 +52,26 @@ class Widget_ProjectLatestDocuments extends Widget {
$group_id = $request->get('group_id');
$qpa = db_construct_qpa();
- $qpa = db_construct_qpa($qpa, 'SELECT docid FROM doc_data WHERE
group_id = $1',
+ $qpa = db_construct_qpa($qpa, 'SELECT docid FROM doc_data,
doc_groups WHERE doc_data.group_id = $1',
array($group_id));
- if (session_loggedin() && forge_check_perm('docman', $group_id,
'approve')) {
- $qpa = db_construct_qpa($qpa, ' AND stateid IN ($1, $2,
$3, $4)', array('1', '3', '4', '5'));
- } else {
- $qpa = db_construct_qpa($qpa, ' AND stateid = $1',
array('1'));
+ $stateIdDg = 1;
+ $stateIdDocuments = array(1);
+ if (forge_check_perm('docman', $group_id, 'approve')) {
+ $stateIdDg = 5;
+ $stateIdDocuments = array(1, 2, 3, 4, 5);
}
-
- $qpa = db_construct_qpa($qpa, ' ORDER BY updatedate,createdate
DESC LIMIT 5',array());
- $res_files = db_query_qpa($qpa);
-
- $rows_files = db_numrows($res_files);
- if (!$res_files || $rows_files < 1) {
- $result .= db_error();
- // No documents
+ $df = new DocumentFactory(group_get_object($group_id));
+ $df->setDocGroupState($stateIdDg);
+ $df->setStateID($stateIdDocuments);
+ $df->setLimit(5);
+ $df->setOrder(array('updatedate', 'createdate'));
+ $df->setSort('DESC');
+ $df->getDocuments();
+
+ $keys = array_keys($df->Documents);
+ $j = 0;
+ if (!count($keys)) {
$result .= $HTML->information(_('This project has not
published any documents.'));
} else {
use_javascript('/js/sortable.js');
@@ -80,55 +85,59 @@ class Widget_ProjectLatestDocuments extends Widget {
$classth[] = 'unsortable';
}
$result .= $HTML->listTableTop($tabletop, false,
'sortable_widget_docman_listfile full', 'sortable', $classth);
- for ($f=0; $f < $rows_files; $f++) {
- $documentObject =
document_get_object(db_result($res_files, $f, 'docid'), $group_id);
- $updatedate = $documentObject->getUpdated();
- $createdate = $documentObject->getCreated();
- $realdate = ($updatedate >= $createdate) ?
$updatedate : $createdate;
- $filename = $documentObject->getFileName();
- $title = $documentObject->getName();
- $realname =
$documentObject->getCreatorRealName();
- $user_name =
$documentObject->getCreatorUserName();
- $statename = $documentObject->getStateName();
- $filetype = $documentObject->getFileType();
- $docid = $documentObject->getID();
- $docgroup = $documentObject->getDocGroupID();
- $ndg = documentgroup_get_object($docgroup,
$group_id);
- $path = $ndg->getPath(true, true);
- switch ($filetype) {
- case "URL": {
- $docurl =
util_make_link($filename, $filename, array(), true);
- break;
- }
- default: {
- $docurl =
util_make_link('/docman/view.php/'.$group_id.'/'.$docid.'/'.urlencode($filename),
'<strong>'.$filename.'</strong>');
- }
- }
- $cells = array();
- $cells[][] = date(_('Y-m-d'),$realdate);
- $cells[][] = $docurl;
- $cells[][] = $title;
- $cells[][] = make_user_link($user_name,
$realname);
- $cells[][] = $path;
- if (session_loggedin()) {
- $cells[][] = $statename;
- if
($documentObject->isMonitoredBy(UserManager::instance()->getCurrentUser()->getID()))
{
- $option = 'stop';
- $titleMonitor = _('Stop
monitoring this document');
- $image =
$HTML->getStopMonitoringPic($titleMonitor, $titleMonitor);
- } else {
- $option = 'start';
- $titleMonitor = _('Start
monitoring this document');
- $image =
$HTML->getStartMonitoringPic($titleMonitor, $titleMonitor);
+
+ foreach ($keys as $key) {
+ $count = count($df->Documents[$key]);
+ for ($i=0; $i < $count; $i++) {
+ $doc =& $df->Documents[$key][$i];
+ $updatedate = $doc->getUpdated();
+ $createdate = $doc->getCreated();
+ $realdate = ($updatedate >=
$createdate) ? $updatedate : $createdate;
+ $filename = $doc->getFileName();
+ $title = $doc->getName();
+ $realname = $doc->getCreatorRealName();
+ $user_name = $doc->getCreatorUserName();
+ $statename = $doc->getStateName();
+ $filetype = $doc->getFileType();
+ $docid = $doc->getID();
+ $docgroup = $doc->getDocGroupID();
+ $ndg =
documentgroup_get_object($docgroup, $group_id);
+ $path = $ndg->getPath(true, true);
+ switch ($filetype) {
+ case "URL": {
+ $docurl =
util_make_link($filename, $filename, array(), true);
+ break;
+ }
+ default: {
+ $docurl =
util_make_link('/docman/view.php/'.$group_id.'/'.$docid.'/'.urlencode($filename),
'<strong>'.$filename.'</strong>');
+ }
}
- $action =
util_make_link('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$docgroup.'&action=monitorfile&option='.$option.'&fileid='.$documentObject->getID(),
$image, array('title' => $titleMonitor));
- if (forge_check_perm('docman',
$group_id, 'approve') && !$documentObject->getLocked()) {
- $action .=
util_make_link('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$docgroup.'&action=trashfile&fileid='.$documentObject->getID(),
$HTML->getDeletePic('', _('Move this document to trash')), array('title' =>
_('Move this document to trash')));
+ $cells = array();
+ $cells[][] = date(_('Y-m-d'),$realdate);
+ $cells[][] = $docurl;
+ $cells[][] = $title;
+ $cells[][] = make_user_link($user_name,
$realname);
+ $cells[][] = $path;
+ if (session_loggedin()) {
+ $cells[][] = $statename;
+ if
($doc->isMonitoredBy(UserManager::instance()->getCurrentUser()->getID())) {
+ $option = 'stop';
+ $titleMonitor = _('Stop
monitoring this document');
+ $image =
$HTML->getStopMonitoringPic($titleMonitor, $titleMonitor);
+ } else {
+ $option = 'start';
+ $titleMonitor =
_('Start monitoring this document');
+ $image =
$HTML->getStartMonitoringPic($titleMonitor, $titleMonitor);
+ }
+ $action =
util_make_link('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$docgroup.'&action=monitorfile&option='.$option.'&fileid='.$doc->getID(),
$image, array('title' => $titleMonitor));
+ if (forge_check_perm('docman',
$group_id, 'approve') && !$doc->getLocked()) {
+ $action .=
util_make_link('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$docgroup.'&action=trashfile&fileid='.$doc->getID(),
$HTML->getDeletePic('', _('Move this document to trash')), array('title' =>
_('Move this document to trash')));
+ }
+ $cells[][] = $action;
}
- $cells[][] = $action;
- }
- $result .= $HTML->multiTableRow(array(),
$cells);
+ $result .=
$HTML->multiTableRow(array(), $cells);
+ }
}
$result .= $HTML->listTableBottom();
}
diff --git a/src/www/activity/index.php b/src/www/activity/index.php
index c153d1e..9a0aec8 100644
--- a/src/www/activity/index.php
+++ b/src/www/activity/index.php
@@ -5,7 +5,7 @@
* Copyright 1999 dtype
* Copyright 2006 (c) GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
- * Copyright 2012-2015, Franck Villaume - TrivialDev
+ * Copyright 2012-2016, Franck Villaume - TrivialDev
* Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
* Copyright 2014, Benoit Debaenst - TrivialDev
* http://fusionforge.org/
@@ -28,6 +28,8 @@
require_once '../env.inc.php';
require_once $gfcommon.'include/pre.php';
+require_once $gfcommon.'docman/Document.class.php';
+require_once $gfcommon.'docman/DocumentGroup.class.php';
global $HTML;
@@ -290,6 +292,7 @@ echo $HTML->closeForm();
$j = 0;
$last_day = 0;
foreach ($results as $arr) {
+ $docmanerror = 0;
if (!check_perm_for_activity($arr)) {
continue;
}
@@ -302,12 +305,6 @@ echo $HTML->closeForm();
echo $HTML->listTableTop($theader);
$displayTableTop = 1;
}
- if ($last_day != strftime($date_format,
$arr['activity_date'])) {
- // echo $HTML->listTableBottom($theader);
- echo '<tr class="tableheading"><td
colspan="3">'.strftime($date_format, $arr['activity_date']).'</td></tr>';
- // echo $HTML->listTableTop($theader);
- $last_day=strftime($date_format,
$arr['activity_date']);
- }
switch (@$arr['section']) {
case 'scm': {
$icon =
html_image('ic/cvs16b.png','','',array('alt'=>_('Source Code')));
@@ -357,11 +354,24 @@ echo $HTML->closeForm();
}
case 'docmannew':
case 'docmanupdate': {
+ $document =
document_get_object($arr['subref_id'], $arr['group_id']);
+ $stateid = $document->getStateID();
+ if ($stateid != 1 &&
!forge_check_perm('docman', $arr['group_id'], 'approve')) {
+ $docmanerror = 1;
+ }
+ $dg =
documentgroup_get_object($arr['ref_id'], $arr['group_id']);
+ if (!$dg->getPath(true, false)) {
+ $docmanerror = 1;
+ }
$icon = html_image('ic/docman16b.png',
'', '', array('alt'=>_('Documents')));
$url =
util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['ref_id'],_('Document').'
'.$arr['description']);
break;
}
case 'docgroupnew': {
+ $dg =
documentgroup_get_object($arr['ref_id'], $arr['group_id']);
+ if ($dg->isError() ||
!$dg->getPath(true, false)) {
+ $docmanerror = 1;
+ }
$icon = html_image('ic/cfolder15.png',
'', '', array("alt"=>_('Directory')));
$url =
util_make_link('docman/?group_id='.$arr['group_id'].'&view=listfile&dirid='.$arr['subref_id'],_('Directory').'
'.$arr['description']);
break;
@@ -371,6 +381,13 @@ echo $HTML->closeForm();
$url = '<a
href="'.$arr['link'].'">'.$arr['title'].'</a>';
}
}
+ if ($docmanerror) {
+ continue;
+ }
+ if ($last_day != strftime($date_format,
$arr['activity_date'])) {
+ echo '<tr class="tableheading"><td
colspan="3">'.strftime($date_format, $arr['activity_date']).'</td></tr>';
+ $last_day=strftime($date_format,
$arr['activity_date']);
+ }
$cells = array();
$cells[][] = date('H:i:s',$arr['activity_date']);
$cells[][] = $icon .' '.$url;
diff --git a/src/www/docman/view.php b/src/www/docman/view.php
index 28f814f..66c9792 100644
--- a/src/www/docman/view.php
+++ b/src/www/docman/view.php
@@ -6,7 +6,7 @@
* Copyright 2002-2003, Tim Perdue/GForge, LLC
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2010-2012 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012,2015, Franck Villaume - TrivialDev
+ * Copyright 2012,2015-2016, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -32,6 +32,9 @@ require_once $gfcommon.'docman/DocumentFactory.class.php';
require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
require_once $gfcommon.'docman/include/utils.php';
+global $warning_msg;
+global $error_msg;
+
$sysdebug_enable = false;
$arr = explode('/', getStringFromServer('REQUEST_URI'));
@@ -102,7 +105,7 @@ if (is_numeric($docid)) {
if ($dgf->isError())
exit_error($dgf->getErrorMessage(), 'docman');
- $nested_groups = $dgf->getNested();
+ $nested_groups = $dgf->getNested(array(1, 5));
if ( $nested_groups != NULL ) {
$filename =
'docman-'.$g->getUnixName().'-'.$docid.'.zip';
@@ -168,6 +171,7 @@ if (is_numeric($docid)) {
session_require_perm('docman', $group_id, 'read');
if (extension_loaded('zip')) {
if ( $arr[5] === 'full' ) {
+
$dirid = $arr[6];
$dg = new DocumentGroup($g, $dirid);
@@ -182,7 +186,12 @@ if (is_numeric($docid)) {
if ($dgf->isError())
exit_error($dgf->getErrorMessage(), 'docman');
- $nested_groups = $dgf->getNested();
+ $stateidArr = array(1);
+ if (forge_check_perm('docman', $g->getID(), 'approve'))
{
+ $stateidArr = array(1, 4, 5);
+ }
+
+ $nested_groups = $dgf->getNested($stateidArr);
if ($dg->hasDocuments($nested_groups, $df)) {
$filename =
'docman-'.$g->getUnixName().'-'.$dg->getID().'.zip';
@@ -195,7 +204,15 @@ if (is_numeric($docid)) {
}
// ugly workaround to get the files at
doc_group_id level
+ $stateidArr = array(1);
+ $stateIdDg = 1;
+ if (forge_check_perm('docman',
$df->Group->getID(), 'approve')) {
+ $stateidArr = array(1, 4, 5);
+ $stateIdDg = 5;
+ }
$df->setDocGroupID($dg->getID());
+ $df->setStateID($stateidArr);
+ $df->setDocGroupState($stateIdDg);
$docs = $df->getDocuments(1); // no caching
if (is_array($docs) && count($docs) > 0) {
// this group has documents
foreach ($docs as $doc) {
@@ -232,7 +249,7 @@ if (is_numeric($docid)) {
unlink($file);
} else {
$warning_msg = _('This documents folder is
empty.');
-
session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid);
+
//session_redirect('/docman/?group_id='.$group_id.'&view=listfile&dirid='.$dirid);
}
} elseif ( $arr[5] === 'selected' ) {
$dirid = $arr[6];
@@ -279,7 +296,7 @@ if (is_numeric($docid)) {
if (is_numeric($dirid)) {
$redirect_url .=
'&dirir='.$dirid;
}
- session_redirect($redirect_url);
+ //session_redirect($redirect_url);
}
}
@@ -299,7 +316,7 @@ if (is_numeric($docid)) {
if(!readfile_chunked($file)) {
unlink($file);
$error_msg = _('Unable to download ZIP
archive');
-
session_redirect('/docman/?group_id='.$group_id);
+
//session_redirect('/docman/?group_id='.$group_id);
}
unlink($file);
} else {
-----------------------------------------------------------------------
Summary of changes:
src/CHANGES | 1 +
src/common/docman/Document.class.php | 22 +++-
src/common/docman/DocumentFactory.class.php | 79 +++++++++----
src/common/docman/DocumentGroup.class.php | 93 +++++++++++----
src/common/docman/DocumentGroupFactory.class.php | 18 +--
src/common/docman/DocumentManager.class.php | 23 +++-
src/common/docman/actions/addsubdocgroup.php | 11 +-
src/common/docman/actions/editdocgroup.php | 6 +-
src/common/docman/include/utils.php | 17 ++-
src/common/docman/include/webdav.php | 26 ++---
src/common/docman/views/addfile.php | 12 +-
src/common/docman/views/addsubdocgroup.php | 3 +-
src/common/docman/views/editdocgroup.php | 10 +-
src/common/docman/views/listfile.php | 26 +++--
src/common/docman/views/listtrashfile.php | 5 +-
src/common/docman/views/movefile.php | 4 +-
src/common/frs/views/docmanfile.php | 8 +-
src/common/include/Group.class.php | 10 +-
.../Widget_MyProjectsLastDocuments.class.php | 11 +-
.../widget/Widget_ProjectLatestDocuments.class.php | 129 +++++++++++----------
src/www/activity/index.php | 31 +++--
src/www/docman/view.php | 29 ++++-
22 files changed, 382 insertions(+), 192 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits