[Fusionforge-commits] r13050 - branches/Branch_5_1/src/www/news/admin

Roland Mas lolando at fusionforge.org
Fri Apr 8 10:51:24 CEST 2011


Author: lolando
Date: 2011-04-08 10:51:23 +0200 (Fri, 08 Apr 2011)
New Revision: 13050

Modified:
   branches/Branch_5_1/src/www/news/admin/index.php
   branches/Branch_5_1/src/www/news/admin/news_admin_utils.php
Log:
Fixed news/admin page for groups.is_public deprecation

Modified: branches/Branch_5_1/src/www/news/admin/index.php
===================================================================
--- branches/Branch_5_1/src/www/news/admin/index.php	2011-04-08 08:17:12 UTC (rev 13049)
+++ branches/Branch_5_1/src/www/news/admin/index.php	2011-04-08 08:51:23 UTC (rev 13050)
@@ -316,7 +316,6 @@
 			WHERE is_approved=0
 			AND news_bytes.group_id=groups.group_id
 			AND post_date > $1
-			AND groups.is_public=1
 			AND groups.status=$2
 			ORDER BY post_date', array ($old_date, 'A')) ;
 

Modified: branches/Branch_5_1/src/www/news/admin/news_admin_utils.php
===================================================================
--- branches/Branch_5_1/src/www/news/admin/news_admin_utils.php	2011-04-08 08:17:12 UTC (rev 13049)
+++ branches/Branch_5_1/src/www/news/admin/news_admin_utils.php	2011-04-08 08:51:23 UTC (rev 13050)
@@ -30,37 +30,45 @@
 
        	// function to show single news item
        	// factored out because called 3 time below
-       	function show_news_item($result,$i,$approved,$selectable) {
+       	function show_news_item($row,$i,$approved,$selectable) {
 	        global $HTML;
 
 		echo '<tr '. $HTML->boxGetAltRowStyle($i) . '><td width="20%">';
        		if ($selectable) {
        			echo '<input type="checkbox" '
        			     .'name="news_id[]" value="'
-       			     .db_result($result, $i, 'id').'" />';
+       			     .$row['id'].'" />';
        		}
-       		echo date(_('Y-m-d'), db_result($result,$i,'post_date')).'</td>
+       		echo date(_('Y-m-d'), $row['post_date']).'</td>
        		<td width="45%">';
        		echo '
-       		<a href="'.getStringFromServer('PHP_SELF').'?approve=1&id='.db_result($result,$i,'id').'">'.db_result($result,$i,'summary').'</a>
+       		<a href="'.getStringFromServer('PHP_SELF').'?approve=1&id='.$row['id'].'">'.$row['summary'].'</a>
        		</td>
 
        		<td width="35%">'
-		.util_make_link_g (db_result($result,$i,'unix_group_name'),db_result($result,$i,'group_id'),db_result($result,$i,'group_name').' ('.db_result($result,$i,'unix_group_name').')')
+		.util_make_link_g ($row['unix_group_name'],$row['group_id'],$row['group_name'].' ('.$row['unix_group_name'].')')
        		.'</td>
        		</tr>'
        		;
        	}
 
-       	$title_arr=array(
+       	$title_arr = array(
        		_('Date'),
        		_('Subject'),
        		_('Project')
        	);
 
-       	$result=db_query_qpa($qpa_pending);
-       	$rows=db_numrows($result);
+	$ra = RoleAnonymous::getInstance() ;
 
+       	$result = db_query_qpa($qpa_pending);
+	$items = array();
+	while ($row_item = db_fetch_array($result)) {
+		if ($ra->hasPermission('project_read', $row_item['group_id'])) {
+			$items[] = $row_item;
+		}
+	}
+       	$rows = count($items);
+
        	echo '<form action="'. getStringFromServer('PHP_SELF') .'" method="post">';
        	echo '<input type="hidden" name="mass_reject" value="1" />';
        	echo '<input type="hidden" name="post_changes" value="y" />';
@@ -72,7 +80,7 @@
        		echo '<h2>'.sprintf(_('These items need to be approved (total: %1$s)'), $rows).'</h2>';
        		echo $GLOBALS['HTML']->listTableTop($title_arr);
        		for ($i=0; $i<$rows; $i++) {
-       			show_news_item($result,$i,false,true);
+       			show_news_item($items[$i],$i,false,true);
        		}
        		echo $GLOBALS['HTML']->listTableBottom();
        		echo '<br /><input type="submit" name="submit" value="'._('Reject Selected').'" />';
@@ -83,8 +91,15 @@
        		Show list of rejected news items for this week
        	*/
 
-       	$result=db_query_qpa($qpa_rejected);
-       	$rows=db_numrows($result);
+       	$result = db_query_qpa($qpa_rejected);
+	$items = array();
+	while ($row_item = db_fetch_array($result)) {
+		if ($ra->hasPermission('project_read', $row_item['group_id'])) {
+			$items[] = $row_item;
+		}
+	}
+       	$rows = count($items);
+
        	if ($rows < 1) {
        		echo '
        			<h2>'._('No rejected items found for this week').'</h2>';
@@ -92,7 +107,7 @@
        		echo '<h2>'.sprintf(_('These items were rejected this past week or were not intended for front page (total: %1$s)'), $rows).'</h2>';
        		echo $GLOBALS['HTML']->listTableTop($title_arr);
        		for ($i=0; $i<$rows; $i++) {
-       			show_news_item($result,$i,false,false);
+       			show_news_item($items[$i],$i,false,true);
        		}
        		echo $GLOBALS['HTML']->listTableBottom();
        	}
@@ -101,8 +116,14 @@
        		Show list of approved news items for this week
        	*/
 
-       	$result=db_query_qpa($qpa_approved);
-       	$rows=db_numrows($result);
+       	$result = db_query_qpa($qpa_approved);
+	$items = array();
+	while ($row_item = db_fetch_array($result)) {
+		if ($ra->hasPermission('project_read', $row_item['group_id'])) {
+			$items[] = $row_item;
+		}
+	}
+       	$rows = count($items);
        	if ($rows < 1) {
        		echo '
        			<h2>'._('No approved items found for this week').'</h2>';
@@ -110,7 +131,7 @@
        		echo '<h2>'.sprintf(_('These items were approved this past week (total: %1$s)'), $rows).'</h2>';
        		echo $GLOBALS['HTML']->listTableTop($title_arr);
        		for ($i=0; $i<$rows; $i++) {
-       			show_news_item($result,$i,true,false);
+       			show_news_item($items[$i],$i,false,true);
        		}
        		echo $GLOBALS['HTML']->listTableBottom();
        	}




More information about the Fusionforge-commits mailing list