[Fusionforge-commits] r13043 - in branches/Branch_5_1/src: common/include www/include www/top

Roland Mas lolando at fusionforge.org
Thu Apr 7 17:18:12 CEST 2011


Author: lolando
Date: 2011-04-07 17:18:11 +0200 (Thu, 07 Apr 2011)
New Revision: 13043

Modified:
   branches/Branch_5_1/src/common/include/FusionForge.class.php
   branches/Branch_5_1/src/common/include/Stats.class.php
   branches/Branch_5_1/src/www/include/features_boxes.php
   branches/Branch_5_1/src/www/top/mostactive.php
   branches/Branch_5_1/src/www/top/toplist.php
Log:
Getting rid of groups.is_public: common/include

Modified: branches/Branch_5_1/src/common/include/FusionForge.class.php
===================================================================
--- branches/Branch_5_1/src/common/include/FusionForge.class.php	2011-04-07 13:26:14 UTC (rev 13042)
+++ branches/Branch_5_1/src/common/include/FusionForge.class.php	2011-04-07 15:18:11 UTC (rev 13043)
@@ -3,7 +3,7 @@
  * FusionForge top-level information
  *
  * Copyright 2002, GForge, LLC
- * Copyright 2009, Roland Mas
+ * Copyright 2009-2011, Roland Mas
  *
  * This file is part of FusionForge.
  *
@@ -42,23 +42,37 @@
 	}
 
 	function getNumberOfPublicHostedProjects() {
-		$res = db_query_params ('SELECT count(*) AS count FROM groups WHERE status=$1 AND is_public=1',
+		$res = db_query_params ('SELECT group_id FROM groups WHERE status=$1',
 				      array ('A'));	
-		if (!$res || db_numrows($res) < 1) {
+		if (!$res) {
 			$this->setError('Unable to get hosted project count: '.db_error());
 			return false;
 		}
-		return $this->parseCount($res);
+		$count = 0;
+		$ra = RoleAnonymous::getInstance() ;
+		while ($row = db_fetch_array($res)) {
+			if ($ra->hasPermission('project_read', $row['group_id'])) {
+				$count++;
+			}
+		}
+		return $count;
 	}
 
 	function getNumberOfHostedProjects() {
-		$res = db_query_params ('SELECT count(*) AS count FROM groups WHERE status=$1',
+		$res = db_query_params ('SELECT group_id FROM groups WHERE status=$1',
 					array ('A'));	
-		if (!$res || db_numrows($res) < 1) {
+		if (!$res) {
 			$this->setError('Unable to get hosted project count: '.db_error());
 			return false;
 		}
-		return $this->parseCount($res);
+		$count = 0;
+		$ra = RoleAnonymous::getInstance() ;
+		while ($row = db_fetch_array($res)) {
+			if ($ra->hasPermission('project_read', $row['group_id'])) {
+				$count++;
+			}
+		}
+		return $count;
 	}
 
 	function getNumberOfActiveUsers() {
@@ -73,16 +87,18 @@
 
 
 	function getPublicProjectNames() {
-		$res = db_query_params ('SELECT unix_group_name FROM groups WHERE status=$1 AND is_public=1 ORDER BY unix_group_name',
+		$res = db_query_params ('SELECT unix_group_name, group_id FROM groups WHERE status=$1 ORDER BY unix_group_name',
 					array ('A'));
 		if (!$res) {
 			$this->setError('Unable to get list of public projects: '.db_error());
 			return false;
 		}
-		$rows=db_numrows($res);
 		$result = array();
-		for ($i=0; $i<$rows; $i++) {
-			$result[$i] = db_result($res, $i, 'unix_group_name');
+		$ra = RoleAnonymous::getInstance() ;
+		while ($row = db_fetch_array($res)) {
+			if ($ra->hasPermission('project_read', $row['group_id'])) {
+				$result[] = $row['unix_group_name'];
+			}
 		}
 		return $result;
 	}

Modified: branches/Branch_5_1/src/common/include/Stats.class.php
===================================================================
--- branches/Branch_5_1/src/common/include/Stats.class.php	2011-04-07 13:26:14 UTC (rev 13042)
+++ branches/Branch_5_1/src/common/include/Stats.class.php	2011-04-07 15:18:11 UTC (rev 13043)
@@ -60,12 +60,12 @@
 	*/
 	function getMostActiveStats($type, $offset) {
 		if ($type == 'week') 	{
-			return db_query_params ('SELECT groups.group_name,groups.unix_group_name,groups.group_id,project_weekly_metric.ranking,project_weekly_metric.percentile FROM groups,project_weekly_metric WHERE groups.group_id=project_weekly_metric.group_id AND groups.is_public=1 AND groups.type_id=1 AND groups.status = $1 AND groups.use_stats=1 ORDER BY ranking ASC',
+			return db_query_params ('SELECT groups.group_name,groups.unix_group_name,groups.group_id,project_weekly_metric.ranking,project_weekly_metric.percentile FROM groups,project_weekly_metric WHERE groups.group_id=project_weekly_metric.group_id AND groups.type_id=1 AND groups.status = $1 AND groups.use_stats=1 ORDER BY ranking ASC',
 						array('A'),
 						0,
 						$offset) ;
 		} else {
-			return db_query_params ('SELECT g.group_name,g.unix_group_name,g.group_id,s.group_ranking as ranking,s.group_metric as percentile FROM groups g,stats_project_all_vw s WHERE g.group_id=s.group_id AND g.is_public=1 AND g.type_id=1 AND g.status = $1 AND g.use_stats=1 AND s.group_ranking > 0 ORDER BY ranking ASC',
+			return db_query_params ('SELECT g.group_name,g.unix_group_name,g.group_id,s.group_ranking as ranking,s.group_metric as percentile FROM groups g,stats_project_all_vw s WHERE g.group_id=s.group_id AND g.type_id=1 AND g.status = $1 AND g.use_stats=1 AND s.group_ranking > 0 ORDER BY ranking ASC',
 						array('A'),
 						0,
 						$offset) ;
@@ -79,7 +79,7 @@
 	* @return a resultset of unix_group_name, group_name, items
 	*/
 	function getTopMessagesPosted() {
-		return db_query_params ('SELECT g.unix_group_name, g.group_name, SUM(s.msg_posted) AS items FROM stats_project s, groups g WHERE s.group_id=g.group_id AND g.is_public=1 AND g.status=$1 GROUP BY g.unix_group_name, g.group_name ORDER BY items DESC',
+		return db_query_params ('SELECT g.unix_group_name, g.group_name, SUM(s.msg_posted) AS items FROM stats_project s, groups g WHERE s.group_id=g.group_id AND g.status=$1 GROUP BY g.unix_group_name, g.group_name ORDER BY items DESC',
 					array ('A'),
 					100) ;
 	}
@@ -91,7 +91,7 @@
 	* @return a resultset of group_name, unix_group_name, items
 	*/
 	function getTopPageViews() {
-		return db_query_params ('SELECT g.group_name, g.unix_group_name, SUM(s.page_views) AS items FROM stats_project_months s, groups g WHERE s.group_id=g.group_id AND g.is_public=1 AND g.status=$1 GROUP BY g.group_name, g.unix_group_name ORDER BY items DESC', 
+		return db_query_params ('SELECT g.group_name, g.unix_group_name, SUM(s.page_views) AS items FROM stats_project_months s, groups g WHERE s.group_id=g.group_id AND g.status=$1 GROUP BY g.group_name, g.unix_group_name ORDER BY items DESC', 
 					array ('A'),
 					100) ;
 	}
@@ -103,7 +103,7 @@
 	* @return a resultset of group_name, unix_group_name, items
 	*/
 	function getTopDownloads() {
-		return db_query_params ('SELECT g.group_name, g.unix_group_name, SUM(frs.downloads) AS items FROM frs_dlstats_grouptotal_vw frs, groups g WHERE g.group_id = frs.group_id AND g.status=$1 AND g.is_public=1 GROUP BY g.group_name, g.unix_group_name ORDER BY items DESC',
+		return db_query_params ('SELECT g.group_name, g.unix_group_name, SUM(frs.downloads) AS items FROM frs_dlstats_grouptotal_vw frs, groups g WHERE g.group_id = frs.group_id AND g.status=$1 GROUP BY g.group_name, g.unix_group_name ORDER BY items DESC',
 					array ('A'),
 					100) ;
 	}

Modified: branches/Branch_5_1/src/www/include/features_boxes.php
===================================================================
--- branches/Branch_5_1/src/www/include/features_boxes.php	2011-04-07 13:26:14 UTC (rev 13042)
+++ branches/Branch_5_1/src/www/include/features_boxes.php	2011-04-07 15:18:11 UTC (rev 13043)
@@ -118,26 +118,13 @@
 
 
 function stats_getprojects_active_public() {
-	$res_count = db_query_params ('SELECT count(*) AS count FROM groups WHERE status=$1 AND is_public=1',
-			array ('A'));
-	if (db_numrows($res_count) > 0) {
-		$row_count = db_fetch_array($res_count);
-		return $row_count['count'];
-	} else {
-		return "error";
-	}
+	$ff = new FusionForge();
+	return $ff->getNumberOfPublicHostedProjects();
 }
 
 function stats_getprojects_total() {
-	$res_count = db_query_params ('SELECT count(*) AS count FROM groups WHERE status=$1 OR status=$2',
-			array('A',
-				'H'));
-	if (db_numrows($res_count) > 0) {
-		$row_count = db_fetch_array($res_count);
-		return $row_count['count'];
-	} else {
-		return "error";
-	}
+	$ff = new FusionForge();
+	return $ff->getNumberOfHostedProjects();
 }
 
 function stats_getpageviews_total() {

Modified: branches/Branch_5_1/src/www/top/mostactive.php
===================================================================
--- branches/Branch_5_1/src/www/top/mostactive.php	2011-04-07 13:26:14 UTC (rev 13042)
+++ branches/Branch_5_1/src/www/top/mostactive.php	2011-04-07 15:18:11 UTC (rev 13043)
@@ -59,6 +59,9 @@
 
 $i=0;
 while ($row_top = db_fetch_array($res_top)) {
+	if (!forge_check_perm ('project_read', $row_top['group_id'])) {
+		continue ;
+	}
 	$i++;
 	print '
 	<tr '. $HTML->boxGetAltRowStyle($i) .'>

Modified: branches/Branch_5_1/src/www/top/toplist.php
===================================================================
--- branches/Branch_5_1/src/www/top/toplist.php	2011-04-07 13:26:14 UTC (rev 13042)
+++ branches/Branch_5_1/src/www/top/toplist.php	2011-04-07 15:18:11 UTC (rev 13043)
@@ -62,6 +62,9 @@
 $display_rank = 0;
 $i=0;
 while ($row_top = db_fetch_array($res_top)) {
+	if (!forge_check_perm ('project_read', $row_top['group_id'])) {
+		continue ;
+	}
 	$i++;
 	if ($row_top["items"] == 0) {
 		continue;




More information about the Fusionforge-commits mailing list