Project

General

Profile

« Previous | Next » 

Revision 1009

Added by Matthias over 15 years ago

-Moved styles from admin/pages/sections.php to sections.htt in backend themes (Thanks to Luisehahne)

- Moved javascript files from admin/pages/index.php to external js files (Thanks to Luisehahne)

- Major improovements and changes to all backend files to get more valide Code output (Thanks to Luisehahne)

View differences:

trunk/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.8.0 -------------------------------------
14
23-June-2009 Matthias Gallas
15
#	Moved styles from admin/pages/sections.php to sections.htt in backend themes
16
	(Thanks to Luisehahne)
17
!	Moved javascript files from admin/pages/index.php to external js files
18
	(Thanks to Luisehahne)
19
#	Major improovements and changes to all backend files to get more valide Code
20
	output (Thanks to Luisehahne)
14 21
22-June-2009 Matthias Gallas
15 22
#	fixed wrong position id when adding a new page
16 23
-	removed obsolete code/modify.html
trunk/wb/include/jscalendar/wb-setup.php
33 33
}
34 34

  
35 35
?>
36
<style type="text/css">
36
<!--<style type="text/css">-->
37 37
<?php
38
require_once(WB_PATH.'/include/jscalendar/calendar-system.css');
38
// require_once(WB_PATH.'/include/jscalendar/calendar-system.css');
39 39
?>
40
</style>
40
<!--</style>  -->
41 41
<script type="text/javascript" src="<?php echo WB_URL ?>/include/jscalendar/calendar.js"></script>
42 42
<?php // some stuff for jscalendar
43 43
	// language
trunk/wb/admin/pages/page_calendar.js
1
Calendar.setup(
2
	{
3
	inputField  : start_date,
4
	ifFormat    : jscal_ifformat,
5
	button      : trigger_start,
6
	firstDay    : jscal_firstday,
7
	showsTime   : showsTime,
8
	timeFormat  : timeFormat,
9
	date        : jscal_today,
10
	range       : [1970, 2037],
11
	step        : 1
12
	}
13
);
14
Calendar.setup(
15
	{
16
	inputField  : end_date,
17
	ifFormat    : jscal_ifformat,
18
	button      : trigger_end,
19
	firstDay    : jscal_firstday,
20
	showsTime   : showsTime,
21
	timeFormat  : timeFormat,
22
	date        : jscal_today,
23
	range       : [1970, 2037],
24
	step        : 1
25
	}
26
);
0 27

  
trunk/wb/admin/pages/settings.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Get page id
27
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
28
	header("Location: index.php");
29
	exit(0);
30
} else {
31
	$page_id = $_GET['page_id'];
32
}
33

  
34
// Create new admin object
35
require('../../config.php');
36
require_once(WB_PATH.'/framework/class.admin.php');
37
$admin = new admin('Pages', 'pages_settings');
38

  
39
// Include the WB functions file
40
require_once(WB_PATH.'/framework/functions-utf8.php');
41

  
42
// Get perms
43
$database = new database();
44
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
45
$results_array = $results->fetchRow();
46
$old_admin_groups = explode(',', $results_array['admin_groups']);
47
$old_admin_users = explode(',', $results_array['admin_users']);
48

  
49
$in_old_group = FALSE;
50
foreach($admin->get_groups_id() as $cur_gid){
51
    if (in_array($cur_gid, $old_admin_groups)) {
52
        $in_old_group = TRUE;
53
    }
54
}
55
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
56
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
57
}
58

  
59
// Get page details
60
$database = new database();
61
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
62
$results = $database->query($query);
63
if($database->is_error()) {
64
	$admin->print_header();
65
	$admin->print_error($database->get_error());
66
}
67
if($results->numRows() == 0) {
68
	$admin->print_header();
69
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
70
}
71
$results_array = $results->fetchRow();
72

  
73
// Get display name of person who last modified the page
74
$user=$admin->get_user_details($results_array['modified_by']);
75

  
76
// Convert the unix ts for modified_when to human a readable form
77
if($results_array['modified_when'] != 0) {
78
	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
79
} else {
80
	$modified_ts = 'Unknown';
81
}
82

  
83
// Setup template object, parse vars to it, then parse it
84
$template = new Template(THEME_PATH.'/templates');
85
$template->set_file('page', 'pages_settings.htt');
86
$template->set_block('page', 'main_block', 'main');
87
$template->set_var(array(
88
								'PAGE_ID' => $results_array['page_id'],
89
								'PAGE_TITLE' => ($results_array['page_title']),
90
								'MENU_TITLE' => ($results_array['menu_title']),
91
								'DESCRIPTION' => ($results_array['description']),
92
								'KEYWORDS' => ($results_array['keywords']),
93
								'MODIFIED_BY' => $user['display_name'],
94
								'MODIFIED_BY_USERNAME' => $user['username'],
95
								'MODIFIED_WHEN' => $modified_ts,
96
								'ADMIN_URL' => ADMIN_URL
97
								)
98
						);
99

  
100
// Work-out if we should show the "manage sections" link
101
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
102
if($query_sections->numRows() > 0) {
103
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
104
} elseif(MANAGE_SECTIONS == 'enabled') {
105
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
106
} else {
107
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
108
}
109

  
110
// Visibility
111
if($results_array['visibility'] == 'public') {
112
	$template->set_var('PUBLIC_SELECTED', ' selected');
113
} elseif($results_array['visibility'] == 'private') {
114
	$template->set_var('PRIVATE_SELECTED', ' selected');
115
} elseif($results_array['visibility'] == 'registered') {
116
	$template->set_var('REGISTERED_SELECTED', ' selected');
117
} elseif($results_array['visibility'] == 'hidden') {
118
	$template->set_var('HIDDEN_SELECTED', ' selected');
119
} elseif($results_array['visibility'] == 'none') {
120
	$template->set_var('NO_VIS_SELECTED', ' selected');
121
}
122
// Group list 1 (admin_groups)
123
	$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
124

  
125
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
126
	
127
	$get_groups = $database->query($query);
128
	$template->set_block('main_block', 'group_list_block', 'group_list');
129
	// Insert admin group and current group first
130
	$admin_group_name = $get_groups->fetchRow();
131
	$template->set_var(array(
132
									'ID' => 1,
133
									'TOGGLE' => '',
134
									'DISABLED' => ' disabled',
135
									'LINK_COLOR' => '000000',
136
									'CURSOR' => 'default',
137
									'NAME' => $admin_group_name['name'],
138
									'CHECKED' => ' checked'
139
									)
140
							);
141
	$template->parse('group_list', 'group_list_block', true);
142
	/*
143
	if(!in_array(1, $admin->get_groups_id())) {
144
		$users_groups = $admin->get_groups_name();
145
		foreach ($admin->get_groups_id() as $users_group_id) {
146
			$template->set_var(array(
147
										'ID' => $users_group_id,
148
										'TOGGLE' => '',
149
										'DISABLED' => ' disabled',
150
										'LINK_COLOR' => '000000',
151
										'CURSOR' => 'default',
152
										'NAME' => $users_groups[$users_group_id],
153
										'CHECKED' => ' checked'
154
										)
155
								);
156
			$template->parse('group_list', 'group_list_block', true);
157
		}
158
	}
159
	*/
160
	while($group = $get_groups->fetchRow()) {
161
		// check if the user is a member of this group
162
		$flag_disabled = '';
163
		$flag_checked =  '';
164
		$flag_cursor =   'pointer';
165
		$flag_color =    '';
166
		if (in_array($group["group_id"], $admin->get_groups_id())) {
167
			$flag_disabled = ''; //' disabled';
168
			$flag_checked =  ''; //' checked';
169
			$flag_cursor =   'default';
170
			$flag_color =    '000000';
171
		}
172

  
173
		// Check if the group is allowed to edit pages
174
		$system_permissions = explode(',', $group['system_permissions']);
175
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
176
			$template->set_var(array(
177
											'ID' => $group['group_id'],
178
											'TOGGLE' => $group['group_id'],
179
											'DISABLED' => $flag_disabled,
180
											'LINK_COLOR' => $flag_color,
181
											'CURSOR' => $flag_cursor,
182
											'NAME' => $group['name'],
183
											'CHECKED' => $flag_checked
184
											)
185
									);
186
			if(is_numeric(array_search($group['group_id'], $admin_groups))) {
187
				$template->set_var('CHECKED', 'checked');
188
			} else {
189
				if (!$flag_checked) $template->set_var('CHECKED', '');
190
			}
191
			$template->parse('group_list', 'group_list_block', true);
192
		}
193
	}
194
// Group list 2 (viewing_groups)
195
	$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
196

  
197
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
198

  
199
	$get_groups = $database->query($query);
200
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
201
	// Insert admin group and current group first
202
	$admin_group_name = $get_groups->fetchRow();
203
	$template->set_var(array(
204
									'ID' => 1,
205
									'TOGGLE' => '',
206
									'DISABLED' => ' disabled',
207
									'LINK_COLOR' => '000000',
208
									'CURSOR' => 'default',
209
									'NAME' => $admin_group_name['name'],
210
									'CHECKED' => ' checked'
211
									)
212
							);
213
	$template->parse('group_list2', 'group_list_block2', true);
214

  
215

  
216
	while($group = $get_groups->fetchRow()) {
217
		// check if the user is a member of this group
218
		$flag_disabled = '';
219
		$flag_checked =  '';
220
		$flag_cursor =   'pointer';
221
		$flag_color =    '';
222
		if (in_array($group["group_id"], $admin->get_groups_id())) {
223
			$flag_disabled = ''; //' disabled';
224
			$flag_checked =  ''; //' checked';
225
			$flag_cursor =   'default';
226
			$flag_color =    '000000';
227
		}
228

  
229
		$template->set_var(array(
230
										'ID' => $group['group_id'],
231
										'TOGGLE' => $group['group_id'],
232
										'DISABLED' => $flag_disabled,
233
										'LINK_COLOR' => $flag_color,
234
										'CURSOR' => $flag_cursor,
235
										'NAME' => $group['name'],
236
										'CHECKED' => $flag_checked
237
										)
238
								);
239
		if(is_numeric(array_search($group['group_id'], $viewing_groups))) {
240
			$template->set_var('CHECKED', 'checked');
241
		} else {
242
			if (!$flag_checked) $template->set_var('CHECKED', '');
243
		}
244
		$template->parse('group_list2', 'group_list_block2', true);
245
	}
246
// Show private viewers
247
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered') {
248
	$template->set_var('DISPLAY_VIEWERS', '');
249
} else {
250
	$template->set_var('DISPLAY_VIEWERS', 'none');
251
}
252

  
253
// Parent page list
254
$database = new database();
255
function parent_list($parent) {
256
	global $admin, $database, $template, $results_array;
257
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
258
	$get_pages = $database->query($query);
259
	while($page = $get_pages->fetchRow()) {
260
		if($admin->page_is_visible($page)==false)
261
			continue;
262
		// If the current page cannot be parent, then its children neither
263
		$list_next_level = true;
264
		// Stop users from adding pages with a level of more than the set page level limit
265
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
266
			// Get user perms
267
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
268
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
269

  
270
			$in_group = FALSE;
271
			foreach($admin->get_groups_id() as $cur_gid){
272
			    if (in_array($cur_gid, $admin_groups)) {
273
			        $in_group = TRUE;
274
			    }
275
			}
276
			
277
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
278
				$can_modify = true;
279
			} else {
280
				$can_modify = false;
281
			}
282
			// Title -'s prefix
283
			$title_prefix = '';
284
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
285
			$template->set_var(array(
286
											'ID' => $page['page_id'],
287
											'TITLE' => ($title_prefix.$page['page_title'])
288
											)
289
									);
290
			if($results_array['parent'] == $page['page_id']) {
291
				$template->set_var('SELECTED', ' selected');
292
			} elseif($results_array['page_id'] == $page['page_id']) {
293
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
294
				$list_next_level=false;
295
			} elseif($can_modify != true) {
296
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
297
			} else {
298
				$template->set_var('SELECTED', '');
299
			}
300
			$template->parse('page_list2', 'page_list_block2', true);
301
		}
302
		if ($list_next_level)
303
			parent_list($page['page_id']);
304
	}
305
}
306
$template->set_block('main_block', 'page_list_block2', 'page_list2');
307
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
308
	if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; }
309
	$template->set_var(array(
310
									'ID' => '0',
311
									'TITLE' => $TEXT['NONE'],
312
									'SELECTED' => $selected
313
									)
314
							);
315
	$template->parse('page_list2', 'page_list_block2', true);
316
}
317
parent_list(0);
318

  
319
if($modified_ts == 'Unknown') {
320
	$template->set_var('DISPLAY_MODIFIED', 'hide');
321
} else {
322
	$template->set_var('DISPLAY_MODIFIED', '');
323
}
324
// Templates list
325
$template->set_block('main_block', 'template_list_block', 'template_list');
326
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' and function = 'template' order by name");
327
if($result->numRows() > 0) {
328
	while($addon = $result->fetchRow()) { 
329
		// Check if the user has perms to use this template
330
		if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) {
331
			$template->set_var('VALUE', $addon['directory']);
332
			$template->set_var('NAME', $addon['name']);
333
			if($addon['directory'] == $results_array['template']) {
334
				$template->set_var('SELECTED', ' selected');
335
			} else {
336
				$template->set_var('SELECTED', '');
337
			}
338
			$template->parse('template_list', 'template_list_block', true);
339
		}
340
	}
341
}
342

  
343
// Menu list
344
if(MULTIPLE_MENUS == false) {
345
	$template->set_var('DISPLAY_MENU_LIST', 'none');
346
}
347
// Include template info file (if it exists)
348
if($results_array['template'] != '') {
349
	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
350
} else {
351
	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
352
}
353
if(file_exists($template_location)) {
354
	require($template_location);
355
}
356
// Check if $menu is set
357
if(!isset($menu[1]) OR $menu[1] == '') {
358
	// Make our own menu list
359
	$menu[1] = $TEXT['MAIN'];
360
}
361
// Add menu options to the list
362
$template->set_block('main_block', 'menu_list_block', 'menu_list');
363
foreach($menu AS $number => $name) {
364
	$template->set_var('NAME', $name);
365
	$template->set_var('VALUE', $number);
366
	if($results_array['menu'] == $number) {
367
		$template->set_var('SELECTED', 'selected');
368
	} else {
369
		$template->set_var('SELECTED', '');
370
	}
371
	$template->parse('menu_list', 'menu_list_block', true);
372
}
373

  
374
// Insert language values
375
$template->set_block('main_block', 'language_list_block', 'language_list');
376
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name");
377
if($result->numRows() > 0) {
378
	while($addon = $result->fetchRow()) {
379
		$l_codes[$addon['name']] = $addon['directory'];
380
		$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround
381
	}
382
	asort($l_names);
383
	foreach($l_names as $l_name=>$v) {
384
		// Insert code and name
385
		$template->set_var(array(
386
								'VALUE' => $l_codes[$l_name],
387
								'NAME' => $l_name
388
								));
389
		// Check if it is selected
390
		if($results_array['language'] == $l_codes[$l_name]) {
391
			$template->set_var('SELECTED', ' selected');
392
		} else {
393
			$template->set_var('SELECTED', '');
394
		}
395
		$template->parse('language_list', 'language_list_block', true);
396
	}
397
}
398

  
399
// Select disabled if searching is disabled
400
if($results_array['searching'] == 0) {
401
	$template->set_var('SEARCHING_DISABLED', ' selected');
402
}
403
// Select what the page target is
404
switch ($results_array['target']) {
405
	case '_top':
406
		$template->set_var('TOP_SELECTED', ' selected');
407
		break;
408
	case '_self':
409
		$template->set_var('SELF_SELECTED', ' selected');
410
		break;
411
	case '_blank':
412
		$template->set_var('BLANK_SELECTED', ' selected');
413
		break;
414
}
415
	
416

  
417
// Insert language text
418
$template->set_var(array(
419
								'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'],
420
								'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
421
								'TEXT_MODIFY' => $TEXT['MODIFY'],
422
								'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
423
								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
424
								'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'],
425
								'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'],
426
								'TEXT_TYPE' => $TEXT['TYPE'],
427
								'TEXT_MENU' => $TEXT['MENU'],
428
								'TEXT_PARENT' => $TEXT['PARENT'],
429
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
430
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
431
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
432
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
433
								'TEXT_NONE' => $TEXT['NONE'],
434
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
435
								'TEXT_TEMPLATE' => $TEXT['TEMPLATE'],
436
								'TEXT_TARGET' => $TEXT['TARGET'],
437
								'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'],
438
								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
439
								'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'],
440
								'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'],
441
								'TEXT_TOP_FRAME' => $TEXT['TOP_FRAME'],
442
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
443
								'TEXT_ALLOWED_VIEWERS' => $TEXT['ALLOWED_VIEWERS'],
444
								'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
445
								'TEXT_KEYWORDS' => $TEXT['KEYWORDS'],
446
								'TEXT_SEARCHING' => $TEXT['SEARCHING'],
447
								'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
448
								'TEXT_ENABLED' => $TEXT['ENABLED'],
449
								'TEXT_DISABLED' => $TEXT['DISABLED'],
450
								'TEXT_SAVE' => $TEXT['SAVE'],
451
								'TEXT_RESET' => $TEXT['RESET'],
452
								'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
453
								'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
454
								)
455
						);
456

  
457
$template->parse('main', 'main_block', false);
458
$template->pparse('output', 'page');
459

  
460
// Print admin footer
461
$admin->print_footer();
462

  
463
?>
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Get page id
27
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
28
	header("Location: index.php");
29
	exit(0);
30
} else {
31
	$page_id = $_GET['page_id'];
32
}
33

  
34
// Create new admin object
35
require('../../config.php');
36
require_once(WB_PATH.'/framework/class.admin.php');
37
$admin = new admin('Pages', 'pages_settings');
38

  
39
// Include the WB functions file
40
require_once(WB_PATH.'/framework/functions-utf8.php');
41

  
42
// Get perms
43
$database = new database();
44
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
45
$results_array = $results->fetchRow();
46
$old_admin_groups = explode(',', $results_array['admin_groups']);
47
$old_admin_users = explode(',', $results_array['admin_users']);
48

  
49
$in_old_group = FALSE;
50
foreach($admin->get_groups_id() as $cur_gid){
51
	if (in_array($cur_gid, $old_admin_groups)) {
52
		$in_old_group = TRUE;
53
	}
54
}
55
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
56
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
57
}
58

  
59
// Get page details
60
$database = new database();
61
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
62
$results = $database->query($query);
63
if($database->is_error()) {
64
	$admin->print_header();
65
	$admin->print_error($database->get_error());
66
}
67
if($results->numRows() == 0) {
68
	$admin->print_header();
69
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
70
}
71
$results_array = $results->fetchRow();
72

  
73
// Get display name of person who last modified the page
74
$user=$admin->get_user_details($results_array['modified_by']);
75

  
76
// Convert the unix ts for modified_when to human a readable form
77
if($results_array['modified_when'] != 0) {
78
	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
79
} else {
80
	$modified_ts = 'Unknown';
81
}
82

  
83
// Setup template object, parse vars to it, then parse it
84
$template = new Template(THEME_PATH.'/templates');
85
$template->set_file('page', 'pages_settings.htt');
86
$template->set_block('page', 'main_block', 'main');
87

  
88
$template->set_var(array(
89
				'PAGE_ID' => $results_array['page_id'],
90
				'PAGE_TITLE' => ($results_array['page_title']),
91
				'MENU_TITLE' => ($results_array['menu_title']),
92
				'DESCRIPTION' => ($results_array['description']),
93
				'KEYWORDS' => ($results_array['keywords']),
94
				'MODIFIED_BY' => $user['display_name'],
95
				'MODIFIED_BY_USERNAME' => $user['username'],
96
				'MODIFIED_WHEN' => $modified_ts,
97
				'ADMIN_URL' => ADMIN_URL,
98
				'WB_URL' => WB_URL,
99
				'WB_PATH' => WB_PATH,
100
				'THEME_URL' => THEME_URL,
101
			) );
102

  
103
// Work-out if we should show the "manage sections" link
104
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
105
if($query_sections->numRows() > 0) {
106
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
107
} elseif(MANAGE_SECTIONS == 'enabled') {
108
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
109
} else {
110
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
111
}
112

  
113
// Visibility
114
if($results_array['visibility'] == 'public') {
115
	$template->set_var('PUBLIC_SELECTED', ' selected="selected"');
116
} elseif($results_array['visibility'] == 'private') {
117
	$template->set_var('PRIVATE_SELECTED', ' selected="selected"');
118
} elseif($results_array['visibility'] == 'registered') {
119
	$template->set_var('REGISTERED_SELECTED', ' selected="selected"');
120
} elseif($results_array['visibility'] == 'hidden') {
121
	$template->set_var('HIDDEN_SELECTED', ' selected="selected"');
122
} elseif($results_array['visibility'] == 'none') {
123
	$template->set_var('NO_VIS_SELECTED', ' selected="selected"');
124
}
125
// Group list 1 (admin_groups)
126
	$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
127

  
128
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
129
	
130
	$get_groups = $database->query($query);
131
	$template->set_block('main_block', 'group_list_block', 'group_list');
132
	// Insert admin group and current group first
133
	$admin_group_name = $get_groups->fetchRow();
134
	$template->set_var(array(
135
									'ID' => 1,
136
									'TOGGLE' => '',
137
									'DISABLED' => ' disabled="disabled"',
138
									'LINK_COLOR' => '000000',
139
									'CURSOR' => 'default',
140
									'NAME' => $admin_group_name['name'],
141
									'CHECKED' => ' checked="checked"'
142
									)
143
							);
144
	$template->parse('group_list', 'group_list_block', true);
145
	/*
146
	if(!in_array(1, $admin->get_groups_id())) {
147
		$users_groups = $admin->get_groups_name();
148
		foreach ($admin->get_groups_id() as $users_group_id) {
149
			$template->set_var(array(
150
										'ID' => $users_group_id,
151
										'TOGGLE' => '',
152
										'DISABLED' => ' disabled',
153
										'LINK_COLOR' => '000000',
154
										'CURSOR' => 'default',
155
										'NAME' => $users_groups[$users_group_id],
156
										'CHECKED' => ' checked'
157
										)
158
								);
159
			$template->parse('group_list', 'group_list_block', true);
160
		}
161
	}
162
	*/
163
	while($group = $get_groups->fetchRow()) {
164
		// check if the user is a member of this group
165
		$flag_disabled = '';
166
		$flag_checked =  '';
167
		$flag_cursor =   'pointer';
168
		$flag_color =    '';
169
		if (in_array($group["group_id"], $admin->get_groups_id())) {
170
			$flag_disabled = ''; //' disabled';
171
			$flag_checked =  ''; //' checked';
172
			$flag_cursor =   'default';
173
			$flag_color =    '000000';
174
		}
175

  
176
		// Check if the group is allowed to edit pages
177
		$system_permissions = explode(',', $group['system_permissions']);
178
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
179
			$template->set_var(array(
180
											'ID' => $group['group_id'],
181
											'TOGGLE' => $group['group_id'],
182
											'DISABLED' => $flag_disabled,
183
											'LINK_COLOR' => $flag_color,
184
											'CURSOR' => $flag_cursor,
185
											'NAME' => $group['name'],
186
											'CHECKED' => $flag_checked
187
											)
188
									);
189
			if(is_numeric(array_search($group['group_id'], $admin_groups))) {
190
				$template->set_var('CHECKED', ' checked="checked"');
191
			} else {
192
				if (!$flag_checked) $template->set_var('CHECKED', '');
193
			}
194
			$template->parse('group_list', 'group_list_block', true);
195
		}
196
	}
197
// Group list 2 (viewing_groups)
198
	$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
199

  
200
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
201

  
202
	$get_groups = $database->query($query);
203
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
204
	// Insert admin group and current group first
205
	$admin_group_name = $get_groups->fetchRow();
206
	$template->set_var(array(
207
									'ID' => 1,
208
									'TOGGLE' => '',
209
									'DISABLED' => ' disabled="disabled"',
210
									'LINK_COLOR' => '000000',
211
									'CURSOR' => 'default',
212
									'NAME' => $admin_group_name['name'],
213
									'CHECKED' => ' checked="checked"'
214
									)
215
							);
216
	$template->parse('group_list2', 'group_list_block2', true);
217

  
218

  
219
	while($group = $get_groups->fetchRow()) {
220
		// check if the user is a member of this group
221
		$flag_disabled = '';
222
		$flag_checked =  '';
223
		$flag_cursor =   'pointer';
224
		$flag_color =    '';
225
		if (in_array($group["group_id"], $admin->get_groups_id())) {
226
			$flag_disabled = ''; //' disabled';
227
			$flag_checked =  ''; //' checked';
228
			$flag_cursor =   'default';
229
			$flag_color =    '000000';
230
		}
231

  
232
		$template->set_var(array(
233
										'ID' => $group['group_id'],
234
										'TOGGLE' => $group['group_id'],
235
										'DISABLED' => $flag_disabled,
236
										'LINK_COLOR' => $flag_color,
237
										'CURSOR' => $flag_cursor,
238
										'NAME' => $group['name'],
239
										'CHECKED' => $flag_checked
240
										)
241
								);
242
		if(is_numeric(array_search($group['group_id'], $viewing_groups))) {
243
			$template->set_var('CHECKED', 'checked="checked"');
244
		} else {
245
			if (!$flag_checked) $template->set_var('CHECKED', '');
246
		}
247
		$template->parse('group_list2', 'group_list_block2', true);
248
	}
249
// Show private viewers
250
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered') {
251
	$template->set_var('DISPLAY_VIEWERS', '');
252
} else {
253
	$template->set_var('DISPLAY_VIEWERS', 'none');
254
}
255

  
256
// Parent page list
257
$database = new database();
258
function parent_list($parent) {
259
	global $admin, $database, $template, $results_array;
260
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
261
	$get_pages = $database->query($query);
262
	while($page = $get_pages->fetchRow()) {
263
		if($admin->page_is_visible($page)==false)
264
			continue;
265
		// if psrent = 0 set flag_icon
266
		$template->set_var('FLAG_ROOT_ICON',' none ');
267
		if( $page['parent'] == 0 ) {
268
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
269
		}
270
		// If the current page cannot be parent, then its children neither
271
		$list_next_level = true;
272
		// Stop users from adding pages with a level of more than the set page level limit
273
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
274
			// Get user perms
275
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
276
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
277
			$in_group = FALSE;
278
			foreach($admin->get_groups_id() as $cur_gid){
279
				if (in_array($cur_gid, $admin_groups)) {
280
					$in_group = TRUE;
281
				}
282
			}
283
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
284
				$can_modify = true;
285
			} else {
286
				$can_modify = false;
287
			}
288
			// Title -'s prefix
289
			$title_prefix = '';
290
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
291
			$template->set_var(array(
292
											'ID' => $page['page_id'],
293
											'TITLE' => ($title_prefix.$page['page_title']),
294
											'FLAG_ICON' => 'none',
295
											));
296

  
297
			if($results_array['parent'] == $page['page_id']) {
298
				$template->set_var('SELECTED', ' selected="selected"');
299
			} elseif($results_array['page_id'] == $page['page_id']) {
300
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
301
				$list_next_level=false;
302
			} elseif($can_modify != true) {
303
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
304
			} else {
305
				$template->set_var('SELECTED', '');
306
			}
307
			$template->parse('page_list2', 'page_list_block2', true);
308
		}
309
		if ($list_next_level)
310
			parent_list($page['page_id']);
311
	}
312
}
313

  
314
$template->set_block('main_block', 'page_list_block2', 'page_list2');
315
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
316
	if($results_array['parent'] == 0) {
317
		$selected = ' selected';
318
	} else { 
319
		$selected = '';
320
	}
321
	$template->set_var(array(
322
									'ID' => '0',
323
									'TITLE' => $TEXT['NONE'],
324
									'SELECTED' => $selected
325
									)
326
							);
327
	$template->parse('page_list2', 'page_list_block2', true);
328
}
329
parent_list(0);
330

  
331
if($modified_ts == 'Unknown') {
332
	$template->set_var('DISPLAY_MODIFIED', 'hide');
333
} else {
334
	$template->set_var('DISPLAY_MODIFIED', '');
335
}
336
// Templates list
337
$template->set_block('main_block', 'template_list_block', 'template_list');
338
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' and function = 'template' order by name");
339
if($result->numRows() > 0) {
340
	while($addon = $result->fetchRow()) { 
341
		// Check if the user has perms to use this template
342
		if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) {
343
			$template->set_var('VALUE', $addon['directory']);
344
			$template->set_var('NAME', $addon['name']);
345
			if($addon['directory'] == $results_array['template']) {
346
				$template->set_var('SELECTED', ' selected="selected"');
347
			} else {
348
				$template->set_var('SELECTED', '');
349
			}
350
			$template->parse('template_list', 'template_list_block', true);
351
		}
352
	}
353
}
354

  
355
// Menu list
356
if(MULTIPLE_MENUS == false) {
357
	$template->set_var('DISPLAY_MENU_LIST', 'none');
358
}
359
// Include template info file (if it exists)
360
if($results_array['template'] != '') {
361
	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
362
} else {
363
	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
364
}
365
if(file_exists($template_location)) {
366
	require($template_location);
367
}
368
// Check if $menu is set
369
if(!isset($menu[1]) OR $menu[1] == '') {
370
	// Make our own menu list
371
	$menu[1] = $TEXT['MAIN'];
372
}
373
// Add menu options to the list
374
$template->set_block('main_block', 'menu_list_block', 'menu_list');
375
foreach($menu AS $number => $name) {
376
	$template->set_var('NAME', $name);
377
	$template->set_var('VALUE', $number);
378
	if($results_array['menu'] == $number) {
379
		$template->set_var('SELECTED', ' selected="selected"');
380
	} else {
381
		$template->set_var('SELECTED', '');
382
	}
383
	$template->parse('menu_list', 'menu_list_block', true);
384
}
385

  
386
// Insert language values
387
$template->set_block('main_block', 'language_list_block', 'language_list');
388
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name");
389
if($result->numRows() > 0) {
390
	while($addon = $result->fetchRow()) {
391
		$l_codes[$addon['name']] = $addon['directory'];
392
		$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround
393
	}
394
	asort($l_names);
395
	foreach($l_names as $l_name=>$v) {
396
		// Insert code and name
397
		$template->set_var(array(
398
								'VALUE' => $l_codes[$l_name],
399
								'NAME' => $l_name,
400
								'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]).'.png)',
401
								));
402
		// Check if it is selected
403
		if($results_array['language'] == $l_codes[$l_name]) {
404
			$template->set_var('SELECTED', ' selected="selected"');
405
		} else {
406
			$template->set_var('SELECTED', '');
407
		}
408
		$template->parse('language_list', 'language_list_block', true);
409
	}
410
}
411

  
412
// Select disabled if searching is disabled
413
if($results_array['searching'] == 0) {
414
	$template->set_var('SEARCHING_DISABLED', ' selected="selected"');
415
}
416
// Select what the page target is
417
switch ($results_array['target']) {
418
	case '_top':
419
		$template->set_var('TOP_SELECTED', ' selected="selected"');
420
		break;
421
	case '_self':
422
		$template->set_var('SELF_SELECTED', ' selected="selected"');
423
		break;
424
	case '_blank':
425
		$template->set_var('BLANK_SELECTED', ' selected="selected"');
426
		break;
427
}
428
	
429

  
430
// Insert language text
431
$template->set_var(array(
432
				'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'],
433
				'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
434
				'TEXT_MODIFY' => $TEXT['MODIFY'],
435
				'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
436
				'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
437
				'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'],
438
				'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'],
439
				'TEXT_TYPE' => $TEXT['TYPE'],
440
				'TEXT_MENU' => $TEXT['MENU'],
441
				'TEXT_PARENT' => $TEXT['PARENT'],
442
				'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
443
				'TEXT_PUBLIC' => $TEXT['PUBLIC'],
444
				'TEXT_PRIVATE' => $TEXT['PRIVATE'],
445
				'TEXT_REGISTERED' => $TEXT['REGISTERED'],
446
				'TEXT_NONE' => $TEXT['NONE'],
447
				'TEXT_HIDDEN' => $TEXT['HIDDEN'],
448
				'TEXT_TEMPLATE' => $TEXT['TEMPLATE'],
449
				'TEXT_TARGET' => $TEXT['TARGET'],
450
				'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'],
451
				'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
452
				'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'],
453
				'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'],
454
				'TEXT_TOP_FRAME' => $TEXT['TOP_FRAME'],
455
				'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
456
				'TEXT_ALLOWED_VIEWERS' => $TEXT['ALLOWED_VIEWERS'],
457
				'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
458
				'TEXT_KEYWORDS' => $TEXT['KEYWORDS'],
459
				'TEXT_SEARCHING' => $TEXT['SEARCHING'],
460
				'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
461
				'TEXT_ENABLED' => $TEXT['ENABLED'],
462
				'TEXT_DISABLED' => $TEXT['DISABLED'],
463
				'TEXT_SAVE' => $TEXT['SAVE'],
464
				'TEXT_RESET' => $TEXT['RESET'],
465
				'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
466
				'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
467
			) );
468

  
469
$template->parse('main', 'main_block', false);
470
$template->pparse('output', 'page');
471

  
472
// Print admin footer
473
$admin->print_footer();
474

  
475
?>
trunk/wb/admin/pages/page_trash.js
1
function toggle_viewers() {
2
	if(document.add.visibility.value == 'private') {
3
		document.getElementById('private_viewers').style.display = 'block';
4
		document.getElementById('registered_viewers').style.display = 'none';
5
	} else if(document.add.visibility.value == 'registered') {
6
		document.getElementById('private_viewers').style.display = 'none';
7
		document.getElementById('registered_viewers').style.display = 'block';
8
	} else {
9
		document.getElementById('private_viewers').style.display = 'none';
10
		document.getElementById('registered_viewers').style.display = 'none';
11
	}
12
}
13

  
14
function toggle_visibility(id){
15
	if(document.getElementById(id).style.display == "block") {
16
		document.getElementById(id).style.display = "none";
17
	} else {
18
		document.getElementById(id).style.display = "block";
19
	}
20
}
21
var plus = new Image;
22
plus.src = "<?php echo THEME_URL; ?>/images/plus_16.png";
23
var minus = new Image;
24
minus.src = "<?php echo THEME_URL; ?>/images/minus_16.png";
25
function toggle_plus_minus(id) {
26
	var img_src = document.images['plus_minus_' + id].src;
27
	if(img_src == plus.src) {
28
		document.images['plus_minus_' + id].src = minus.src;
29
	} else {
30
		document.images['plus_minus_' + id].src = plus.src;
31
	}
32
}
0 33

  
trunk/wb/admin/pages/index.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
require('../../config.php');
27
require_once(WB_PATH.'/framework/class.admin.php');
28
$admin = new admin('Pages', 'pages');
29
// Include the WB functions file
30
require_once(WB_PATH.'/framework/functions.php');
31

  
32
?>
33
<!-- Addition for remembering expanded state of pages -->
34
<script language="JavaScript">
35
function writeSessionCookie (cookieName, cookieValue) {
36
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + ";";
37
}
38
</script>
39
<!-- End addition -->
40

  
41
<script type="text/javascript" language="javascript">
42
function toggle_viewers() {
43
	if(document.add.visibility.value == 'private') {
44
		document.getElementById('viewers').style.display = 'block';
45
	} else if(document.add.visibility.value == 'registered') {
46
		document.getElementById('viewers').style.display = 'block';
47
	} else {
48
		document.getElementById('viewers').style.display = 'none';
49
	}
50
}
51
function toggle_visibility(id){
52
	if(document.getElementById(id).style.display == "block") {
53
		document.getElementById(id).style.display = "none";
54
		writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
55
	} else {
56
		document.getElementById(id).style.display = "block";
57
		writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
58
	}
59
}
60
var plus = new Image;
61
plus.src = "<?php echo THEME_URL; ?>/images/plus_16.png";
62
var minus = new Image;
63
minus.src = "<?php echo THEME_URL; ?>/images/minus_16.png";
64
function toggle_plus_minus(id) {
65
	var img_src = document.images['plus_minus_' + id].src;
66
	if(img_src == plus.src) {
67
		document.images['plus_minus_' + id].src = minus.src;
68
	} else {
69
		document.images['plus_minus_' + id].src = plus.src;
70
	}
71
}
72
</script>
73

  
74
<?php
75

  
76
function make_list($parent, $editable_pages) {
77
	// Get objects and vars from outside this function
78
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING;
79
	?>
80
	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list" '; if(isset($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1'){ echo 'style="display:block"'; }} ?>>
81
	<?php	
82
	// Get page list from database
83
	$database = new database();
84
	if(PAGE_TRASH != 'inline') {
85
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
86
	} else {
87
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
88
	}
89
	$get_pages = $database->query($query);
90
	
91
	// Insert values into main page list
92
	if($get_pages->numRows() > 0)	{
93
		while($page = $get_pages->fetchRow()) {
94
			// Get user perms
95
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
96
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
97

  
98
			$in_group = FALSE;
99
			foreach($admin->get_groups_id() as $cur_gid){
100
			    if (in_array($cur_gid, $admin_groups)) {
101
			        $in_group = TRUE;
102
			    }
103
			}
104
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
105
				if($page['visibility'] == 'deleted') {
106
					if(PAGE_TRASH == 'inline') {
107
						$can_modify = true;
108
						$editable_pages = $editable_pages+1;
109
					} else {
110
						$can_modify = false;
111
					}
112
				} elseif($page['visibility'] != 'deleted') {
113
					$can_modify = true;
114
					$editable_pages = $editable_pages+1;
115
				}
116
			} else {
117
				if($page['visibility'] == 'private') {
118
					continue;
119
				}
120
				else {
121
					$can_modify = false;
122
				}
123
			}
124
						
125
			// Work out if we should show a plus or not
126
			if(PAGE_TRASH != 'inline') {
127
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
128
			} else {
129
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
130
			}
131
			if($get_page_subs->numRows() > 0) {
132
				$display_plus = true;
133
			} else {
134
				$display_plus = false;
135
			}
136
			
137
			// Work out how many pages there are for this parent
138
			$num_pages = $get_pages->numRows();
139
			?>
140
			
141
			<li id="p<?php echo $page['parent']; ?>">
142
			<table class="pages_view">
143
			<tr>
144
				<td width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
145
					<?php
146
					if($display_plus == true) {
147
					?>
148
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
149
						<img src="<?php echo THEME_URL; ?>/images/<?php if(isset($_COOKIE['p'.$page['page_id']]) && $_COOKIE['p'.$page['page_id']] == '1'){ echo 'minus'; } else { echo 'plus'; } ?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" border="0" alt="+" />
150
					</a>
151
					<?php
152
					}
153
					?>
154
				</td>
155
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
156
				<td>
157
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
158
						<?php if($page['visibility'] == 'public') { ?>
159
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
160
						<?php } elseif($page['visibility'] == 'private') { ?>
161
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
162
						<?php } elseif($page['visibility'] == 'registered') { ?>
163
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
164
						<?php } elseif($page['visibility'] == 'hidden') { ?>
165
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
166
						<?php } elseif($page['visibility'] == 'none') { ?>
167
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
168
						<?php } elseif($page['visibility'] == 'deleted') { ?>
169
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
170
						<?php } 
171
						echo '<div class="modify_link">'.($page['page_title']).'</div>'; ?>
172
					</a>				
173
				</td>
174
				<?php } else { ?>
175
				<td>
176
					<?php if($page['visibility'] == 'public') { ?>
177
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
178
					<?php } elseif($page['visibility'] == 'private') { ?>
179
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
180
					<?php } elseif($page['visibility'] == 'registered') { ?>
181
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
182
					<?php } elseif($page['visibility'] == 'hidden') { ?>
183
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
184
					<?php } elseif($page['visibility'] == 'none') { ?>
185
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
186
					<?php } elseif($page['visibility'] == 'deleted') { ?>
187
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
188
					<?php } 
189
					echo ($page['page_title']); ?>
190
				</td>
191
				<?php } ?>
192
				<td align="left" width="252">
193
					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
194
				</td>
195
				<td width="20">
196
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
197
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
198
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
199
					</a>
200
					<?php } ?>
201
				</td>
202
				<td width="20">
203
					<?php if($page['visibility'] != 'deleted') { ?>
204
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
205
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
206
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
207
						</a>
208
						<?php } ?>
209
					<?php } else { ?>
210
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
211
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
212
						</a>
213
					<?php } ?>
214
				</td>
215
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
216
				<td width="20">
217
				<?php
218
				// Work-out if we should show the "manage dates" link
219
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true) {
220
					$query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
221
					if($query_sections->numRows() > 0) {
222
						$mdate_display=false;
223
						while($mdate_res = $query_sections->fetchRow()) {
224
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0') {
225
								$mdate_display=true;
226
								break;
227
							}
228
						}
229
						if($mdate_display==1) {
230
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
231
							?>
232
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
233
							<img src="<?php echo THEME_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />	
234
							</a>
235
						<?php } else { ?>
236
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
237
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>	
238
						<?php } ?>
239
					<?php } ?>
240
				<?php } ?>
241
				</td>
242
				<td width="20">
243
				<?php if($page['position'] != 1) { ?>
244
					<?php if($page['visibility'] != 'deleted') { ?>
245
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
246
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
247
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
248
						</a>
249
						<?php } ?>
250
					<?php } ?>
251
				<?php } ?>
252
				</td>
253
				<td width="20">
254
				<?php if($page['position'] != $num_pages) { ?>
255
					<?php if($page['visibility'] != 'deleted') { ?>
256
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
257
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
258
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
259
						</a>
260
						<?php } ?>
261
					<?php } ?>
262
				<?php } ?>
263
				</td>
264
				<td width="20">
265
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
266
					<a href="javascript: confirm_link('<?php echo $MESSAGE['PAGES']['DELETE_CONFIRM']; ?>?', '<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
267
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
268
					</a>
269
					<?php } ?>
270
				</td>
271
			</tr>
272
			</table>
273
			</li>
274
							
275
			<?php
276
			// Get subs
277
			$editable_pages=make_list($page['page_id'], $editable_pages);
278
		}
279

  
280
	}
281
	?>
282
	</ul>
283
	<?php
284
	return $editable_pages;
285
}
286

  
287
// Generate pages list
288
if($admin->get_permission('pages_view') == true) {
289
	?>
290
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
291
	<tr>
292
		<td>
293
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
294
		</td>
295
		<td align="right">
296
			<?php
297
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
298
				if(PAGE_TRASH == 'separate') {
299
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
300
					if($query_trash->numRows() > 0) {
301
						?>
302
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
303
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
304
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
305
						<?php
306
					}
307
				}
308
			?>
309
		</td>
310
	</tr>
311
	</table>
312
	<div class="pages_list">
313
	<table cellpadding="0" cellspacing="0" border="0">
314
	<tr>
315
		<td width="20px">
316
			&nbsp;
317
		</td>
318
		<td width="314px">
319
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
320
		</td>
321
		<td width="256px" align="left">
322
			<?php echo $TEXT['MENU_TITLE']; ?>:
323
		</td>
324
		<td width="130px" align="center">
325
			<?php echo $TEXT['ACTIONS']; ?>:
326
		</td>		
327
	</tr>
328
	</table>
329
	<?php
330
	$editable_pages = make_list(0, 0);
331
	?>
332
	</div>
333
	<div class="empty_list">
334
		<?php echo $TEXT['NONE_FOUND']; ?>
335
	</div>
336
	<?php
337
} else {
338
	$editable_pages = 0;
339
}
340

  
341
// Setup template object
342
$template = new Template(THEME_PATH.'/templates');
343
$template->set_file('page', 'pages.htt');
344
$template->set_block('page', 'main_block', 'main');
345

  
346
// Figure out if the no pages found message should be shown or not
347
if($editable_pages == 0) {
348
	?>
349
	<style type="text/css">
350
	.pages_list {
351
		display: none;
352
	}
353
	</style>
354
	<?php
355
} else {
356
	?>
357
	<style type="text/css">
358
	.empty_list {
359
		display: none;
360
	}
361
	</style>
362
	<?php
363
}
364

  
365
// Insert values into the add page form
366

  
367
// Group list 1
368

  
369
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
370

  
371
	$get_groups = $database->query($query);
372
	$template->set_block('main_block', 'group_list_block', 'group_list');
373
	// Insert admin group and current group first
374
	$admin_group_name = $get_groups->fetchRow();
375
	$template->set_var(array(
376
									'ID' => 1,
377
									'TOGGLE' => '',
378
									'DISABLED' => ' disabled',
379
									'LINK_COLOR' => '000000',
380
									'CURSOR' => 'default',
381
									'NAME' => $admin_group_name['name'],
382
									'CHECKED' => ' checked'
383
									)
384
							);
385
	$template->parse('group_list', 'group_list_block', true);
386

  
387
	while($group = $get_groups->fetchRow()) {
388
		// check if the user is a member of this group
389
		$flag_disabled = '';
390
		$flag_checked =  '';
391
		$flag_cursor =   'pointer';
392
		$flag_color =    '';
393
		if (in_array($group["group_id"], $admin->get_groups_id())) {
394
			$flag_disabled = ''; //' disabled';
395
			$flag_checked =  ' checked';
396
			$flag_cursor =   'default';
397
			$flag_color =    '000000';
398
		}
399

  
400
		// Check if the group is allowed to edit pages
401
		$system_permissions = explode(',', $group['system_permissions']);
402
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
403
			$template->set_var(array(
404
											'ID' => $group['group_id'],
405
											'TOGGLE' => $group['group_id'],
406
											'CHECKED' => $flag_checked,
407
											'DISABLED' => $flag_disabled,
408
											'LINK_COLOR' => $flag_color,
409
											'CURSOR' => $flag_checked,
410
											'NAME' => $group['name'],
411
											)
412
									);
413
			$template->parse('group_list', 'group_list_block', true);
414
		}
415
	}
416
// Group list 2
417

  
418
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
419

  
420
	$get_groups = $database->query($query);
421
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
422
	// Insert admin group and current group first
423
	$admin_group_name = $get_groups->fetchRow();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff