Commit aabfad26 authored by chealer's avatar chealer

[FIX] DB abstraction: support sequences starting at 0

parent 1de8ecac
......@@ -178,7 +178,7 @@ class TikiLib extends TikiDb_Bridge {
return false;
}
/*shared*/
// $noteId 0 means create a new note
function replace_note($user, $noteId, $name, $data, $parse_mode = null) {
$size = strlen($data);
......@@ -186,8 +186,8 @@ class TikiLib extends TikiDb_Bridge {
$query = "update `tiki_user_notes` set `name` = ?, `data` = ?, `size` = ?, `lastModif` = ?, `parse_mode` = ? where `user`=? and `noteId`=?";
$this->query($query,array($name,$data,(int)$size,(int)$this->now,$parse_mode,$user,(int)$noteId));
} else {
$query = "insert into `tiki_user_notes`(`user`,`noteId`,`name`,`data`,`created`,`lastModif`,`size`,`parse_mode`) values(?,?,?,?,?,?,?,?)";
$this->query($query,array($user,(int)$noteId,$name,$data,(int)$this->now,(int)$this->now,(int)$size,$parse_mode));
$query = "insert into `tiki_user_notes`(`user`,`name`,`data`,`created`,`lastModif`,`size`,`parse_mode`) values(?,?,?,?,?,?,?)";
$this->query($query,array($user,$name,$data,(int)$this->now,(int)$this->now,(int)$size,$parse_mode));
$noteId = $this->getOne( "select max(`noteId`) from `tiki_user_notes` where `user`=? and `name`=? and `created`=?",array($user,$name,(int)$this->now));
}
......
......@@ -22,13 +22,12 @@ if ($tiki_p_notepad != 'y') {
$smarty->display("error.tpl");
die;
}
if (!isset($_REQUEST["noteId"])) $_REQUEST["noteId"] = 0;
if (isset($_REQUEST["remove"])) {
check_ticket('notepad-write');
$notepadlib->remove_note($user, $_REQUEST['remove']);
}
include 'lib/setup/editmode.php';
if ($_REQUEST["noteId"]) {
if (isset($_REQUEST["noteId"])) {
$info = $notepadlib->get_note($user, $_REQUEST["noteId"]);
if ($info['parse_mode'] == 'raw') {
$info['parsed'] = nl2br(htmlspecialchars($info['data']));
......@@ -42,8 +41,8 @@ if ($_REQUEST["noteId"]) {
}
if (isset($_REQUEST['save'])) {
check_ticket('notepad-write');
$_REQUEST["noteId"] = $notepadlib->replace_note($user, $_REQUEST["noteId"], $_REQUEST["name"], $_REQUEST["data"], $_REQUEST["parse_mode"]);
header('location: tiki-notepad_read.php?noteId=' . $_REQUEST["noteId"]);
$noteId = $notepadlib->replace_note($user, isset($_REQUEST["noteId"]) ? $_REQUEST["noteId"] : 0, $_REQUEST["name"], $_REQUEST["data"], $_REQUEST["parse_mode"]);
header('location: tiki-notepad_read.php?noteId=' . $noteId);
die;
}
$smarty->assign('noteId', $_REQUEST["noteId"]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment