[Fusionforge-commits] FusionForge branch master updated. v6.0.3-238-gc998a0a
Franck Villaume
nerville at libremir.placard.fr.eu.org
Sun Nov 22 14:19:28 CET 2015
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 c998a0a80c5398eddf69ac978a63f25f02fd4f22 (commit)
from 5aa5d488be13c5f83d18a07446966b4bbf10aad5 (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=c998a0a80c5398eddf69ac978a63f25f02fd4f22
commit c998a0a80c5398eddf69ac978a63f25f02fd4f22
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date: Sun Nov 22 14:19:09 2015 +0100
docman: refactor code in DocumentFactory to better handle document status filter, reuse LUSER rather new object
diff --git a/src/common/docman/DocumentFactory.class.php b/src/common/docman/DocumentFactory.class.php
index 9c5c58f..75e05f1 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-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2015, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -46,10 +46,10 @@ class DocumentFactory extends Error {
var $Documents;
/**
- * The stateid limit
- * @var integer Contains the stateid to limit return documents in getDocuments.
+ * The stateid Array limit
+ * @var array Contains the different stateid to limit return documents in getDocuments.
*/
- var $stateid;
+ var $stateidArr;
/**
* The doc_group_id limit
@@ -111,13 +111,13 @@ class DocumentFactory extends Error {
}
/**
- * setStateID - call this before getDocuments() if you want to limit to a specific state.
+ * setStateID - call this before getDocuments() if you want to limit to some specific states.
*
- * @param int $stateid The stateid from the doc_states table.
+ * @param array $stateidArr Array of stateid from the doc_states table.
* @access public
*/
- function setStateID($stateid) {
- $this->stateid = $stateid;
+ function setStateID($stateidArr) {
+ $this->stateidArr = $stateidArr;
}
/**
@@ -290,7 +290,7 @@ class DocumentFactory extends Error {
$valid = true; // do we need to return this document?
$doc =& $this->Documents[$key][$i];
- if (!$this->stateid) {
+ if (!count($this->stateidArr)) {
$perm =& $this->Group->getPermission();
if (!$perm || !is_object($perm)) {
if ($doc->getStateID() != 1) {
@@ -301,7 +301,7 @@ class DocumentFactory extends Error {
}
}
} else {
- if ($this->stateid != "ALL" && $doc->getStateID() != $this->stateid) {
+ if (!in_array($doc->getStateID(), $this->stateidArr)) {
$valid = false;
}
}
@@ -330,8 +330,7 @@ class DocumentFactory extends Error {
*/
private function getFromStorage() {
$this->Documents = array();
- $qpa = db_construct_qpa();
- $qpa = db_construct_qpa($qpa, 'SELECT * FROM docdata_vw WHERE group_id = $1 ',
+ $qpa = db_construct_qpa(false, 'SELECT * FROM docdata_vw WHERE group_id = $1 ',
array($this->Group->getID()));
if ($this->docgroupid) {
@@ -350,7 +349,7 @@ class DocumentFactory extends Error {
$qpa = db_construct_qpa($qpa, $this->sort);
- if ($this->limit !== 0 ) {
+ if ($this->limit !== 0) {
$qpa = db_construct_qpa($qpa, ' LIMIT $1', array($this->limit));
}
diff --git a/src/common/docman/actions/monitorfile.php b/src/common/docman/actions/monitorfile.php
index 02476d5..a4c6460 100644
--- a/src/common/docman/actions/monitorfile.php
+++ b/src/common/docman/actions/monitorfile.php
@@ -26,6 +26,7 @@
/* global variables used */
global $dirid; //id of doc_group
global $group_id; // id of group
+global $LUSER; //user object
$redirecturl = '/docman/?group_id='.$group_id.'&dirid='.$dirid;
diff --git a/src/common/docman/views/listfile.php b/src/common/docman/views/listfile.php
index 80a271a..36b1744 100644
--- a/src/common/docman/views/listfile.php
+++ b/src/common/docman/views/listfile.php
@@ -8,7 +8,7 @@
* Copyright (C) 2010 Alcatel-Lucent
* Copyright 2010-2011, Franck Villaume - Capgemini
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2015, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -32,9 +32,10 @@
global $group_id; // id of the group
global $dirid; // id of doc_group
global $HTML; // Layout object
-global $u; // User object
+global $LUSER; // User object
global $g; // the Group object
global $dm; // the docman manager
+global $warning_msg;
$linkmenu = 'listfile';
$baseredirecturl = '/docman/?group_id='.$group_id;
@@ -48,7 +49,7 @@ echo html_ao('div', array('id' => 'leftdiv'));
include ($gfcommon.'docman/views/tree.php');
echo html_ac(html_ap() - 1);
-// plugin projects-hierarchy
+// plugin projects-hierarchy support
$childgroup_id = getIntFromRequest('childgroup_id');
if ($childgroup_id) {
if (!forge_check_perm('docman', $childgroup_id, 'read')) {
@@ -69,27 +70,12 @@ if ($dgf->isError())
$df->setDocGroupID($dirid);
-$df->setStateID('1');
+//active, hidden & private state ids
+$df->setStateID(array(1, 4, 5));
$d_arr_active =& $df->getDocuments();
if ($d_arr_active != NULL)
$d_arr = $d_arr_active;
-$df->setStateID('4');
-$d_arr_hidden =& $df->getDocuments();
-if ($d_arr != NULL && $d_arr_hidden != NULL) {
- $d_arr = array_merge($d_arr, $d_arr_hidden);
-} elseif ($d_arr_hidden != NULL) {
- $d_arr = $d_arr_hidden;
-}
-
-$df->setStateID('5');
-$d_arr_private =& $df->getDocuments();
-if ($d_arr != NULL && $d_arr_private != NULL) {
- $d_arr = array_merge($d_arr, $d_arr_private);
-} elseif ($d_arr_private != NULL) {
- $d_arr = $d_arr_private;
-}
-
$nested_groups = $dgf->getNested();
$nested_docs = array();
@@ -109,7 +95,7 @@ if ($dirid) {
}
}
-if ($d_arr != NULL ) {
+if ($d_arr != NULL) {
if (!$d_arr || count($d_arr) > 0) {
// Get the document groups info
//put the doc objects into an array keyed off the docgroup
@@ -119,10 +105,10 @@ if ($d_arr != NULL ) {
}
}
-$df->setStateID('3');
+$df->setStateID(array(3));
$d_pending_arr =& $df->getDocuments();
-if ($d_pending_arr != NULL ) {
+if ($d_pending_arr != NULL) {
if (!$d_pending_arr || count($d_pending_arr) > 0) {
// Get the document groups info
//put the doc objects into an array keyed off the docgroup
@@ -174,7 +160,7 @@ if ($DocGroupName) {
echo html_e('span', array(), _('Document Folder')._(': ').html_e('i', array(), $DocGroupName, false).' ', false);
/* should we steal the lock on folder ? */
if ($ndg->getLocked()) {
- if ($ndg->getLockedBy() == $u->getID()) {
+ if (session_loggedin() && ($ndg->getLockedBy() == $LUSER->getID())) {
$ndg->setLock(0);
/* if you change the 60000 lockIntervalDelay value, please update here too */
} elseif ((time() - $ndg->getLockdate()) > 600) {
@@ -203,7 +189,7 @@ if ($DocGroupName) {
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()) {
- if ($ndg->isMonitoredBy($u->getID())) {
+ if ($ndg->isMonitoredBy($LUSER->getID())) {
$option = 'stop';
$titleMonitor = _('Stop monitoring this folder');
$image = $HTML->getStopMonitoringPic($titleMonitor, '');
@@ -243,7 +229,7 @@ if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
$cells = array();
/* should we steal the lock on file ? */
if ($d->getLocked()) {
- if ($d->getLockedBy() == $u->getID()) {
+ if ($d->getLockedBy() == $LUSER->getID()) {
$d->setLock(0);
/* if you change the 60000 value below, please update here too */
} elseif ((time() - $d->getLockdate()) > 600) {
@@ -253,7 +239,7 @@ if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
if (!$d->getLocked() && !$d->getReserved()) {
$cells[][] = html_e('input', array('type' => 'checkbox', 'value' => $d->getID(), 'class' => 'checkeddocidactive', 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
} else {
- if (session_loggedin() && ($d->getReservedBy() != $u->getID())) {
+ if (session_loggedin() && ($d->getReservedBy() != $LUSER->getID())) {
$cells[][] = html_e('input', array('type' => 'checkbox', 'name' => 'disabled', 'disabled' => 'disabled'));
} else {
$cells[][] = html_e('input', array('type' => 'checkbox', 'value' => $d->getID(), 'class' => 'checkeddocidactive', 'title' => _('Select / Deselect this document for massaction'), 'onClick' => 'controllerListFile.checkgeneral("active")'));
@@ -320,7 +306,7 @@ if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
$nextcell .= util_make_link($redirecturl.'&action=reservefile&fileid='.$d->getID(), html_image('docman/reserve-document.png', 22, 22, array('alt' => _('Reserve this document'))), array('title' => _('Reserve this document for later edition')));
}
} else {
- if (session_loggedin() && $d->getReservedBy() != $u->getID()) {
+ if (session_loggedin() && $d->getReservedBy() != $LUSER->getID()) {
if (forge_check_perm('docman', $ndg->Group->getID(), 'admin')) {
$nextcell .= util_make_link($redirecturl.'&action=enforcereserve&fileid='.$d->getID(), html_image('docman/enforce-document.png',22,22,array('alt'=>_('Enforce reservation'))), array('title' => _('Enforce reservation')));
}
@@ -331,7 +317,7 @@ if (isset($nested_docs[$dirid]) && is_array($nested_docs[$dirid])) {
}
}
if (session_loggedin()) {
- if ($d->isMonitoredBy($u->getID())) {
+ if ($d->isMonitoredBy($LUSER->getID())) {
$option = 'stop';
$titleMonitor = _('Stop monitoring this document');
$image = $HTML->getStopMonitoringPic($titleMonitor, '');
diff --git a/src/common/docman/views/listtrashfile.php b/src/common/docman/views/listtrashfile.php
index 957da86..6115799 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-2014, Franck Villaume - TrivialDev
+ * Copyright 2011-2015, Franck Villaume - TrivialDev
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
* http://fusionforge.org
*
@@ -63,7 +63,8 @@ $dgf = new DocumentGroupFactory($g);
if ($dgf->isError())
exit_error($dgf->getErrorMessage(), 'docman');
-$df->setStateID('2');
+// deleted state id
+$df->setStateID(array(2));
$d_arr =& $df->getDocuments();
diff --git a/src/www/docman/index.php b/src/www/docman/index.php
index 90c9044..e17c7c6 100644
--- a/src/www/docman/index.php
+++ b/src/www/docman/index.php
@@ -99,15 +99,6 @@ switch ($action) {
}
}
-if (session_loggedin()) {
- $u = user_get_object(user_getid());
- if (!$u || !is_object($u)) {
- exit_error(_('Could Not Get User'));
- } elseif ($u->isError()) {
- exit_error($u->getErrorMessage(), 'my');
- }
-}
-
html_use_storage();
html_use_simplemenu();
html_use_jqueryui();
-----------------------------------------------------------------------
Summary of changes:
src/common/docman/DocumentFactory.class.php | 25 ++++++++--------
src/common/docman/actions/monitorfile.php | 1 +
src/common/docman/views/listfile.php | 44 ++++++++++-------------------
src/common/docman/views/listtrashfile.php | 5 ++--
src/www/docman/index.php | 9 ------
5 files changed, 31 insertions(+), 53 deletions(-)
hooks/post-receive
--
FusionForge
More information about the Fusionforge-commits
mailing list