<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#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
#
#$Id: Comments.module.php 2114 2005-11-04 21:51:13Z wishy $

class Comments extends CMSModule
{
	function GetName()
	{
		return 'Comments';
	}

	function GetVersion()
	{
		return '1.4';
	}

	function GetHelp($lang = 'en_US')
	{
		return $this->Lang('help');
	}

	function GetAuthor()
	{
		return 'Ted Kulp';
	}

	function GetAuthorEmail()
	{
		return 'wishy@cmsmadesimple.org';
	}

	function Install()
	{
		$db = $this->cms->db;
		$dict = NewDataDictionary($db);
		$flds = "
			comment_id I KEY,
			comment_data X,
			comment_date T,
			comment_author C(255),
			page_id C(255),
			create_date T,
			modified_date T
		";
		$taboptarray = array('mysql' => 'TYPE=MyISAM');
		$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_comments", $flds, $taboptarray);
		$dict->ExecuteSQLArray($sqlarray);

		$db->CreateSequence(cms_db_prefix()."module_comments_seq");
		
		$this->CreatePermission('Manage Comments', 'Manage Comments');

	}

	function Upgrade($oldversion, $newversion)
	{
		$current_version = $oldversion;
		switch($current_version)
		{
			case "1.0":
			case "1.1":
			case "1.2":
			case "1.3":
				$this->CreatePermission('Manage Comments', 'Manage Comments');
				$current_version = "1.4";
		}
	}
	
	function Uninstall()
	{
		$db = $this->cms->db;
		$dict = NewDataDictionary($db);
		$sqlarray = $dict->DropTableSQL(cms_db_prefix()."module_comments");
		$dict->ExecuteSQLArray($sqlarray);

		$db->DropSequence(cms_db_prefix()."module_comments_seq");

		$this->RemovePermission('Manage Comments');
	}

	function GetChangeLog()
	{
		return "
			1.4: April 2006 (updates by Katon)<br />
			Actions moved in separate files<br />
			Added admin management panel<br />
			Added mailing functionality<br />
			1.3: Module API changes<br />
			1.2: Oct 13, 2004<br />
			Added newline parsing (kickthedonkey)<br />
			Removed a rogue div (kickthedonkey)<br />
			1.1: Sep 28, 2004<br />
			Added <em>number</em> and <em>dateformat</em> options, plus little cosmetic changes.<br />
			1.0: Initial Release
		";
	}

	function SetParameters()
	{
		$this->CreateParameter('dateformat', '', $this->lang('helpdateformat'));
		$this->CreateParameter('number', '5', $this->lang('helpnumber'));
	}

	function IsPluginModule()
	{
		return true;
	}

	function HasAdmin()
	{
		return true;
	}

    function VisibleToAdminUser()
    {
      return $this->CheckPermission('Manage Comments');
    }

	function MinimumCMSVersion()
	{
		return '0.11.2';
	}

	function GetAdminDescription()
	{
		return $this->Lang('description');
	}

	function GetAdminSection()
	{
		return 'extensions';
	}

}

# vim:ts=4 sw=4 noet
?>
