<?php
// Submits new note
function createNote ()
{
global $db_tableName;
global $action;
global $note;
global $tags;
global $new;
global $selectedTags;
CheckIfIsEmptyTag ($tags);
$dateTime = time ();
$query = "INSERT INTO $db_tableName (note, datetime) VALUES ('$note', '$dateTime');";
$result = mysql_query ($query);
if (!$result)
{
$errorText = mysql_error();
}
$id = mysql_insert_id();
UpdateNoteTags ($note, $tags, $id);
$newNote = new Note ($id, $note, $note, $tags, $dateTime);
$jsonArray = array();
$jsonArray[0]["tagLinks"] = getTagLinks();
$jsonArray[0]["errorText"] = $errorText;
$jsonArray[1]["id"] = $newNote->getId();
$jsonArray[1]["note"] = $newNote->getNote();
$jsonArray[1]["tags"] = $newNote->getTags();
$jsonArray[1]["date"] = $newNote->getDate();
$jsonArray[1]["innerHTML"] = $newNote->getInnerHTML();
$json = new Services_JSON();
echo $json->encode($jsonArray);
exit;
}
?>