Commit b41630ba authored by nyloth's avatar nyloth

[FIX] user notes: handle the type of note ('parse_mode' is set to 'wiki' by...

[FIX] user notes: handle the type of note ('parse_mode' is set to 'wiki' by default) when creating a new note + when saving a new note, the redirect was wrong and the note '0' was displayed.
parent 6fcbfc82
<?php
// CVS: $Id: tikilib.php,v 1.760 2007-07-14 20:33:34 nyloth Exp $
// CVS: $Id: tikilib.php,v 1.761 2007-07-15 14:16:15 nyloth Exp $
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) {
header("location: index.php");
......@@ -153,19 +153,19 @@ class TikiLib extends TikiDB {
}
/*shared*/
function replace_note($user, $noteId, $name, $data) {
function replace_note($user, $noteId, $name, $data, $parse_mode = null) {
$size = strlen($data);
if ($noteId) {
$query = "update `tiki_user_notes` set `name` = ?, `data` = ?, `size` = ?, `lastModif` = ? where `user`=? and `noteId`=?";
$this->query($query,array($name,$data,(int)$size,(int)$this->now,$user,(int)$noteId));
return $noteId;
$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`) values(?,?,?,?,?,?,?)";
$this->query($query,array($user,(int)$noteId,$name,$data,(int)$this->now,(int)$this->now,(int)$size));
$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));
$noteId = $this->getOne( "select max(`noteId`) from `tiki_user_notes` where `user`=? and `name`=? and `created`=?",array($user,$name,(int)$this->now));
return $noteId;
}
return $noteId;
}
function list_watches($offset, $maxRecords, $sort_mode, $find) {
......
......@@ -6,6 +6,7 @@
<br /><br />
<form action="tiki-notepad_write.php" method="post">
<input type="hidden" name="parse_mode" value="{$info.parse_mode|escape}" />
<input type="hidden" name="noteId" value="{$noteId|escape}" />
<table class="normal">
<tr class="formcolor"><td>{tr}Name{/tr}</td><td><input type="text" name="name" value="{$info.name|escape}" /></td></tr>
......
<?php
// $Header: /cvsroot/tikiwiki/tiki/tiki-notepad_write.php,v 1.14 2007-03-06 19:29:50 sylvieg Exp $
// $Header: /cvsroot/tikiwiki/tiki/tiki-notepad_write.php,v 1.15 2007-07-15 14:16:15 nyloth Exp $
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
......@@ -34,26 +34,23 @@ if (isset($_REQUEST["remove"])) {
$notepadlib->remove_note($user, $_REQUEST['remove']);
}
include 'tiki-parsemode_setup.php';
if ($_REQUEST["noteId"]) {
$info = $notepadlib->get_note($user, $_REQUEST["noteId"]);
if ($info['parse_mode'] == 'raw') {
if ( $info['parse_mode'] == 'raw' ) {
$info['parsed'] = nl2br(htmlspecialchars($info['data']));
$smarty->assign('wysiwyg','n');
} else {
include 'tiki-parsemode_setup.php';
$info['parsed'] = $tikilib->parse_data($info['data'],$is_html);
}
$smarty->assign('wysiwyg', 'n');
} else $info['parsed'] = $tikilib->parse_data($info['data'], $is_html);
} else {
$info = array();
$info['name'] = '';
$info['data'] = '';
$info['parse_mode'] = 'raw';
$smarty->assign('wysiwyg','n');
$info['parse_mode'] = 'wiki';
}
if (isset($_REQUEST['save'])) {
check_ticket('notepad-write');
$notepadlib->replace_note($user, $_REQUEST["noteId"], $_REQUEST["name"], $_REQUEST["data"]);
$_REQUEST["noteId"] = $notepadlib->replace_note($user, $_REQUEST["noteId"], $_REQUEST["name"], $_REQUEST["data"], $_REQUEST["parse_mode"]);
header ('location: tiki-notepad_read.php?noteId='.$_REQUEST["noteId"]);
die;
}
......
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