1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11$section = 'mytiki'; 12require_once('tiki-setup.php'); 13include_once('lib/notepad/notepadlib.php'); 14$access->check_feature('feature_notepad'); 15$access->check_user($user); 16$access->check_permission('tiki_p_notepad'); 17if (! isset($_REQUEST["noteId"])) { 18 $smarty->assign('msg', tra("No note indicated")); 19 $smarty->display("error.tpl"); 20 die; 21} 22if (isset($_REQUEST["remove"])) { 23 $access->check_authenticity(tra('Are you sure you want to delete this note?')); 24 $notepadlib->remove_note($user, $_REQUEST['noteId']); 25 header('location: tiki-notepad_list.php'); 26 die; 27} 28$info = $notepadlib->get_note($user, $_REQUEST["noteId"]); 29if (! $info) { 30 $smarty->assign('msg', tra("Note not found")); 31 $smarty->display("error.tpl"); 32 die; 33} 34 35if (isset($_REQUEST['wikify']) || isset($_REQUEST['over'])) { 36 check_ticket('notepad-read'); 37 if (empty($_REQUEST['wiki_name'])) { 38 $smarty->assign('msg', tra("No name indicated for wiki page")); 39 $smarty->display("error.tpl"); 40 die; 41 } 42 if ($tikilib->page_exists($_REQUEST['wiki_name'])) { 43 if (isset($_REQUEST['over'])) { 44 $pageperms = $tikilib->get_perm_object($_REQUEST['wiki_name'], 'wiki page', '', false); 45 if ($pageperms["tiki_p_edit"] == 'y') { 46 $tikilib->update_page($_REQUEST['wiki_name'], $info['data'], tra('created from notepad'), $user, '127.0.1.1', $info['name']); 47 } else { 48 $smarty->assign('errortype', 401); 49 $smarty->assign('msg', tra("You do not have permission to edit this page.")); 50 $smarty->display("error.tpl"); 51 die; 52 } 53 } else { 54 $smarty->assign('msg', tra("Page already exists")); 55 $smarty->display("error.tpl"); 56 die; 57 } 58 } else { 59 if ($tiki_p_edit == 'y') { 60 $tikilib->create_page($_REQUEST['wiki_name'], 0, $info['data'], $tikilib->now, tra('created from notepad'), $user, $ip = '0.0.0.0', $info['name']); 61 } else { 62 $smarty->assign('errortype', 401); 63 $smarty->assign('msg', tra("You do not have permission to edit this page.")); 64 $smarty->display("error.tpl"); 65 die; 66 } 67 } 68} 69 70if ($tikilib->page_exists($info['name'])) { 71 $smarty->assign("wiki_exists", "y"); 72} else { 73 $smarty->assign("wiki_exists", "n"); 74} 75if (isset($_REQUEST['parse_mode']) and $_REQUEST['parse_mode'] != $info['parse_mode']) { 76 $notepadlib->set_note_parsing($user, $_REQUEST['noteId'], $_REQUEST['parse_mode']); 77 $info['parse_mode'] = $_REQUEST['parse_mode']; 78} 79if ($info['parse_mode'] == 'raw') { 80 $info['parsed'] = nl2br(htmlspecialchars($info['data'])); 81 $smarty->assign('wysiwyg', 'n'); 82} else { 83 include 'lib/setup/editmode.php'; 84 $info['parsed'] = TikiLib::lib('parser')->parse_data($info['data'], ['is_html' => $is_html]); 85} 86$smarty->assign('noteId', $_REQUEST["noteId"]); 87$smarty->assign('info', $info); 88include_once('tiki-section_options.php'); 89include_once('tiki-mytiki_shared.php'); 90ask_ticket('notepad-read'); 91$smarty->assign('mid', 'tiki-notepad_read.tpl'); 92$smarty->display("tiki.tpl"); 93