<?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://www.gekkoware.org
	*/

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

	Class GekkoModule_Users {
		function create_menu() {
			menuAddLink(1, _l("L_LOGIN"), "%index%/index.php/users/login", "login.png", "?");
			menuAddLink(2, _l("L_MY_ACCOUNT"), "%index%/index.php/users", "account.png", "$");
			menuAddLink(2, _l("L_LOGOUT"), "%index%/index.php/users/logout", "logout.png", "$");
			return true;
		}
		function configure() {
			Conf::getKey("users", "account.require_confirmation", "1", "b");
			Conf::getKey("users", "account.enable_self_registration", "1", "b");
			Conf::getKey("users", "account.send_welcome_letter", "1", "b");

			Conf::getKey("users", "account.enable_password_reset", "1", "b");
			Conf::getKey("users", "account.register.interval", 60*60*24, "i");
			Conf::getKey("users", "account.register.limit", "5", "i");
			Conf::getKey("users", "password.min_length", "4", "i");

			conf::getKey("users", "login.multi_session", 0, "b");
		}
		function install() {
			$GLOBALS["db"]->query("
			CREATE TABLE ".db_table("user")." (
				ID MEDIUMINT (8) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID),
				Username VARCHAR (32),
				Realname VARCHAR (64),
				Password VARCHAR (32),
				Email VARCHAR (64),
				SesLen SMALLINT (5),
				RegTime INT (11) UNSIGNED NOT NULL,
				LastLogin INT (11) UNSIGNED NOT NULL,
				AuthKey VARCHAR (32),
				Status TINYINT (3) UNSIGNED NOT NULL,
				ResetCookie VARCHAR (64),
				Groups TEXT,
				Preferences TEXT
			)
			",__FILE__, __LINE__, true);

			$GLOBALS["db"]->query("
			CREATE TABLE ".db_table("user_profile")." (
				ID MEDIUMINT (8) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (ID),
				Nickname VARCHAR (32),
				PublicEmail VARCHAR (64),
				BirthDate TIMESTAMP,
				WebSite VARCHAR (64),
				Avatar VARCHAR (128),
				AboutMe TEXT,
				Signature VARCHAR (255),
				Location VARCHAR (255),
				Gender TINYINT (1) UNSIGNED NOT NULL,
				imMSN VARCHAR (64),
				imYIM VARCHAR (64),
				imICQ VARCHAR (64)
			)
			",__FILE__, __LINE__, true);

			modCore::registerModule($GLOBALS["cgdb"]["users"], "users", "*", $GLOBALS["cgdb"]["users"]);
		}
		function uninstall() {
			$GLOBALS["db"]->query("DROP TABLE IF EXISTS ".db_table("users"),__FILE__, __LINE__, true);
			$GLOBALS["db"]->query("DROP TABLE IF EXISTS ".db_table("users_profile"),__FILE__, __LINE__, true);
		}
		function upgrade($provided_v) {

		}
		function ext_uninstall($module) {

		}
	}

?>