<?php 
# ************** LICENCE ****************
/*
	Copyright (c) PORTANEO.
*/
# ***************************************
# 
#		Add a task
# 
# ***************************************

$not_access=1;
$granted="I";

require_once('../scripts/includes_mobile.php');
require_once('../../../../db_layer/'.__DBTYPE.'/widget.php');

$title = $_POST['titre'];
$com = $_POST['comment'];
$id = isset($_POST['id'])   ?   $_POST['id']    :   0;
$act = isset($_GET['act'])      ?     $_GET['act']      :    "";
$mod_id = $_REQUEST['mod_id'];
$tab = $_REQUEST['tab'];
$uniq = $_REQUEST['uniq'];

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

if ($act=="add") {
	if(empty($id)) {
		$sharedMD5 = md5(uniqid(rand(), true));
		$DB->execute($widtask_addNewTaskId, $DB->escape($_SESSION['user_id']), $DB->quote($sharedMD5));
		$id = $DB->getId();
		$DB->execute($updModule,$DB->quote("taskid=".$id),$DB->escape($_SESSION['user_id']), $DB->escape($uniq));
	}
	$DB->execute($widtask_newModInsertTask, $DB->escape($id), $DB->quote($com), $DB->quote($title));
} else {
	$DB->execute($widtask_newModUpdateTask, $DB->quote($title),$DB->quote($com), $DB->escape($id));
}

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