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

		}
		function install() {

			$GLOBALS["db"]->query("
			CREATE TABLE ".db_table("group")." (
				ID SMALLINT (5) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID),
				Groupname VARCHAR (32),
				Description VARCHAR (128),
				Status ENUM('0','1') NOT NULL default '1',
				IncludeGroups TEXT
			)
			",__FILE__, __LINE__, true);

			foreach ($GLOBALS["cgdb"] as $group => $id) {
				if (file_exists(GEKKO_ROOT."modules/$group") || $id >= 500) {
					$GLOBALS["db"]->query("
						INSERT INTO ".db_table("group")." (
							ID,
							Groupname,
							Description
						) VALUES (
							'{$id}',
							'{$group}',
							'".ucfirst($group)."'
						)
					", __FILE__, __LINE__, true);
				}
			}

			modCore::registerModule($GLOBALS["cgdb"]["groups"], "groups", "#", $GLOBALS["cgdb"]["groups"]);
		}
		function uninstall() {
			$GLOBALS["db"]->query("DROP TABLE IF EXISTS ".db_table("group"),__FILE__, __LINE__, true);
		}
		function upgrade($provided_v) {
			if (check_version("0.5.7", $provided_v) < 0) {
				$GLOBALS["db"]->query("ALTER TABLE ".db_table("group")."
				CHANGE COLUMN Status Status ENUM('0','1') NOT NULL default '1'");
			}
		}
		function ext_uninstall($module) {

		}
	}

?>