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

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

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

$new_note = $_POST['new_note'];
$id = $_POST['id'];
$uniq = $_POST['uniq'];
$tab = $_POST['tab'];
$widname = $_POST['widname'];
$notes = $_POST['notes'];
$mod_id = $_POST['mod_id'];

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

if (empty($notes)) {
    $sharedMD5 = md5(uniqid(rand(), true));
    $DB->execute($widnote_addNote,$DB->escape($_SESSION['user_id']),$DB->quote($new_note),$DB->quote($sharedMD5));
    $idmod = $DB->getId();
    $variables='ptitl='.$widname.'&noteid='.$idmod;
    $DB->execute($scrsavevar_updateVar,$DB->quote($variables),$DB->escape($_SESSION['user_id']),$DB->escape($tab),$DB->escape($uniq));
}

$note_full = $notes.'<br><br>'.$new_note;

$DB->execute($widnote_updateNote,$DB->quote($note_full),$DB->escape($id),$DB->escape($_SESSION['user_id']));
$DB->freeResults();

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