<?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_Menu_Editor {
		function create_menu() {
			return false;
		}
		function configure() {

		}
		function install() {

			$GLOBALS["db"]->query("
			CREATE TABLE ".db_table("menu_block")." (
				ID SMALLINT (5) UNSIGNED NOT NULL,
				Title VARCHAR (128),
				Type TINYINT (1) UNSIGNED NOT NULL,
				opt_noIcons ENUM('0','1') NOT NULL default '0'
			)
			",__FILE__, __LINE__, true);

			$GLOBALS["db"]->query("
			CREATE TABLE ".db_table("menu_link")." (
				ID MEDIUMINT (8) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID),
				MenuLink SMALLINT (5) UNSIGNED NOT NULL,
				OrderID SMALLINT (5),
				Type TINYINT (1) UNSIGNED NOT NULL default '0',
				Level TINYINT (1) UNSIGNED NOT NULL default '0',
				Title VARCHAR (128),
				Link VARCHAR (255),
				Tooltip VARCHAR (255),
				Icon VARCHAR (32),
				auth_Access VARCHAR (255) NOT NULL default '*'
			)
			",__FILE__, __LINE__, true);

			modCore::registerModule($GLOBALS["cgdb"]["menu-editor"], "menu-editor", "#", $GLOBALS["cgdb"]["menu-editor"]);
		}
		function uninstall() {
			$GLOBALS["db"]->query("DROP TABLE IF EXISTS ".db_table("menu_link"),__FILE__, __LINE__, true);
			$GLOBALS["db"]->query("DROP TABLE IF EXISTS ".db_table("menu_block"),__FILE__, __LINE__, true);
		}
		function upgrade($provided_v) {
			if (check_version("0.5.6", $provided_v) < 0) {
				// version minor than 0.5.6
				$GLOBALS["db"]->query("ALTER TABLE ".db_table("menu_block")."
				ADD opt_noIcons ENUM('0','1') NOT NULL default '0' AFTER Type",
				__FILE__, __LINE__);
				// note that I'm not using break!
			}
			if (check_version("0.5.9", $provided_v) < 0) {
				$GLOBALS["db"]->query("ALTER TABLE ".db_table("menu_block")."
				CHANGE COLUMN opt_noIcons opt_noIcons ENUM('0','1') NOT NULL default '0'",
				__FILE__, __LINE__);
			}
		}
		function ext_uninstall($module) {

		}
	}

?>