<?PHP
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Free Web Based Training System                           |
// +----------------------------------------------------------------------------+
// | <G a n e s h a> - Plate-forme de téléformation gratuite et en open source  |
// +----------------------------------------------------------------------------|
// | Copyright (C) 2001-2003  Anéma Formation  <http://www.anema.fr/>           |
// +----------------------------------------------------------------------------+
// |           Developer : Georges CALDEIRA <gcaldeira@anemalab.org>            |
// +----------------------------------------------------------------------------+
// |              Infos on project <http://anemalab.org/>                       |
// +----------------------------------------------------------------------------+
// | This program 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.                                        |
// |                                                                            |
// | This program 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 this program; if not, write to the Free Software                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   |
// +----------------------------------------------------------------------------+

/**
* Definition de la class pour la gestion des forums
* @author	Georges Caldeira <gcaldeira@anemalab.org>
* @package	GaneshaClass
*/
/**
* Fournit une API pour la gestion des forums.
* @author	Georges Caldeira <gcaldeira@anemalab.org>
* @access	public
* @package	GaneshaClass
*/
class Phorum {

	/**
	* Creation d'un nouveau forum pour un groupe
	* @param	integer	$idg numero(id) du groupe
	* @param	string	$groupename nom du groupe
	* @access	public
	*/
	function CreatePhorum($idg,$groupename) {
	 global $ext, $TBL, $db ;
		$sSQL = "DROP TABLE IF EXISTS g".$idg ;
		$db->query($sSQL);
		$sSQL = "DROP TABLE IF EXISTS g".$idg."_bodies" ;
		$db->query($sSQL);
		$sSQL = "CREATE TABLE g".$idg." (id bigint(20) unsigned DEFAULT '0' NOT NULL, datestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, thread int(11) DEFAULT '0' NOT NULL, parent int(11) DEFAULT '0' NOT NULL, author char(37) DEFAULT '' NOT NULL, subject char(255) DEFAULT '' NOT NULL, email char(200) DEFAULT '' NOT NULL, attachment char(64) DEFAULT '' NOT NULL, host char(50) DEFAULT '' NOT NULL, email_reply char(1) NOT NULL DEFAULT 'N', approved char(1) NOT NULL DEFAULT 'N', msgid char(100) DEFAULT '' NOT NULL, PRIMARY KEY (id), KEY author (author), KEY datestamp (datestamp), KEY subject (subject), KEY thread (thread), KEY parent (parent), KEY approved (approved), KEY msgid (msgid))";
		$db->query($sSQL)		;
		$sSQL="CREATE TABLE g".$idg."_bodies (id bigint(20) unsigned DEFAULT '0' NOT NULL AUTO_INCREMENT, body text DEFAULT '' NOT NULL, thread int(11) DEFAULT '0' NOT NULL, PRIMARY KEY (id), KEY thread (thread))";
		$db->query($sSQL)		;
		$sSQL= "SELECT id FROM ".$TBL['forums']." order by id DESC";
		$db->query($sSQL)		;
		$db->next_record()		;
		$numphorum = $db->f(0)+1;
		$sSQL = "INSERT INTO ".$TBL['forums']." (id, name, active, description, config_suffix, folder, parent, display, table_name, moderation, mod_email, mod_pass, email_list, email_return, email_tag, check_dup, multi_level, collapse, flat, staff_host, lang, html, table_width, table_header_color, table_header_font_color, table_body_color_1, table_body_color_2, table_body_font_color_1, table_body_font_color_2, nav_color, nav_font_color, allow_uploads) ";
		$sSQL.= "VALUES ('$numphorum', '$groupename', '1', 'Forum du groupe $groupename', '1', '0', '0', '30', 'g".$idg."', 'n', '', '', '', '', '', '0', '1', '1', '1', '', '".GLANG."', 'N', '80%', '#999999', '#FFFFFF', '#FFFFFF', '#F2F2F2', '#000000', '#000000', '#F2F2F2', '#000000','N')";
		$db->query($sSQL)	;
		return($numphorum);
	}

	/**
	* maj d'un groupe
	* @param	integer	$idg id du forum	
	* @param	string	$name nom du forum
	* @access	public
	*/
	function update($idf,$name) {
		global $TBL, $db ;
		$sSQL = "UPDATE ".$TBL['forums']." SET name='".$name."' WHERE id=".$idf ;
		die($sSQL);
		//$db->query($sSQL)	;
	}
	
 } // class Phorum 

/**
* Instance de la classe Phorum 
* @var	object	Formation	$ClsPhorum 
*/
$ClsPhorum  = new Phorum  ;

?>