| 1 |
<?php
|
| 2 |
|
| 3 |
// $Header: /cvsroot/tikiwiki/tiki/tiki-rename_page.php,v 1.9.2.11 2006/09/03 16:32:30 ohertel Exp $
|
| 4 |
|
| 5 |
// Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
|
| 6 |
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
|
| 7 |
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
|
| 8 |
|
| 9 |
// Initialization
|
| 10 |
require_once ('tiki-setup.php');
|
| 11 |
|
| 12 |
include_once ('lib/wiki/wikilib.php');
|
| 13 |
|
| 14 |
if ($feature_wiki != 'y') {
|
| 15 |
$smarty->assign('msg', tra("This feature is disabled").": feature_wiki");
|
| 16 |
|
| 17 |
$smarty->display("error.tpl");
|
| 18 |
die;
|
| 19 |
}
|
| 20 |
|
| 21 |
// Get the page from the request var or default it to HomePage
|
| 22 |
if (!isset($_REQUEST["page"])) {
|
| 23 |
$smarty->assign('msg', tra("No page indicated"));
|
| 24 |
|
| 25 |
$smarty->display("error.tpl");
|
| 26 |
die;
|
| 27 |
} else {
|
| 28 |
$page = $_REQUEST["page"];
|
| 29 |
|
| 30 |
$smarty->assign_by_ref('page', $_REQUEST["page"]);
|
| 31 |
}
|
| 32 |
|
| 33 |
include_once ("tiki-pagesetup.php");
|
| 34 |
|
| 35 |
// Now check permissions to rename this page
|
| 36 |
$info=null;
|
| 37 |
if ($tiki_p_rename == 'y') {
|
| 38 |
if ($tiki_p_admin_wiki != 'y' && $feature_wiki_usrlock == 'y') {
|
| 39 |
$info = $tikilib->get_page_info($page);
|
| 40 |
$allowed = ($wikilib->is_editable($page, $user, $info))? 'y': 'n';
|
| 41 |
} else {
|
| 42 |
$allowed = 'y';
|
| 43 |
}
|
| 44 |
} else {
|
| 45 |
$allowed = 'n';
|
| 46 |
}
|
| 47 |
if ($allowed == 'n') {
|
| 48 |
$smarty->assign('msg', tra("Permission denied you cannot rename this page"));
|
| 49 |
|
| 50 |
$smarty->display("error.tpl");
|
| 51 |
die;
|
| 52 |
}
|
| 53 |
|
| 54 |
// If the page doesn't exist then display an error
|
| 55 |
if (!$tikilib->page_exists($page,true)) { // true: casesensitive check here
|
| 56 |
$smarty->assign('msg', tra("Page cannot be found"));
|
| 57 |
|
| 58 |
$smarty->display("error.tpl");
|
| 59 |
die;
|
| 60 |
}
|
| 61 |
|
| 62 |
if (isset($_REQUEST["rename"])) {
|
| 63 |
check_ticket('rename-page');
|
| 64 |
// If the new pagename does match userpage prefix then display an error
|
| 65 |
$newName = $_REQUEST['newpage'];
|
| 66 |
if (stristr($newName, $feature_wiki_userpage_prefix) == $newName) {//stripos is only php5
|
| 67 |
$smarty->assign('msg', tra("Cannot rename page because the new name begins with reserved prefix").' ('.$feature_wiki_userpage_prefix.').');
|
| 68 |
|
| 69 |
$smarty->display("error.tpl");
|
| 70 |
die;
|
| 71 |
}
|
| 72 |
if (!$wikilib->wiki_rename_page($page, $newName)) {
|
| 73 |
$smarty->assign('msg', tra("Cannot rename page maybe new page already exists"));
|
| 74 |
|
| 75 |
$smarty->display("error.tpl");
|
| 76 |
die;
|
| 77 |
}
|
| 78 |
|
| 79 |
header ('location: tiki-index.php?page='.urlencode($newName));
|
| 80 |
}
|
| 81 |
|
| 82 |
ask_ticket('rename-page');
|
| 83 |
|
| 84 |
// disallow robots to index page:
|
| 85 |
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
|
| 86 |
|
| 87 |
$smarty->assign('mid', 'tiki-rename_page.tpl');
|
| 88 |
$smarty->assign('show_page_bar', 'y');
|
| 89 |
$smarty->display("tiki.tpl");
|
| 90 |
|
| 91 |
?>
|