<?php
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: The Xoops Project
// Author Website : http://www.xoops.org
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

//include_once('../header.php');
include_once('../../../mainfile.php');
include_once('../../../header.php');

global $myts;

$result = $db->query("UPDATE ".$db->prefix("modules")." SET dirname='ecal' WHERE dirname='eCal'");
$result = $db->queryF("RENAME TABLE ".$db->prefix("eCal")." TO ".$db->prefix("ecal")."");
$result = @mysql_query("select id from ".$db->prefix("ecal_remind")."");
if (!$result) {
	$result = $db->queryF("CREATE TABLE  ".$db->prefix("ecal_remind")."(id int( 8 ) unsigned NOT NULL )AUTO_INCREMENT=0 ");
    $result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_remind")." ADD tid int(8) unsigned NOT NULL default '0'");
	$result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_remind")." ADD uid int(8) unsigned NOT NULL default '0'");
	$result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_remind")." ADD date int(10) default NULL");
	    if ($result) {
                $status = 1;
        } else {
                $status = 0;
        }
} else {
	$status = 2;
}

$result = @mysql_query("select uid from ".$db->prefix("ecal_userblock")."");
if (!$result) {
	$result = $db->queryF("CREATE TABLE  ".$db->prefix("ecal_userblock")."(uid int( 8 ) unsigned NOT NULL default '0')");
    $result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_userblock")." ADD locationid smallint(4) unsigned NOT NULL default '0'");
	$result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_userblock")." ADD catid smallint(4) unsigned NOT NULL default '0'");
	$result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_userblock")." ADD bllimit smallint(2) default NULL");
	    if ($result) {
                $status = 1;
        } else {
                $status = 0;
        }
} else {
	$status = 2;
}

$result = @mysql_query("select uid from ".$db->prefix("ecal_teiln")."");
if (!$result) {
	$result = $db->queryF("CREATE TABLE  ".$db->prefix("ecal_teiln")."(id int(8) unsigned NOT NULL )AUTO_INCREMENT=0");
    $result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_teiln")." ADD tid int(8) unsigned NOT NULL default '0'");
	$result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_teiln")." ADD uid int(8) unsigned NOT NULL default '0'");
	$result = $db->queryF("ALTER TABLE ".$db->prefix("ecal_teiln")." ADD uname varchar(30) NOT NULL default ''");
	    if ($result) {
                $status = 1;
        } else {
                $status = 0;
        }
} else {
	$status = 2;
}
OpenTable();

if ($status == 1) {
    echo "Datenbank wurde aktualisiert OK.";
}
if ($status == 0) {
    echo "Datenbank konnte nicht aktualisiert werden !!!";
}
if ($status == 2) {
    echo "Datenbank ist aktuell es brauchten keine Änderungen durchgeführt werden OK";
}

CloseTable();
include_once('../../../footer.php');
?>