Commit e39e062a authored by killianebel's avatar killianebel

[FIX] Redirect plugin doesn't redirect in preview mode or just after saving page

parent b36b24fc
<?php
// (c) Copyright 2002-2010 by authors of the Tiki Wiki/CMS/Groupware Project
//
// (c) Copyright 2002-2010 by authors of the Tiki Wiki CMS Groupware Project
//
// 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.
// $Id$
......@@ -15,7 +15,7 @@ function wikiplugin_redirect_help() {
function wikiplugin_redirect_info() {
return array(
'name' => tra('Redirect'),
'documentation' => tra('PluginRedirect'),
'documentation' => tra('PluginRedirect'),
'description' => tra('Redirect the user to a wiki page or generic URL.'),
'prefs' => array( 'wikiplugin_redirect' ),
'validate' => 'arguments',
......@@ -37,19 +37,21 @@ function wikiplugin_redirect_info() {
}
function wikiplugin_redirect($data, $params, $offset, $options) {
global $tikilib;
global $tikilib, $just_saved;
extract ($params,EXTR_SKIP);
$areturn = '';
if (!isset($page)) {$areturn = "REDIRECT plugin: No page specified!";}
if (!isset($url)) {$areturn += "REDIRECT plugin: No url specified!";}
if ((isset($_REQUEST['redirectpage']))) {
$areturn = "REDIRECT plugin: redirect loop detected!";
} elseif (isset($options['print']) && $options['print'] == 'y') {
$info = $tikilib->get_page_info(isset($page)?$page: $url);
return $tikilib->parse_data($info['data'], $options);
} elseif (isset($options['indexing']) && $options['indexing']) {
$info = $tikilib->get_page_info(isset($page)?$page: $url);
$location = isset($page) ? $page : $url;
if ($just_saved) {
$areturn = sprintf(tra("REDIRECT plugin: The redirection to '%s' is disabled just after saving the page."), $location);
} else if ($options['preview_mode']) {
$areturn = sprintf(tra("REDIRECT plugin: The redirection to '%s' is disabled in preview mode. "), $location);
} else if ((isset($_REQUEST['redirectpage']))) {
$areturn = tra("REDIRECT plugin: redirect loop detected!");
} else if (isset($options['print']) && $options['print'] == 'y') {
$info = $tikilib->get_page_info( $location );
return $tikilib->parse_data($info['data'], $options);
} else {
/* SEO: Redirect with HTTP status 301 - Moved Permanently than default 302 - Found */
......@@ -62,6 +64,6 @@ function wikiplugin_redirect($data, $params, $offset, $options) {
exit;
}
}
return $areturn;
}
......@@ -449,11 +449,13 @@ if( isset( $_REQUEST['pagenum'] ) && $_REQUEST['pagenum'] > 0 ) {
$pageRenderer->setPageNumber( (int) $_REQUEST['pagenum'] );
}
$just_saved = false;
if (isset($_SESSION['saved_msg']) && $_SESSION['saved_msg'] == $info['pageName'] && $info['user'] == $user ) {
// Generate the 'Page has been saved...' message
require_once('lib/smarty_tiki/modifier.userlink.php');
$smarty->assign('saved_msg', sprintf( tra('Page saved (version %d).'), $info['version'] ) );
unset($_SESSION['saved_msg']);
$just_saved = true;
}
if($prefs['feature_wiki_attachments'] == 'y') {
......
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