<?php
// $Id: addlocation.php,v 1.1 2004/07/11 10:27:50 Farsus Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Nobse, bama
// Author Website : http://www.e-xoops.de, http://service.bama-webdesign.de
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
    include_once("header.php");
    include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
    $mytree = new XoopsTree($db->prefix('ecal_cat'), "cid", "pid");
    
    //bama
    include("cache/config.php");
    if (!defined("ECAL_LOCATION_INCLUDED")) {include_once(XOOPS_ROOT_PATH."/modules/ecal/class/location.php");}
//---------------------------------------------------------------------------------------//
    function addlocation() {
        global $mytree, $locat_yn, $xoopsUser;    
        include(XOOPS_ROOT_PATH."/header.php");
        OpenTable();
        $form_titel = _CAL_ADDLOCATION;
        $form_action = "addlocation.php";
        $ophidden = "addsave";
        $sub_button_text = _ADD;
        include_once(XOOPS_ROOT_PATH."/modules/ecal/include/form_location.php");
        CloseTable();
        include(XOOPS_ROOT_PATH."/footer.php");
    }

//---------------------------------------------------------------------------------------//
    function addsave() {
        global $HTTP_POST_VARS, $myts, $db;

        $loc_store = new CalLocation();
        $loc_store->setVar("cid", intval($HTTP_POST_VARS['cid']));
        $loc_store->setVar("location", $myts->makeTboxData4Save($HTTP_POST_VARS['location']));
        $loc_store->setVar("beschreibung", $myts->makeTboxData4Save($HTTP_POST_VARS['beschreibung']));
        $loc_store->setVar("ort", $myts->makeTboxData4Save($HTTP_POST_VARS['ort']));
        $loc_store->setVar("plz", $myts->makeTboxData4Save($HTTP_POST_VARS['plz']));
        $loc_store->setVar("strasse", $myts->makeTboxData4Save($HTTP_POST_VARS['strasse']));
        $loc_store->setVar("tel", $myts->makeTboxData4Save($HTTP_POST_VARS['tel']));
        $loc_store->setVar("email", $myts->makeTboxData4Save($HTTP_POST_VARS['email']));
        $loc_store->setVar("url", $myts->makeTboxData4Save($HTTP_POST_VARS['url']));
        $loc_store->setVar("valid", $myts->makeTboxData4Save($HTTP_POST_VARS['valid']));
        $result = $loc_store->store();
        if (!$result){
            xoops_cp_header();
            OpenTable();
            echo "konnte nicht in Location DB Schreiben";
            CloseTable();
            xoops_cp_footer();
            
        }else{
            redirect_header("addevent.php", 1, _CAL_NEWLOCADDED);
            exit();
        }
    }

    $op = $HTTP_POST_VARS['op'];
    if (intval($user_locyn) == 0){
        redirect_header("index.php", 3, _NO_AUTHORIZ);
        exit();
    }
    switch ($op) {
    
    case "addsave":
    	addsave();
    	break;
    
    default:
    	addlocation();
    	break;
    }

?>