[Fusionforge-commits] FusionForge branch master updated. 17c719a docman: use cached objects

Franck Villaume nerville at libremir.placard.fr.eu.org
Sun Jun 7 17:41:39 CEST 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  17c719aba8cbe64da895797f77f9296d267426f1 (commit)
      from  350d21cc4581b125fae4818988f0834aa155de18 (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 -----------------------------------------------------------------
commit 17c719aba8cbe64da895797f77f9296d267426f1
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Jun 7 17:41:05 2015 +0200

    docman: use cached objects

diff --git a/src/common/docman/Document.class.php b/src/common/docman/Document.class.php
index a7c5ffc..837a3b0 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-2014, Franck Villaume - TrivialDev
+ * Copyright 2011-2015, Franck Villaume - TrivialDev
  * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
  * http://fusionforge.org
  *
@@ -160,7 +160,7 @@ class Document extends Error {
 			}
 		}
 
-		$dg = new DocumentGroup($this->getGroup(), $doc_group);
+		$dg = documentgroup_get_object($doc_group);
 		if ($dg->hasDocument($filename)) {
 			$this->setError(_('Document already published in this folder').' '.$dg->getPath());
 			return false;
@@ -243,7 +243,7 @@ class Document extends Error {
 		}
 
 		if ($perm->isDocEditor()) {
-			$localDg = new DocumentGroup($this->Group, $doc_group);
+			$localDg = documentgroup_get_object($doc_group);
 			if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
 				$this->setError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
 				if ($filesize) {
@@ -818,9 +818,9 @@ class Document extends Error {
 			return false;
 		}
 
-		$dg = new DocumentGroup($this->getGroup(), $doc_group);
-		if ($dg->hasDocument($filename)) {
-			$this->setError(_('Document already published in this folder').' '.$dg->getPath());
+		$localDg = documentgroup_get_object($doc_group);
+		if ($localDg->hasDocument($filename)) {
+			$this->setError(_('Document already published in this folder').' '.$localDg->getPath());
 			return false;
 		}
 
@@ -832,7 +832,6 @@ class Document extends Error {
 			return false;
 		}
 
-		$localDg = new DocumentGroup($this->Group, $doc_group);
 		if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
 			$this->setOnUpdateError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
 			db_rollback();
@@ -875,7 +874,7 @@ class Document extends Error {
 		if ($this->isMonitoredBy('ALL')) {
 			$BCC .= $this->getMonitoredUserEmailAddress();
 		}
-		$dg = new DocumentGroup($this->Group, $this->getDocGroupID());
+		$dg = documentgroup_get_object($this->getDocGroupID());
 		if ($dg->isMonitoredBy('ALL')) {
 			$BCC .= $dg->getMonitoredUserEmailAddress();
 		}
@@ -1069,7 +1068,7 @@ class Document extends Error {
 			$this->setOnUpdateError(db_error());
 			return false;
 		}
-		$localDg = new DocumentGroup($this->Group, $this->getDocGroupID());
+		$localDg = documentgroup_get_object($this->getDocGroupID());
 		if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
 			$this->setError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
 			return false;
diff --git a/src/common/docman/DocumentGroup.class.php b/src/common/docman/DocumentGroup.class.php
index 22d489e..ddc0b41 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-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2015, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -52,7 +52,8 @@ function &documentgroup_get_object($docgroup_id, $res = false) {
 		if (!$res || db_numrows($res) < 1) {
 			$DOCUMENTGROUP_OBJ["_".$docgroup_id."_"] = false;
 		} else {
-			$DOCUMENTGROUP_OBJ["_".$docgroup_id."_"] = new DocumentGroup(group_get_object(db_result($res,0,'group_id')), $docgroup_id, db_fetch_array($res));
+			$Group = &group_get_object(db_result($res,0,'group_id'));
+			$DOCUMENTGROUP_OBJ["_".$docgroup_id."_"] = new DocumentGroup($Group, db_fetch_array($res));
 		}
 	}
 	return $DOCUMENTGROUP_OBJ["_".$docgroup_id."_"];
@@ -187,7 +188,7 @@ class DocumentGroup extends Error {
 
 		if ($parent_doc_group) {
 			/* update the parent */
-			$parentDg = new DocumentGroup($this->Group, $parent_doc_group);
+			$parentDg = documentgroup_get_object($parent_doc_group);
 			$parentDg->update($parentDg->getName(), $parentDg->getParentID(), 1);
 		}
 		$this->sendNotice(true);
@@ -226,7 +227,7 @@ class DocumentGroup extends Error {
 		}
 
 		/* update the parent */
-		$parentDg = new DocumentGroup($this->Group, $this->getParentID());
+		$parentDg = documentgroup_get_object($this->getParentID());
 		$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',
@@ -643,7 +644,7 @@ class DocumentGroup extends Error {
 
 		$returnPath = '';
 		if ($this->getParentID()) {
-			$parentDg = new DocumentGroup($this->Group, $this->getParentID());
+			$parentDg = documentgroup_get_object($this->getParentID());
 			$returnPath = $parentDg->getPath($url);
 		}
 		if ($includename) {
@@ -949,7 +950,7 @@ class DocumentGroup extends Error {
 		$this->data_array['lockdate'] = $thistime;
 		$subGroupArray = $this->getSubgroup($this->getID(), $this->getState());
 		foreach ($subGroupArray as $docgroupId) {
-			$ndg = new DocumentGroup($this->Group, $docgroupId);
+			$ndg = documentgroup_get_object($docgroupId);
 			$ndg->setLock($stateLock, $userid, $thistime);
 		}
 		return true;

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

Summary of changes:
 src/common/docman/Document.class.php      | 17 ++++++++---------
 src/common/docman/DocumentGroup.class.php | 13 +++++++------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/common/docman/Document.class.php b/src/common/docman/Document.class.php
index a7c5ffc..837a3b0 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-2014, Franck Villaume - TrivialDev
+ * Copyright 2011-2015, Franck Villaume - TrivialDev
  * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
  * http://fusionforge.org
  *
@@ -160,7 +160,7 @@ class Document extends Error {
 			}
 		}
 
-		$dg = new DocumentGroup($this->getGroup(), $doc_group);
+		$dg = documentgroup_get_object($doc_group);
 		if ($dg->hasDocument($filename)) {
 			$this->setError(_('Document already published in this folder').' '.$dg->getPath());
 			return false;
@@ -243,7 +243,7 @@ class Document extends Error {
 		}
 
 		if ($perm->isDocEditor()) {
-			$localDg = new DocumentGroup($this->Group, $doc_group);
+			$localDg = documentgroup_get_object($doc_group);
 			if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
 				$this->setError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
 				if ($filesize) {
@@ -818,9 +818,9 @@ class Document extends Error {
 			return false;
 		}
 
-		$dg = new DocumentGroup($this->getGroup(), $doc_group);
-		if ($dg->hasDocument($filename)) {
-			$this->setError(_('Document already published in this folder').' '.$dg->getPath());
+		$localDg = documentgroup_get_object($doc_group);
+		if ($localDg->hasDocument($filename)) {
+			$this->setError(_('Document already published in this folder').' '.$localDg->getPath());
 			return false;
 		}
 
@@ -832,7 +832,6 @@ class Document extends Error {
 			return false;
 		}
 
-		$localDg = new DocumentGroup($this->Group, $doc_group);
 		if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
 			$this->setOnUpdateError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
 			db_rollback();
@@ -875,7 +874,7 @@ class Document extends Error {
 		if ($this->isMonitoredBy('ALL')) {
 			$BCC .= $this->getMonitoredUserEmailAddress();
 		}
-		$dg = new DocumentGroup($this->Group, $this->getDocGroupID());
+		$dg = documentgroup_get_object($this->getDocGroupID());
 		if ($dg->isMonitoredBy('ALL')) {
 			$BCC .= $dg->getMonitoredUserEmailAddress();
 		}
@@ -1069,7 +1068,7 @@ class Document extends Error {
 			$this->setOnUpdateError(db_error());
 			return false;
 		}
-		$localDg = new DocumentGroup($this->Group, $this->getDocGroupID());
+		$localDg = documentgroup_get_object($this->getDocGroupID());
 		if (!$localDg->update($localDg->getName(), $localDg->getParentID(), 1)) {
 			$this->setError(_('Error updating document group')._(': ').$localDg->getErrorMessage());
 			return false;
diff --git a/src/common/docman/DocumentGroup.class.php b/src/common/docman/DocumentGroup.class.php
index 22d489e..ddc0b41 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-2014, Franck Villaume - TrivialDev
+ * Copyright 2012-2015, Franck Villaume - TrivialDev
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -52,7 +52,8 @@ function &documentgroup_get_object($docgroup_id, $res = false) {
 		if (!$res || db_numrows($res) < 1) {
 			$DOCUMENTGROUP_OBJ["_".$docgroup_id."_"] = false;
 		} else {
-			$DOCUMENTGROUP_OBJ["_".$docgroup_id."_"] = new DocumentGroup(group_get_object(db_result($res,0,'group_id')), $docgroup_id, db_fetch_array($res));
+			$Group = &group_get_object(db_result($res,0,'group_id'));
+			$DOCUMENTGROUP_OBJ["_".$docgroup_id."_"] = new DocumentGroup($Group, db_fetch_array($res));
 		}
 	}
 	return $DOCUMENTGROUP_OBJ["_".$docgroup_id."_"];
@@ -187,7 +188,7 @@ class DocumentGroup extends Error {
 
 		if ($parent_doc_group) {
 			/* update the parent */
-			$parentDg = new DocumentGroup($this->Group, $parent_doc_group);
+			$parentDg = documentgroup_get_object($parent_doc_group);
 			$parentDg->update($parentDg->getName(), $parentDg->getParentID(), 1);
 		}
 		$this->sendNotice(true);
@@ -226,7 +227,7 @@ class DocumentGroup extends Error {
 		}
 
 		/* update the parent */
-		$parentDg = new DocumentGroup($this->Group, $this->getParentID());
+		$parentDg = documentgroup_get_object($this->getParentID());
 		$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',
@@ -643,7 +644,7 @@ class DocumentGroup extends Error {
 
 		$returnPath = '';
 		if ($this->getParentID()) {
-			$parentDg = new DocumentGroup($this->Group, $this->getParentID());
+			$parentDg = documentgroup_get_object($this->getParentID());
 			$returnPath = $parentDg->getPath($url);
 		}
 		if ($includename) {
@@ -949,7 +950,7 @@ class DocumentGroup extends Error {
 		$this->data_array['lockdate'] = $thistime;
 		$subGroupArray = $this->getSubgroup($this->getID(), $this->getState());
 		foreach ($subGroupArray as $docgroupId) {
-			$ndg = new DocumentGroup($this->Group, $docgroupId);
+			$ndg = documentgroup_get_object($docgroupId);
 			$ndg->setLock($stateLock, $userid, $thistime);
 		}
 		return true;


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list