Project

General

Profile

1 1441 Luisehahne
<?php
2
/**
3
 *
4
 * @category        backend
5
 * @package         modules
6
 * @author          WebsiteBaker Project
7 1718 Luisehahne
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 1441 Luisehahne
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id$
13
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15
 *
16 1718 Luisehahne
 */
17 1441 Luisehahne
18 1805 Luisehahne
/* -------------------------------------------------------- */
19
// Must include code to stop this file being accessed directly
20
if(!defined('WB_PATH')) {
21
	require_once((dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
22
	throw new IllegalFileException();
23 1441 Luisehahne
}
24 1805 Luisehahne
/* -------------------------------------------------------- */
25
// Create new admin object, you can set the next variable in your module
26
// to print with or without header, default is with header
27
// it is recommed to set the variable before including the /modules/admin.php
28
    $admin_header = (!isset($admin_header)) ? true : $admin_header;
29
    if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
30
    $admin = new admin('Pages', 'pages_modify',(bool)$admin_header);
31 1441 Luisehahne
32 1805 Luisehahne
    $requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
33
    $aActionRequest = (isset(${$requestMethod})) ? ${$requestMethod} : null;
34
35
    $page_id = isset($aActionRequest['page_id']) ? intval($aActionRequest['page_id']) :  (isset($page_id) ? intval($page_id) : 0);
36
    $section_id = isset($aActionRequest['section_id']) ? intval($aActionRequest['section_id']) : (isset($section_id) ? intval($section_id) : 0);
37
38 1836 Luisehahne
	if(	($page_id == 0) ) {
39 1805 Luisehahne
		$admin->send_header("Location: index.php");
40 1441 Luisehahne
		exit(0);
41
	}
42
43
// Create js back link
44
// $js_back = 'javascript: history.go(-1);';
45 1457 Luisehahne
$js_back = ADMIN_URL.'/pages/sections.php?page_id='.$page_id;
46 1805 Luisehahne
47 1441 Luisehahne
// Get perms
48
// unset($admin_header);
49
50 1718 Luisehahne
$page = $admin->get_page_details($page_id, ADMIN_URL.'/pages/index.php' );
51 1441 Luisehahne
52
$old_admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
53
$old_admin_users = explode(',', str_replace('_', '', $page['admin_users']));
54
55
$in_group = false;
56
foreach($admin->get_groups_id() as $cur_gid){
57
    if (in_array($cur_gid, $old_admin_groups)) {
58
        $in_group = true;
59
    }
60
}
61
62
if((!$in_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
63
	print $admin->get_group_id().$admin->get_user_id();
64 1457 Luisehahne
	// print_r ($old_admin_groups);
65 1718 Luisehahne
	$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
66 1441 Luisehahne
}
67
68
// some additional security checks:
69
// Check whether the section_id belongs to the page_id at all
70
if ($section_id != 0) {
71
	$section = $admin->get_section_details($section_id,ADMIN_URL.'/pages/index.php');
72
	if (!$admin->get_permission($section['module'], 'module'))
73
	{
74 1718 Luisehahne
		$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
75 1457 Luisehahne
	}
76 1441 Luisehahne
}
77
78
// Workout if the developer wants to show the info banner
79
if(isset($print_info_banner) && $print_info_banner == true) {
80
	// Get page details already defined
81
82
	// Get display name of person who last modified the page
83
	$user = $admin->get_user_details($page['modified_by']);
84
85
	// Convert the unix ts for modified_when to human a readable form
86
	if($page['modified_when'] != 0) {
87
		$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $page['modified_when']+TIMEZONE);
88
	} else {
89
		$modified_ts = 'Unknown';
90
	}
91
92 1529 Luisehahne
	// Setup template object, parse vars to it, then parse it
93
	// Create new template object
94 1718 Luisehahne
	$template = new Template(dirname($admin->correct_theme_source('pages_modify.htt')),'keep');
95 1529 Luisehahne
	// $template->debug = true;
96 1441 Luisehahne
	$template->set_file('page', 'pages_modify.htt');
97
	$template->set_block('page', 'main_block', 'main');
98
	$template->set_block('main_block', 'section_block', 'section_list');
99
	$template->set_block('section_block', 'block_block', 'block_list');
100
	$template->set_var(array(
101
				'PAGE_ID' => $page['page_id'],
102
				// 'PAGE_IDKEY' => $admin->getIDKEY($page['page_id']),
103
				'PAGE_IDKEY' => $page['page_id'],
104
				'PAGE_TITLE' => ($page['page_title']),
105
				'MENU_TITLE' => ($page['menu_title']),
106
				'ADMIN_URL' => ADMIN_URL,
107
				'WB_URL' => WB_URL,
108
				'THEME_URL' => THEME_URL
109
				));
110
111
	$template->set_var(array(
112
				'MODIFIED_BY' => $user['display_name'],
113 1718 Luisehahne
				'TEXT_LAST_MODIFIED' => $TEXT['LAST_UPDATED_BY'],
114 1441 Luisehahne
				'MODIFIED_BY_USERNAME' => $user['username'],
115
				'MODIFIED_WHEN' => $modified_ts,
116 1718 Luisehahne
				'LAST_MODIFIED' => $MESSAGE['PAGES_LAST_MODIFIED'],
117
				'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS']
118
			));
119 1441 Luisehahne
120
	$template->set_block('main_block', 'show_modify_block', 'show_modify');
121
	if($modified_ts == 'Unknown')
122
	{
123
	    $template->set_block('show_modify', '');
124
		$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
125
126
	} else {
127
		$template->set_var('CLASS_DISPLAY_MODIFIED', '');
128
	    $template->parse('show_modify', 'show_modify_block', true);
129
	}
130
131
	// Work-out if we should show the "manage sections" link
132 1718 Luisehahne
//	$sql  = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id` = '.(int)$page_id.' ';
133
//	$sql .= 'AND `module` = "menu_link"';
134
//	$query_sections = $database->query($sql);
135
/*-- workout if we should show the "manage sections" link ------------------------------*/
136
	$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
137
	     . 'WHERE `page_id`='.$page_id.' AND `module`=\'menu_link\'';
138
	$bIsMenuLink = (intval($database->get_one($sql)) != 0);
139
//	if(!$bIsMenuLink && (MANAGE_SECTIONS == true) && $admin->get_permission('pages_add') )
140
	if((MANAGE_SECTIONS == true) && $admin->get_permission('pages_add') )
141
	{
142
		$template->set_var(array(
143
				'SECTIONS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/sections.php?page_id='.$page['page_id'].'">',
144
				'SECTIONS_LINK_AFTER' => '</a>',
145
				'DISPLAY_MANAGE_SECTIONS' => 'link',
146
				));
147
	}else {
148
//		$oTpl->set_block('show_manage_sections', '');
149
		$template->set_var(array(
150
				'SECTIONS_LINK_BEFORE' => '<span class="bold grey">',
151
				'SECTIONS_LINK_AFTER' => '</span>',
152
				'DISPLAY_MANAGE_SECTIONS' => 'link',
153
				));
154
	}
155 1441 Luisehahne
156 1718 Luisehahne
	if( $admin->get_permission('pages_settings') )
157
	{
158
		$template->set_var(array(
159
				'SETTINGS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/settings.php?page_id='.$page['page_id'].'">',
160
				'SETTINGS_LINK_AFTER' => '</a>',
161
				'DISPLAY_MANAGE_SETTINGS' => 'link',
162
				));
163
	} else {
164
		$template->set_var(array(
165
				'SETTINGS_LINK_BEFORE' => '<span class="bold grey">',
166
				'SETTINGS_LINK_AFTER' => '</span>',
167
				'DISPLAY_MANAGE_SECTIONS' => 'link',
168
				));
169
	}
170
/*
171 1441 Luisehahne
	$template->set_block('main_block', 'show_section_block', 'show_section');
172
	if($query_sections->numRows() > 0)
173
	{
174
		$template->set_block('show_section', '');
175
		$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
176
177
	} elseif(MANAGE_SECTIONS == 'enabled')
178
	{
179
180
		$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
181
	    $template->parse('show_section', 'show_section_block', true);
182
183
	} else {
184
		$template->set_block('show_section', '');
185
		$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
186
187
	}
188 1718 Luisehahne
*/
189 1441 Luisehahne
	// Insert language TEXT
190
	$template->set_var(array(
191
					'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
192
					'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
193
					'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
194
					));
195
196
	// Parse and print header template
197
	$template->parse('main', 'main_block', false);
198
	$template->pparse('output', 'page');
199
	// unset($print_info_banner);
200
	unset($template);
201
202 1889 Luisehahne
//	if (SECTION_BLOCKS) {
203
		if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '') {
204 1457 Luisehahne
			$block_name = htmlentities(strip_tags($block[$section['block']]));
205
		} else {
206 1718 Luisehahne
			if ($section['block'] == 1) {
207 1457 Luisehahne
				$block_name = $TEXT['MAIN'];
208
			} else {
209
				$block_name = '#' . (int) $section['block'];
210
			}
211
		}
212 1889 Luisehahne
		$sec_anchor = '#'.(defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR.$section_id : 'section_'.$section_id );
213 1745 Luisehahne
		//print '<div class="section-info" ><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name;
214
		print '<div class="section-info" '.$sec_anchor.' ><b>' . $TEXT['BLOCK'] . ': </b>' . $block_name;
215 1457 Luisehahne
		print '<b>  Modul: </b>' . $section['module']." ";
216 1867 Luisehahne
		print '<b>  ID: </b>' . $section_id."</div>\n";
217 1889 Luisehahne
//	}
218 1441 Luisehahne
} //
219
220
// Work-out if the developer wants us to update the timestamp for when the page was last modified
221
if(isset($update_when_modified) && $update_when_modified == true) {
222
	$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'");
223
}