[Fusionforge-commits] FusionForge branch master updated. e562fe893ee27065bd941f54d5500da401ad135a

Franck VILLAUME nerville at fusionforge.org
Sun May 5 15:20:42 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  e562fe893ee27065bd941f54d5500da401ad135a (commit)
      from  684e9e0884972ad92469099d3c994a8698cb9fad (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 e562fe893ee27065bd941f54d5500da401ad135a
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun May 5 15:20:09 2013 +0200

    patch #536: add control on subject, message and forum name

diff --git a/src/common/forum/Forum.class.php b/src/common/forum/Forum.class.php
index db94fd5..3611cbf 100644
--- a/src/common/forum/Forum.class.php
+++ b/src/common/forum/Forum.class.php
@@ -160,11 +160,11 @@ class Forum extends Error {
 	 * @return	boolean	success.
 	 */
 	function create($forum_name,$description,$send_all_posts_to='',$create_default_message=1) {
-		if (!$this->is_news && strlen($forum_name) < 3) {
+		if (!$this->is_news && strlen(trim($forum_name)) < 3) {
 			$this->setError(_('Forum Name Must Be At Least 3 Characters'));
 			return false;
 		}
-		if (!$this->is_news && strlen($description) < 10) {
+		if (!$this->is_news && strlen(trim($description)) < 10) {
 			$this->setError(_('Forum Description Must Be At Least 10 Characters'));
 			return false;
 		}
diff --git a/src/common/forum/ForumHTML.class.php b/src/common/forum/ForumHTML.class.php
index e694d60..464e02a 100644
--- a/src/common/forum/ForumHTML.class.php
+++ b/src/common/forum/ForumHTML.class.php
@@ -7,6 +7,7 @@
  * Copyright 2010 (c) Franck Villaume - Capgemini
  * Copyright (C) 2010-2012 Alain Peyrat - Alcatel-Lucent
  * Copyright 2013, Franck Villaume - TrivialDev
+ * Copyright 2013, French Ministry of National Education
  * http://fusionforge.org
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -514,7 +515,7 @@ class ForumHTML extends Error {
 			</td><td valign="top">
 			<br />
 		<strong><?php echo _('Subject:'); ?></strong><?php echo utils_requiredField(); ?><br />
-				<input type="text" name="subject" value="<?php echo $subject; ?>" size="80" maxlength="80" />
+				<input type="text" required="required" name="subject" value="<?php echo $subject; ?>" size="80" maxlength="80" />
 		<br />
 		<strong><?php echo _('Message:'); ?></strong><?php echo notepad_button('document.forms.ForumEditForm.body') ?><?php echo utils_requiredField(); ?><br />
 		<?php
@@ -527,7 +528,7 @@ class ForumHTML extends Error {
 		plugin_hook("text_editor",$params);
 		if (!$GLOBALS['editor_was_set_up']) {
 			//if we don't have any plugin for text editor, display a simple textarea edit box
-			echo '<textarea name="body"  rows="10" cols="70">' . $body . '</textarea>';
+			echo '<textarea name="body" required="required" rows="10" cols="70">' . $body . '</textarea>';
 		}
 		unset($GLOBALS['editor_was_set_up']);
 				?>
@@ -579,7 +580,7 @@ function showPostForm($thread_id=0, $is_followup_to=0, $subject="") {
 			</td><td valign="top">
 			<br />
 		<strong><?php echo _('Subject:'); ?></strong><?php echo utils_requiredField(); ?><br />
-				<input type="text" name="subject" value="<?php echo $subject; ?>" size="80" maxlength="80" />
+				<input type="text" required="required" name="subject" value="<?php echo $subject; ?>" size="80" maxlength="80" />
 			<br />
 		<strong><?php echo _('Message:'); ?></strong><?php echo notepad_button('document.forms.ForumPostForm.body') ?><?php echo utils_requiredField(); ?><br />
 
@@ -593,7 +594,7 @@ function showPostForm($thread_id=0, $is_followup_to=0, $subject="") {
 		plugin_hook("text_editor",$params);
 		if (!$GLOBALS['editor_was_set_up']) {
 			//if we don't have any plugin for text editor, display a simple textarea edit box
-					echo '<textarea name="body"  rows="10" cols="70">' . $body . '</textarea>';
+					echo '<textarea name="body" required="required" rows="10" cols="70">' . $body . '</textarea>';
 		}
 		unset($GLOBALS['editor_was_set_up']);
 		?> <?php //$text_support->displayTextField('body'); ?> <br>
diff --git a/src/common/forum/ForumMessage.class.php b/src/common/forum/ForumMessage.class.php
index 106d7cc..1d0cc4c 100644
--- a/src/common/forum/ForumMessage.class.php
+++ b/src/common/forum/ForumMessage.class.php
@@ -5,6 +5,8 @@
  * Copyright 1999-2000, Tim Perdue/Sourceforge
  * Copyright 2002, Tim Perdue/GForge, LLC
  * Copyright 2009, Roland Mas
+ * Copyright 2013, Franck Villaume - TrivialDev
+ * Copyright 2013, French Ministry of National Education
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -351,8 +353,8 @@ class ForumMessage extends Error {
 	 *	@return	boolean success.
 	 */
 	function create($subject, $body, $thread_id='', $is_followup_to='',$has_attach=false, $timestamp = 0) {
-		if (!$body || !$subject) {
-			$this->setError(_('Must Include A Message Body And Subject'));
+		if (!strlen(trim($body)) || !strlen(trim($subject))) {
+			$this->setError(_('Error: a forum message must iclude a message body and a subject.'));
 			return false;
 		}
 		if (!forge_check_perm ('forum', $this->Forum->getID(), 'post')) {
@@ -796,8 +798,11 @@ Or reply to this e-mail entering your response between the following markers:
 	 *	@return boolean success.
 	 */
 	function updatemsg($group_forum_id,$posted_by,$subject,$body,$post_date,$is_followup_to,$thread_id,$has_followups,$most_recent_date) {
+		if (!strlen(trim($body)) || !strlen(trim($subject))) {
+			$this->setError(_('Error: a forum message must include a message body and a subject.'));
+			return false;
+		}
 		$subject = htmlspecialchars($subject);
-		$body = $body;
 		$msg_id = $this->getID();
 		$res = db_query_params ('UPDATE forum
 			SET group_forum_id=$1, posted_by=$2, subject=$3,
diff --git a/src/www/forum/admin/index.php b/src/www/forum/admin/index.php
index 810ea42..d1943be 100644
--- a/src/www/forum/admin/index.php
+++ b/src/www/forum/admin/index.php
@@ -6,6 +6,8 @@
  * Copyright 2002-2004 (c) GForge Team
  * Copyright 2010 (c) Franck Villaume - Capgemini
  * Copyright (C) 2011-2012 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2013, French Ministry of National Education
+ * Copyright 2013, Franck Villaume - TrivialDev
  * http://fusionforge.org/
  *
  * This file is part of FusionForge. FusionForge is free software;
@@ -82,12 +84,16 @@ if (getStringFromRequest('post_changes')) {
 			$feedback .= $fa->ExecuteAction("add_forum");
 			if ($fa->isError()){
 				$error_msg = $fa->getErrorMessage();
+			} else {
+				$g->normalizeAllRoles();
 			}
-			$g->normalizeAllRoles () ;
 		}
 	} elseif (getStringFromRequest('change_status')) {
 		$fa = new ForumAdmin($group_id);
 		$feedback .= $fa->ExecuteAction("change_status");
+		if ($fa->isError()){
+			$error_msg = $fa->getErrorMessage();
+		}
 	}
 }
 
@@ -104,14 +110,14 @@ if (getStringFromRequest('add_forum')) {
 			<input type="hidden" name="add_forum" value="y" />
 			<input type="hidden" name="group_id" value="'.$group_id.'" />
 			<input type="hidden" name="form_key" value="' . form_generate_key() . '" />
-			<strong>'._('Forum Name').':</strong><br />
-			<input type="text" name="forum_name" value="" size="20" maxlength="30" />
+			<strong>'._('Forum Name').':'.utils_requiredField().'</strong><br />
+			<input type="text" name="forum_name" required="required" value="" size="20" maxlength="30" />
 			</p>
 			<p>
-			<strong>'._('Description').':</strong><br />
-			<input type="text" name="description" value="" size="40" maxlength="80" />
+			<strong>'._('Description').':'.utils_requiredField().'</strong><br />
+			<input type="text" name="description" required="required" value="" size="40" maxlength="80" />
 			</p>
-                        <p>
+			<p>
 			<strong>'._('Email All Posts To:').'</strong><br />
 			<input type="text" name="send_all_posts_to" value="" size="60" />
 			</p>
@@ -119,7 +125,7 @@ if (getStringFromRequest('add_forum')) {
 			<input type="submit" name="submit" value="'._('Add This Forum').'" />
 			</p>
 			</form>';
-
+	echo '<span>'.sprintf(_('%s Mandatory fields'), utils_requiredField()).'</span>';
 	forum_footer(array());
 
 } elseif (getStringFromRequest('change_status')) {
@@ -141,16 +147,16 @@ if (getStringFromRequest('add_forum')) {
 				<input type="hidden" name="change_status" value="y" />
 				<input type="hidden" name="group_forum_id" value="'. $f->getID() .'" />
 				<input type="hidden" name="group_id" value="'.$group_id.'" />
-				<strong>'._('Forum Name').':</strong><br />
-				<input type="text" name="forum_name" value="'. $f->getName() .'" size="20" maxlength="30" />
+				<strong>'._('Forum Name').':'.utils_requiredField().'</strong><br />
+				<input type="text" name="forum_name" required="required" value="'. $f->getName() .'" size="20" maxlength="30" />
 				</p>
 				<p>
 				<strong>'._('Email All Posts To:').'</strong><br />
 				<input type="text" name="send_all_posts_to" value="'. $f->getSendAllPostsTo() .'" size="60" />
 				</p>
 				<p>
-				<strong>'._('Description').':</strong><br />
-				<input type="text" name="description" value="'. $f->getDescription() .'" size="60" maxlength="80" /><br />
+				<strong>'._('Description').':'.utils_requiredField().'</strong><br />
+				<input type="text" name="description" required="required" value="'. $f->getDescription() .'" size="60" maxlength="80" /><br />
 				</p>
 				<p>
 				<input type="submit" name="submit" value="'._('Update').'" />
@@ -158,6 +164,7 @@ if (getStringFromRequest('add_forum')) {
 			</form><p>';
 	//echo '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_forum_id='.$group_forum_id.'&delete=1">'._('Delete Message').'</a><br />';
 	echo '<a href="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'&group_forum_id='.$group_forum_id.'&deleteforum=1">'._('Delete entire forum and all content').'</a></p>';
+	echo '<span>'.sprintf(_('%s Mandatory fields'), utils_requiredField()).'</span>';
 	forum_footer(array());
 
 } elseif ($deleteforum && $group_forum_id) {
@@ -200,9 +207,9 @@ if (getStringFromRequest('add_forum')) {
 		// the user cancelled the request, go back to forum
 		//if thread_id is 0, then we came from message.php. else, we came from forum.php
 		if (!$thread_id) {
-            session_redirect('/forum/message.php?msg_id='.$msg_id);
+			session_redirect('/forum/message.php?msg_id='.$msg_id);
 		} else {
-            session_redirect('/forum/forum.php?thread_id='.$thread_id.'&forum_id='.$forum_id);
+			session_redirect('/forum/forum.php?thread_id='.$thread_id.'&forum_id='.$forum_id);
 		}
 		exit;
 	} else {
@@ -262,7 +269,7 @@ if (getStringFromRequest('add_forum')) {
 		if ($fm->updatemsg($forum_id,$posted_by,$subject,$body,$post_date,$is_followup_to,$thread_id,$has_followups,$most_recent_date)) {
 			$feedback .= _('Message Edited Successfully');
 		} else {
-			$error_msg .= $fm->getErrorMessage();
+			session_redirect('/forum/admin/index.php?editmsg='.$msg_id.'&group_id='.$group_id.'&thread_id='.$thread_id.'&forum_id='.$forum_id.'&error_msg='.urlencode($fm->getErrorMessage()));
 		}
 		forum_header(array('title'=>_('Edit a Message')));
 		echo '<p>'.util_make_link ('/forum/forum.php?forum_id=' . $forum_id, _("Return to the forum")) ;
diff --git a/src/www/forum/forum.php b/src/www/forum/forum.php
index d2cedd7..58f3295 100644
--- a/src/www/forum/forum.php
+++ b/src/www/forum/forum.php
@@ -6,6 +6,7 @@
  * Copyright 2002, Tim Perdue - GForge, LLC
  * Copyright 2010-2011, Franck Villaume - Capgemini
  * Copyright (C) 2010-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;
@@ -106,7 +107,7 @@ if ($forum_id) {
 
 		if (!$fm->create($subject, $body, $thread_id, $is_followup_to,$has_attach) || $fm->isError()) {
 			form_release_key(getStringFromRequest("form_key"));
-			exit_error(_('Error creating ForumMessage:').' '.$fm->getErrorMessage(), 'forums');
+			session_redirect('/forum/new.php?forum_id='.$forum_id.'&group_id='.$group_id.'&error_msg='.urlencode($fm->getErrorMessage()));
 		} else {
 			if ($fm->isPending() ) {
 				$feedback = _('Message Queued for moderation -> Please wait until the admin approves/rejects it');
diff --git a/src/www/forum/index.php b/src/www/forum/index.php
index 3c861bc..91fa01e 100644
--- a/src/www/forum/index.php
+++ b/src/www/forum/index.php
@@ -44,7 +44,7 @@ if ($group_id) {
 	$farr = $ff->getForums();
 
 	if ( $farr !== false && count($farr) == 1 ) {
-        session_redirect('/forum/forum.php?forum_id='.$farr[0]->getID());
+         session_redirect('/forum/forum.php?forum_id='.$farr[0]->getID());
 	}
 
 	forum_header(array('title'=>sprintf(_('Forums for %1$s'), $g->getPublicName()) ));

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

Summary of changes:
 src/common/forum/Forum.class.php        |    4 ++--
 src/common/forum/ForumHTML.class.php    |    9 ++++----
 src/common/forum/ForumMessage.class.php |   11 +++++++---
 src/www/forum/admin/index.php           |   35 ++++++++++++++++++-------------
 src/www/forum/forum.php                 |    3 ++-
 src/www/forum/index.php                 |    2 +-
 6 files changed, 39 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list