<?php

# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# 
#			Add an Event
# 
# ***************************************
 
$not_access=1;
$granted="I";
 
require_once('../scripts/includes_mobile.php');
 
$calid = isset($_GET['cal_id'])     ?       $_GET['cal_id']     :       0;
$id = isset($_POST['id'])       ?       $_POST['id']    :       0;
$title = $_POST['title'];
$com = $_POST['com'];
$date = $_POST['annee'].'-'.$_POST['mois'].'-'.$_POST['jour'];
$time = $_POST['heure1'].':'.$_POST['minute1'];
$etime = $_POST['heure2'].':'.$_POST['minute2'];
$act = isset($_GET["act"])      ?       $_GET["act"]        :       "";
$mod_id = $_POST['mod_id'];
$tab = $_REQUEST['tab'];
$uniq = $_POST['uniq'];

if (empty($title)) {
    header("location:../scripts/display_widget.php?mod_id=".$mod_id."&tab=".$tab);
    exit();
}

if($act=="upd") {
	$DB->execute($widCal_updateEvent,$DB->quote($title),$DB->quote($com),$DB->quote($date),$DB->quote($time),$DB->quote($etime),$DB->escape($calid), $DB->escape($_SESSION["user_id"]));
} else {
	if(empty($id)) {
		$sharedMD5 = md5(uniqid(rand(), true));
		$DB->execute($widcal_newModuleId2, $DB->escape($_SESSION['user_id']), $DB->quote($sharedMD5));
		$id = $DB->getId();
		$DB->execute($updModule,$DB->quote("calid=".$id),$DB->escape($_SESSION['user_id']), $DB->escape($uniq));
	}
	$DB->execute($widcal_newModuleEvent, $DB->escape($id),$DB->quote($title),$DB->quote($com),$DB->quote($date),$DB->quote($time),$DB->quote($etime));
}

header("location:../scripts/display_widget.php?mod_id=".$mod_id."&tab=".$tab);
?>