[Fusionforge-commits] FusionForge branch master updated. 8ef71344aeeb1fc9bac6ff5eec0f73f3f2c78092

Franck VILLAUME nerville at fusionforge.org
Fri May 3 12:15:05 CEST 2013


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  8ef71344aeeb1fc9bac6ff5eec0f73f3f2c78092 (commit)
      from  b243ba998e07511c4024aaf50f6eb355f7030199 (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 8ef71344aeeb1fc9bac6ff5eec0f73f3f2c78092
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Fri May 3 12:14:32 2013 +0200

    patch #542: in advanced search, news belong to news section

diff --git a/src/common/search/ForumsSearchQuery.class.php b/src/common/search/ForumsSearchQuery.class.php
index 308a3d2..6d41564 100644
--- a/src/common/search/ForumsSearchQuery.class.php
+++ b/src/common/search/ForumsSearchQuery.class.php
@@ -5,6 +5,7 @@
  * Copyright 2004, Dominik Haas
  * Copyright 2009, Roland Mas
  * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -129,8 +130,8 @@ class ForumsSearchQuery extends SearchQuery {
 	 * @param $showNonPublic boolean if we should consider non public sections
 	 */
 	static function getSections($groupId, $showNonPublic=false) {
-		$sql = 'SELECT group_forum_id, forum_name FROM forum_group_list WHERE group_id = $1';
-		$sql .= ' ORDER BY forum_name';
+		$sql = 'SELECT group_forum_id, forum_name FROM forum_group_list WHERE group_id = $1 AND ';
+		$sql .= 'group_forum_id NOT IN (SELECT forum_id FROM news_bytes)  ORDER BY forum_name';
 
 		$sections = array();
 		$res = db_query_params ($sql,
diff --git a/src/common/search/NewsSearchQuery.class.php b/src/common/search/NewsSearchQuery.class.php
index ea12b1c..0fc9c9c 100644
--- a/src/common/search/NewsSearchQuery.class.php
+++ b/src/common/search/NewsSearchQuery.class.php
@@ -4,6 +4,7 @@
  *
  * Copyright 2004, Dominik Haas
  * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -85,6 +86,29 @@ class NewsSearchQuery extends SearchQuery {
 		}
 		return $qpa ;
 	}
+		
+	/**
+	 * getSections - returns the list of available forums
+	 *
+	 * @param $groupId int group id
+	 * @param $showNonPublic boolean if we should consider non public sections
+	 */
+	static function getSections($groupId, $showNonPublic=false) {
+
+		// Select survey of the project
+		$sql = 'SELECT group_forum_id, forum_name FROM forum_group_list WHERE group_id = $1 AND ';
+		$sql .= 'group_forum_id IN (SELECT forum_id FROM news_bytes) ORDER BY forum_name';
+
+		$sections = array();
+		$res = db_query_params ($sql,
+					array ($groupId));
+		while($data = db_fetch_array($res)) {
+			if (forge_check_perm('forum',$data['group_forum_id'],'read')) {
+				$sections[$data['group_forum_id']] = $data['forum_name'];
+			}
+		}
+		return $sections;
+	}
 }
 
 // Local Variables:
diff --git a/src/www/search/include/renderers/AdvancedSearchHtmlSearchRenderer.class.php b/src/www/search/include/renderers/AdvancedSearchHtmlSearchRenderer.class.php
index 7b5e655..a894ea8 100644
--- a/src/www/search/include/renderers/AdvancedSearchHtmlSearchRenderer.class.php
+++ b/src/www/search/include/renderers/AdvancedSearchHtmlSearchRenderer.class.php
@@ -3,6 +3,7 @@
  * Search Engine
  *
  * Copyright 2004 (c) Dominik Haas, GForge Team
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -244,7 +245,12 @@ class AdvancedSearchHtmlSearchRenderer extends HtmlGroupSearchRenderer {
 
 		if ($group->usesNews()) {
 			require_once $gfwww.'search/include/renderers/NewsHtmlSearchRenderer.class.php';
-			$sections['short_news'] = true;
+			$undersections = NewsHtmlSearchRenderer::getSections($this->groupId);
+			if(count($undersections) > 0){
+				$sections['short_news'] = $undersections;
+			} else {
+				$sections['short_news'] = true;
+			}
 		}
 
 		if ($group->usesFRS()) {
diff --git a/src/www/search/include/renderers/NewsHtmlSearchRenderer.class.php b/src/www/search/include/renderers/NewsHtmlSearchRenderer.class.php
index 8fb7f4b..61f4ce7 100644
--- a/src/www/search/include/renderers/NewsHtmlSearchRenderer.class.php
+++ b/src/www/search/include/renderers/NewsHtmlSearchRenderer.class.php
@@ -3,6 +3,7 @@
  * Search Engine
  *
  * Copyright 2004 (c) Dominik Haas, GForge Team
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -72,6 +73,17 @@ class NewsHtmlSearchRenderer extends HtmlGroupSearchRenderer {
 		}
 		return $return;
 	}
+	
+	/**
+	 * getSections - get the array of possible sections to search in
+	 *
+	 * @return array sections
+	 */
+	static function getSections($groupId) {
+		$userIsGroupMember = NewsHtmlSearchRenderer::isGroupMember($groupId);
+
+		return NewsSearchQuery::getSections($groupId, $userIsGroupMember);
+	}
 }
 
 // Local Variables:

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

Summary of changes:
 src/common/search/ForumsSearchQuery.class.php      |    5 ++--
 src/common/search/NewsSearchQuery.class.php        |   24 ++++++++++++++++++++
 .../AdvancedSearchHtmlSearchRenderer.class.php     |    8 ++++++-
 .../renderers/NewsHtmlSearchRenderer.class.php     |   12 ++++++++++
 4 files changed, 46 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list