tiki-rollback.php 1.94 KB
Newer Older
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
3
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
changi67's avatar
changi67 committed
6
// $Id$
7

8 9
require_once ('tiki-setup.php');
include_once ('lib/wiki/histlib.php');
10
include_once ('lib/wiki/wikilib.php');
11

12
$access->check_feature('feature_wiki');
13

14
// Get the page from the request var or default it to HomePage
15 16
if (!isset($_REQUEST["page"])) {
	$smarty->assign('msg', tra("No page indicated"));
17
	$smarty->display("error.tpl");
18
	die;
19
} else {
20 21
	$page = $_REQUEST["page"];
	$smarty->assign_by_ref('page', $_REQUEST["page"]);
22
}
23 24
if (!isset($_REQUEST["version"])) {
	$smarty->assign('msg', tra("No version indicated"));
25
	$smarty->display("error.tpl");
26
	die;
27
} else {
28 29
	$version = $_REQUEST["version"];
	$smarty->assign_by_ref('version', $_REQUEST["version"]);
30
}
31 32 33 34 35
if (!($info = $tikilib->get_page_info($page))) {
	$smarty->assign('msg', tra('Page cannot be found'));
	$smarty->display('error.tpl');
	die;
}
36
if (!$histlib->version_exists($page, $version)) {
mose's avatar
mose committed
37
	$smarty->assign('msg', tra("Non-existent version"));
38
	$smarty->display("error.tpl");
39
	die;
40
}
41

changi67's avatar
changi67 committed
42
$tikilib->get_perm_object($page, 'wiki page', $info);
43 44
$access->check_permission( array('tiki_p_rollback', 'tiki_p_edit') );

45
if (isset($_REQUEST["rollback"])) {
46 47 48
	require_once('lib/diff/difflib.php');
	require_once('lib/categories/categlib.php');
	rollback_page_to_version($_REQUEST['page'], $_REQUEST['version']);
chealer's avatar
chealer committed
49
	header("location: tiki-index.php?page=" . urlencode($page));
50
	die;
51
}
52
$version = $histlib->get_version($page, $version);
53
$version["data"] = $tikilib->parse_data($version["data"], array('preview_mode' => true, 'is_html' => $version['is_html']));
54
$smarty->assign_by_ref('preview', $version);
55 56
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
57
$smarty->assign('mid', 'tiki-rollback.tpl');
58
$smarty->display("tiki.tpl");