[Fusionforge-commits] r14008 - trunk/src/common/docman

Franck VILLAUME nerville at fusionforge.org
Fri Jul 29 16:22:06 CEST 2011


Author: nerville
Date: 2011-07-29 16:22:06 +0200 (Fri, 29 Jul 2011)
New Revision: 14008

Modified:
   trunk/src/common/docman/DocumentGroup.class.php
   trunk/src/common/docman/DocumentManager.class.php
Log:
fix number of files in trash tree & add cache system

Modified: trunk/src/common/docman/DocumentGroup.class.php
===================================================================
--- trunk/src/common/docman/DocumentGroup.class.php	2011-07-29 14:01:59 UTC (rev 14007)
+++ trunk/src/common/docman/DocumentGroup.class.php	2011-07-29 14:22:06 UTC (rev 14008)
@@ -246,6 +246,7 @@
 			return false;
 		}
 		$this->data_array = db_fetch_array($res);
+		$this->data_array['numberFiles'] = array();
 		db_free_result($res);
 		return true;
 	}
@@ -408,12 +409,18 @@
 	}
 
 	function getNumberOfDocuments($stateId = 1) {
+		if (isset($this->data_array['numberFiles'][$stateId])) {
+			echo "from cache";
+			return $this->data_array['numberFiles'][$stateId];
+		}
+
 		$res = db_query_params('select count(*) from docdata_vw where doc_group = $1 and group_id = $2 and stateid = $3',
 					array($this->getID(), $this->Group->getID(), $stateId));
 		if (!$res) {
 			return 0;
 		}
 		$arr = db_fetch_array($res);
+		$this->data_array['numberFiles'][$stateId] = $arr[0];
 		return $arr[0];
 	}
 

Modified: trunk/src/common/docman/DocumentManager.class.php
===================================================================
--- trunk/src/common/docman/DocumentManager.class.php	2011-07-29 14:01:59 UTC (rev 14007)
+++ trunk/src/common/docman/DocumentManager.class.php	2011-07-29 14:22:06 UTC (rev 14008)
@@ -158,8 +158,8 @@
 					$link = '/docman/?group_id='.$this->Group->getID().'&view='.$linkmenu.'&dirid='.$localDg->getID();
 				}
 				$nbDocsLabel = '';
-				$nbDocs = $localDg->getNumberOfDocuments();
-				if (forge_check_perm('docman', $this->Group->getID(), 'approve'))
+				$nbDocs = $localDg->getNumberOfDocuments($stateId);
+				if ($stateId == 1 && forge_check_perm('docman', $this->Group->getID(), 'approve'))
 					$nbDocsPending = $localDg->getNumberOfDocuments(3);
 
 				if ($nbDocs && (!isset($nbDocsPending) || $nbDocsPending == 0)) {




More information about the Fusionforge-commits mailing list