<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2005, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sf.net>
	*	@version	CVS: $Id:$
	*	@link		http://gekkoware.sourceforge.net
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");

	Class GekkoModule_Blocks {
		function create_menu() {
			return false;
		}
		function configure() {
			Conf::getKey("blocks", "block_positions", "U,L,R,TC,DC,D", "s");
			Conf::getKey("blocks", "block_classes", "block,info,error,tbox1,tbox2,tbox3", "s");
		}
		function install() {
			$GLOBALS["db"]->query("
			CREATE TABLE ".db_table("block")." (
				ID SMALLINT (5) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID),
				Modules VARCHAR (255),

				Icon VARCHAR (64),
				Title VARCHAR (126),
				Content TEXT,

				ScriptPath VARCHAR (126),
				ScriptVars TEXT,

				OrderID SMALLINT (5) NOT NULL,
				Position VARCHAR (3),

				blockClass VARCHAR (32),

				cssText VARCHAR (128),

				CreationTime INT (11) UNSIGNED NOT NULL,
				auth_Access VARCHAR (255),
				Status ENUM('0','1') NOT NULL default '1'
			)
			", __FILE__, __LINE__, true);

			modCore::registerModule($GLOBALS["cgdb"]["blocks"], "blocks", "#", $GLOBALS["cgdb"]["blocks"]);
		}
		function uninstall() {
			$GLOBALS["db"]->query("DROP TABLE IF EXISTS ".db_table("block"), __FILE__, __LINE__, true);
		}
		function upgrade($provided_v) {
			if (check_version("0.5.6", $provided_v) < 0) {
				// version minor than 0.5.6
				Conf::setKey("blocks", "block_positions", "U,L,R,TC,DC,D", "s");
			}
			if (check_version("0.5.9", $provided_v) < 0) {
				$GLOBALS["db"]->query("ALTER TABLE ".db_table("block")."
				CHANGE COLUMN Status Status ENUM('0','1') NOT NULL default '1'",
				__FILE__, __LINE__);
			}
		}
		function ext_uninstall($module) {

		}
	}
?>