[Fusionforge-commits] r11055 - in trunk/src: common/forum www/forum www/forum/admin www/forum/include

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Tue Oct 19 18:31:46 CEST 2010


Author: aljeux
Date: 2010-10-19 18:31:45 +0200 (Tue, 19 Oct 2010)
New Revision: 11055

Added:
   trunk/src/common/forum/AttachManager.class.php
   trunk/src/common/forum/ForumAdmin.class.php
   trunk/src/common/forum/ForumHTML.class.php
Removed:
   trunk/src/www/forum/admin/ForumAdmin.class.php
   trunk/src/www/forum/include/AttachManager.class.php
   trunk/src/www/forum/include/ForumHTML.class.php
Modified:
   trunk/src/www/forum/admin/attachments.php
   trunk/src/www/forum/admin/index.php
   trunk/src/www/forum/admin/monitor.php
   trunk/src/www/forum/admin/pending.php
   trunk/src/www/forum/admin/pendingmsgdetail.php
   trunk/src/www/forum/attachment.php
   trunk/src/www/forum/forum.php
   trunk/src/www/forum/index.php
   trunk/src/www/forum/message.php
   trunk/src/www/forum/monitor.php
   trunk/src/www/forum/myforums.php
   trunk/src/www/forum/new.php
   trunk/src/www/forum/save.php
Log:
Relocate forums libs in common/forums.
No prev/next in forums if not needed.
Warning fixes & SQL commands in upercase.

Copied: trunk/src/common/forum/AttachManager.class.php (from rev 11054, trunk/src/www/forum/include/AttachManager.class.php)
===================================================================
--- trunk/src/common/forum/AttachManager.class.php	                        (rev 0)
+++ trunk/src/common/forum/AttachManager.class.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -0,0 +1,362 @@
+<?php
+
+/**
+ * FusionForge Attachment manager class
+ *
+ * Copyright 1999-2001 (c) VA Linux Systems
+ * The rest Copyright 2002-2005 (c) GForge Team
+ * http://fusionforge.org/
+ *
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* 
+	by Daniel Perez - 2005
+*/
+
+class AttachManager extends Error {
+	
+	var $attachs = array(); //the attached files
+	var $msg_id; //the msg_id that links to the attachs
+	var $user_id,$dateline,$filename,$filedata,$filesize,$visible,$filehash,$posthash;
+	var $messages = array();
+	var $ForumMsg; // The Forum object
+	
+	function Setmsgid($id) {
+		$this->msg_id = $id;
+	}
+	
+	function Getmessages() {
+		return $this->messages;
+	}
+	
+	function fillvalues($user_id,$dateline,$filename,$filedata,$filesize,$visible,$filehash,$posthash) {
+		$this->user_id = $user_id;
+		$this->dateline = $dateline;
+		$this->filename = $filename;
+		$this->filedata = $filedata;
+		$this->visible = $visible;
+		$this->filehash = $filehash;
+		$this->posthash = $posthash;
+	}
+	
+	/**
+	* Function SetForumMsg
+	*
+	* Sets the forum message associated with the attachment
+	*/
+	function SetForumMsg(&$ForumMsg) {
+		$this->ForumMsg =& $ForumMsg;
+	}
+	
+	/**
+	* Function GetAttachId
+	*
+	* Returns the attach id for the message id passed as a parameter or false if error
+	*/
+	function GetAttachId($msg_id) {
+		$res = db_query_params ('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
+			array ($msg_id));
+		if ($res) {
+			return db_result($res,0,0);
+		} else {
+			return false;
+		}
+	}
+	
+	/**
+	* Function PrintHelperFunctions
+	*
+	*
+	* @return 	returns the javascript helper functions
+	*/
+	
+	function PrintHelperFunctions() {
+		return '<script type="text/javascript">
+		
+		function confirmDel() {
+			var agree=confirm("Proceed with deletion? ");
+			if (agree) return true ;
+			else return false ;
+		}
+		
+		function manageattachments(url,del) {
+			var newwindow;
+			if (del=="yes") {
+				if (!confirmDel())
+					return;
+			}
+			newwindow = window.open(url, \'Attach\', \'statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=600,height=480\');
+			if (window.focus) {newwindow.focus()}
+		}
+		</script>';
+	}
+	
+	 /**
+	 * Function PrintAttachLink
+	 *
+	 * @param 	object	The message.
+	 * @param 	int		The group id.
+	 * @param 	int		The forum id.
+	 *
+	 * @return 	returns link to attachment /delete if corresponding; else returns a message about no attachment found
+	 */
+	function PrintAttachLink(&$msg,$group_id,$forum_id) {
+		
+		//ask if the message has an attachment
+		$msg_id = $msg->getID();
+		if ($msg->isPending()) {
+			$res = db_query_params ('SELECT attachmentid,filename,userid,counter FROM forum_pending_attachment where msg_id=$1',
+						array ($msg_id));
+			$pend = "&amp;pending=yes";
+		} else {
+			$res = db_query_params ('SELECT attachmentid,filename,userid,counter FROM forum_attachment where msg_id=$1',
+						array ($msg_id));
+			$pend = "";
+		}
+		
+		$attachid = '';
+		if ($res && db_numrows($res)) {
+			$attachid = db_result($res,0,'attachmentid');
+		}
+		if ($attachid) {
+			$attach = "<br/>
+			<a href=\"javascript:manageattachments('".util_make_url("/forum/attachment.php?attachid=$attachid&amp;group_id=$group_id&amp;forum_id=$forum_id$pend")."','no');\">" . html_image('ic/cfolder15.png',"15","13") . db_result($res,0,'filename') . "</a>  (" . db_result($res,0,'counter') . ") downloads";
+			$attach_userid = db_result($res,0,'userid');
+			
+			$f = $msg->getForum();
+			if (!$f || !is_object($f)) {
+			exit_error('Error', _('Could Not Get Forum Object'));
+			} else {
+				if ( ((user_getid() == $attach_userid)
+				      || (forge_check_perm ('forum_admin', $f->Group->getID())))
+				     && (!$msg->isPending()) ) { //only permit the user who created the attach to delete it, or an admin
+					$attach .= "   <a href=\"javascript:manageattachments('/forum/attachment.php?attachid=$attachid&amp;group_id=$group_id&amp;forum_id=$forum_id&amp;msg_id=$msg_id&amp;edit=yes','no');\">" .  "<font size=\"-3\">" .  html_image('ic/forum_edit.gif','37','15',array('alt'=>_("Edit"))) . "</font></a>";
+					$attach .= "     <a href=\"javascript:manageattachments('/forum/attachment.php?attachid=$attachid&amp;group_id=$group_id&amp;forum_id=$forum_id&amp;delete=yes','yes');\">" .  "<font size=\"-3\">" .  html_image('ic/forum_delete.gif','16','18',array('alt'=>_("Delete"))) . "</font></a>";
+				}
+			}
+		}	else {
+			//add attach for existing message
+			$f = $msg->getForum();
+			if (!$f || !is_object($f)) {
+			exit_error('Error','Could Not Get Forum Object');
+			} else {
+//				$attach = html_image('ic/cfolder15.png',"15","13") . _('No attachment found');
+				$attach = '';
+				if ( ((user_getid() == $msg->getPosterID())
+				      || (forge_check_perm ('forum_admin', $f->Group->getID())))
+				     && (!$msg->isPending()) ) { //only permit the user who created the message to insert an attach
+					$attach .= "   <a href=\"javascript:manageattachments('".util_make_url ("/forum/attachment.php?attachid=0&amp;group_id=$group_id&amp;forum_id=$forum_id&amp;msg_id=$msg_id&amp;edit=yes")."','no');\">" .  "<font size=\"-3\">" .  html_image('ic/forum_add.gif','37','15',array('alt'=>_("Add"))) . "</font></a>";
+				}
+			}
+		}
+		
+		return $attach;
+	}
+	
+	/**
+	 * Function AddToDBOnly : DB Query Only - used for releasing pending messages
+	 *
+	 *
+	 */
+	function AddToDBOnly($userid, $dateline, $filename, $filedata, $filesize, $visible, $filehash, $mimetype) {
+		$result=db_query_params ('SELECT max(msg_id) AS id FROM forum',
+			array());
+		if (!$result || db_numrows($result) < 1) {
+			$this->messages[] = _('Couldn\'t get message id');
+		} else {
+			$this->msg_id = db_result($result,0,0);
+			if (db_query_params ('INSERT INTO forum_attachment (userid, dateline, filename, filedata, filesize, visible, msg_id , filehash, mimetype)
+					VALUES 
+					( $1 , $2, $3,
+					$4, $5, $6, $7,  $8, $9)',
+			array ($userid,
+				$dateline ,
+				$filename ,
+				$filedata ,
+				$filesize,
+				$visible,
+				$this->msg_id,
+				$filehash ,
+				$mimetype  ))) {
+				$this->messages[] = _('File uploaded');
+			}	else {
+				$this->messages[] = _('File not uploaded');
+				$this->setError();
+			}
+		}
+	}
+	
+	
+	
+	/**
+	 * Function attach : saves the file in the DB
+	 *
+	 * @param 	int		The file to attach
+	 * @param 	int		The group.
+	 * @param 	int		Whether we are updating an existing attach (attachid to update or cero for new message (inserts using the hights msg id from forum table)
+	 * @param 	int		msg id. if update is 0 and we pass a msg_id <> 0, then we are adding an attach for an existing msg
+	 *
+	 * @return	int	    Attach id on success, false otherwise
+	 *
+	 */
+	function attach($attach,$group_id,$update=0,$msg_id=0) {
+		global $_FILES;
+
+		$attachment = trim($attach['tmp_name']);
+		$attachment_name = trim($attach['name']);
+		$attachment_size = trim($attach['size']);
+		$attachment_type = trim($attach['type']);
+			
+		if ($attachment == 'none' OR empty($attachment) OR empty($attachment_name))
+		{
+			return false; //no point in continuing if there's no file
+		}
+		
+		$attachment_name2 = strtolower($attachment_name);
+		$extension = substr(strrchr($attachment_name2, '.'), 1);
+		
+		if ($extension == 'exe')
+		{
+			// invalid extension
+			$this->messages[] = _('Invalid Extension');
+
+			@unlink($attachment);
+			return false;
+		}
+		
+		if (!is_uploaded_file($attachment) || !($filestuff = @file_get_contents($attachment)) )
+		{
+			$this->messages[] = _('Error, problem with the attachment file uploaded into the server');
+			return false;
+		}
+		
+		if (!session_loggedin()) {
+			$user_id = 100;
+		}	else {
+			$user_id = user_getid();
+		}
+		
+		$id = 0;
+			
+		if ($this->ForumMsg->isPending()) {
+			if ($update) {
+				//update the fileinfo
+				// not implemented
+			} else {
+				// add to db
+				if ($msg_id!=0) {
+					$this->msg_id = $msg_id;
+				} else {
+					$result=db_query_params ('SELECT max(msg_id) AS id FROM forum_pending_messages',
+			array());
+					if (!$result || db_numrows($result) < 1) {
+						$this->messages[] = _('Couldn\'t get message id');
+						@unlink($attachment);
+						return false;
+					} else {
+						$this->msg_id = db_result($result,0,0);
+					}
+				}
+				$res = db_query_params ('INSERT INTO forum_pending_attachment (userid, dateline, filename, filedata, filesize, visible, msg_id , filehash, mimetype)
+					VALUES 
+					( $1 , $2, $3,
+					$4, $5, 1, $6,  $7, $8)',
+			array ($user_id,
+				time() ,
+				addslashes($attachment_name) ,
+				base64_encode($filestuff) ,
+				$attachment_size,
+				$this->msg_id,
+				addslashes(md5($filestuff)) ,
+				addslashes($attachment_type) ));
+				if ($res) {
+					$this->messages[] = _('File uploaded');
+					$id = db_insertid($res,'forum_pending_attachment','attachmentid');
+				}	else {
+					$this->messages[] = _('File not uploaded');
+				}
+			}
+		} else {
+			if ($update) {
+				//update the fileinfo
+				if (db_query_params ('UPDATE forum_attachment SET dateline = $1 , filedata = $2 ,
+				 filename = $3 , 
+				 filehash = $4 , 
+				 mimetype = $5 ,
+				 counter = 0 ,
+				 filesize = $6 where attachmentid=$7',
+			array (time() ,
+				base64_encode($filestuff) ,
+				addslashes($attachment_name) ,
+				addslashes(md5($filestuff)) ,
+				addslashes($attachment_type) ,
+				$attachment_size ,
+				$update))) {
+					$this->messages[] = _('File uploaded');
+					$this->messages[] = _('File Updated Successfully');
+					$id = $update;
+				}	else {
+					$this->messages[] = _('File not uploaded');
+				}
+			} else {
+				// add to db
+				if ($msg_id!=0) {
+					$this->msg_id = $msg_id;
+				} else {
+					$result=db_query_params ('SELECT max(msg_id) AS id FROM forum_pending_messages',
+			array());
+					if (!$result || db_numrows($result) < 1) {
+						$this->messages[] = _('Couldn\'t get message id');
+						@unlink($attachment);
+						return false;
+					} else {
+						$this->msg_id = db_result($result,0,0);
+					}
+				}
+				$res = db_query_params ('INSERT INTO forum_attachment (userid, dateline, filename, filedata, filesize, visible, msg_id , filehash, mimetype)
+					VALUES 
+					( $1 , $2, $3,
+					$4, $5, 1, $6,  $7, $8)',
+			array ($user_id,
+				time() ,
+				addslashes($attachment_name) ,
+				base64_encode($filestuff) ,
+				$attachment_size,
+				$this->msg_id,
+				addslashes(md5($filestuff)) ,
+				addslashes($attachment_type) ));
+				if ($res) {
+					$this->messages[] = _('File uploaded');
+					$id = db_insertid($res,'forum_attachment','attachmentid');
+				}	else {
+					$this->messages[] = _('File not uploaded');
+				}
+			}
+		}
+		@unlink($attachment);
+		return $id;
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Copied: trunk/src/common/forum/ForumAdmin.class.php (from rev 11054, trunk/src/www/forum/admin/ForumAdmin.class.php)
===================================================================
--- trunk/src/common/forum/ForumAdmin.class.php	                        (rev 0)
+++ trunk/src/common/forum/ForumAdmin.class.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -0,0 +1,515 @@
+<?php
+/**
+ * Forum Admin Class
+ *
+ * Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright 2002-2004 (c) GForge Team
+ * Copyright 2005 (c) Daniel Perez
+ * Copyright 2010 (c) Franck Villaume - Capgemini
+ * http://fusionforge.org/
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class ForumAdmin extends Error {
+	var $group_id;
+	var $p,$g;
+	
+	function ForumAdmin($group_id) {
+		$this->group_id = $group_id; 
+		if ($group_id) {
+			$this->group_id = $group_id;
+			$this->g = group_get_object($group_id);
+			$this->p =& $this->g->getPermission ();
+		}
+	}
+	
+	/**
+	 *  PrintAdminMessageOptions - prints the different administrator options for a message
+	 *
+	 *	@param   integer	The Message ID
+	 *	@param   integer	The Project ID
+	 *	@param   integer	The Thread ID : to return to the message if the user cancels (forumhtml only, not message.php)
+	 *	@param   integer	The Forum ID : to return to the message if the user cancels (forumhtml only, not message.php)
+	 *	@return  The HTML output
+	 */
+	
+	function PrintAdminMessageOptions($msg_id,$group_id,$thread_id=0,$forum_id=0,$return_to_message=0) {
+		
+		$return = '<a href="admin/index.php?movethread=' . $thread_id  . '&amp;msg_id=' . $msg_id . '&amp;group_id=' . $group_id . '&amp;forum_id=' . $forum_id .
+				  '&amp;return_to_message=' . $return_to_message . '">' . html_image('ic/forum_move.gif','37','15',array('alt'=>_('Move thread'))). "</a>";
+
+		// Following code (if ...) is to keep old implementation but need to be cleaned
+		if ($return_to_message) {
+			$thread_id = 0;
+		}
+
+		$return .= '    <a href="admin/index.php?editmsg=' . $msg_id  . '&amp;group_id=' . $group_id .  '&amp;thread_id=' . $thread_id. '&amp;forum_id=' . $forum_id . '">' . html_image('ic/forum_edit.gif','37','15',array('alt'=>_("Edit"))) . "</a>";
+		$return .= '    <a href="admin/index.php?deletemsg=' . $msg_id  . '&amp;group_id=' . $group_id . '&amp;thread_id=' . $thread_id. '&amp;forum_id=' . $forum_id . '">' . html_image('ic/forum_delete.gif','16','18',array('alt'=>_("Delete"))) . "</a>";
+		//		$return .= "<br />";
+		return $return;
+	}
+	
+	
+	/**
+	 *  PrintAdminOptions - prints the different administrator option for the forums (heading).
+	 *
+	 */
+	
+	function PrintAdminOptions() {
+		global $group_id,$forum_id;
+		
+		echo '
+			<p>
+			<a href="index.php?group_id='.$group_id.'&amp;add_forum=1">'._('Add forum').'</a>';
+		echo '
+			| <a href="pending.php?action=view_pending&amp;group_id=' . $group_id . '">' . _('Manage Pending Messages').'</a><br /></p>';
+	}
+	
+	/**
+	 *  PrintAdminOptions - prints the administrator option for an individual forum, to link to the pending messages management
+	 *
+	 *	@param 	int		The Forum ID.
+	 */
+	
+	function PrintAdminPendingOption($forum_id) {
+		echo '
+			<p>
+			<a href="pending.php?action=view_pending&amp;group_id=' . $this->group_id . '&amp;forum_id=' . $forum_id . '">' . _('Manage Pending Messages').'</a><br /></p>';
+	}
+	
+	/**
+	 *  GetPermission - Gets the permission for the user
+	 *
+	 *  @return  object	 The permission
+	 */
+	function &GetPermission() {
+		return $this->p;
+	}
+	
+	/**
+	 *  GetGroupObject - Gets the group object of the forum
+	 *
+	 *  @return  object	 The group obj
+	 */
+	function &GetGroupObject() {
+		return $this->g;
+	}
+	
+	/**
+	 *  isGroupAdmin - checks whether the authorized user is a group admin for the forums. The user must be authenticated
+	 *
+	 */
+	function isGroupAdmin() {
+		return forge_check_perm ('forum_admin', $this->group_id) ;
+	}
+	
+	/**
+	 *  Authorized - authorizes and returns true if the user is authorized for the group, or false.
+	 *
+	 *  @param  string	 The group id.
+	 */
+	
+	function Authorized($group_id) {
+		if (!$group_id) {
+			$this->setGroupIdError();
+			return false;
+		}
+		if (!session_loggedin()) {
+			$this->setPermissionDeniedError();
+			return false;
+		}
+		$this->group_id = $group_id;
+		$this->g = group_get_object($group_id);
+		if (!$this->g || !is_object($this->g) || $this->g->isError()) {
+			$this->setGroupIdError();
+			return false;
+		}
+		$this->p =& $this->g->getPermission ();
+		if (!$this->p || !is_object($this->p) || $this->p->isError()) {
+			$this->setPermissionDeniedError();
+			return false;
+		}
+		return true;
+	}
+	
+	/**
+	 *  ExecuteAction - Executes the action passed as parameter
+	 *
+	 *  @param  string	 action to execute.
+	 */
+	function ExecuteAction ($action) {
+        global $HTML;
+		
+		if ($action == "change_status") { //change a forum
+			$forum_name = getStringFromRequest('forum_name');
+			$description = getStringFromRequest('description');
+			$send_all_posts_to = getStringFromRequest('send_all_posts_to');
+			$allow_anonymous = getIntFromRequest('allow_anonymous');
+			$is_public = getIntFromRequest('is_public');
+			$moderation_level = getIntFromRequest('moderation_level');
+			$group_forum_id = getIntFromRequest('group_forum_id');
+			/*
+				Change a forum
+			*/
+			$f=new Forum($this->g,$group_forum_id);
+			if (!$f || !is_object($f)) {
+				exit_error(_('Error getting Forum'),'forums');
+			} elseif ($f->isError()) {
+				exit_error($f->getErrorMessage(),'forums');
+			}
+
+			session_require_perm ('forum_admin', $f->Group->getID()) ;
+
+			if (!$f->update($forum_name,$description,$allow_anonymous,$is_public,$send_all_posts_to,$moderation_level)) {
+				exit_error($f->getErrorMessage(),'forums');
+			} else {
+				$feedback = _('Forum Info Updated Successfully');
+			}
+			return $feedback;
+		}
+		if ($action == "add_forum") { //add forum
+			$forum_name = getStringFromRequest('forum_name');
+			$description = getStringFromRequest('description');
+			$is_public = getStringFromRequest('is_public');
+			$send_all_posts_to = getStringFromRequest('send_all_posts_to');
+			$allow_anonymous = getStringFromRequest('allow_anonymous');
+			$moderation_level = getIntFromRequest('moderation_level');
+			/*
+				Adding forums to this group
+			*/
+			if (!forge_check_perm ('forum_admin', $this->g->getID())) {
+				form_release_key(getStringFromRequest("form_key"));
+				exit_permission_denied('forums');
+			}
+			$f=new Forum($this->g);
+			if (!$f || !is_object($f)) {
+				form_release_key(getStringFromRequest("form_key"));
+				exit_error(_('Error getting Forum'),'forums');
+			} elseif ($f->isError()) {
+				form_release_key(getStringFromRequest("form_key"));
+				exit_error($f->getErrorMessage(),'forums');
+			}
+			if (!$f->create($forum_name,$description,$is_public,$send_all_posts_to,1,$allow_anonymous,$moderation_level)) {
+				form_release_key(getStringFromRequest("form_key"));
+				exit_error($f->getErrorMessage(),'forums');
+			} else {
+				$feedback = _('Forum created successfully');
+			}
+			return $feedback;
+		}
+		if ($action == "delete") { //Deleting messages or threads
+			$msg_id = getIntFromRequest('deletemsg');
+			$forum_id = getIntFromRequest('forum_id');
+			$f=new Forum($this->g,$forum_id);
+			if (!$f || !is_object($f)) {
+				exit_error(_('Error getting Forum'),'forums');
+			} elseif ($f->isError()) {
+				exit_error($f->getErrorMessage(),'forums');
+			}
+
+			session_require_perm ('forum_admin', $f->Group->getID()) ;
+
+			$fm=new ForumMessage($f,$msg_id);
+			if (!$fm || !is_object($fm)) {
+				exit_error(_('Error Getting ForumMessage'),'forums');
+			} elseif ($fm->isError()) {
+				exit_error($fm->getErrorMessage(),'forums');
+			}
+			$count=$fm->delete();
+			if (!$count || $fm->isError()) {
+				exit_error($fm->getErrorMessage(),'forums');
+			} else {
+				$feedback = sprintf(ngettext('%1$s message deleted', '%1$s messages deleted', $count), $count);
+			}
+			return $feedback;
+		}
+		if ($action == "delete_forum") { //delete the forum
+			/*
+				Deleting entire forum
+			*/
+			$group_forum_id = getIntFromRequest('group_forum_id');
+			$f=new Forum($this->g,$group_forum_id);
+			if (!$f || !is_object($f)) {
+				exit_error(_('Error getting Forum'),'forums');
+			} elseif ($f->isError()) {
+				exit_error($f->getErrorMessage(),'forums');
+			}
+
+			session_require_perm ('forum_admin', $f->Group->getID()) ;
+
+			if (!$f->delete(getStringFromRequest('sure'),getStringFromRequest('really_sure'))) {
+				exit_error($f->getErrorMessage(),'forums');
+			} else {
+				$feedback = _('Successfully Deleted');
+			}
+			return $feedback;
+		}
+		if ($action=="view_pending") {
+			//show the pending messages, awaiting moderation
+			$group_id = $this->group_id;
+			$forum_id = getStringFromRequest("forum_id");
+			if ($this->isGroupAdmin()) {
+				$this->PrintAdminOptions();
+			}
+			$res = db_query_params ('SELECT fgl.forum_name, fgl.group_forum_id FROM forum_group_list fgl, forum_pending_messages fpm WHERE fgl.group_id=$1 AND fpm.group_forum_id = fgl.group_forum_id GROUP BY fgl.forum_name, fgl.group_forum_id',
+						array ($group_id));
+			if (!$res) {
+				echo db_error();
+				return;			
+			}
+			
+			$moderated_forums = array();
+			for ($i=0;$i<db_numrows($res);$i++) {
+				$aux = db_fetch_array($res);
+				$moderated_forums[$aux[1]] = $aux[0];
+			}
+			
+			if (count($moderated_forums)==0) {
+				echo $HTML->feedback(_('No forums are moderated for this group'));
+				forum_footer(array());
+				exit();
+			}
+			if (!$forum_id) {
+				//get the first one
+				$keys = array_keys($moderated_forums);
+				$forum_id = $keys[0];
+			}
+			
+			echo '
+			<script type="text/javascript">
+		
+			function confirmDel() {
+				var agree=confirm("Proceed? Actions are permanent!");
+				if (agree) {
+					return true;
+				} else {
+					return false;
+				}
+			}
+			</script>
+			<form name="pending" action="pending.php" method="post">
+			<input type="hidden" name="action" value="update_pending" />
+			<input type="hidden" name="form_key" value="' . form_generate_key() . '" />
+			<input type="hidden" name="group_id" value="' . getIntFromRequest("group_id") . '" />
+			<input type="hidden" name="forum_id" value="' . $forum_id . '" />
+
+			';
+			
+			echo html_build_select_box_from_assoc($moderated_forums,'forum_id',$forum_id);
+			echo '    <input name="Go" type="submit" value="Go" />';
+			
+			$title = array();
+			$title[] = _('Forum Name');
+			$title[] = _('Message');
+			$title[] = "Action";
+			
+			$res = db_query_params ('SELECT msg_id,subject,pm.group_forum_id,gl.forum_name FROM forum_pending_messages pm, forum_group_list gl WHERE pm.group_forum_id=$1 AND pm.group_forum_id=gl.group_forum_id AND gl.group_forum_id=$2',
+			array ($forum_id,
+				$forum_id));
+			if (!$res) {
+				echo db_error();
+				return;			
+			}
+
+			$options = array("1" => "No action","2" => "Delete","3" => "Release"); //array with the supported actions
+			//i'll make a hidden variable, helps to determine when the user updates the info, which action corresponds to which msgID
+			$ids='';
+			for($i=0;$i<db_numrows($res);$i++) {
+				$ids .= db_result($res,$i,'msg_id') . ",";
+			}
+			
+			$i = 2;
+			echo $HTML->listTableTop($title);
+			while ($onemsg = db_fetch_array($res)) {
+
+				//$url = 'pendingmsgdetail.php?msg_id=' . $onemsg[msg_id];
+				//<a href=\"javascript:msgdetail('$url');\">$onemsg[subject]</a>
+				$url = "http://www.google.com";
+				echo "
+				<tr" . $HTML->boxGetAltRowStyle($i++). ">
+					<td>$onemsg[forum_name]</td>	
+					<td><a href=\"#\" onclick=\"window.open('pendingmsgdetail.php?msg_id=$onemsg[msg_id]&amp;forum_id=$onemsg[group_forum_id]&amp;group_id=$group_id','PendingMessageDetail','width=800,height=600,status=no,resizable=yes');\">$onemsg[subject]</a></td>
+					<td><div align=\"right\">" . html_build_select_box_from_assoc($options,"doaction[]",1) . "</div></td>
+				</tr>";
+			}
+			
+			echo $HTML->listTableBottom();
+			echo '
+			<input type="hidden" name="msgids" value="' . $ids . '" />
+			<p align="right"><input type="submit" onclick="return confirmDel();" name="update" value="' . _('Update') . '" /></p>
+			</form>
+			';
+		}
+		if ($action == "update_pending") {
+			$group_id = getIntFromRequest("group_id");
+			$forum_id = getIntFromRequest("forum_id");
+			$msgids = getStringFromRequest("msgids");//the message ids to update
+			$doaction = getArrayFromRequest("doaction"); //the actions for the messages
+			
+			$msgids = split(",",$msgids);
+			array_pop($msgids);//this last one is empty
+			
+			/*if ($this->isGroupAdmin()) {
+				$this->PrintAdminOptions();
+			}*/
+			
+			$results = array(); //messages
+			for($i=0;$i<count($msgids);$i++) {
+				switch ($doaction[$i]) {
+					case 1 : { 
+						//no action
+						break;
+					}
+					case 2 : { 
+						//delete
+						db_begin();
+						if (!db_query_params ('DELETE FROM forum_pending_attachment WHERE msg_id=$1',
+			array ($msgids[$i]))) {
+							$error_msg .= "DB Error: ". db_error();
+							db_rollback();
+							break;
+						}
+						if (!db_query_params ('DELETE FROM forum_pending_messages WHERE msg_id=$1',
+			array ($msgids[$i]))) {
+							$error_msg .= "DB Error: ". db_error();
+							db_rollback();
+							break;
+						}
+						db_commit();
+						$feedback .= _('Forum deleted');
+						break;
+					}
+					case 3 : { 
+						//release
+						$res1 = db_query_params ('SELECT * FROM forum_pending_messages WHERE msg_id=$1',
+			array ($msgids[$i]));
+						if (!$res1) {
+							$error_msg .= "DB Error: " . db_error();
+							break;
+						}
+						$res2 = db_query_params ('SELECT * FROM forum_pending_attachment WHERE msg_id=$1',
+			array ($msgids[$i]));
+						if (!$res2) {
+							$error_msg .= "DB Error " . db_error();
+							break;
+						}
+						$f = new Forum($this->g,$forum_id);
+						if (!$f || !is_object($f)) {
+							exit_error(_('Error getting new Forum'),'forums');
+						} elseif ($f->isError()) {
+							exit_error($f->getErrorMessage(),'forums');
+						}
+						$fm = new ForumMessage($f); // pending = false
+						if (!$fm || !is_object($fm)) {
+							exit_error(_('Error getting new ForumMessage'),'forums');
+						} elseif ($fm->isError()) {
+							exit_error(_('Error getting new ForumMessage: ').$fm->getErrorMessage(),'forums');
+						}
+						$group_forum_id = db_result($res1,0,"group_forum_id");
+						$subject = db_result($res1,0,"subject");
+						$body = db_result($res1,0,"body");
+						$post_date = db_result($res1,0,"post_date");
+						$thread_id = db_result($res1,0,"thread_id");
+						$is_followup_to = db_result($res1,0,"is_followup_to");
+						$posted_by = db_result($res1,0,"posted_by");
+						$has_followups = db_result($res1,0,"has_followups");
+						$most_recent_date = db_result($res1,0,"most_recent_date");
+						if ($fm->insertreleasedmsg($group_forum_id,$subject, $body,$post_date, $thread_id, $is_followup_to,$posted_by,$has_followups,time())) {
+							$feedback .= "( $subject ) " . _('Pending message released') . "<br />";
+							if (db_numrows($res2)>0) {
+								//if there's an attachment
+								$am = NEW AttachManager();//object that will handle and insert the attachment into the db
+								$am->SetForumMsg($fm);
+								$userid = db_result($res2,0,"userid");
+								$dateline = db_result($res2,0,"dateline");
+								$filename = db_result($res2,0,"filename");
+								$filedata = db_result($res2,0,"filedata");
+								$filesize = db_result($res2,0,"filesize");
+								$visible = db_result($res2,0,"visible");
+								$msg_id = db_result($res2,0,"msg_id");
+								$filehash = db_result($res2,0,"filehash");
+								$mimetype = db_result($res2,0,"mimetype");
+								$am->AddToDBOnly($userid, $dateline, $filename, $filedata, $filesize, $visible, $filehash, $mimetype);
+								foreach ($am->Getmessages() as $item) {
+									$feedback .= "$msg_id - " . $item . "<br />";
+								}
+							}
+							$deleteok = true;
+						} else {
+							if ($fm->isError()) {
+							    if ( $fm->getErrorMessage() == (_('Couldn\'t Update Master Thread parent with current time')) ) {
+							    	//the thread which the message was replying to doesn't exist any more
+							    	$feedback .= "( " . $subject . " ) " . _('The thread which the message was posted to doesn\'t exist anymore, please delete the message.');
+							    } else {
+									$error_msg .= "$msg_id - " . $fm->getErrorMessage();
+							    }
+								$deleteok = false;
+							}
+						}
+								
+						if ( isset($am) && (is_object($am)) ) {
+							//if there was an attach, check if it was uploaded ok
+							 if ((!$am->isError())) {
+								$deleteok = true;
+							 } else {
+							 	//undo the changes to the forum table
+								db_begin();
+								if (!db_query_params ('DELETE FROM forum WHERE msg_id=$1',
+										      array ($fm->getID()))) {
+									$error_msg .= "DB Error ". db_error();
+									db_rollback();
+									break;
+								}
+								db_commit();
+								$deleteok = false;
+							 }
+						}
+						
+						if ($deleteok) {
+							//delete the message and attach
+							db_begin();
+							if (!db_query_params ('DELETE FROM forum_pending_attachment WHERE msg_id=$1',
+			array ($msgids[$i]))) {
+								$error_msg .= "DB Error: ". db_error();
+								db_rollback();
+								break;
+							}
+							if (!db_query_params ('DELETE FROM forum_pending_messages WHERE msg_id=$1',
+			array ($msgids[$i]))) {
+								$error_msg .= "DB Error: ". db_error();
+								db_rollback();
+								break;
+							}
+							db_commit();
+						}
+					}
+				}
+			}
+			html_feedback_top($feedback);
+			$page = 0;
+			$this->ExecuteAction("view_pending");
+		}
+	}
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Copied: trunk/src/common/forum/ForumHTML.class.php (from rev 11054, trunk/src/www/forum/include/ForumHTML.class.php)
===================================================================
--- trunk/src/common/forum/ForumHTML.class.php	                        (rev 0)
+++ trunk/src/common/forum/ForumHTML.class.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -0,0 +1,644 @@
+<?php
+/**
+ * Forums Facility
+ *
+ * Copyright 1999-2001, Tim Perdue - Sourceforge
+ * Copyright 2002, Tim Perdue - GForge, LLC
+ * Copyright 2010 (c) Franck Villaume - Capgemini
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once $gfwww.'include/note.php';
+require_once $gfwww.'include/trove.php';
+require_once $gfwww.'news/news_utils.php';
+require_once $gfcommon.'forum/ForumAdmin.class.php';
+require_once $gfcommon.'forum/AttachManager.class.php';
+
+function forum_header($params) {
+	global $HTML,$group_id,$forum_name,$forum_id,$f,$group_forum_id;
+
+	if ($group_forum_id) {
+		$forum_id=$group_forum_id;
+	}
+	if (!forge_get_config('use_forum')) {
+		exit_disabled();
+	}
+
+	$params['group']=$group_id;
+	$params['toptab']='forums';
+
+	/*
+		bastardization for news
+		Show icon bar unless it's a news forum
+	*/
+	if ($group_id == forge_get_config('news_group')) {
+		//this is a news item, not a regular forum
+		if ($forum_id) {
+			// Show this news item at the top of the page
+			$result = db_query_params ('SELECT submitted_by, post_date, group_id, forum_id, summary, details FROM news_bytes WHERE forum_id=$1',
+						   array ($forum_id));
+
+			// checks which group the news item belongs to
+			$params['group']=db_result($result,0,'group_id');
+			$params['toptab']='news';
+			$HTML->header($params);
+			echo '<h1>' . $params['title'] . '</h1>';
+
+			echo '<table><tr><td valign="top">';
+			if (!$result || db_numrows($result) < 1) {
+				echo '<p class="error">'._('Error - this news item was not found').'</p>';
+			} else {
+				$user = user_get_object(db_result($result,0,'submitted_by'));
+				$group = group_get_object($params['group']);
+				if (!$group || !is_object($group) || $group->isError()) {
+					exit_no_group();
+				}
+				echo '<p>
+				<strong>'._('Posted by').':</strong> '.$user->getRealName().'<br />
+				<strong>'._('Date').':</strong> '. date(_('Y-m-d H:i'),db_result($result,0,'post_date')).'<br />
+				<strong>'._('Summary').':</strong>'.
+					util_make_link ('/forum/forum.php?forum_id='.db_result($result,0,'forum_id').'&amp;group_id='.$group_id,
+							db_result($result,0,'summary')).'<br/>
+				<strong>'._('Project').':</strong>'.
+					util_make_link_g ($group->getUnixName(),db_result($result,0,'group_id'),$group->getPublicName()).'<br />
+				</p>
+				';
+				$body = db_result($result,0,'details');
+				$body = TextSanitizer::purify($body);
+				if (!strstr($body,'<')) {
+					//backwards compatibility for non html messages
+					echo util_make_links(nl2br($body)); 
+				} else {
+					echo util_make_links($body);
+				}
+
+				// display classification
+				if ($params['group'] == forge_get_config('news_group')) { 
+				   print stripslashes(trove_news_getcatlisting(db_result($result,0,'forum_id'),0,1));
+				} elseif (forge_get_config('use_trove')) {
+				   print stripslashes(trove_getcatlisting($params['group'],0,1));
+				}
+			}
+			echo '</td><td valign="top" width="35%">';
+			echo $HTML->boxTop(_('Latest News'));
+			echo news_show_latest($params['group'],5,false);
+			echo $HTML->boxBottom();
+			echo '</td></tr></table>';
+		} else {
+			site_project_header($params);
+			echo '<h1>' . $params['title'] . '</h1>';
+		}
+	} else {
+		site_project_header($params);
+		echo '<h1>' . $params['title'] . '</h1>';
+	}
+
+	$menu_text=array();
+	$menu_links=array();
+
+	if ($f){
+		if ($forum_id) {
+			$menu_text[]=_('Discussion Forums:') .' '. $f->getName();
+			$menu_links[]='/forum/forum.php?forum_id='.$forum_id;
+		}
+		if (forge_check_perm ('forum_admin', $f->Group->getID())) {
+			$menu_text[]=_('Admin');
+			$menu_links[]='/forum/admin/?group_id='.$group_id;
+		} 
+	} else {
+			$gg=&group_get_object($group_id);
+			if (forge_check_perm ('forum_admin', $group_id)) {
+				$menu_text[]=_('Admin');
+				$menu_links[]='/forum/admin/?group_id='.$group_id;
+			}
+	}
+	if (count($menu_text) > 0) {
+		echo $HTML->subMenu(
+			$menu_text,
+			$menu_links
+		);
+	}
+
+	$pluginManager = plugin_manager_get_object();
+	if ($f && $pluginManager->PluginIsInstalled('blocks') && plugin_hook ("blocks", "forum_".$f->getName()))
+		echo '<br />';
+	
+	if (session_loggedin() ) {
+		if ($f) {
+			if ($f->isMonitoring()) {
+				echo util_make_link ('/forum/monitor.php?forum_id='.$forum_id.'&amp;group_id='.$group_id.'&amp;stop=1',
+						     html_image('ic/xmail16w.png','20','20').' '._('Stop Monitoring')).' | ';
+			} else {
+				echo util_make_link ('/forum/monitor.php?forum_id='.$forum_id.'&amp;group_id='.$group_id.'&amp;start=1',
+						     html_image('ic/mail16w.png','20','20').' '._('Monitor Forum')).' | ';
+			}
+			echo util_make_link ('/forum/save.php?forum_id='.$forum_id.'&amp;group_id='.$group_id,
+					     html_image('ic/save.png','24','24') .' '._('Save Place')).' | ';
+		}
+	} elseif ($f) {
+		echo '<a href="/forum/monitor.php?forum_id='.$forum_id.'&amp;group_id='.$group_id.'&amp;start=1">' .
+			html_image('ic/mail16w.png','20','20').' '._('Monitor Forum').'</a> | ';		
+	}
+
+	if ($f && $forum_id) {
+		echo util_make_link ('/forum/new.php?forum_id='.$forum_id.'&amp;group_id='.$group_id,
+				     html_image('ic/write16w.png','20','20',array('alt'=>_('Start New Thread'))) .' '.
+				     _('Start New Thread'));
+	}
+}
+
+function forum_footer($params) {
+	site_project_footer($params);
+}
+
+
+/**
+
+	Wrap many forum functions in this class
+
+**/
+class ForumHTML extends Error {
+	/**
+	 * The Forum object.
+	 *
+	 * @var  object  $Forum
+	 */
+	var $Forum;
+
+	function ForumHTML(&$Forum) {
+		$this->Error();
+		if (!$Forum || !is_object($Forum)) {
+			$this->setError('ForumMessage:: No Valid Forum Object');
+			return false;
+		}
+		if ($Forum->isError()) {
+			$this->setError('ForumMessage:: '.$Forum->getErrorMessage());
+			return false;
+		}
+		$this->Forum =& $Forum;
+		return true;
+	}
+
+
+	/**
+	 * Function showPendingMessage
+	 *
+	 * @param 	object	The message.
+	 *
+	 * @return 	returns the html output
+	 */
+	function showPendingMessage ( &$msg) {
+		global $HTML,$group_id;
+
+		$am = new AttachManager();
+		$ret_val = $am->PrintHelperFunctions();
+		html_feedback_top(_('This is the content of the pending message'));
+		$ret_val .= '
+		<table border="0">
+			<tr>
+				<td class="tablecontent" style="white-space: nowrap;">'._('By:').
+		$msg->getPosterRealName().
+		'<br />
+					';
+		$msgforum =& $msg->getForum();
+		$ret_val .= $am->PrintAttachLink($msg,$group_id,$msgforum->getID()) . '
+					<br />
+					'.
+		html_image('ic/msg.png',"10","12") .
+		$bold_begin. $msg->getSubject() . $bold_end .'&nbsp; '.
+		'<br />'. date(_('Y-m-d H:i'),$msg->getPostDate()) .'
+				</td>
+			</tr>
+			<tr>
+				<td>
+					'.  $msg->getBody() .'
+				</td>
+			</tr>
+		</table>';
+		return $ret_val;
+
+	}
+
+	function showNestedMessage ( &$msg ) {
+		/*
+
+		accepts a database result handle to display a single message
+		in the format appropriate for the nested messages
+
+		*/
+		global $HTML,$group_id;
+		/*
+			See if this message is new or not
+			If so, highlite it in bold
+		*/
+		if ($this->Forum->getSavedDate() < $msg->getPostDate()) {
+			$bold_begin='<strong>';
+			$bold_end='</strong>';
+		} else {
+			$bold_begin = '';
+			$bold_end = '';
+		}
+		$am = new AttachManager();
+		$msgforum =& $msg->getForum();
+		$fa = new ForumAdmin($msgforum->Group->getID());
+		$url = util_make_url('/forum/message.php?msg_id='. $msg->getID() .'&amp;group_id='.$group_id);
+		$ret_val = 		
+		'<table border="0" width="100%" cellspacing="0">
+			<tr>
+				<td class="tablecontent" style="white-space: nowrap;" valign="top">'; 
+
+		$params = array('user_id' => $msg->getPosterID(), 'size' => 's', 'content' => '');
+		plugin_hook_by_reference("user_logo", $params);
+		if ($params['content']) {
+			$ret_val .= $params['content'];
+		}
+
+		$ret_val .= $bold_begin. $msg->getSubject(). ' <a href="'.$url.'">[ '._("reply").' ]</a>'. $bold_end;
+		$ret_val .= '<br/>'._('By:').' '.util_make_link_u ($msg->getPosterName(),$msg->getPosterID(),$msg->getPosterRealName());
+		$ret_val .= ' on '.date('Y-m-d H:i',$msg->getPostDate());
+		$ret_val .= '</td><td class="tablecontent"  align="right">';
+		$ret_val .= '<a href="'.$url.'">[forum:'.$msg->getID().']</a><br/>';
+		if (forge_check_perm ('forum_admin', $msgforum->Group->getID())) {
+			$ret_val .= $fa->PrintAdminMessageOptions($msg->getID(),$group_id,$msg->getThreadID(),$msgforum->getID());
+		} 
+		$ret_val .= $am->PrintAttachLink($msg,$group_id,$msgforum->getID());
+		$ret_val .= '
+				</td>
+			</tr>
+			<tr>
+				<td colspan="2">
+					'; 
+					if (strpos($msg->getBody(),'<') === false) {
+			$ret_val .= nl2br($msg->getBody()); //backwards compatibility for non html messages
+		} else {
+			$ret_val .= $msg->getBody();
+		}
+		$ret_val .= '
+				</td>
+			</tr>
+		</table>';
+		return $ret_val;
+	}
+
+	/**
+	 *  LinkAttachEditForm - Returns the link to the attach form for editing
+	 *
+	 *	@param 		string	Filename
+	 *	@param 		int		group id
+	 *	@param 		int		forum id
+	 *	@param 		int		attach id
+	 *	@param 		int		msg id
+	 *
+	 *	@return		The HTML output
+	 */
+
+	function LinkAttachEditForm($filename,$group_id,$forum_id,$attachid,$msg_id) {
+		$return_val = '
+			
+			<form action="' . getStringFromServer('PHP_SELF') . '" method="post" enctype="multipart/form-data">
+			<table>
+			<tr>
+				<td>' . _('Current File') . ": <span class=\"selected\">" . $filename . '</span></td>
+			</tr>
+			</table>
+			
+			<fieldset class=\"fieldset\">
+			<table>
+					
+					<tr>
+						<td>' . _('Use the "Browse" button to find the file you want to attach') . '</td>
+					</tr>
+					<tr>
+						<td>' . _('File to upload') . ':   <input type="file" name="attachment1"/></td>
+					</tr>
+					<tr>
+						<td class="warning">' . _('Warning: Current file will be deleted permanently') . '</td>
+					</tr>
+			</table>
+			<input type="submit" name="go" value="'._('Update').'">
+			<input type="hidden" name="doedit" value="1"/>
+			<input type="hidden" name="edit" value="yes"/>
+			<input type="hidden" name="forum_id" value="'.$forum_id.'"/>
+			<input type="hidden" name="group_id" value="'.$group_id.'"/>
+			<input type="hidden" name="attachid" value="'.$attachid.'"/>
+			<input type="hidden" name="msg_id" value="'.$msg_id.'"/>
+			</fieldset></form><p>';
+		return $return_val;
+	}
+
+	/**
+	 *  LinkAttachForm - echoes the link to the attach form
+	 *
+	 *	@return		The HTML output echoed
+	 */
+
+	function LinkAttachForm() {
+		$poststarttime = time();
+		$posthash = md5($poststarttime . user_getid() );
+		echo "
+		<fieldset class=\"fieldset\">
+		<table>
+				<tr>
+					<td>" . _('Use the "Browse" button to find the file you want to attach') . "</td>
+				</tr>
+				<tr>
+					<td>" . _('File to upload') . ":   <input type=\"file\" name=\"attachment1\"/></td>
+				</tr>
+		</table>
+		
+		</fieldset>";	
+
+	}
+
+
+	function showNestedMessages ( &$msg_arr, $msg_id ) {
+		global $total_rows;
+
+		$rows=count($msg_arr["$msg_id"]);
+		$ret_val='';
+
+		if ($msg_arr["$msg_id"] && $rows > 0) {
+			$ret_val .= '
+			<ul><li style="list-style: none">';
+
+			/*
+
+			iterate and show the messages in this result
+
+			for each message, recurse to show any submessages
+
+			*/
+			$am = new AttachManager();
+			for ($i=($rows-1); $i >= 0; $i--) {
+				//	  increment the global total count
+				$total_rows++;
+
+				//	  show the actual nested message
+				$ret_val .= $this->showNestedMessage ($msg_arr["$msg_id"][$i]).'<p />';
+
+				if ($msg_arr["$msg_id"][$i]->hasFollowups()) {
+					//	  Call yourself if there are followups
+					$ret_val .= $this->showNestedMessages ( $msg_arr,$msg_arr["$msg_id"][$i]->getID() );
+				}
+			}
+			$ret_val .= '
+			</li></ul>';
+		} else {
+			//$ret_val .= "<p><strong>no messages actually follow up to $msg_id</strong>";
+		}
+
+		return $ret_val;
+	}
+
+	function showSubmessages(&$msg_arr, $msg_id, $level) {
+		/*
+			Recursive. Selects this message's id in this thread,
+			then checks if any messages are nested underneath it.
+			If there are, it calls itself, incrementing $level
+			$level is used for indentation of the threads.
+		*/
+		global $total_rows,$forum_id,$current_message,$group_id;
+
+		if (!isset($msg_arr["$msg_id"]))
+			return "";
+
+		$rows=count($msg_arr["$msg_id"]);
+		$ret_val = "";
+		//echo "<p>ShowSubmessages() $msg_id | $rows";
+		if ($rows > 0) {
+			for ($i=($rows-1); $i >= 0; $i--) {
+				/*
+					Is this row's background shaded or not?
+				*/
+				$total_rows++;
+
+				$ret_val .= '
+					<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($total_rows) .'><td style="white-space: nowrap;">';
+				/*
+					How far should it indent?
+				*/
+				for ($i2=0; $i2<$level; $i2++) {
+					$ret_val .= ' &nbsp; &nbsp; &nbsp; ';
+				}
+
+				/*
+					If it this is the message being displayed, don't show a link to it
+				*/
+				if ($current_message != $msg_arr["$msg_id"][$i]->getID()) {
+					$ah_begin='<a href="'.util_make_url ('/forum/message.php?msg_id='. $msg_arr["$msg_id"][$i]->getID() .'&amp;group_id='.$group_id).'">';
+					$ah_end='</a>';
+				} else {
+					$ah_begin='';
+					$ah_end='';
+				}
+
+				$ret_val .= $ah_begin .
+					html_image('ic/msg.png',"10","12").' ';
+				/*
+					See if this message is new or not
+				*/
+				if ($this->Forum->getSavedDate() < $msg_arr["$msg_id"][$i]->getPostDate()) {
+					$bold_begin='<strong>';
+					$bold_end='</strong>';
+				} else {
+					$bold_begin='';
+					$bold_end='';
+				}
+
+				$ret_val .= $bold_begin.$msg_arr["$msg_id"][$i]->getSubject() .$bold_end.$ah_end.'</td>'.
+					'<td>'.util_make_link_u ($msg_arr["$msg_id"][$i]->getPosterName(),$msg_arr["$msg_id"][$i]->getPosterID(),$msg_arr["$msg_id"][$i]->getPosterRealName()) .'</td>'.
+				'<td>'.date(_('Y-m-d H:i'), $msg_arr["$msg_id"][$i]->getPostDate() ).'</td></tr>';
+
+				if ($msg_arr["$msg_id"][$i]->hasFollowups() > 0) {
+					/*
+						Call yourself, incrementing the level
+					*/
+					$ret_val .= $this->showSubmessages($msg_arr,$msg_arr["$msg_id"][$i]->getID(),($level+1));
+				}
+			}
+		}
+		return $ret_val;
+	}
+
+	/**
+	 *  showEditForm - Prints the form to edit a message
+	 *
+	 *	@param 		int		The Message
+	 *	@return		The HTML output echoed
+	 */
+
+	function showEditForm(&$msg) {
+		$thread_id = $msg->getThreadID();
+		$msg_id = $msg->getID();
+		$posted_by = $msg->getPosterID();
+		$subject = $msg->getSubject();
+		$body = $msg->getBody();
+		$post_date = $msg->getPostDate();
+		$is_followup_to = $msg->getParentID();
+		$has_followups = $msg->hasFollowups();
+		$most_recent_date = $msg->getMostRecentDate();
+		$g =& $this->Forum->getGroup();
+		$group_id = $g->getID();
+
+		if (forge_check_perm ('forum', $this->Forum->getID(), 'post')) { // minor control, but anyways it should be an admin at this point
+			echo notepad_func();
+			?>
+<div align="center">
+	 <form id="ForumEditForm" enctype="multipart/form-data" action="<?php echo util_make_url ('/forum/admin/index.php') ?>" method="post">
+	<?php $objid = $this->Forum->getID();?>
+	<input type="hidden" name="thread_id" value="<?php echo $thread_id; ?>" />
+	<input type="hidden" name="forum_id" value="<?php echo $objid; ?>" />
+	<input type="hidden" name="editmsg" value="<?php echo $msg_id; ?>" />
+	<input type="hidden" name="is_followup_to" value="<?php echo $is_followup_to; ?>" />
+	<input type="hidden" name="form_key" value="<?php echo form_generate_key();?>">
+	<input type="hidden" name="posted_by" value="<?php echo $posted_by;?>">
+	<input type="hidden" name="post_date" value="<?php echo $post_date;?>">
+	<input type="hidden" name="has_followups" value="<?php echo $has_followups;?>">
+	<input type="hidden" name="most_recent_date" value="<?php echo $most_recent_date;?>">
+	<input type="hidden" name="group_id" value="<?php echo $group_id;?>">
+<fieldset class="fieldset">
+			<table><tr><td valign="top">
+			</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" />
+		<br /><br />
+		<strong><?php echo _('Message:'); ?></strong><?php echo notepad_button('document.forms.ForumEditForm.body') ?><?php echo utils_requiredField(); ?><br />
+		<?php
+		$GLOBALS['editor_was_set_up']=false;
+		$params = array() ;
+		$params['body'] = $body;
+		$params['width'] = "800";
+		$params['height'] = "500";
+		$params['group'] = $group_id;
+		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>';
+		}
+		unset($GLOBALS['editor_was_set_up']);
+				?>
+			<br /><br />		
+
+				<p>
+				<?php //$this->LinkAttachForm();?>
+				<p>
+		
+		
+		<?php
+		?>
+		<br />
+		<center><input type="submit" name="ok" value="<?php echo _('Update'); ?>" />
+			<input type="submit" name="cancel" value="<?php echo _('Cancel'); ?>" />
+		</center>
+		</p>
+			</td></tr></table></fieldset>
+</form>
+</div>
+		<?php
+}
+}
+
+function showPostForm($thread_id=0, $is_followup_to=0, $subject="") {
+	global $group_id;
+
+	$body = '';
+	
+	if (forge_check_perm ('forum', $this->Forum->getID(), 'post')) {
+		if ($subject) {
+			//if this is a followup, put a RE: before it if needed
+			if (!preg_match('/RE:/i',$subject,$test)) {
+				$subject ='RE: '.$subject;
+			}
+		}
+		echo notepad_func();
+		?>
+<div align="center">
+<form id="ForumPostForm" enctype="multipart/form-data" action="<?php echo util_make_url ('/forum/forum.php?forum_id='.$this->Forum->getID().'&amp;group_id='.$group_id); ?>" method="post">
+	<?php $objid = $this->Forum->getID();?>
+	<input type="hidden" name="post_message" value="y" />
+	<input type="hidden" name="thread_id" value="<?php echo $thread_id; ?>" />
+	<input type="hidden" name="msg_id" value="<?php echo $is_followup_to; ?>" />
+	<input type="hidden" name="is_followup_to" value="<?php echo $is_followup_to; ?>" />
+	<input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
+			<fieldset class="fieldset"><table><tr><td valign="top">
+			</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" />
+			<br /><br />
+		<strong><?php echo _('Message:'); ?></strong><?php echo notepad_button('document.forms.ForumPostForm.body') ?><?php echo utils_requiredField(); ?><br />
+
+		<?php
+		$GLOBALS['editor_was_set_up']=false;
+		$params = array();
+		$params['body'] = $body;
+		$params['width'] = "800";
+		$params['height'] = "500";
+		$params['group'] = $group_id;
+		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" wrap="soft">' . $body . '</textarea>';
+		}
+		unset($GLOBALS['editor_was_set_up']);
+		?> <?php //$text_support->displayTextField('body'); ?> <br>
+		<br>
+		<!--		<span class="selected"><?php echo _('HTML tags will display in your post as text'); ?></span> -->
+		<p><?php $this->LinkAttachForm();?>
+		
+		
+		<p><?php
+		if (!session_loggedin()) {
+			echo '<span class="highlight">';
+			printf (_('You are posting anonymously because you are not <a href="%1$s">logged in</a>'),util_make_url ('/account/login.php?return_to='. urlencode(getStringFromServer('REQUEST_URI')))) .'</span>';
+		}
+		?> <br />
+		<input type="submit" name="submit"
+			value="<?php echo _('Post Comment'); echo ((!session_loggedin())?' '._('Anonymously'):''); ?>" /><?php
+			echo ((session_loggedin()) ? '&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="monitor" />&nbsp;'._('Receive followups via email').'.' : ''); ?>
+		</p>
+		</td>
+	</tr>
+</table>
+</fieldset>
+</form>
+</div>
+			<?php
+
+} elseif ($this->Forum->allowAnonymous()) {
+	echo '<span class="error">';
+	printf(_('You could post if you were <a href="%1$s">logged in</a>.'), util_make_url ('/account/login.php?return_to='.urlencode(getStringFromServer('REQUEST_URI'))));
+	echo '</span>';
+} elseif (!session_loggedin()) {
+	echo '<span class="error">';
+	printf(_('Please <a href="%1$s">log in</a>'), util_make_url('/account/login.php?return_to='.urlencode(getStringFromServer('REQUEST_URI'))));
+	echo '</span><br/></p>';
+} else {
+	//do nothing
+}
+
+}
+
+}
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>

Deleted: trunk/src/www/forum/admin/ForumAdmin.class.php
===================================================================
--- trunk/src/www/forum/admin/ForumAdmin.class.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/admin/ForumAdmin.class.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -1,517 +0,0 @@
-<?php
-/**
- * Forum Admin Class
- *
- * Copyright 1999-2001 (c) VA Linux Systems
- * Copyright 2002-2004 (c) GForge Team
- * Copyright 2005 (c) Daniel Perez
- * Copyright 2010 (c) Franck Villaume - Capgemini
- * http://fusionforge.org/
- *
- * This file is part of FusionForge.
- *
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * FusionForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-require_once $gfcommon.'include/pre.php';
-
-class ForumAdmin extends Error {
-	var $group_id;
-	var $p,$g;
-	
-	function ForumAdmin($group_id) {
-		$this->group_id = $group_id; 
-		if ($group_id) {
-			$this->group_id = $group_id;
-			$this->g =& group_get_object($group_id);
-			$this->p =& $this->g->getPermission ();
-		}
-	}
-	
-	/**
-	 *  PrintAdminMessageOptions - prints the different administrator options for a message
-	 *
-	 *	@param   integer	The Message ID
-	 *	@param   integer	The Project ID
-	 *	@param   integer	The Thread ID : to return to the message if the user cancels (forumhtml only, not message.php)
-	 *	@param   integer	The Forum ID : to return to the message if the user cancels (forumhtml only, not message.php)
-	 *	@return  The HTML output
-	 */
-	
-	function PrintAdminMessageOptions($msg_id,$group_id,$thread_id=0,$forum_id=0,$return_to_message=0) {
-		
-		$return = '<a href="admin/index.php?movethread=' . $thread_id  . '&amp;msg_id=' . $msg_id . '&amp;group_id=' . $group_id . '&amp;forum_id=' . $forum_id .
-				  '&amp;return_to_message=' . $return_to_message . '">' . html_image('ic/forum_move.gif','37','15',array('alt'=>_('Move thread'))). "</a>";
-
-		// Following code (if ...) is to keep old implementation but need to be cleaned
-		if ($return_to_message) {
-			$thread_id = 0;
-		}
-
-		$return .= '    <a href="admin/index.php?editmsg=' . $msg_id  . '&amp;group_id=' . $group_id .  '&amp;thread_id=' . $thread_id. '&amp;forum_id=' . $forum_id . '">' . html_image('ic/forum_edit.gif','37','15',array('alt'=>_("Edit"))) . "</a>";
-		$return .= '    <a href="admin/index.php?deletemsg=' . $msg_id  . '&amp;group_id=' . $group_id . '&amp;thread_id=' . $thread_id. '&amp;forum_id=' . $forum_id . '">' . html_image('ic/forum_delete.gif','16','18',array('alt'=>_("Delete"))) . "</a>";
-		//		$return .= "<br />";
-		return $return;
-	}
-	
-	
-	/**
-	 *  PrintAdminOptions - prints the different administrator option for the forums (heading).
-	 *
-	 */
-	
-	function PrintAdminOptions() {
-		global $group_id,$forum_id;
-		
-		echo '
-			<p>
-			<a href="index.php?group_id='.$group_id.'&amp;add_forum=1">'._('Add forum').'</a>';
-		echo '
-			| <a href="pending.php?action=view_pending&amp;group_id=' . $group_id . '">' . _('Manage Pending Messages').'</a><br /></p>';
-	}
-	
-	/**
-	 *  PrintAdminOptions - prints the administrator option for an individual forum, to link to the pending messages management
-	 *
-	 *	@param 	int		The Forum ID.
-	 */
-	
-	function PrintAdminPendingOption($forum_id) {
-		echo '
-			<p>
-			<a href="pending.php?action=view_pending&amp;group_id=' . $this->group_id . '&amp;forum_id=' . $forum_id . '">' . _('Manage Pending Messages').'</a><br /></p>';
-	}
-	
-	/**
-	 *  GetPermission - Gets the permission for the user
-	 *
-	 *  @return  object	 The permission
-	 */
-	function &GetPermission() {
-		return $this->p;
-	}
-	
-	/**
-	 *  GetGroupObject - Gets the group object of the forum
-	 *
-	 *  @return  object	 The group obj
-	 */
-	function &GetGroupObject() {
-		return $this->g;
-	}
-	
-	/**
-	 *  isGroupAdmin - checks whether the authorized user is a group admin for the forums. The user must be authenticated
-	 *
-	 */
-	function isGroupAdmin() {
-		return forge_check_perm ('forum_admin', $this->group_id) ;
-	}
-	
-	/**
-	 *  Authorized - authorizes and returns true if the user is authorized for the group, or false.
-	 *
-	 *  @param  string	 The group id.
-	 */
-	
-	function Authorized($group_id) {
-		if (!$group_id) {
-			$this->setGroupIdError();
-			return false;
-		}
-		if (!session_loggedin()) {
-			$this->setPermissionDeniedError();
-			return false;
-		}
-		$this->group_id = $group_id;
-		$this->g =& group_get_object($group_id);
-		if (!$this->g || !is_object($this->g) || $this->g->isError()) {
-			$this->setGroupIdError();
-			return false;
-		}
-		$this->p =& $this->g->getPermission ();
-		if (!$this->p || !is_object($this->p) || $this->p->isError()) {
-			$this->setPermissionDeniedError();
-			return false;
-		}
-		return true;
-	}
-	
-	/**
-	 *  ExecuteAction - Executes the action passed as parameter
-	 *
-	 *  @param  string	 action to execute.
-	 */
-	function ExecuteAction ($action) {
-        global $HTML;
-		
-		if ($action == "change_status") { //change a forum
-			$forum_name = getStringFromRequest('forum_name');
-			$description = getStringFromRequest('description');
-			$send_all_posts_to = getStringFromRequest('send_all_posts_to');
-			$allow_anonymous = getIntFromRequest('allow_anonymous');
-			$is_public = getIntFromRequest('is_public');
-			$moderation_level = getIntFromRequest('moderation_level');
-			$group_forum_id = getIntFromRequest('group_forum_id');
-			/*
-				Change a forum
-			*/
-			$f=new Forum($this->g,$group_forum_id);
-			if (!$f || !is_object($f)) {
-				exit_error(_('Error getting Forum'),'forums');
-			} elseif ($f->isError()) {
-				exit_error($f->getErrorMessage(),'forums');
-			}
-
-			session_require_perm ('forum_admin', $f->Group->getID()) ;
-
-			if (!$f->update($forum_name,$description,$allow_anonymous,$is_public,$send_all_posts_to,$moderation_level)) {
-				exit_error($f->getErrorMessage(),'forums');
-			} else {
-				$feedback = _('Forum Info Updated Successfully');
-			}
-			return $feedback;
-		}
-		if ($action == "add_forum") { //add forum
-			$forum_name = getStringFromRequest('forum_name');
-			$description = getStringFromRequest('description');
-			$is_public = getStringFromRequest('is_public');
-			$send_all_posts_to = getStringFromRequest('send_all_posts_to');
-			$allow_anonymous = getStringFromRequest('allow_anonymous');
-			$moderation_level = getIntFromRequest('moderation_level');
-			/*
-				Adding forums to this group
-			*/
-			if (!forge_check_perm ('forum_admin', $this->g->getID())) {
-				form_release_key(getStringFromRequest("form_key"));
-				exit_permission_denied('forums');
-			}
-			$f=new Forum($this->g);
-			if (!$f || !is_object($f)) {
-				form_release_key(getStringFromRequest("form_key"));
-				exit_error(_('Error getting Forum'),'forums');
-			} elseif ($f->isError()) {
-				form_release_key(getStringFromRequest("form_key"));
-				exit_error($f->getErrorMessage(),'forums');
-			}
-			if (!$f->create($forum_name,$description,$is_public,$send_all_posts_to,1,$allow_anonymous,$moderation_level)) {
-				form_release_key(getStringFromRequest("form_key"));
-				exit_error($f->getErrorMessage(),'forums');
-			} else {
-				$feedback = _('Forum created successfully');
-			}
-			return $feedback;
-		}
-		if ($action == "delete") { //Deleting messages or threads
-			$msg_id = getIntFromRequest('deletemsg');
-			$forum_id = getIntFromRequest('forum_id');
-			$f=new Forum($this->g,$forum_id);
-			if (!$f || !is_object($f)) {
-				exit_error(_('Error getting Forum'),'forums');
-			} elseif ($f->isError()) {
-				exit_error($f->getErrorMessage(),'forums');
-			}
-
-			session_require_perm ('forum_admin', $f->Group->getID()) ;
-
-			$fm=new ForumMessage($f,$msg_id);
-			if (!$fm || !is_object($fm)) {
-				exit_error(_('Error Getting ForumMessage'),'forums');
-			} elseif ($fm->isError()) {
-				exit_error($fm->getErrorMessage(),'forums');
-			}
-			$count=$fm->delete();
-			if (!$count || $fm->isError()) {
-				exit_error($fm->getErrorMessage(),'forums');
-			} else {
-				$feedback = sprintf(ngettext('%1$s message deleted', '%1$s messages deleted', $count), $count);
-			}
-			return $feedback;
-		}
-		if ($action == "delete_forum") { //delete the forum
-			/*
-				Deleting entire forum
-			*/
-			$group_forum_id = getIntFromRequest('group_forum_id');
-			$f=new Forum($this->g,$group_forum_id);
-			if (!$f || !is_object($f)) {
-				exit_error(_('Error getting Forum'),'forums');
-			} elseif ($f->isError()) {
-				exit_error($f->getErrorMessage(),'forums');
-			}
-
-			session_require_perm ('forum_admin', $f->Group->getID()) ;
-
-			if (!$f->delete(getStringFromRequest('sure'),getStringFromRequest('really_sure'))) {
-				exit_error($f->getErrorMessage(),'forums');
-			} else {
-				$feedback = _('Successfully Deleted');
-			}
-			return $feedback;
-		}
-		if ($action=="view_pending") {
-			//show the pending messages, awaiting moderation
-			$group_id = $this->group_id;
-			$forum_id = getStringFromRequest("forum_id");
-			if ($this->isGroupAdmin()) {
-				$this->PrintAdminOptions();
-			}
-			$res = db_query_params ('SELECT fgl.forum_name, fgl.group_forum_id FROM forum_group_list fgl, forum_pending_messages fpm WHERE fgl.group_id=$1 AND fpm.group_forum_id = fgl.group_forum_id GROUP BY fgl.forum_name, fgl.group_forum_id',
-						array ($group_id));
-			if (!$res) {
-				echo db_error();
-				return;			
-			}
-			
-			$moderated_forums = array();
-			for ($i=0;$i<db_numrows($res);$i++) {
-				$aux = db_fetch_array($res);
-				$moderated_forums[$aux[1]] = $aux[0];
-			}
-			
-			if (count($moderated_forums)==0) {
-				echo $HTML->feedback(_('No forums are moderated for this group'));
-				forum_footer(array());
-				exit();
-			}
-			if (!$forum_id) {
-				//get the first one
-				$keys = array_keys($moderated_forums);
-				$forum_id = $keys[0];
-			}
-			
-			echo '
-			<script type="text/javascript">
-		
-			function confirmDel() {
-				var agree=confirm("Proceed? Actions are permanent!");
-				if (agree) {
-					return true;
-				} else {
-					return false;
-				}
-			}
-			</script>
-			<form name="pending" action="pending.php" method="post">
-			<input type="hidden" name="action" value="update_pending" />
-			<input type="hidden" name="form_key" value="' . form_generate_key() . '" />
-			<input type="hidden" name="group_id" value="' . getIntFromRequest("group_id") . '" />
-			<input type="hidden" name="forum_id" value="' . $forum_id . '" />
-
-			';
-			
-			echo html_build_select_box_from_assoc($moderated_forums,'forum_id',$forum_id);
-			echo '    <input name="Go" type="submit" value="Go" />';
-			
-			$title = array();
-			$title[] = _('Forum Name');
-			$title[] = _('Message');
-			$title[] = "Action";
-			
-			$res = db_query_params ('SELECT msg_id,subject,pm.group_forum_id,gl.forum_name FROM forum_pending_messages pm, forum_group_list gl WHERE pm.group_forum_id=$1 AND pm.group_forum_id=gl.group_forum_id AND gl.group_forum_id=$2',
-			array ($forum_id,
-				$forum_id));
-			if (!$res) {
-				echo db_error();
-				return;			
-			}
-
-			$options = array("1" => "No action","2" => "Delete","3" => "Release"); //array with the supported actions
-			//i'll make a hidden variable, helps to determine when the user updates the info, which action corresponds to which msgID
-			$ids='';
-			for($i=0;$i<db_numrows($res);$i++) {
-				$ids .= db_result($res,$i,'msg_id') . ",";
-			}
-			
-			$i = 2;
-			echo $HTML->listTableTop($title);
-			while ($onemsg = db_fetch_array($res)) {
-
-				//$url = 'pendingmsgdetail.php?msg_id=' . $onemsg[msg_id];
-				//<a href=\"javascript:msgdetail('$url');\">$onemsg[subject]</a>
-				$url = "http://www.google.com";
-				echo "
-				<tr" . $HTML->boxGetAltRowStyle($i++). ">
-					<td>$onemsg[forum_name]</td>	
-					<td><a href=\"#\" onclick=\"window.open('pendingmsgdetail.php?msg_id=$onemsg[msg_id]&amp;forum_id=$onemsg[group_forum_id]&amp;group_id=$group_id','PendingMessageDetail','width=800,height=600,status=no,resizable=yes');\">$onemsg[subject]</a></td>
-					<td><div align=\"right\">" . html_build_select_box_from_assoc($options,"doaction[]",1) . "</div></td>
-				</tr>";
-			}
-			
-			echo $HTML->listTableBottom();
-			echo '
-			<input type="hidden" name="msgids" value="' . $ids . '" />
-			<p align="right"><input type="submit" onclick="return confirmDel();" name="update" value="' . _('Update') . '" /></p>
-			</form>
-			';
-		}
-		if ($action == "update_pending") {
-			$group_id = getIntFromRequest("group_id");
-			$forum_id = getIntFromRequest("forum_id");
-			$msgids = getStringFromRequest("msgids");//the message ids to update
-			$doaction = getArrayFromRequest("doaction"); //the actions for the messages
-			
-			$msgids = split(",",$msgids);
-			array_pop($msgids);//this last one is empty
-			
-			/*if ($this->isGroupAdmin()) {
-				$this->PrintAdminOptions();
-			}*/
-			
-			$results = array(); //messages
-			for($i=0;$i<count($msgids);$i++) {
-				switch ($doaction[$i]) {
-					case 1 : { 
-						//no action
-						break;
-					}
-					case 2 : { 
-						//delete
-						db_begin();
-						if (!db_query_params ('DELETE FROM forum_pending_attachment WHERE msg_id=$1',
-			array ($msgids[$i]))) {
-							$error_msg .= "DB Error: ". db_error();
-							db_rollback();
-							break;
-						}
-						if (!db_query_params ('DELETE FROM forum_pending_messages WHERE msg_id=$1',
-			array ($msgids[$i]))) {
-							$error_msg .= "DB Error: ". db_error();
-							db_rollback();
-							break;
-						}
-						db_commit();
-						$feedback .= _('Forum deleted');
-						break;
-					}
-					case 3 : { 
-						//release
-						$res1 = db_query_params ('SELECT * FROM forum_pending_messages WHERE msg_id=$1',
-			array ($msgids[$i]));
-						if (!$res1) {
-							$error_msg .= "DB Error: " . db_error();
-							break;
-						}
-						$res2 = db_query_params ('SELECT * FROM forum_pending_attachment WHERE msg_id=$1',
-			array ($msgids[$i]));
-						if (!$res2) {
-							$error_msg .= "DB Error " . db_error();
-							break;
-						}
-						$f = new Forum($this->g,$forum_id);
-						if (!$f || !is_object($f)) {
-							exit_error(_('Error getting new Forum'),'forums');
-						} elseif ($f->isError()) {
-							exit_error($f->getErrorMessage(),'forums');
-						}
-						$fm = new ForumMessage($f); // pending = false
-						if (!$fm || !is_object($fm)) {
-							exit_error(_('Error getting new ForumMessage'),'forums');
-						} elseif ($fm->isError()) {
-							exit_error(_('Error getting new ForumMessage: ').$fm->getErrorMessage(),'forums');
-						}
-						$group_forum_id = db_result($res1,0,"group_forum_id");
-						$subject = db_result($res1,0,"subject");
-						$body = db_result($res1,0,"body");
-						$post_date = db_result($res1,0,"post_date");
-						$thread_id = db_result($res1,0,"thread_id");
-						$is_followup_to = db_result($res1,0,"is_followup_to");
-						$posted_by = db_result($res1,0,"posted_by");
-						$has_followups = db_result($res1,0,"has_followups");
-						$most_recent_date = db_result($res1,0,"most_recent_date");
-						if ($fm->insertreleasedmsg($group_forum_id,$subject, $body,$post_date, $thread_id, $is_followup_to,$posted_by,$has_followups,time())) {
-							$feedback .= "( $subject ) " . _('Pending message released') . "<br />";
-							if (db_numrows($res2)>0) {
-								//if there's an attachment
-								$am = NEW AttachManager();//object that will handle and insert the attachment into the db
-								$am->SetForumMsg($fm);
-								$userid = db_result($res2,0,"userid");
-								$dateline = db_result($res2,0,"dateline");
-								$filename = db_result($res2,0,"filename");
-								$filedata = db_result($res2,0,"filedata");
-								$filesize = db_result($res2,0,"filesize");
-								$visible = db_result($res2,0,"visible");
-								$msg_id = db_result($res2,0,"msg_id");
-								$filehash = db_result($res2,0,"filehash");
-								$mimetype = db_result($res2,0,"mimetype");
-								$am->AddToDBOnly($userid, $dateline, $filename, $filedata, $filesize, $visible, $filehash, $mimetype);
-								foreach ($am->Getmessages() as $item) {
-									$feedback .= "$msg_id - " . $item . "<br />";
-								}
-							}
-							$deleteok = true;
-						} else {
-							if ($fm->isError()) {
-							    if ( $fm->getErrorMessage() == (_('Couldn\'t Update Master Thread parent with current time')) ) {
-							    	//the thread which the message was replying to doesn't exist any more
-							    	$feedback .= "( " . $subject . " ) " . _('The thread which the message was posted to doesn\'t exist anymore, please delete the message.');
-							    } else {
-									$error_msg .= "$msg_id - " . $fm->getErrorMessage();
-							    }
-								$deleteok = false;
-							}
-						}
-								
-						if ( isset($am) && (is_object($am)) ) {
-							//if there was an attach, check if it was uploaded ok
-							 if ((!$am->isError())) {
-								$deleteok = true;
-							 } else {
-							 	//undo the changes to the forum table
-								db_begin();
-								if (!db_query_params ('DELETE FROM forum WHERE msg_id=$1',
-										      array ($fm->getID()))) {
-									$error_msg .= "DB Error ". db_error();
-									db_rollback();
-									break;
-								}
-								db_commit();
-								$deleteok = false;
-							 }
-						}
-						
-						if ($deleteok) {
-							//delete the message and attach
-							db_begin();
-							if (!db_query_params ('DELETE FROM forum_pending_attachment WHERE msg_id=$1',
-			array ($msgids[$i]))) {
-								$error_msg .= "DB Error: ". db_error();
-								db_rollback();
-								break;
-							}
-							if (!db_query_params ('DELETE FROM forum_pending_messages WHERE msg_id=$1',
-			array ($msgids[$i]))) {
-								$error_msg .= "DB Error: ". db_error();
-								db_rollback();
-								break;
-							}
-							db_commit();
-						}
-					}
-				}
-			}
-			html_feedback_top($feedback);
-			$page = 0;
-			$this->ExecuteAction("view_pending");
-		}
-	}
-}
-
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End:
-
-?>

Modified: trunk/src/www/forum/admin/attachments.php
===================================================================
--- trunk/src/www/forum/admin/attachments.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/admin/attachments.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -26,8 +26,8 @@
 
 require_once('../../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
-require_once $gfwww.'forum/admin/ForumAdmin.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumAdmin.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/ForumMessageFactory.class.php';

Modified: trunk/src/www/forum/admin/index.php
===================================================================
--- trunk/src/www/forum/admin/index.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/admin/index.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -26,9 +26,9 @@
 
 require_once('../../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
-require_once $gfwww.'forum/admin/ForumAdmin.class.php';
+require_once $gfcommon.'forum/ForumAdmin.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/ForumMessageFactory.class.php';
 require_once $gfcommon.'forum/ForumMessage.class.php';
@@ -48,7 +48,7 @@
 //
 //  Set up local objects
 //
-$g =& group_get_object($group_id);
+$g = group_get_object($group_id);
 if (!$g || !is_object($g) || $g->isError()) {
 	exit_no_group();
 }

Modified: trunk/src/www/forum/admin/monitor.php
===================================================================
--- trunk/src/www/forum/admin/monitor.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/admin/monitor.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -26,9 +26,9 @@
 
 require_once('../../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
-require_once $gfwww.'forum/admin/ForumAdmin.class.php';
+require_once $gfcommon.'forum/ForumAdmin.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/ForumMessageFactory.class.php';
 require_once $gfcommon.'forum/ForumMessage.class.php';

Modified: trunk/src/www/forum/admin/pending.php
===================================================================
--- trunk/src/www/forum/admin/pending.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/admin/pending.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -27,11 +27,11 @@
 
 require_once('../../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
-require_once $gfwww.'forum/admin/ForumAdmin.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumAdmin.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 require_once $gfcommon.'forum/ForumMessage.class.php';
-require_once $gfwww.'forum/include/AttachManager.class.php'; //attachent manager
+require_once $gfcommon.'forum/AttachManager.class.php'; //attachent manager
 
 $action = getStringFromRequest('action');
 $group_id = getIntFromRequest('group_id');

Modified: trunk/src/www/forum/admin/pendingmsgdetail.php
===================================================================
--- trunk/src/www/forum/admin/pendingmsgdetail.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/admin/pendingmsgdetail.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -26,8 +26,8 @@
 
 require_once('../../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
-require_once $gfwww.'forum/admin/ForumAdmin.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumAdmin.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 require_once $gfcommon.'forum/ForumMessage.class.php';
 

Modified: trunk/src/www/forum/attachment.php
===================================================================
--- trunk/src/www/forum/attachment.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/attachment.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -32,7 +32,7 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 
 
 /**
@@ -66,7 +66,7 @@
 	exit_missing_param();
 }
 
-$g =& group_get_object($group_id);
+$g = group_get_object($group_id);
 if (!$g || !is_object($g) || $g->isError()) {
 	exit_no_group();
 }
@@ -95,7 +95,7 @@
 		goodbye(_('You cannot delete this attachment'));
 	}	else {
 		if (!$pending) {
-			if (db_query_params ('DELETE FROM forum_attachment where attachmentid=$1',
+			if (db_query_params ('DELETE FROM forum_attachment WHERE attachmentid=$1',
 			array($attachid))) {
 				goodbye(_('Attachment deleted'));
 			} else {
@@ -181,10 +181,10 @@
 }
 
 if ($pending=="yes") {
-	$res = db_query_params ('SELECT * FROM forum_pending_attachment where attachmentid=$1',
+	$res = db_query_params ('SELECT * FROM forum_pending_attachment WHERE attachmentid=$1',
 			array ($attachid));
 } else {
-	$res = db_query_params ('SELECT * FROM forum_attachment where attachmentid=$1',
+	$res = db_query_params ('SELECT * FROM forum_attachment WHERE attachmentid=$1',
 			array ($attachid));
 }
 if ( (!$res) ) {
@@ -228,7 +228,7 @@
 flush();
 //increase the attach count
 if (!$pending) { //we don't care for the pending attach counter, it's just for administrative purposes
-	db_query_params ('UPDATE forum_attachment set counter=counter+1 where attachmentid=$1',
+	db_query_params ('UPDATE forum_attachment SET counter=counter+1 WHERE attachmentid=$1',
 			array($attachid));
 }
 

Modified: trunk/src/www/forum/forum.php
===================================================================
--- trunk/src/www/forum/forum.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/forum.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -25,12 +25,12 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/ForumMessageFactory.class.php';
 require_once $gfcommon.'forum/ForumMessage.class.php';
-require_once $gfwww.'forum/include/AttachManager.class.php'; //attachent manager
+require_once $gfcommon.'forum/AttachManager.class.php'; //attachent manager
 require_once $gfcommon.'include/TextSanitizer.class.php'; // to make the HTML input by the user safe to store
 
 $forum_id = getIntFromRequest('forum_id');
@@ -58,7 +58,7 @@
 	//
 	//	Set up local objects
 	//
-	$g =& group_get_object($group_id);
+	$g = group_get_object($group_id);
 	if (!$g || !is_object($g) || $g->isError()) {
 		exit_no_group();
 	}
@@ -373,28 +373,30 @@
 	/*
 		This code puts the nice next/prev.
 	*/
-	$ret_val .= '<table width="100%" border="0">
-		<tr class="tablecontent"><td width="50%">';
-	if ($offset != 0) {
-		$ret_val .= '<span class="prev">
-		<a href="javascript:history.back()"><strong>' .
-			html_image('t2.png',"15","15") ._('Newer Messages').'</strong></a></span>';
-	} else {
-		$ret_val .= '&nbsp;';
-	}
+	if (($offset != 0) or ($avail_rows > $max_rows)) {
+		$ret_val .= '<table width="100%" border="0">
+			<tr class="tablecontent"><td width="50%">';
+		if ($offset != 0) {
+			$ret_val .= '<span class="prev">
+			<a href="javascript:history.back()"><strong>' .
+				html_image('t2.png',"15","15") ._('Newer Messages').'</strong></a></span>';
+		} else {
+			$ret_val .= '&nbsp;';
+		}
 
-	$ret_val .= '</td><td>&nbsp;</td><td align="right" width="50%">';
+		$ret_val .= '</td><td>&nbsp;</td><td align="right" width="50%">';
 
-	if ($avail_rows > $max_rows) {
-		$ret_val .= '<span class="next">
-		<a href="'.util_make_url ('/forum/forum.php?max_rows='.$max_rows.'&amp;style='.$style.'&amp;offset='.($offset+$i).
-					  '&amp;forum_id='.$forum_id.'&amp;group_id='.$group_id).'">
-		<strong> '._('Older Messages') .
-			html_image('t.png',"15","15") . '</strong></a></span>';
-	} else {
-		$ret_val .= '&nbsp;';
+		if ($avail_rows > $max_rows) {
+			$ret_val .= '<span class="next">
+			<a href="'.util_make_url ('/forum/forum.php?max_rows='.$max_rows.'&amp;style='.$style.'&amp;offset='.($offset+$i).
+						  '&amp;forum_id='.$forum_id.'&amp;group_id='.$group_id).'">
+			<strong> '._('Older Messages') .
+				html_image('t.png',"15","15") . '</strong></a></span>';
+		} else {
+			$ret_val .= '&nbsp;';
+		}
+		$ret_val .= '</td></tr></table>';
 	}
-	$ret_val .= '</td></tr></table>';
 
 	echo $ret_val;
 /*

Deleted: trunk/src/www/forum/include/AttachManager.class.php
===================================================================
--- trunk/src/www/forum/include/AttachManager.class.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/include/AttachManager.class.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -1,363 +0,0 @@
-<?php
-
-/**
- * FusionForge Attachment manager class
- *
- * Copyright 1999-2001 (c) VA Linux Systems
- * The rest Copyright 2002-2005 (c) GForge Team
- * http://fusionforge.org/
- *
- *
- * This file is part of FusionForge.
- *
- * FusionForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * FusionForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FusionForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/* 
-	by Daniel Perez - 2005
-*/
-
-require_once $gfcommon.'include/pre.php';
-
-class AttachManager extends Error {
-	
-	var $attachs = array(); //the attached files
-	var $msg_id; //the msg_id that links to the attachs
-	var $user_id,$dateline,$filename,$filedata,$filesize,$visible,$filehash,$posthash;
-	var $messages = array();
-	var $ForumMsg; // The Forum object
-	
-	function Setmsgid($id) {
-		$this->msg_id = $id;
-	}
-	
-	function Getmessages() {
-		return $this->messages;
-	}
-	
-	function fillvalues($user_id,$dateline,$filename,$filedata,$filesize,$visible,$filehash,$posthash) {
-		$this->user_id = $user_id;
-		$this->dateline = $dateline;
-		$this->filename = $filename;
-		$this->filedata = $filedata;
-		$this->visible = $visible;
-		$this->filehash = $filehash;
-		$this->posthash = $posthash;
-	}
-	
-	/**
-	* Function SetForumMsg
-	*
-	* Sets the forum message associated with the attachment
-	*/
-	function SetForumMsg(&$ForumMsg) {
-		$this->ForumMsg =& $ForumMsg;
-	}
-	
-	/**
-	* Function GetAttachId
-	*
-	* Returns the attach id for the message id passed as a parameter or false if error
-	*/
-	function GetAttachId($msg_id) {
-		$res = db_query_params ('SELECT attachmentid FROM forum_attachment WHERE msg_id=$1',
-			array ($msg_id));
-		if ($res) {
-			return db_result($res,0,0);
-		} else {
-			return false;
-		}
-	}
-	
-	/**
-	* Function PrintHelperFunctions
-	*
-	*
-	* @return 	returns the javascript helper functions
-	*/
-	
-	function PrintHelperFunctions() {
-		return '<script type="text/javascript">
-		
-		function confirmDel() {
-			var agree=confirm("Proceed with deletion? ");
-			if (agree) return true ;
-			else return false ;
-		}
-		
-		function manageattachments(url,del) {
-			var newwindow;
-			if (del=="yes") {
-				if (!confirmDel())
-					return;
-			}
-			newwindow = window.open(url, \'Attach\', \'statusbar=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,width=600,height=480\');
-			if (window.focus) {newwindow.focus()}
-		}
-		</script>';
-	}
-	
-	 /**
-	 * Function PrintAttachLink
-	 *
-	 * @param 	object	The message.
-	 * @param 	int		The group id.
-	 * @param 	int		The forum id.
-	 *
-	 * @return 	returns link to attachment /delete if corresponding; else returns a message about no attachment found
-	 */
-	function PrintAttachLink(&$msg,$group_id,$forum_id) {
-		
-		//ask if the message has an attachment
-		$msg_id = $msg->getID();
-		if ($msg->isPending()) {
-			$res = db_query_params ('SELECT attachmentid,filename,userid,counter FROM forum_pending_attachment where msg_id=$1',
-						array ($msg_id));
-			$pend = "&amp;pending=yes";
-		} else {
-			$res = db_query_params ('SELECT attachmentid,filename,userid,counter FROM forum_attachment where msg_id=$1',
-						array ($msg_id));
-			$pend = "";
-		}
-		
-		if ($res) {
-			$attachid = db_result($res,0,'attachmentid');
-		}
-		if ($attachid) {
-			$attach = "<br/>
-			<a href=\"javascript:manageattachments('".util_make_url("/forum/attachment.php?attachid=$attachid&amp;group_id=$group_id&amp;forum_id=$forum_id$pend")."','no');\">" . html_image('ic/cfolder15.png',"15","13") . db_result($res,0,'filename') . "</a>  (" . db_result($res,0,'counter') . ") downloads";
-			$attach_userid = db_result($res,0,'userid');
-			
-			$f = $msg->getForum();
-			if (!$f || !is_object($f)) {
-			exit_error('Error', _('Could Not Get Forum Object'));
-			} else {
-				if ( ((user_getid() == $attach_userid)
-				      || (forge_check_perm ('forum_admin', $f->Group->getID())))
-				     && (!$msg->isPending()) ) { //only permit the user who created the attach to delete it, or an admin
-					$attach .= "   <a href=\"javascript:manageattachments('/forum/attachment.php?attachid=$attachid&amp;group_id=$group_id&amp;forum_id=$forum_id&amp;msg_id=$msg_id&amp;edit=yes','no');\">" .  "<font size=\"-3\">" .  html_image('ic/forum_edit.gif','37','15',array('alt'=>_("Edit"))) . "</font></a>";
-					$attach .= "     <a href=\"javascript:manageattachments('/forum/attachment.php?attachid=$attachid&amp;group_id=$group_id&amp;forum_id=$forum_id&amp;delete=yes','yes');\">" .  "<font size=\"-3\">" .  html_image('ic/forum_delete.gif','16','18',array('alt'=>_("Delete"))) . "</font></a>";
-				}
-			}
-		}	else {
-			//add attach for existing message
-			$f = $msg->getForum();
-			if (!$f || !is_object($f)) {
-			exit_error('Error','Could Not Get Forum Object');
-			} else {
-//				$attach = html_image('ic/cfolder15.png',"15","13") . _('No attachment found');
-				$attach = '';
-				if ( ((user_getid() == $msg->getPosterID())
-				      || (forge_check_perm ('forum_admin', $f->Group->getID())))
-				     && (!$msg->isPending()) ) { //only permit the user who created the message to insert an attach
-					$attach .= "   <a href=\"javascript:manageattachments('".util_make_url ("/forum/attachment.php?attachid=0&amp;group_id=$group_id&amp;forum_id=$forum_id&amp;msg_id=$msg_id&amp;edit=yes")."','no');\">" .  "<font size=\"-3\">" .  html_image('ic/forum_add.gif','37','15',array('alt'=>_("Add"))) . "</font></a>";
-				}
-			}
-		}
-		
-		return $attach;
-	}
-	
-	/**
-	 * Function AddToDBOnly : DB Query Only - used for releasing pending messages
-	 *
-	 *
-	 */
-	function AddToDBOnly($userid, $dateline, $filename, $filedata, $filesize, $visible, $filehash, $mimetype) {
-		$result=db_query_params ('SELECT max(msg_id) AS id FROM forum',
-			array());
-		if (!$result || db_numrows($result) < 1) {
-			$this->messages[] = _('Couldn\'t get message id');
-		} else {
-			$this->msg_id = db_result($result,0,0);
-			if (db_query_params ('INSERT INTO forum_attachment (userid, dateline, filename, filedata, filesize, visible, msg_id , filehash, mimetype)
-					VALUES 
-					( $1 , $2, $3,
-					$4, $5, $6, $7,  $8, $9)',
-			array ($userid,
-				$dateline ,
-				$filename ,
-				$filedata ,
-				$filesize,
-				$visible,
-				$this->msg_id,
-				$filehash ,
-				$mimetype  ))) {
-				$this->messages[] = _('File uploaded');
-			}	else {
-				$this->messages[] = _('File not uploaded');
-				$this->setError();
-			}
-		}
-	}
-	
-	
-	
-	/**
-	 * Function attach : saves the file in the DB
-	 *
-	 * @param 	int		The file to attach
-	 * @param 	int		The group.
-	 * @param 	int		Whether we are updating an existing attach (attachid to update or cero for new message (inserts using the hights msg id from forum table)
-	 * @param 	int		msg id. if update is 0 and we pass a msg_id <> 0, then we are adding an attach for an existing msg
-	 *
-	 * @return	int	    Attach id on success, false otherwise
-	 *
-	 */
-	function attach($attach,$group_id,$update=0,$msg_id=0) {
-		global $_FILES;
-
-		$attachment = trim($attach['tmp_name']);
-		$attachment_name = trim($attach['name']);
-		$attachment_size = trim($attach['size']);
-		$attachment_type = trim($attach['type']);
-			
-		if ($attachment == 'none' OR empty($attachment) OR empty($attachment_name))
-		{
-			return false; //no point in continuing if there's no file
-		}
-		
-		$attachment_name2 = strtolower($attachment_name);
-		$extension = substr(strrchr($attachment_name2, '.'), 1);
-		
-		if ($extension == 'exe')
-		{
-			// invalid extension
-			$this->messages[] = _('Invalid Extension');
-
-			@unlink($attachment);
-			return false;
-		}
-		
-		if (!is_uploaded_file($attachment) || !($filestuff = @file_get_contents($attachment)) )
-		{
-			$this->messages[] = _('Error, problem with the attachment file uploaded into the server');
-			return false;
-		}
-		
-		if (!session_loggedin()) {
-			$user_id = 100;
-		}	else {
-			$user_id = user_getid();
-		}
-		
-		$id = 0;
-			
-		if ($this->ForumMsg->isPending()) {
-			if ($update) {
-				//update the fileinfo
-				// not implemented
-			} else {
-				// add to db
-				if ($msg_id!=0) {
-					$this->msg_id = $msg_id;
-				} else {
-					$result=db_query_params ('SELECT max(msg_id) AS id FROM forum_pending_messages',
-			array());
-					if (!$result || db_numrows($result) < 1) {
-						$this->messages[] = _('Couldn\'t get message id');
-						@unlink($attachment);
-						return false;
-					} else {
-						$this->msg_id = db_result($result,0,0);
-					}
-				}
-				$res = db_query_params ('INSERT INTO forum_pending_attachment (userid, dateline, filename, filedata, filesize, visible, msg_id , filehash, mimetype)
-					VALUES 
-					( $1 , $2, $3,
-					$4, $5, 1, $6,  $7, $8)',
-			array ($user_id,
-				time() ,
-				addslashes($attachment_name) ,
-				base64_encode($filestuff) ,
-				$attachment_size,
-				$this->msg_id,
-				addslashes(md5($filestuff)) ,
-				addslashes($attachment_type) ));
-				if ($res) {
-					$this->messages[] = _('File uploaded');
-					$id = db_insertid($res,'forum_pending_attachment','attachmentid');
-				}	else {
-					$this->messages[] = _('File not uploaded');
-				}
-			}
-		} else {
-			if ($update) {
-				//update the fileinfo
-				if (db_query_params ('UPDATE forum_attachment SET dateline = $1 , filedata = $2 ,
-				 filename = $3 , 
-				 filehash = $4 , 
-				 mimetype = $5 ,
-				 counter = 0 ,
-				 filesize = $6 where attachmentid=$7',
-			array (time() ,
-				base64_encode($filestuff) ,
-				addslashes($attachment_name) ,
-				addslashes(md5($filestuff)) ,
-				addslashes($attachment_type) ,
-				$attachment_size ,
-				$update))) {
-					$this->messages[] = _('File uploaded');
-					$this->messages[] = _('File Updated Successfully');
-					$id = $update;
-				}	else {
-					$this->messages[] = _('File not uploaded');
-				}
-			} else {
-				// add to db
-				if ($msg_id!=0) {
-					$this->msg_id = $msg_id;
-				} else {
-					$result=db_query_params ('SELECT max(msg_id) AS id FROM forum_pending_messages',
-			array());
-					if (!$result || db_numrows($result) < 1) {
-						$this->messages[] = _('Couldn\'t get message id');
-						@unlink($attachment);
-						return false;
-					} else {
-						$this->msg_id = db_result($result,0,0);
-					}
-				}
-				$res = db_query_params ('INSERT INTO forum_attachment (userid, dateline, filename, filedata, filesize, visible, msg_id , filehash, mimetype)
-					VALUES 
-					( $1 , $2, $3,
-					$4, $5, 1, $6,  $7, $8)',
-			array ($user_id,
-				time() ,
-				addslashes($attachment_name) ,
-				base64_encode($filestuff) ,
-				$attachment_size,
-				$this->msg_id,
-				addslashes(md5($filestuff)) ,
-				addslashes($attachment_type) ));
-				if ($res) {
-					$this->messages[] = _('File uploaded');
-					$id = db_insertid($res,'forum_attachment','attachmentid');
-				}	else {
-					$this->messages[] = _('File not uploaded');
-				}
-			}
-		}
-		@unlink($attachment);
-		return $id;
-	}
-}
-
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End:
-
-?>

Deleted: trunk/src/www/forum/include/ForumHTML.class.php
===================================================================
--- trunk/src/www/forum/include/ForumHTML.class.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/include/ForumHTML.class.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -1,646 +0,0 @@
-<?php
-/**
- * Forums Facility
- *
- * Copyright 1999-2001, Tim Perdue - Sourceforge
- * Copyright 2002, Tim Perdue - GForge, LLC
- * Copyright 2010 (c) Franck Villaume - Capgemini
- * http://fusionforge.org
- *
- * This file is part of FusionForge. FusionForge is free software;
- * you can redistribute it and/or modify it under the terms of the
- * GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the Licence, or (at your option)
- * any later version.
- *
- * FusionForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with FusionForge; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'include/note.php';
-require_once $gfwww.'include/trove.php';
-require_once $gfwww.'news/news_utils.php';
-require_once $gfwww.'forum/admin/ForumAdmin.class.php';
-require_once $gfwww.'forum/include/AttachManager.class.php';
-
-function forum_header($params) {
-	global $HTML,$group_id,$forum_name,$forum_id,$f,$group_forum_id;
-
-	if ($group_forum_id) {
-		$forum_id=$group_forum_id;
-	}
-	if (!forge_get_config('use_forum')) {
-		exit_disabled();
-	}
-
-	$params['group']=$group_id;
-	$params['toptab']='forums';
-
-	/*
-		bastardization for news
-		Show icon bar unless it's a news forum
-	*/
-	if ($group_id == forge_get_config('news_group')) {
-		//this is a news item, not a regular forum
-		if ($forum_id) {
-			// Show this news item at the top of the page
-			$result = db_query_params ('SELECT submitted_by, post_date, group_id, forum_id, summary, details FROM news_bytes WHERE forum_id=$1',
-						   array ($forum_id));
-
-			// checks which group the news item belongs to
-			$params['group']=db_result($result,0,'group_id');
-			$params['toptab']='news';
-			$HTML->header($params);
-			echo '<h1>' . $params['title'] . '</h1>';
-
-
-			echo '<table><tr><td valign="top">';
-			if (!$result || db_numrows($result) < 1) {
-				echo '<p class="error">'._('Error - this news item was not found').'</p>';
-			} else {
-				$user = user_get_object(db_result($result,0,'submitted_by'));
-				$group =& group_get_object($params['group']);
-				if (!$group || !is_object($group) || $group->isError()) {
-					exit_no_group();
-				}
-				echo '<p>
-				<strong>'._('Posted by').':</strong> '.$user->getRealName().'<br />
-				<strong>'._('Date').':</strong> '. date(_('Y-m-d H:i'),db_result($result,0,'post_date')).'<br />
-				<strong>'._('Summary').':</strong>'.
-					util_make_link ('/forum/forum.php?forum_id='.db_result($result,0,'forum_id').'&amp;group_id='.$group_id,
-							db_result($result,0,'summary')).'<br/>
-				<strong>'._('Project').':</strong>'.
-					util_make_link_g ($group->getUnixName(),db_result($result,0,'group_id'),$group->getPublicName()).'<br />
-				</p>
-				';
-				$body = db_result($result,0,'details');
-				$body = TextSanitizer::purify($body);
-				if (!strstr($body,'<')) {
-					//backwards compatibility for non html messages
-					echo util_make_links(nl2br($body)); 
-				} else {
-					echo util_make_links($body);
-				}
-
-				// display classification
-				if ($params['group'] == forge_get_config('news_group')) { 
-				   print stripslashes(trove_news_getcatlisting(db_result($result,0,'forum_id'),0,1));
-				} elseif (forge_get_config('use_trove')) {
-				   print stripslashes(trove_getcatlisting($params['group'],0,1));
-				}
-			}
-			echo '</td><td valign="top" width="35%">';
-			echo $HTML->boxTop(_('Latest News'));
-			echo news_show_latest($params['group'],5,false);
-			echo $HTML->boxBottom();
-			echo '</td></tr></table>';
-		} else {
-			site_project_header($params);
-			echo '<h1>' . $params['title'] . '</h1>';
-		}
-	} else {
-		site_project_header($params);
-		echo '<h1>' . $params['title'] . '</h1>';
-	}
-
-	$menu_text=array();
-	$menu_links=array();
-
-	if ($f){
-		if ($forum_id) {
-			$menu_text[]=_('Discussion Forums:') .' '. $f->getName();
-			$menu_links[]='/forum/forum.php?forum_id='.$forum_id;
-		}
-		if (forge_check_perm ('forum_admin', $f->Group->getID())) {
-			$menu_text[]=_('Admin');
-			$menu_links[]='/forum/admin/?group_id='.$group_id;
-		} 
-	} else {
-			$gg=&group_get_object($group_id);
-			if (forge_check_perm ('forum_admin', $group_id)) {
-				$menu_text[]=_('Admin');
-				$menu_links[]='/forum/admin/?group_id='.$group_id;
-			}
-	}
-	if (count($menu_text) > 0) {
-		echo $HTML->subMenu(
-			$menu_text,
-			$menu_links
-		);
-	}
-
-	$pluginManager = plugin_manager_get_object();
-	if ($f && $pluginManager->PluginIsInstalled('blocks') && plugin_hook ("blocks", "forum_".$f->getName()))
-		echo '<br />';
-	
-	if (session_loggedin() ) {
-		if ($f) {
-			if ($f->isMonitoring()) {
-				echo util_make_link ('/forum/monitor.php?forum_id='.$forum_id.'&amp;group_id='.$group_id.'&amp;stop=1',
-						     html_image('ic/xmail16w.png','20','20').' '._('Stop Monitoring')).' | ';
-			} else {
-				echo util_make_link ('/forum/monitor.php?forum_id='.$forum_id.'&amp;group_id='.$group_id.'&amp;start=1',
-						     html_image('ic/mail16w.png','20','20').' '._('Monitor Forum')).' | ';
-			}
-			echo util_make_link ('/forum/save.php?forum_id='.$forum_id.'&amp;group_id='.$group_id,
-					     html_image('ic/save.png','24','24') .' '._('Save Place')).' | ';
-		}
-	} elseif ($f) {
-		echo '<a href="/forum/monitor.php?forum_id='.$forum_id.'&amp;group_id='.$group_id.'&amp;start=1">' .
-			html_image('ic/mail16w.png','20','20').' '._('Monitor Forum').'</a> | ';		
-	}
-
-	if ($f && $forum_id) {
-		echo util_make_link ('/forum/new.php?forum_id='.$forum_id.'&amp;group_id='.$group_id,
-				     html_image('ic/write16w.png','20','20',array('alt'=>_('Start New Thread'))) .' '.
-				     _('Start New Thread'));
-	}
-}
-
-function forum_footer($params) {
-	site_project_footer($params);
-}
-
-
-/**
-
-	Wrap many forum functions in this class
-
-**/
-class ForumHTML extends Error {
-	/**
-	 * The Forum object.
-	 *
-	 * @var  object  $Forum
-	 */
-	var $Forum;
-
-	function ForumHTML(&$Forum) {
-		$this->Error();
-		if (!$Forum || !is_object($Forum)) {
-			$this->setError('ForumMessage:: No Valid Forum Object');
-			return false;
-		}
-		if ($Forum->isError()) {
-			$this->setError('ForumMessage:: '.$Forum->getErrorMessage());
-			return false;
-		}
-		$this->Forum =& $Forum;
-		return true;
-	}
-
-
-	/**
-	 * Function showPendingMessage
-	 *
-	 * @param 	object	The message.
-	 *
-	 * @return 	returns the html output
-	 */
-	function showPendingMessage ( &$msg) {
-		global $HTML,$group_id;
-
-		$am = new AttachManager();
-		$ret_val = $am->PrintHelperFunctions();
-		html_feedback_top(_('This is the content of the pending message'));
-		$ret_val .= '
-		<table border="0">
-			<tr>
-				<td class="tablecontent" style="white-space: nowrap;">'._('By:').
-		$msg->getPosterRealName().
-		'<br />
-					';
-		$msgforum =& $msg->getForum();
-		$ret_val .= $am->PrintAttachLink($msg,$group_id,$msgforum->getID()) . '
-					<br />
-					'.
-		html_image('ic/msg.png',"10","12") .
-		$bold_begin. $msg->getSubject() . $bold_end .'&nbsp; '.
-		'<br />'. date(_('Y-m-d H:i'),$msg->getPostDate()) .'
-				</td>
-			</tr>
-			<tr>
-				<td>
-					'.  $msg->getBody() .'
-				</td>
-			</tr>
-		</table>';
-		return $ret_val;
-
-	}
-
-	function showNestedMessage ( &$msg ) {
-		/*
-
-		accepts a database result handle to display a single message
-		in the format appropriate for the nested messages
-
-		*/
-		global $HTML,$group_id;
-		/*
-			See if this message is new or not
-			If so, highlite it in bold
-		*/
-		if ($this->Forum->getSavedDate() < $msg->getPostDate()) {
-			$bold_begin='<strong>';
-			$bold_end='</strong>';
-		} else {
-			$bold_begin = '';
-			$bold_end = '';
-		}
-		$am = new AttachManager();
-		$msgforum =& $msg->getForum();
-		$fa = new ForumAdmin($msgforum->Group->getID());
-		$url = util_make_url('/forum/message.php?msg_id='. $msg->getID() .'&amp;group_id='.$group_id);
-		$ret_val = 		
-		'<table border="0" width="100%" cellspacing="0">
-			<tr>
-				<td class="tablecontent" style="white-space: nowrap;" valign="top">'; 
-
-		$params = array('user_id' => $msg->getPosterID(), 'size' => 's', 'content' => '');
-		plugin_hook_by_reference("user_logo", $params);
-		if ($params['content']) {
-			$ret_val .= $params['content'];
-		}
-
-		$ret_val .= $bold_begin. $msg->getSubject(). ' <a href="'.$url.'">[ '._("reply").' ]</a>'. $bold_end;
-		$ret_val .= '<br/>'._('By:').' '.util_make_link_u ($msg->getPosterName(),$msg->getPosterID(),$msg->getPosterRealName());
-		$ret_val .= ' on '.date('Y-m-d H:i',$msg->getPostDate());
-		$ret_val .= '</td><td class="tablecontent"  align="right">';
-		$ret_val .= '<a href="'.$url.'">[forum:'.$msg->getID().']</a><br/>';
-		if (forge_check_perm ('forum_admin', $msgforum->Group->getID())) {
-			$ret_val .= $fa->PrintAdminMessageOptions($msg->getID(),$group_id,$msg->getThreadID(),$msgforum->getID());
-		} 
-		$ret_val .= $am->PrintAttachLink($msg,$group_id,$msgforum->getID());
-		$ret_val .= '
-				</td>
-			</tr>
-			<tr>
-				<td colspan="2">
-					'; 
-					if (strpos($msg->getBody(),'<') === false) {
-			$ret_val .= nl2br($msg->getBody()); //backwards compatibility for non html messages
-		} else {
-			$ret_val .= $msg->getBody();
-		}
-		$ret_val .= '
-				</td>
-			</tr>
-		</table>';
-		return $ret_val;
-	}
-
-	/**
-	 *  LinkAttachEditForm - Returns the link to the attach form for editing
-	 *
-	 *	@param 		string	Filename
-	 *	@param 		int		group id
-	 *	@param 		int		forum id
-	 *	@param 		int		attach id
-	 *	@param 		int		msg id
-	 *
-	 *	@return		The HTML output
-	 */
-
-	function LinkAttachEditForm($filename,$group_id,$forum_id,$attachid,$msg_id) {
-		$return_val = '
-			
-			<form action="' . getStringFromServer('PHP_SELF') . '" method="post" enctype="multipart/form-data">
-			<table>
-			<tr>
-				<td>' . _('Current File') . ": <span class=\"selected\">" . $filename . '</span></td>
-			</tr>
-			</table>
-			
-			<fieldset class=\"fieldset\">
-			<table>
-					
-					<tr>
-						<td>' . _('Use the "Browse" button to find the file you want to attach') . '</td>
-					</tr>
-					<tr>
-						<td>' . _('File to upload') . ':   <input type="file" name="attachment1"/></td>
-					</tr>
-					<tr>
-						<td class="warning">' . _('Warning: Current file will be deleted permanently') . '</td>
-					</tr>
-			</table>
-			<input type="submit" name="go" value="'._('Update').'">
-			<input type="hidden" name="doedit" value="1"/>
-			<input type="hidden" name="edit" value="yes"/>
-			<input type="hidden" name="forum_id" value="'.$forum_id.'"/>
-			<input type="hidden" name="group_id" value="'.$group_id.'"/>
-			<input type="hidden" name="attachid" value="'.$attachid.'"/>
-			<input type="hidden" name="msg_id" value="'.$msg_id.'"/>
-			</fieldset></form><p>';
-		return $return_val;
-	}
-
-	/**
-	 *  LinkAttachForm - echoes the link to the attach form
-	 *
-	 *	@return		The HTML output echoed
-	 */
-
-	function LinkAttachForm() {
-		$poststarttime = time();
-		$posthash = md5($poststarttime . user_getid() );
-		echo "
-		<fieldset class=\"fieldset\">
-		<table>
-				<tr>
-					<td>" . _('Use the "Browse" button to find the file you want to attach') . "</td>
-				</tr>
-				<tr>
-					<td>" . _('File to upload') . ":   <input type=\"file\" name=\"attachment1\"/></td>
-				</tr>
-		</table>
-		
-		</fieldset>";	
-
-	}
-
-
-	function showNestedMessages ( &$msg_arr, $msg_id ) {
-		global $total_rows;
-
-		$rows=count($msg_arr["$msg_id"]);
-		$ret_val='';
-
-		if ($msg_arr["$msg_id"] && $rows > 0) {
-			$ret_val .= '
-			<ul><li style="list-style: none">';
-
-			/*
-
-			iterate and show the messages in this result
-
-			for each message, recurse to show any submessages
-
-			*/
-			$am = new AttachManager();
-			for ($i=($rows-1); $i >= 0; $i--) {
-				//	  increment the global total count
-				$total_rows++;
-
-				//	  show the actual nested message
-				$ret_val .= $this->showNestedMessage ($msg_arr["$msg_id"][$i]).'<p />';
-
-				if ($msg_arr["$msg_id"][$i]->hasFollowups()) {
-					//	  Call yourself if there are followups
-					$ret_val .= $this->showNestedMessages ( $msg_arr,$msg_arr["$msg_id"][$i]->getID() );
-				}
-			}
-			$ret_val .= '
-			</li></ul>';
-		} else {
-			//$ret_val .= "<p><strong>no messages actually follow up to $msg_id</strong>";
-		}
-
-		return $ret_val;
-	}
-
-	function showSubmessages(&$msg_arr, $msg_id, $level) {
-		/*
-			Recursive. Selects this message's id in this thread,
-			then checks if any messages are nested underneath it.
-			If there are, it calls itself, incrementing $level
-			$level is used for indentation of the threads.
-		*/
-		global $total_rows,$forum_id,$current_message,$group_id;
-
-		if (!isset($msg_arr["$msg_id"]))
-			return "";
-
-		$rows=count($msg_arr["$msg_id"]);
-		$ret_val = "";
-		//echo "<p>ShowSubmessages() $msg_id | $rows";
-		if ($rows > 0) {
-			for ($i=($rows-1); $i >= 0; $i--) {
-				/*
-					Is this row's background shaded or not?
-				*/
-				$total_rows++;
-
-				$ret_val .= '
-					<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($total_rows) .'><td style="white-space: nowrap;">';
-				/*
-					How far should it indent?
-				*/
-				for ($i2=0; $i2<$level; $i2++) {
-					$ret_val .= ' &nbsp; &nbsp; &nbsp; ';
-				}
-
-				/*
-					If it this is the message being displayed, don't show a link to it
-				*/
-				if ($current_message != $msg_arr["$msg_id"][$i]->getID()) {
-					$ah_begin='<a href="'.util_make_url ('/forum/message.php?msg_id='. $msg_arr["$msg_id"][$i]->getID() .'&amp;group_id='.$group_id).'">';
-					$ah_end='</a>';
-				} else {
-					$ah_begin='';
-					$ah_end='';
-				}
-
-				$ret_val .= $ah_begin .
-					html_image('ic/msg.png',"10","12").' ';
-				/*
-					See if this message is new or not
-				*/
-				if ($this->Forum->getSavedDate() < $msg_arr["$msg_id"][$i]->getPostDate()) {
-					$bold_begin='<strong>';
-					$bold_end='</strong>';
-				} else {
-					$bold_begin='';
-					$bold_end='';
-				}
-
-				$ret_val .= $bold_begin.$msg_arr["$msg_id"][$i]->getSubject() .$bold_end.$ah_end.'</td>'.
-					'<td>'.util_make_link_u ($msg_arr["$msg_id"][$i]->getPosterName(),$msg_arr["$msg_id"][$i]->getPosterID(),$msg_arr["$msg_id"][$i]->getPosterRealName()) .'</td>'.
-				'<td>'.date(_('Y-m-d H:i'), $msg_arr["$msg_id"][$i]->getPostDate() ).'</td></tr>';
-
-				if ($msg_arr["$msg_id"][$i]->hasFollowups() > 0) {
-					/*
-						Call yourself, incrementing the level
-					*/
-					$ret_val .= $this->showSubmessages($msg_arr,$msg_arr["$msg_id"][$i]->getID(),($level+1));
-				}
-			}
-		}
-		return $ret_val;
-	}
-
-	/**
-	 *  showEditForm - Prints the form to edit a message
-	 *
-	 *	@param 		int		The Message
-	 *	@return		The HTML output echoed
-	 */
-
-	function showEditForm(&$msg) {
-		$thread_id = $msg->getThreadID();
-		$msg_id = $msg->getID();
-		$posted_by = $msg->getPosterID();
-		$subject = $msg->getSubject();
-		$body = $msg->getBody();
-		$post_date = $msg->getPostDate();
-		$is_followup_to = $msg->getParentID();
-		$has_followups = $msg->hasFollowups();
-		$most_recent_date = $msg->getMostRecentDate();
-		$g =& $this->Forum->getGroup();
-		$group_id = $g->getID();
-
-		if (forge_check_perm ('forum', $this->Forum->getID(), 'post')) { // minor control, but anyways it should be an admin at this point
-			echo notepad_func();
-			?>
-<div align="center">
-	 <form id="ForumEditForm" enctype="multipart/form-data" action="<?php echo util_make_url ('/forum/admin/index.php') ?>" method="post">
-	<?php $objid = $this->Forum->getID();?>
-	<input type="hidden" name="thread_id" value="<?php echo $thread_id; ?>" />
-	<input type="hidden" name="forum_id" value="<?php echo $objid; ?>" />
-	<input type="hidden" name="editmsg" value="<?php echo $msg_id; ?>" />
-	<input type="hidden" name="is_followup_to" value="<?php echo $is_followup_to; ?>" />
-	<input type="hidden" name="form_key" value="<?php echo form_generate_key();?>">
-	<input type="hidden" name="posted_by" value="<?php echo $posted_by;?>">
-	<input type="hidden" name="post_date" value="<?php echo $post_date;?>">
-	<input type="hidden" name="has_followups" value="<?php echo $has_followups;?>">
-	<input type="hidden" name="most_recent_date" value="<?php echo $most_recent_date;?>">
-	<input type="hidden" name="group_id" value="<?php echo $group_id;?>">
-<fieldset class="fieldset">
-			<table><tr><td valign="top">
-			</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" />
-		<br /><br />
-		<strong><?php echo _('Message:'); ?></strong><?php echo notepad_button('document.forms.ForumEditForm.body') ?><?php echo utils_requiredField(); ?><br />
-		<?php
-		$GLOBALS['editor_was_set_up']=false;
-		$params = array() ;
-		$params['body'] = $body;
-		$params['width'] = "800";
-		$params['height'] = "500";
-		$params['group'] = $group_id;
-		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>';
-		}
-		unset($GLOBALS['editor_was_set_up']);
-				?>
-			<br /><br />		
-
-				<p>
-				<?php //$this->LinkAttachForm();?>
-				<p>
-		
-		
-		<?php
-		?>
-		<br />
-		<center><input type="submit" name="ok" value="<?php echo _('Update'); ?>" />
-			<input type="submit" name="cancel" value="<?php echo _('Cancel'); ?>" />
-		</center>
-		</p>
-			</td></tr></table></fieldset>
-</form>
-</div>
-		<?php
-}
-}
-
-function showPostForm($thread_id=0, $is_followup_to=0, $subject="") {
-	global $group_id;
-
-	$body = '';
-	
-	if (forge_check_perm ('forum', $this->Forum->getID(), 'post')) {
-		if ($subject) {
-			//if this is a followup, put a RE: before it if needed
-			if (!preg_match('/RE:/i',$subject,$test)) {
-				$subject ='RE: '.$subject;
-			}
-		}
-		echo notepad_func();
-		?>
-<div align="center">
-<form id="ForumPostForm" enctype="multipart/form-data" action="<?php echo util_make_url ('/forum/forum.php?forum_id='.$this->Forum->getID().'&amp;group_id='.$group_id); ?>" method="post">
-	<?php $objid = $this->Forum->getID();?>
-	<input type="hidden" name="post_message" value="y" />
-	<input type="hidden" name="thread_id" value="<?php echo $thread_id; ?>" />
-	<input type="hidden" name="msg_id" value="<?php echo $is_followup_to; ?>" />
-	<input type="hidden" name="is_followup_to" value="<?php echo $is_followup_to; ?>" />
-	<input type="hidden" name="form_key" value="<?php echo form_generate_key();?>" />
-			<fieldset class="fieldset"><table><tr><td valign="top">
-			</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" />
-			<br /><br />
-		<strong><?php echo _('Message:'); ?></strong><?php echo notepad_button('document.forms.ForumPostForm.body') ?><?php echo utils_requiredField(); ?><br />
-
-		<?php
-		$GLOBALS['editor_was_set_up']=false;
-		$params = array();
-		$params['body'] = $body;
-		$params['width'] = "800";
-		$params['height'] = "500";
-		$params['group'] = $group_id;
-		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" wrap="soft">' . $body . '</textarea>';
-		}
-		unset($GLOBALS['editor_was_set_up']);
-		?> <?php //$text_support->displayTextField('body'); ?> <br>
-		<br>
-		<!--		<span class="selected"><?php echo _('HTML tags will display in your post as text'); ?></span> -->
-		<p><?php $this->LinkAttachForm();?>
-		
-		
-		<p><?php
-		if (!session_loggedin()) {
-			echo '<span class="highlight">';
-			printf (_('You are posting anonymously because you are not <a href="%1$s">logged in</a>'),util_make_url ('/account/login.php?return_to='. urlencode(getStringFromServer('REQUEST_URI')))) .'</span>';
-		}
-		?> <br />
-		<input type="submit" name="submit"
-			value="<?php echo _('Post Comment'); echo ((!session_loggedin())?' '._('Anonymously'):''); ?>" /><?php
-			echo ((session_loggedin()) ? '&nbsp;&nbsp;&nbsp;<input type="checkbox" value="1" name="monitor" />&nbsp;'._('Receive followups via email').'.' : ''); ?>
-		</p>
-		</td>
-	</tr>
-</table>
-</fieldset>
-</form>
-</div>
-			<?php
-
-} elseif ($this->Forum->allowAnonymous()) {
-	echo '<span class="error">';
-	printf(_('You could post if you were <a href="%1$s">logged in</a>.'), util_make_url ('/account/login.php?return_to='.urlencode(getStringFromServer('REQUEST_URI'))));
-	echo '</span>';
-} elseif (!session_loggedin()) {
-	echo '<span class="error">';
-	printf(_('Please <a href="%1$s">log in</a>'), util_make_url('/account/login.php?return_to='.urlencode(getStringFromServer('REQUEST_URI'))));
-	echo '</span><br/></p>';
-} else {
-	//do nothing
-}
-
-}
-
-}
-// Local Variables:
-// mode: php
-// c-file-style: "bsd"
-// End:
-
-?>

Modified: trunk/src/www/forum/index.php
===================================================================
--- trunk/src/www/forum/index.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/index.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -24,7 +24,7 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 

Modified: trunk/src/www/forum/message.php
===================================================================
--- trunk/src/www/forum/message.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/message.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -25,8 +25,8 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
-require_once $gfwww.'forum/include/AttachManager.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
+require_once $gfcommon.'forum/AttachManager.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/ForumMessageFactory.class.php';

Modified: trunk/src/www/forum/monitor.php
===================================================================
--- trunk/src/www/forum/monitor.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/monitor.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -25,17 +25,19 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 
-if (session_loggedin()) {
+session_require_login();
+
 	$forum_id = getIntFromRequest('forum_id');
 	$group_id = getIntFromRequest('group_id');
+
 	if ($forum_id && $group_id) {
 		//
 		//  Set up local objects
 		//
-		$g =& group_get_object($group_id);
+	$g = group_get_object($group_id);
 		if (!$g || !is_object($g) || $g->isError()) {
 			exit_no_group();
 		}
@@ -76,10 +78,6 @@
 		}
 	} else {
 		exit_missing_param('',array(_('Forum ID'),_('Project ID')),'forums');
-	}
-
-} else {
-	exit_not_logged_in();
 }
 
 ?>

Modified: trunk/src/www/forum/myforums.php
===================================================================
--- trunk/src/www/forum/myforums.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/myforums.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -28,7 +28,7 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 require_once $gfcommon.'forum/ForumFactory.class.php';
 require_once $gfcommon.'forum/ForumMessageFactory.class.php';

Modified: trunk/src/www/forum/new.php
===================================================================
--- trunk/src/www/forum/new.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/new.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -24,9 +24,9 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
-require_once $gfwww.'forum/include/AttachManager.class.php';
+require_once $gfcommon.'forum/AttachManager.class.php';
 
 /*
 	User obviously has to be logged in to save place

Modified: trunk/src/www/forum/save.php
===================================================================
--- trunk/src/www/forum/save.php	2010-10-18 22:21:44 UTC (rev 11054)
+++ trunk/src/www/forum/save.php	2010-10-19 16:31:45 UTC (rev 11055)
@@ -24,16 +24,15 @@
 
 require_once('../env.inc.php');
 require_once $gfcommon.'include/pre.php';
-require_once $gfwww.'forum/include/ForumHTML.class.php';
+require_once $gfcommon.'forum/ForumHTML.class.php';
 require_once $gfcommon.'forum/Forum.class.php';
 
-if (session_loggedin()) {
-	/*
-		User obviously has to be logged in to save place
-	*/
+// User obviously has to be logged in to save place
+session_require_login();
 
 	$forum_id = getIntFromRequest('forum_id');
 	$group_id = getIntFromRequest('group_id');
+
 	if ($forum_id && $group_id) {
 		//
 		//  Set up local objects
@@ -57,10 +56,6 @@
 		}
 	} else {
 		exit_missing_param('',array(_('Forum ID'),_('Project ID')),'forums');
-	}
-
-} else {
-	exit_not_logged_in();
 }
 
 ?>




More information about the Fusionforge-commits mailing list