Project

General

Profile

« Previous | Next » 

Revision 698

Added by thorn almost 17 years ago

allow external links in menulink-module

View differences:

index.php
59 59
if($query_this_module->numRows() == 1) { // This is a menu_link. Get link of target-page and redirect
60 60
	// get target_page_id
61 61
	$table = TABLE_PREFIX.'mod_menu_link';
62
	$query_tpid = $database->query("SELECT target_page_id, anchor FROM $table WHERE page_id = '$this_page_id'");
62
	$query_tpid = $database->query("SELECT target_page_id, anchor, extern FROM $table WHERE page_id = '$this_page_id'");
63 63
	if($query_tpid->numRows() == 1) {
64 64
		$res=$query_tpid->fetchRow();
65 65
		$target_page_id = $res['target_page_id'];
66 66
		$anchor = $res['anchor'];
67
		$extern = $res['extern'];
67 68
		if($anchor != '0') $anchor = ''.$anchor;
68 69
		else $anchor = FALSE;
69
		// get link of target-page
70
		$table = TABLE_PREFIX.'pages';
71
		$query_link = $database->query("SELECT link FROM $table WHERE page_id = '$target_page_id'");
72
		if($query_link->numRows() == 1) {
73
			$res=$query_link->fetchRow();
74
			$target_page_link = $res['link'];
75
			// redirect
76
			header('Location: '.WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.($anchor?'#'.$anchor:''));
77
			exit;
70
		if($target_page_id == -1) {
71
			if($extern!='') {
72
				$extern=rtrim($extern, '/');
73
				header("Location: $extern/".($anchor?'#'.$anchor:''));
74
			}
75
		} else {
76
			// get link of target-page
77
			$table = TABLE_PREFIX.'pages';
78
			$query_link = $database->query("SELECT link FROM $table WHERE page_id = '$target_page_id'");
79
			if($query_link->numRows() == 1) {
80
				$res=$query_link->fetchRow();
81
				$target_page_link = $res['link'];
82
				// redirect
83
				header('Location: '.WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.($anchor?'#'.$anchor:''));
84
				exit;
85
			}
78 86
		}
79 87
	}
80 88
}

Also available in: Unified diff