[Fusionforge-commits] r11904 - branches/Branch_5_1/src/www/news

Roland Mas lolando at libremir.placard.fr.eu.org
Tue Dec 28 11:19:00 CET 2010


Author: lolando
Date: 2010-12-28 11:19:00 +0100 (Tue, 28 Dec 2010)
New Revision: 11904

Modified:
   branches/Branch_5_1/src/www/news/submit.php
Log:
Fix news creation without default Site News forum permission (patch [#243] from Sylvain Le Gall)

Modified: branches/Branch_5_1/src/www/news/submit.php
===================================================================
--- branches/Branch_5_1/src/www/news/submit.php	2010-12-28 10:11:23 UTC (rev 11903)
+++ branches/Branch_5_1/src/www/news/submit.php	2010-12-28 10:19:00 UTC (rev 11904)
@@ -91,34 +91,31 @@
 			}
 
 			/*
-				Insert the row into the db if it's a generic message
-				OR this person is an admin for the group involved
+			  create a new discussion forum without a default msg
+			  if one isn't already there
 			*/
-
-	   			/*
-	   				create a new discussion forum without a default msg
-	   				if one isn't already there
-	   			*/
-
-				db_begin();
-				$f=new Forum(group_get_object(forge_get_config('news_group')));
-				if (!$f->create(preg_replace('/[^_\.0-9a-z-]/','-', strtolower($summary)),$details,1,'',0,0)) {
-					db_rollback();
-					exit_error($f->getErrorMessage(),'news');
-				}
-	   			$new_id=$f->getID();
-				$sql='INSERT INTO news_bytes (group_id,submitted_by,is_approved,post_date,forum_id,summary,details) 
+			
+			db_begin();
+			$g=group_get_object(forge_get_config('news_group'));
+			$f=new Forum($g);
+			if (!$f->create(preg_replace('/[^_\.0-9a-z-]/','-', strtolower($summary)),$details,1,'',0,0)) {
+				db_rollback();
+				exit_error($f->getErrorMessage(),'news');
+			}
+			$g->normalizeAllRoles();
+			$new_id=$f->getID();
+			$sql='INSERT INTO news_bytes (group_id,submitted_by,is_approved,post_date,forum_id,summary,details) 
  VALUES ($1, $2, $3, $4, $5, $6, $7)';
-				$result=db_query_params($sql,
-					array($group_id, user_getid(), 0, time(), $new_id, htmlspecialchars($summary), $details));
-				if (!$result) {
-					db_rollback();
-					form_release_key(getStringFromRequest('form_key'));
-					$error_msg = _('ERROR doing insert');
-				} else {
-					db_commit();
-					$feedback = _('News Added.');
-	   			}
+			$result=db_query_params($sql,
+						array($group_id, user_getid(), 0, time(), $new_id, htmlspecialchars($summary), $details));
+			if (!$result) {
+				db_rollback();
+				form_release_key(getStringFromRequest('form_key'));
+				$error_msg = _('ERROR doing insert');
+			} else {
+				db_commit();
+				$feedback = _('News Added.');
+			}
 		} else {
 			form_release_key(getStringFromRequest('form_key'));
 			$error_msg = _('ERROR - both subject and body are required');




More information about the Fusionforge-commits mailing list