Project

General

Profile

« Previous | Next » 

Revision 1664

Added by darkviper over 12 years ago

added additional rights for AdminUsers/ViewerUsers in /pages/page_settings
/pages/settings2.php renamed into /pages/settings_save.php

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
17 Apr-2012 Build 1664 Werner v.d.Decken(DarkViper)
15
+ added additional rights for AdminUsers/ViewerUsers in /pages/page_settings
16
! /pages/settings2.php renamed into /pages/settings_save.php
14 17
17 Apr-2012 Build 1663 Dietmar Woellbrink (Luisehahne)
15 18
! update round print.css for better output
16 19
17 Apr-2012 Build 1662 Werner v.d.Decken(DarkViper)
branches/2.8.x/wb/admin/skel/themes/htt/pages_settings.htt
1 1
<!-- BEGIN main_block -->
2

  
3 2
<script src="{ADMIN_URL}/pages/page_settings.js" type="text/javascript"></script>
4

  
3
<link href="http://istmzw01.isteam.loc/WB28x-Branch/wb/templates/wb_theme/theme.css" rel="stylesheet" type="text/css" />
5 4
<table summary="" cellpadding="5" cellspacing="0" border="0" align="center" width="100%" style="margin-bottom:10px;">
6 5
  <tr style="background:#f0f0f0;">
7 6
	<td valign="middle" align="left"><h2>{HEADING_MODIFY_PAGE_SETTINGS}</h2></td>
......
10 9
		{TEXT_CURRENT_PAGE}:
11 10
		<b>{PAGE_TITLE}</b>
12 11
		-
13
		<a href="{ADMIN_URL}/pages/modify.php?page_id={PAGE_IDKEY}">{TEXT_MODIFY_PAGE}</a>
14
		<font style="{DISPLAY_MANAGE_SECTIONS}">-</font>
15
		<a href="{ADMIN_URL}/pages/sections.php?page_id={PAGE_IDKEY}" style="{DISPLAY_MANAGE_SECTIONS}">{TEXT_MANAGE_SECTIONS}</a>
12
		<a href="{ADMIN_URL}/pages/modify.php?page_id={PAGE_ID}">{TEXT_MODIFY_PAGE}</a>
13
		<span style="{DISPLAY_MANAGE_SECTIONS}">
14
		- <a href="{ADMIN_URL}/pages/sections.php?page_id={PAGE_ID}">{TEXT_MANAGE_SECTIONS}</a>
15
		</span>
16 16
		<br />
17
		<font style="color:#999;" class="{DISPLAY_MODIFIED}">
17
		<span style="color:#999;" class="{DISPLAY_MODIFIED}">
18 18
			{LAST_MODIFIED} {MODIFIED_BY} ({MODIFIED_BY_USERNAME}), {MODIFIED_WHEN}
19
		</font>
19
		</span>
20 20
	</td>
21 21
  </tr>
22 22
</table>
23 23

  
24
<form name="settings" action="settings2.php" method="post">
25
{FTAN}
26
<input type="hidden" name="page_id" value="{PAGE_ID}" />
27
<table summary="" cellpadding="2" cellspacing="0" border="0" width="100%" align="center">
28
<tr>
29
	<td width="100" height="20">{TEXT_PAGE_TITLE}:</td>
30
	<td width="240" height="20">
31
		<input type="text" name="page_title" value="{PAGE_TITLE}" style="width: 232px;" />
32
	</td>
33
	<td rowspan="10" valign="top" style="padding-left: 20px; padding-top: 8px;">
34
		{TEXT_ADMINISTRATORS}:
35
		<ul style="list-style-type: none; margin: 0; padding: 0;">
36
			<!-- BEGIN group_list_block -->
37
			<li>
38
			<input type="checkbox" name="admin_groups[]" id="admin_group_{ID}" value="{ID}"{CHECKED}{DISABLED} />
39
			<label for="admin_group_{TOGGLE}">{NAME}</label>
40
			</li>
41
			<!-- END group_list_block -->
42
		</ul>
43
	</td>
44
	<td rowspan="10" valign="top" style="padding:8px 0 0 20px;">
45
		<div id="allowed_viewers" style="{DISPLAY_VIEWERS}">
46
			{TEXT_ALLOWED_VIEWERS}:
24
<form name="settings" action="settings_save.php" method="post">
25
	{FTAN}
26
	<input type="hidden" name="page_id" value="{PAGE_IDKEY}" />
27
	<div class="page-settings">
28
		<div class="page-settings-leftcol"> <!-- left column -->
29
			<div>
30
				<label for="">{TEXT_PAGE_TITLE}:</label><input
31
					type="text" name="page_title" value="{PAGE_TITLE}" />
32
			</div>
33
			<div>
34
				<label for="">{TEXT_MENU_TITLE}:</label><input
35
					type="text" name="menu_title" value="{MENU_TITLE}" />
36
			</div>
37
			<div>
38
				<label for="">{TEXT_PARENT}:</label><select name="parent">
39
				<!-- BEGIN parent_page_list_block -->
40
					<option value="{ID}"{SELECTED} style="background: {FLAG_ROOT_ICON} no-repeat center left; padding-left: 20px;">{TITLE}</option>
41
				<!-- END parent_page_list_block -->
42
				</select>
43
			</div>
44
			<div>
45
				<label for="">{TEXT_VISIBILITY}:</label><select
46
					name="visibility" onchange="javascript: toggle_viewers();">
47
					<option value="public"{PUBLIC_SELECTED}>{TEXT_PUBLIC}</option>
48
					<option value="private"{PRIVATE_SELECTED}>{TEXT_PRIVATE}</option>
49
					<option value="registered"{REGISTERED_SELECTED}>{TEXT_REGISTERED}</option>
50
					<option value="hidden"{HIDDEN_SELECTED}>{TEXT_HIDDEN}</option>
51
					<option value="none"{NO_VIS_SELECTED}>{TEXT_NONE}</option>
52
				</select>
53
			</div>
54
			<div>
55
				<label for="">{TEXT_DESCRIPTION}:</label><textarea
56
					name="description" rows="14" cols="1">{DESCRIPTION}</textarea>
57
			</div>
58
			<div>
59
				<label for="">{TEXT_KEYWORDS}:</label><textarea
60
					name="keywords" rows="14" cols="1">{KEYWORDS}</textarea>
61
			</div>
62
			<div>
63
				<label for="">{TEXT_TARGET}:</label><select
64
					name="target" ><!--  value="{TARGET}" -->
65
					<option value="_blank"{BLANK_SELECTED}>{TEXT_NEW_WINDOW}</option>
66
					<option value="_self"{SELF_SELECTED}>{TEXT_SAME_WINDOW}</option>
67
					<option value="_top"{TOP_SELECTED}>{TEXT_TOP_FRAME}</option>
68
				</select>
69
			</div>
70
			<div>
71
				<label for="">{TEXT_TEMPLATE}:</label><select
72
					name="template">
73
					<option value="">{TEXT_SYSTEM_DEFAULT}</option>
74
					<option value="">----------------------</option>
75
				<!-- BEGIN template_list_block -->
76
					<option value="{VALUE}"{SELECTED}>{NAME}</option>
77
				<!-- END template_list_block -->
78
				</select>
79
			</div>
80
		<!-- BEGIN show_menu_list_block -->
81
			<div>
82
				<label for="">{TEXT_MENU}:</label><select
83
					name="menu">
84
				<!-- BEGIN menu_list_block -->
85
					<option value="{VALUE}"{SELECTED}>{NAME}</option>
86
				<!-- END menu_list_block -->
87
				</select>
88
			</div>
89
		<!-- END show_menu_list_block -->
90
			<div>
91
				<label for="">{TEXT_LANGUAGE}:</label><select
92
					name="language">
93
				<!-- BEGIN language_list_block -->
94
					<option value="{VALUE}"{SELECTED} style="background: {FLAG_LANG_ICONS} no-repeat center left; padding-left: 20px;">{NAME}</option>
95
				<!-- END language_list_block -->
96
				</select>
97
			</div>
98
		<!-- BEGIN show_page_code_block -->
99
			<div>
100
				<label for="">{TEXT_PAGE_CODE}:</label><select
101
					name="page_code" class="value_page_code">
102
				<!-- BEGIN page_code_list_block -->
103
						<option value="{VALUE}"{SELECTED} style="background: {FLAG_CODE_ICON} no-repeat center left; padding-left: 20px;">&nbsp;{PAGE_VALUE}</option>
104
				<!-- END page_code_list_block -->
105
				</select>
106
			</div>
107
		<!-- END show_page_code_block -->
108
			<div>
109
				<label for="">{TEXT_SEARCHING}:</label><select
110
					name="searching">
111
					<option value="1"{SEARCHING_SELECTED_ON}>{TEXT_ENABLED}</option>
112
					<option value="0"{SEARCHING_SELECTED_OFF}>{TEXT_DISABLED}</option>
113
				</select>
114
			</div>
115
		</div>
116
		<div class="page-settings-centercol"> <!-- center column -->
117
			{TEXT_ADMINISTRATORS}<hr />
118
			{TEXT_GROUP}<br />
119
<!-- *** List of groups which can administrate this page *** -->
120
			<ul style="list-style-type: none; margin: 0; padding: 0;">
121
			<!-- BEGIN admin_group_list_block -->
122
				<li>
123
					<input type="checkbox" name="admin_groups[]" id="admin_group_{ID}" value="{ID}"{CHECKED}{DISABLED} />
124
					<label for="admin_group_{ID}">{NAME}</label>
125
				</li>
126
			<!-- END admin_group_list_block -->
127
			</ul>
128
			<hr />
129
			{TEXT_USER}<br />
130
<!-- *** List of users which can administrate this page *** -->
131
			<select name="admin_users[]" multiple="multiple" size="{USER_LIST_SIZE}">
132
				<option value="0">--- {TEXT_NO_SELECTION} ---</option>
133
			<!-- BEGIN admin_user_list_block -->
134
				<option value="{ID}"{SELECTED}>{NAME}</option>
135
			<!-- END admin_user_list_block -->
136
			</select>
137
		</div>
138

  
139
		<div id="allowed_viewers" class="page-settings-rightcol" style="{DISPLAY_VIEWERS}"> <!-- right column -->
140
			{TEXT_ALLOWED_VIEWERS}<hr />
141
			{TEXT_GROUP}<br />
142
<!-- *** List of groups which can see this page *** -->
47 143
			<ul style="list-style-type:none;margin:0;padding:0;">
48
				<!-- BEGIN group_list_block2 -->
144
			<!-- BEGIN viewer_group_list_block -->
49 145
				<li>
50
				<input type="checkbox" name="viewing_groups[]" id="viewing_group_{ID}" value="{ID}"{CHECKED}{DISABLED} />
51
				<label for="viewing_group_{TOGGLE}">{NAME}</label>
146
					<input type="checkbox" name="viewing_groups[]" id="viewing_group_{ID}" value="{ID}"{CHECKED}{DISABLED} />
147
					<label for="viewing_group_{ID}">{NAME}</label>
52 148
				</li>
53
				<!-- END group_list_block2 -->
149
			<!-- END viewer_group_list_block -->
54 150
			</ul>
151
			<hr />
152
			{TEXT_USER}<br />
153
<!-- *** List of users which can see this page *** -->
154
			<select name="viewing_users[]" multiple="multiple" size="{USER_LIST_SIZE}">
155
				<option value="0">--- {TEXT_NO_SELECTION} ---</option>
156
			<!-- BEGIN viewer_user_list_block -->
157
				<option value="{ID}"{SELECTED}>{NAME}</option>
158
			<!-- END viewer_user_list_block -->
159
			</select>
55 160
		</div>
56
	</td>
57
</tr>
58
<tr>
59
	<td width="100" height="20">{TEXT_MENU_TITLE}:</td>
60
	<td width="240" height="20">
61
		<input type="text" name="menu_title" value="{MENU_TITLE}" style="width: 232px;" />
62
	</td>
63
</tr>
64
<tr>
65
	<td width="100">{TEXT_PARENT}:</td>
66
	<td width="240">
67
		<select name="parent" style="width: 240px;" onchange="return disabled_hack_for_ie(this);">
68
			<!-- BEGIN page_list_block2 -->
69
			<option value="{ID}"{SELECTED} style="background: {FLAG_ROOT_ICON} no-repeat center left; padding-left: 20px;">{TITLE}</option>
70
			<!-- END page_list_block2 -->
71
		</select>
72
	</td>
73
</tr>
74
<tr>
75
	<td width="100">{TEXT_VISIBILITY}:</td>
76
	<td width="240">
77
		<select name="visibility" onchange="javascript: toggle_viewers();" style="width: 240px;">
78
			<option value="public"{PUBLIC_SELECTED}>{TEXT_PUBLIC}</option>
79
			<option value="private"{PRIVATE_SELECTED}>{TEXT_PRIVATE}</option>
80
			<option value="registered"{REGISTERED_SELECTED}>{TEXT_REGISTERED}</option>
81
			<option value="hidden"{HIDDEN_SELECTED}>{TEXT_HIDDEN}</option>
82
			<option value="none"{NO_VIS_SELECTED}>{TEXT_NONE}</option>
83
		</select>
84
	</td>
85
</tr>
86
<tr>
87
	<td width="100" valign="top">{TEXT_DESCRIPTION}:</td>
88
	<td>
89
		<textarea name="description" rows="10" cols="1" style="width:236px;height:50px;">{DESCRIPTION}</textarea>
90
	</td>
91
</tr>
92
<tr>
93
	<td width="100" valign="top">{TEXT_KEYWORDS}:</td>
94
	<td>
95
		<textarea name="keywords" rows="10" cols="1" style="width:236px;height:50px;">{KEYWORDS}</textarea>
96
	</td>
97
</tr>
98
<tr>
99
	<td>
100
		{TEXT_TARGET}:
101
	</td>
102
	<td>
103
		<select name="target" style="width: 240px;" ><!--  value="{TARGET}" -->
104
			<option value="_blank"{BLANK_SELECTED}>{TEXT_NEW_WINDOW}</option>
105
			<option value="_self"{SELF_SELECTED}>{TEXT_SAME_WINDOW}</option>
106
			<option value="_top"{TOP_SELECTED}>{TEXT_TOP_FRAME}</option>
107
		</select>
108
	</td>
109
</tr>
110
<tr>
111
	<td width="100">{TEXT_TEMPLATE}:</td>
112
	<td width="240">
113
		<select name="template" style="width: 240px;">
114
			<option value="">{TEXT_SYSTEM_DEFAULT}</option>
115
			<option value="">----------------------</option>
116
			<!-- BEGIN template_list_block -->
117
			<option value="{VALUE}"{SELECTED}>{NAME}</option>
118
			<!-- END template_list_block -->
119
		</select>
120
	</td>
121
</tr>
122
<tr style="{DISPLAY_MENU_LIST}">
123
	<td width="100">{TEXT_MENU}:</td>
124
	<td width="240">
125
		<select name="menu" style="width: 240px;">
126
			<!-- BEGIN menu_list_block -->
127
			<option value="{VALUE}"{SELECTED}>{NAME}</option>
128
			<!-- END menu_list_block -->
129
		</select>
130
	</td>
131
</tr>
132
<tr style="{DISPLAY_LANGUAGE_LIST}">
133
	<td width="100">{TEXT_LANGUAGE}:</td>
134
	<td width="240">
135
		<select name="language" style="width: 240px;">
136
			<!-- BEGIN language_list_block -->
137
			<option value="{VALUE}"{SELECTED} style="background: {FLAG_LANG_ICONS} no-repeat center left; padding-left: 20px;">{NAME}</option>
138
			<!-- END language_list_block -->
139
		</select>
140
	</td>
141
</tr>
142
<!-- insert page_code 20090904-->
143
<tr{DISPLAY_CODE_PAGE_LIST}>
144
	<td width="100">{TEXT_PAGE_CODE}:</td>
145
	<td class="list_page_code">
146
		<select name="page_code" class="value_page_code">
147
			<!-- BEGIN page_code_list_block -->
148
			<option value="{VALUE}"{SELECTED} style="background: {FLAG_CODE_ICON} no-repeat center left; padding-left: 20px;">&nbsp;{PAGE_VALUE}</option>
149
			<!-- END page_code_list_block -->
150
		</select>
151
	</td>
152
</tr>
153
<!-- page code -->
154
<tr>
155
	<td width="100">{TEXT_SEARCHING}:</td>
156
	<td width="240">
157
		<select name="searching" style="width: 240px;">
158
			<option value="1">{TEXT_ENABLED}</option>
159
			<option value="0"{SEARCHING_DISABLED}>{TEXT_DISABLED}</option>
160
		</select>
161
	</td>
162
</tr>
163
<tr>
164
	<td width="100">&nbsp;</td>
165
	<td colspan="4">
166
		<input type="submit" name="submit" value="{TEXT_SAVE} {SECTION_SETTINGS}" style="width: 117px;" />
167
		<input type="reset" name="reset" value="{TEXT_RESET}" style="width: 117px;" />
168
	</td>
169
</tr>
170
<tr>
171
	<td>&nbsp;</td>
172
	<td>&nbsp;</td>
173
</tr>
174
</table>
175

  
161
		<div style="clear:both; padding-top: 1em;">
162
			<input type="submit" name="submit" value="{TEXT_SAVE}" style="width: 117px;" />
163
			<input type="reset" name="reset" value="{TEXT_RESET}" style="width: 117px;" />
164
		</div>
165
	</div>
176 166
</form>
177

  
178
<!-- END main_block -->
167
<!-- END main_block -->
branches/2.8.x/wb/admin/pages/settings2.php
1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
 */
18
/* */
19

  
20
// Create new admin object and print admin header
21
require('../../config.php');
22
require_once(WB_PATH.'/framework/class.admin.php');
23

  
24
// suppress to print the header, so no new FTAN will be set
25
$admin = new admin('Pages', 'pages_settings',false);
26

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

  
36
/*
37
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
38
{
39
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
40
}
41
*/
42
$pagetree_url = ADMIN_URL.'/pages/index.php';
43
$target_url = ADMIN_URL.'/pages/settings.php?page_id='.$page_id;
44

  
45
if (!$admin->checkFTAN())
46
{
47
	$admin->print_header();
48
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$target_url);
49
}
50
// After check print the header
51
$admin->print_header();
52

  
53
// Include the WB functions file
54
require_once(WB_PATH.'/framework/functions.php');
55

  
56
// Get values
57
$page_title = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->get_post_escaped('page_title')));
58
$menu_title = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->get_post_escaped('menu_title')));
59
$page_code = intval($admin->get_post('page_code')) ;
60
$description = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->add_slashes($admin->get_post('description'))));
61
$keywords = str_replace(array("[[", "]]"), '', htmlspecialchars($admin->add_slashes($admin->get_post('keywords'))));
62
$parent = intval($admin->get_post('parent')); // fix secunia 2010-91-3
63
$visibility = $admin->get_post_escaped('visibility');
64
if (!in_array($visibility, array('public', 'private', 'registered', 'hidden', 'none'))) {$visibility = 'public';} // fix secunia 2010-93-3
65
$template = preg_replace('/[^a-z0-9_-]/i', "", $admin->get_post('template')); // fix secunia 2010-93-3
66
$template = (($template == DEFAULT_TEMPLATE ) ? '' : $template);
67
$target = preg_replace("/\W/", "", $admin->get_post('target'));
68
$admin_groups = $admin->get_post_escaped('admin_groups');
69
$viewing_groups = $admin->get_post_escaped('viewing_groups');
70
$searching = intval($admin->get_post('searching'));
71
$language = strtoupper($admin->get_post('language'));
72
$language = (preg_match('/^[A-Z]{2}$/', $language) ? $language : DEFAULT_LANGUAGE);
73
$menu = intval($admin->get_post('menu')); // fix secunia 2010-91-3
74

  
75
// Validate data
76
if($page_title == '' || substr($page_title,0,1)=='.')
77
{
78
	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
79
}
80
if($menu_title == '' || substr($menu_title,0,1)=='.')
81
{
82
	$admin->print_error($MESSAGE['PAGES']['BLANK_MENU_TITLE']);
83
}
84

  
85
// Get existing perms
86
// $database = new database();
87

  
88
$sql = 'SELECT `parent`,`link`,`position`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id;
89
$results = $database->query($sql);
90

  
91
$results_array = $results->fetchRow();
92
$old_parent = $results_array['parent'];
93
$old_link = $results_array['link'];
94
$old_position = $results_array['position'];
95
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
96
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users']));
97

  
98
// Work-out if we should check for existing page_code
99
$field_set = $database->field_exists(TABLE_PREFIX.'pages', 'page_code');
100

  
101
$in_old_group = FALSE;
102
foreach($admin->get_groups_id() as $cur_gid)
103
{
104
    if (in_array($cur_gid, $old_admin_groups))
105
    {
106
	$in_old_group = TRUE;
107
    }
108
}
109
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
110
{
111
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
112
}
113

  
114
// Setup admin groups
115
$admin_groups[] = 1;
116
//if(!in_array(1, $admin->get_groups_id())) {
117
//	$admin_groups[] = implode(",",$admin->get_groups_id());
118
//}
119
$admin_groups = preg_replace("/[^\d,]/", "", implode(',', $admin_groups));
120
// Setup viewing groups
121
$viewing_groups[] = 1;
122
//if(!in_array(1, $admin->get_groups_id())) {
123
//	$viewing_groups[] = implode(",",$admin->get_groups_id());
124
//}
125
$viewing_groups = preg_replace("/[^\d,]/", "", implode(',', $viewing_groups));
126

  
127
// If needed, get new order
128
if($parent != $old_parent)
129
{
130
	// Include ordering class
131
	require(WB_PATH.'/framework/class.order.php');
132
	$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
133
	// Get new order
134
	$position = $order->get_new($parent);
135
	// Clean new order
136
	$order->clean($parent);
137
} else {
138
	$position = $old_position;
139
}
140

  
141
// Work out level and root parent
142
if ($parent!='0')
143
{
144
	$level = level_count($parent)+1;
145
	$root_parent = root_parent($parent);
146
}
147
else {
148
	$level = '0';
149
	$root_parent = '0';
150
}
151

  
152
// Work-out what the link should be
153
if($parent == '0')
154
{
155
	$link = '/'.page_filename($menu_title);
156
	// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
157
	if($link == '/index' || $link == '/intro')
158
    {
159
		$link .= '_' .$page_id;
160
		$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).'_'.$page_id .PAGE_EXTENSION;
161
	} else {
162
		$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($menu_title).PAGE_EXTENSION;
163
	}
164
} else {
165
	$parent_section = '';
166
	$parent_titles = array_reverse(get_parent_titles($parent));
167
	foreach($parent_titles AS $parent_title)
168
    {
169
		$parent_section .= page_filename($parent_title).'/';
170
	}
171
	if($parent_section == '/')
172
    {
173
      $parent_section = '';
174
    }
175
	$link = '/'.$parent_section.page_filename($menu_title);
176
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($menu_title).PAGE_EXTENSION;
177
}
178

  
179
// Check if a page with same page filename exists
180
// $database = new database();
181
$sql = 'SELECT `page_id`,`page_title` FROM `'.TABLE_PREFIX.'pages` WHERE `link` = "'.$link.'" AND `page_id` != '.$page_id;
182
$get_same_page = $database->query($sql);
183

  
184
if($get_same_page->numRows() > 0)
185
{
186
	$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']);
187
}
188

  
189
// Update page with new order
190
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET `parent`='.$parent.', `position`='.$position.' WHERE `page_id`='.$page_id.'';
191
// $database = new database();
192
$database->query($sql);
193

  
194
// Get page trail
195
$page_trail = get_page_trail($page_id);
196

  
197
// Update page settings in the pages table
198
$sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
199
$sql .= '`parent` = '.$parent.', ';
200
$sql .= '`page_title` = "'.$page_title.'", ';
201
$sql .= '`menu_title` = "'.$menu_title.'", ';
202
$sql .= '`menu` = '.$menu.', ';
203
$sql .= '`level` = '.$level.', ';
204
$sql .= '`page_trail` = "'.$page_trail.'", ';
205
$sql .= '`root_parent` = '.$root_parent.', ';
206
$sql .= '`link` = "'.$link.'", ';
207
$sql .= '`template` = "'.$template.'", ';
208
$sql .= '`target` = "'.$target.'", ';
209
$sql .= '`description` = "'.$description.'", ';
210
$sql .= '`keywords` = "'.$keywords.'", ';
211
$sql .= '`position` = '.$position.', ';
212
$sql .= '`visibility` = "'.$visibility.'", ';
213
$sql .= '`searching` = '.$searching.', ';
214
$sql .= '`language` = "'.$language.'", ';
215
$sql .= '`admin_groups` = "'.$admin_groups.'", ';
216
$sql .= '`viewing_groups` = "'.$viewing_groups.'"';
217
$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')) ? ', `page_code` = '.(int)$page_code.' ' : ' ';
218
$sql .= 'WHERE `page_id` = '.$page_id;
219
$database->query($sql);
220

  
221
$target_url = ADMIN_URL.'/pages/settings.php?page_id='.$page_id;
222
if($database->is_error())
223
{
224
	$admin->print_error($database->get_error(), $target_url );
225
}
226
// Clean old order if needed
227
if($parent != $old_parent)
228
{
229
	$order->clean($old_parent);
230
}
231

  
232
/* BEGIN page "access file" code */
233

  
234
// Create a new file in the /pages dir if title changed
235
if(!is_writable(WB_PATH.PAGES_DIRECTORY.'/'))
236
{
237
	$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
238
} else {
239
    $old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
240
	// First check if we need to create a new file
241
	if(($old_link != $link) || (!file_exists($old_filename)))
242
    {
243
		// Delete old file
244
		$old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
245
		if(file_exists($old_filename))
246
        {
247
			unlink($old_filename);
248
		}
249
		// Create access file
250
		create_access_file($filename,$page_id,$level);
251
		// Move a directory for this page
252
		if(file_exists(WB_PATH.PAGES_DIRECTORY.$old_link.'/') && is_dir(WB_PATH.PAGES_DIRECTORY.$old_link.'/'))
253
        {
254
			rename(WB_PATH.PAGES_DIRECTORY.$old_link.'/', WB_PATH.PAGES_DIRECTORY.$link.'/');
255
		}
256
		// Update any pages that had the old link with the new one
257
		$old_link_len = strlen($old_link);
258
        $sql = '';
259
		$query_subs = $database->query("SELECT page_id,link,level FROM ".TABLE_PREFIX."pages WHERE link LIKE '%$old_link/%' ORDER BY LEVEL ASC");
260

  
261
		if($query_subs->numRows() > 0)
262
        {
263
			while($sub = $query_subs->fetchRow())
264
            {
265
				// Double-check to see if it contains old link
266
				if(substr($sub['link'], 0, $old_link_len) == $old_link)
267
                {
268
					// Get new link
269
					$replace_this = $old_link;
270
					$old_sub_link_len =strlen($sub['link']);
271
					$new_sub_link = $link.'/'.substr($sub['link'],$old_link_len+1,$old_sub_link_len);
272
					// Work out level
273
					$new_sub_level = level_count($sub['page_id']);
274
					// Update level and link
275
					$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$new_sub_link', level = '$new_sub_level' WHERE page_id = '".$sub['page_id']."' LIMIT 1");
276
					// Re-write the access file for this page
277
					$old_subpage_file = WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION;
278
					if(file_exists($old_subpage_file))
279
                    {
280
						unlink($old_subpage_file);
281
					}
282
					create_access_file(WB_PATH.PAGES_DIRECTORY.$new_sub_link.PAGE_EXTENSION, $sub['page_id'], $new_sub_level);
283
				}
284
			}
285
		}
286
	}
287
}
288

  
289
// Function to fix page trail of subs
290
function fix_page_trail($parent,$root_parent)
291
{
292
	// Get objects and vars from outside this function
293
	global $admin, $template, $database, $TEXT, $MESSAGE;
294
	// Get page list from database
295
	// $database = new database();
296
	$query = "SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent'";
297
	$get_pages = $database->query($query);
298
	// Insert values into main page list
299
	if($get_pages->numRows() > 0)
300
    {
301
		while($page = $get_pages->fetchRow())
302
        {
303
			// Fix page trail
304

  
305
			$database->query("UPDATE ".TABLE_PREFIX."pages SET ".($root_parent != 0 ?"root_parent = '$root_parent', ":"")." page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
306
			// Run this query on subs
307
			fix_page_trail($page['page_id'],$root_parent);
308
		}
309
	}
310
}
311

  
312
// Fix sub-pages page trail
313
fix_page_trail($page_id,$root_parent);
314

  
315
/* END page "access file" code */
316

  
317
//$pagetree_url = ADMIN_URL.'/pages/index.php';
318
//$target_url = ADMIN_URL.'/pages/settings.php?page_id='.$page_id;
319
// Check if there is a db error, otherwise say successful
320
if($database->is_error())
321
{
322
	$admin->print_error($database->get_error(), $target_url );
323
} else {
324
	$admin->print_success($MESSAGE['PAGES']['SAVED_SETTINGS'], $target_url );
325
}
326

  
327
// Print admin footer
328
$admin->print_footer();
329 0

  
branches/2.8.x/wb/admin/pages/settings.php
23 23
require_once(WB_PATH.'/framework/class.admin.php');
24 24
$admin = new admin('Pages', 'pages_settings');
25 25
// Include the WB functions file
26
require_once(WB_PATH.'/framework/functions-utf8.php');
26
//require_once(WB_PATH.'/framework/functions-utf8.php');
27 27

  
28
/*-- Parent page list ------------------------------------------------------------------*/
29
	function parent_list($parent)
30
	{
31
		global $admin, $database, $oTpl, $aCurrentPage, $field_set;
32
		$sDisabled = ' disabled="disabled"';
33
		$sSelected  = ' selected="selected"';
34

  
35
		$sql = 'SELECT `page_id`, `level`, `parent`, `menu_title`, `page_title`, '
36
		     .        '`language`, `admin_groups`, `admin_users`, `visibility`, '
37
		     .        '`viewing_groups`, `viewing_users` '
38
		     . 'FROM `'.TABLE_PREFIX.'pages` '
39
			 . 'WHERE `parent`='.$parent.' '
40
			 . 'ORDER BY `position` ASC';
41
		$get_pages = $database->query($sql);
42

  
43
		while($page = $get_pages->fetchRow(MYSQL_ASSOC))
44
		{
45
			if(!$admin->page_is_visible($page)) { continue; }
46
			// if parent = 0 set flag_icon
47
			$oTpl->set_var('FLAG_ROOT_ICON',' none ');
48
			if( $page['parent'] == 0  && $field_set) {
49
				$oTpl->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
50
			}
51
			// If the current page cannot be parent, then its children neither
52
			$list_next_level = true;
53
			// Stop users from adding pages with a level of more than the set page level limit
54
			if($page['level']+1 < PAGE_LEVEL_LIMIT)
55
			{
56
			// Get user permisions
57
				$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
58
				               $admin->is_group_match($admin->get_user_id(), $page['admin_users']));
59
				// Title -'s prefix
60
				$title_prefix = '';
61
				for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
62
				$oTpl->set_var(array(
63
							'ID' => $page['page_id'],
64
							'TITLE' => ($title_prefix.$page['menu_title']),
65
							'MENU-TITLE' => ($title_prefix.$page['menu_title']),
66
							'PAGE-TITLE' => ($title_prefix.$page['page_title']),
67
							'FLAG_ICON' => ' none ',
68
							));
69
				if($aCurrentPage['parent'] == $page['page_id']) {
70
					$oTpl->set_var('SELECTED', $sSelected);
71
				} elseif($aCurrentPage['page_id'] == $page['page_id']) {
72
					$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
73
					$list_next_level=false;
74
				} elseif($can_modify != true) {
75
					$oTpl->set_var('SELECTED', $sDisabled.' class="disabled"');
76
				} else {
77
					$oTpl->set_var('SELECTED', '');
78
				}
79
				$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
80
			}
81
			if ($list_next_level) {
82
			  parent_list($page['page_id']);
83
			}
84
		}
85
	} // end of function parent_list
86
/* -------------------------------------------------------------------------------------*/
87
	$sDisabled = ' disabled="disabled"';
88
	$sSelected  = ' selected="selected"';
89
	$sChecked   = ' checked="checked"';
90

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

  
92
	$page_id = $_GET['page_id'] ? intval($_GET['page_id']) : 0;
93
	if(!$page_id) {
94
		header("Location: index.php");
95
		exit(0);
96
	}
37 97
/*
38 98
if( (!($page_id = $admin->checkIDKEY('page_id', 0, $_SERVER['REQUEST_METHOD']))) )
39 99
{
......
41 101
	exit();
42 102
}
43 103
*/
44
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
45
$results = $database->query($sql);
46
$results_array = $results->fetchRow();
47

  
48
$old_admin_groups = explode(',', $results_array['admin_groups']);
49
$old_admin_users = explode(',', $results_array['admin_users']);
50

  
51
// Work-out if we should check for existing page_code
52
$field_set = $database->field_exists(TABLE_PREFIX.'pages', 'page_code');
53

  
54
$in_old_group = FALSE;
55
foreach($admin->get_groups_id() as $cur_gid)
56
{
57
	if (in_array($cur_gid, $old_admin_groups))
58
    {
59
		$in_old_group = TRUE;
104
/*-- get all details of current page ---------------------------------------------------*/
105
	$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
106
	if( ($oPages = $database->query($sql)) ) {
107
		$aCurrentPage = $oPages->fetchRow(MYSQL_ASSOC);
108
		// Work-out if we should check for existing page_code
109
		$field_set = isset($aCurrentPage['page_code']);
110
		if( !$admin->ami_group_member($aCurrentPage['admin_groups']) &&
111
			!$admin->is_group_match($admin->get_user_id(), $aCurrentPage['admin_users']) )
112
		{
113
			$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
114
		}
115
	}else {
116
		$admin->print_header();
117
		$admin->print_error($database->get_error());
60 118
	}
61
}
62
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
63
{
64
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
65
}
66

  
67
// Get page details
68
/* $database = new database();  */
69
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id;
70
$results = $database->query($sql);
71
if($database->is_error()) {
72
	$admin->print_header();
73
	$admin->print_error($database->get_error());
74
}
75
if($results->numRows() == 0) {
76
	$admin->print_header();
77
	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
78
}
79
$results_array = $results->fetchRow();
80

  
119
	if(!isset($aCurrentPage['page_code'])) {
120
		$database->field_add(TABLE_PREFIX.'pages', 'page_code', 'INT NOT NULL DEFAULT \'0\'');
121
	}
122
	if($oPages->numRows() == 0) {
123
		$admin->print_header();
124
		$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
125
	}
81 126
// Get display name of person who last modified the page
82
$user=$admin->get_user_details($results_array['modified_by']);
83

  
127
	$user=$admin->get_user_details($aCurrentPage['modified_by']);
84 128
// Convert the unix ts for modified_when to human a readable form
85
if($results_array['modified_when'] != 0)
86
{
87
	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
88
} else {
89
	$modified_ts = 'Unknown';
90
}
91

  
129
	if($aCurrentPage['modified_when'] != 0) {
130
		$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $aCurrentPage['modified_when']+TIMEZONE);
131
	}else {
132
		$modified_ts = 'Unknown';
133
	}
92 134
// Setup template object, parse vars to it, then parse it
93 135
// Create new template object
94
$template = new Template(dirname($admin->correct_theme_source('pages_settings.htt')));
95
// $template->debug = true;
96
$template->set_file('page', 'pages_settings.htt');
97
$template->set_block('page', 'main_block', 'main');
98
$template->set_var('FTAN', $admin->getFTAN());
136
	$oTpl = new Template(dirname($admin->correct_theme_source('pages_settings.htt')), 'keep');
137
	$oTpl->set_file('page', 'pages_settings.htt');
138
	$oTpl->set_block('page', 'main_block', 'main');
139
	$oTpl->set_var('FTAN', $admin->getFTAN());
140
	$oTpl->set_var(array(
141
			'PAGE_ID'              => $aCurrentPage['page_id'],
142
			'PAGE_IDKEY'           => $admin->getIDKEY($aCurrentPage['page_id']),
143
			'PAGE_TITLE'           => ($aCurrentPage['page_title']),
144
			'MENU_TITLE'           => ($aCurrentPage['menu_title']),
145
			'DESCRIPTION'          => ($aCurrentPage['description']),
146
			'KEYWORDS'             => ($aCurrentPage['keywords']),
147
			'MODIFIED_BY'          => $user['display_name'],
148
			'MODIFIED_BY_USERNAME' => $user['username'],
149
			'MODIFIED_WHEN'        => $modified_ts,
150
			'ADMIN_URL'            => ADMIN_URL,
151
			'WB_URL'               => WB_URL,
152
			'THEME_URL'            => THEME_URL
153
			));
154
/*-- workout if we should show the "manage sections" link ------------------------------*/
155
	$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
156
	     . 'WHERE `page_id`='.$page_id.' AND `module`=\'menu_link\'';
157
	$sections_available = (intval($database->get_one($sql)) != 0);
158
	if ($sections_available) {
159
		$oTpl->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
160
	} elseif(MANAGE_SECTIONS == 'enabled') {
161
		$oTpl->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
162
	} else {
163
		$oTpl->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
164
	}
99 165

  
100
$template->set_var(array(
101
				'PAGE_ID' => $results_array['page_id'],
102
				// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
103
				'PAGE_IDKEY' => $results_array['page_id'],
104
				'PAGE_TITLE' => ($results_array['page_title']),
105
				'MENU_TITLE' => ($results_array['menu_title']),
106
				'DESCRIPTION' => ($results_array['description']),
107
				'KEYWORDS' => ($results_array['keywords']),
108
				'MODIFIED_BY' => $user['display_name'],
109
				'MODIFIED_BY_USERNAME' => $user['username'],
110
				'MODIFIED_WHEN' => $modified_ts,
111
				'ADMIN_URL' => ADMIN_URL,
112
				'WB_URL' => WB_URL,
113
				'THEME_URL' => THEME_URL
114
				)
115
		);
166
/*-- show visibility select box --------------------------------------------------------*/
167
	$aVisibility = array();
168
	$aVisibility['PUBLIC_SELECTED']     = ($aCurrentPage['visibility'] == 'public' ? $sSelected : '');
169
	$aVisibility['PRIVATE_SELECTED']    = ($aCurrentPage['visibility'] == 'private' ? $sSelected : '');
170
	$aVisibility['REGISTERED_SELECTED'] = ($aCurrentPage['visibility'] == 'registered' ? $sSelected : '');
171
	$aVisibility['HIDDEN_SELECTED']     = ($aCurrentPage['visibility'] == 'hidden' ? $sSelected : '');
172
	$aVisibility['NO_VIS_SELECTED']     = ($aCurrentPage['visibility'] == 'none' ? $sSelected : '');
173
	$oTpl->set_var($aVisibility);
116 174

  
117
// Work-out if we should show the "manage sections" link
118
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id.' AND `module`="menu_link"';
119
$sections_available = (intval($database->get_one($sql)) != 0);
120
if ($sections_available)
121
{
122
    $template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
123
} elseif(MANAGE_SECTIONS == 'enabled')
124
{
125
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
126
} else {
127
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
128
}
129

  
130
// Visibility
131
if($results_array['visibility'] == 'public') {
132
	$template->set_var('PUBLIC_SELECTED', ' selected="selected"');
133
} elseif($results_array['visibility'] == 'private') {
134
	$template->set_var('PRIVATE_SELECTED', ' selected="selected"');
135
} elseif($results_array['visibility'] == 'registered') {
136
	$template->set_var('REGISTERED_SELECTED', ' selected="selected"');
137
} elseif($results_array['visibility'] == 'hidden') {
138
	$template->set_var('HIDDEN_SELECTED', ' selected="selected"');
139
} elseif($results_array['visibility'] == 'none') {
140
	$template->set_var('NO_VIS_SELECTED', ' selected="selected"');
141
}
142
// Group list 1 (admin_groups)
143
	$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
144

  
145
	$sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`';
146
    $get_groups = $database->query($sql);
147

  
148
	$template->set_block('main_block', 'group_list_block', 'group_list');
149
	// Insert admin group and current group first
150
	$admin_group_name = $get_groups->fetchRow();
151
	$template->set_var(array(
152
									'ID' => 1,
153
									'TOGGLE' => '',
154
									'DISABLED' => ' disabled="disabled"',
155
									'LINK_COLOR' => '000000',
156
									'CURSOR' => 'default',
157
									'NAME' => $admin_group_name['name'],
158
									'CHECKED' => ' checked="checked"'
159
									)
160
							);
161
	$template->parse('group_list', 'group_list_block', true);
162
	while($group = $get_groups->fetchRow()) {
163
		// check if the user is a member of this group
164
		$flag_disabled = '';
165
		$flag_checked =  '';
166
		$flag_cursor =   'pointer';
167
		$flag_color =    '';
168
		if (in_array($group["group_id"], $admin->get_groups_id())) {
169
			$flag_disabled = ''; //' disabled';
170
			$flag_checked =  ''; //' checked';
171
			$flag_cursor =   'default';
172
			$flag_color =    '000000';
175
/*-- admin group list block ------------------------------------------------------------*/
176
	$aAdminGroups = explode(',', '1,'.$aCurrentPage['admin_groups']);
177
	$sAdminGroups = implode(',', array_unique($aAdminGroups));
178
	$sql = 'SELECT `group_id` `ID`, `name` `NAME`, `system_permissions` `permissions` '
179
	     . 'FROM `'.TABLE_PREFIX.'groups` '
180
	     . 'ORDER BY (`ID` NOT IN('.$sAdminGroups.')), `NAME`';
181
	if( ($oGroups = $database->query($sql)))
182
	{
183
		$oTpl->set_block('main_block', 'admin_group_list_block', 'admin_group_list');
184
		while( $aGroup = $oGroups->fetchRow(MYSQL_ASSOC))
185
		{
186
			if($aGroup['ID'] == 1) {
187
			// never uncheck admin group
188
				$aGroup['CHECKED'] = $sChecked;
189
				$aGroup['DISABLED'] = $sDisabled;
190
			}else {
191
			// skip groups without system_permissions
192
				if(!$admin->is_group_match('pages_modify', $aGroup['permissions'])) { continue; }
193
			// check already selected groups
194
				$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['admin_groups']);
195
			// disable selected groups where current user is not member of
196
				$bDisabled = !$admin->ami_group_member($aGroup['ID']);
197
				$aGroup['CHECKED']  = $bChecked ? $sChecked : '';
198
				$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
199
			}
200
			unset($aGroup['permissions']);
201
			$oTpl->set_var($aGroup);
202
			$oTpl->parse('admin_group_list', 'admin_group_list_block', true);
173 203
		}
204
	}
174 205

  
175
		// Check if the group is allowed to edit pages
176
		$system_permissions = explode(',', $group['system_permissions']);
177
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
178
			$template->set_var(array(
179
											'ID' => $group['group_id'],
180
											'TOGGLE' => $group['group_id'],
181
											'DISABLED' => $flag_disabled,
182
											'LINK_COLOR' => $flag_color,
183
											'CURSOR' => $flag_cursor,
184
											'NAME' => $group['name'],
185
											'CHECKED' => $flag_checked
186
											)
187
									);
188
			if(is_numeric(array_search($group['group_id'], $admin_groups))) {
189
				$template->set_var('CHECKED', ' checked="checked"');
190
			} else {
191
				if (!$flag_checked) $template->set_var('CHECKED', '');
206
/*-- viewer group list block -----------------------------------------------------------*/
207
	$aViewingGroups = explode(',', '1,'.$aCurrentPage['viewing_groups']);
208
	$sViewingGroups = implode(',', array_unique($aViewingGroups));
209
	$oTpl->set_block('main_block', 'viewer_group_list_block', 'viewer_group_list');
210
	$sql = 'SELECT `group_id` `ID`, `name` `NAME` '
211
		 . 'FROM `'.TABLE_PREFIX.'groups` '
212
	     . 'ORDER BY (`ID` NOT IN('.$sViewingGroups.')), `NAME`';
213
	if(($oGroups = $database->query($sql))) {
214
		while($aGroup = $oGroups->fetchRow(MYSQL_ASSOC)) {
215
			if($aGroup['ID'] == 1) {
216
			// never uncheck admin group
217
				$aGroup['CHECKED'] = $sChecked;
218
				$aGroup['DISABLED'] = $sDisabled;
219
			}else {
220
			// check already selected groups
221
				$bChecked = $admin->is_group_match($aGroup['ID'], $aCurrentPage['viewing_groups']);
222
			// disable selected groups where current user is not member of
223
				$bDisabled = !$admin->ami_group_member($aGroup['ID']);
224
				$aGroup['CHECKED']  = $bChecked ? $sChecked : '';
225
				$aGroup['DISABLED'] = ($bChecked && $bDisabled) ? $sDisabled : '';
192 226
			}
193
			$template->parse('group_list', 'group_list_block', true);
227
			$oTpl->set_var($aGroup);
228
			$oTpl->parse('viewer_group_list', 'viewer_group_list_block', true);
194 229
		}
195 230
	}
196 231

  
197
// Group list 2 (viewing_groups)
198
	$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
232
/*-- admin user list block -------------------------------------------------------------*/
233
	$aAdminUsers = ($aCurrentPage['admin_users'] == ''
234
	                ? array()
235
	                : explode(',', $aCurrentPage['admin_users']));
236
	$aAdminUsers = explode(',', $aCurrentPage['admin_users']);
237
	$oTpl->set_block('main_block', 'admin_user_list_block', 'admin_user_list');
238
	$sAllowedAdminUsers = trim(implode(',',$aAdminUsers));
239
	$sAllowedAdminUsers = $sAllowedAdminUsers ? $sAllowedAdminUsers : '-1';
240
	$sql = 'SELECT `user_id`, `display_name` '
241
		 . 'FROM `'.TABLE_PREFIX.'users` '
242
	     . 'WHERE `active`=1 '
243
	     . 'ORDER BY (`user_id` NOT IN('.$sAllowedAdminUsers.')), `display_name`';
244
	if( ($oUsers = $database->query($sql)) ) {
245
		while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
246
			if($aUser['user_id'] == 1) { continue; }
247
			$oTpl->set_var(array(
248
				'ID'        => $aUser['user_id'],
249
				'NAME'      => $aUser['display_name'],
250
			    'SELECTED'  => (in_array($aUser['user_id'], $aAdminUsers) ? $sSelected : ''),
251
			));
252
			$oTpl->parse('admin_user_list', 'admin_user_list_block', true);
253
		}
254
	}
199 255

  
200
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`';
201
    $get_groups = $database->query($sql);
202

  
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
	while($group = $get_groups->fetchRow())
219
    {
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
        {
227
			$flag_disabled = ''; //' disabled';
228
			$flag_checked =  ''; //' checked';
229
			$flag_cursor =   'default';
230
			$flag_color =    '000000';
256
/*-- viewer users list block -----------------------------------------------------------*/
257
	$aViewingUsers = ($aCurrentPage['viewing_users'] == ''
258
	                  ? array()
259
	                  : explode(',', $aCurrentPage['viewing_users']));
260
	$aViewingUsers = explode(',', $aCurrentPage['viewing_users']);
261
	$oTpl->set_block('main_block', 'viewer_user_list_block', 'viewer_user_list');
262
	$sAllowedViewingUsers = trim(implode(',',$aViewingUsers));
263
	$sAllowedViewingUsers = $sAllowedViewingUsers ? $sAllowedViewingUsers : '-1';
264
	$sql = 'SELECT `user_id`, `display_name` '
265
		 . 'FROM `'.TABLE_PREFIX.'users` '
266
	     . 'WHERE `active`=1 '
267
	     . 'ORDER BY (`user_id` NOT IN('.$sAllowedViewingUsers.')), `display_name`';
268
	if( ($oUsers = $database->query($sql)) ) {
269
		while($aUser = $oUsers->fetchRow(MYSQL_ASSOC)) {
270
			if($aUser['user_id'] == 1) { continue; }
271
			$oTpl->set_var(array(
272
				'ID'        => $aUser['user_id'],
273
				'NAME'      => $aUser['display_name'],
274
			    'SELECTED'  => (in_array($aUser['user_id'], $aViewingUsers) ? $sSelected : ''),
275
			));
276
			$oTpl->parse('viewer_user_list', 'viewer_user_list_block', true);
231 277
		}
278
	}
232 279

  
233
		$template->set_var(array(
234
										'ID' => $group['group_id'],
235
										'TOGGLE' => $group['group_id'],
236
										'DISABLED' => $flag_disabled,
237
										'LINK_COLOR' => $flag_color,
238
										'CURSOR' => $flag_cursor,
239
										'NAME' => $group['name'],
240
										'CHECKED' => $flag_checked
241
										)
242
								);
243
		if(is_numeric(array_search($group['group_id'], $viewing_groups)))
244
        {
245
			$template->set_var('CHECKED', 'checked="checked"');
246
		} else {
247
			if (!$flag_checked) {$template->set_var('CHECKED', '');}
280
/*-- size user lists -------------------------------------------------------------------*/
281
	$aSkaleSizeOfList = array(0 => 5, 12 => 10, 25 => 20, 50 => 30, 75 => 40, 100 => 50);
282
	$iListSize = 6;
283
	if($oUsers) {
284
		$iNumberOfUsers = $oUsers->numRows();
285
		foreach($aSkaleSizeOfList as $key => $val){
286
			if($iNumberOfUsers > $key) {
287
				$iListSize = $val;
288
			}else { break; }
248 289
		}
290
	}
291
	$oTpl->set_var('USER_LIST_SIZE', $iListSize);
249 292

  
250
		$template->parse('group_list2', 'group_list_block2', true);
251

  
293
/*-- show private viewers block --------------------------------------------------------*/
294
	if($aCurrentPage['visibility'] == 'private' OR $aCurrentPage['visibility'] == 'registered')
295
	{
296
		$oTpl->set_var('DISPLAY_VIEWERS', '');
297
	} else {
298
		$oTpl->set_var('DISPLAY_VIEWERS', 'display:none;');
252 299
	}
253

  
254
// Show private viewers
255
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered')
256
{
257
	$template->set_var('DISPLAY_VIEWERS', '');
258
} else {
259
	$template->set_var('DISPLAY_VIEWERS', 'display:none;');
260
}
261

  
262
//-- insert page_code 20090904-->
263
$template->set_var('DISPLAY_CODE_PAGE_LIST', ' id="multi_lingual" style="display:none;"');
264

  
300
/*-- start multilanguage page_code 20090904 --------------------------------------------*/
265 301
// Work-out if page languages feature is enabled
266
if((defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') )
267
{
268
    // workout field is set but module missing
269
    $TEXT['PAGE_CODE'] = empty($TEXT['PAGE_CODE']) ? 'Pagecode' : $TEXT['PAGE_CODE'];
270
	$template->set_var( array(
271
            'DISPLAY_CODE_PAGE_LIST' => ' id="multi_lingual"',
272
            'TEXT_PAGE_CODE' => '<a href="'.WB_URL.'/modules/mod_multilingual/update_keys.php?page_id='.$page_id.'">'.$TEXT['PAGE_CODE'].'</a>'
273
        )
274
    );
302
	$oTpl->set_block('main_block', 'show_page_code_block',  'show_page_code');
303
	if( (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) &&
304
		 isset($aCurrentPage['page_code']) &&
305
		 file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') )
306
	{
307
		// workout field is set but module missing
308
		$TEXT['PAGE_CODE'] = empty($TEXT['PAGE_CODE']) ? 'Pagecode' : $TEXT['PAGE_CODE'];
309
		$oTpl->set_var('TEXT_PAGE_CODE',
310
						   '<a href="'.WB_URL.'/modules/mod_multilingual/update_keys.php?page_id='.
311
						   $page_id.'">'.$TEXT['PAGE_CODE'].'</a>'
312
		);
313
	/*-- begin recursive function page_code list ---------------------------------------*/
314
		function page_code_list($parent)
315
		{
316
			global $admin, $database, $oTpl, $aCurrentPage, $pageCode;
317
			$default_language = DEFAULT_LANGUAGE;
275 318

  
276
	// Page_code list
277
   /* 	$database = new database();  */
278
	function page_code_list($parent)
279
    {
280
		global $admin, $database, $template, $results_array, $pageCode;
281
		$default_language = DEFAULT_LANGUAGE;
319
			$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` '
320
				 . 'WHERE `parent`='.$parent.' AND `language`=\''.$default_language.'\' '
321
				 . 'ORDER BY `position` ASC';
322
			$get_pages = $database->query($sql);
282 323

  
283
        $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' AND `language` = "'.$default_language.'" ORDER BY `position` ASC';
284
        $get_pages = $database->query($sql);
324
			while($page = $get_pages->fetchRow(MYSQL_ASSOC))
325
			{
326
				if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; }
285 327

  
286
		while($page = $get_pages->fetchRow())
287
        {
288
			if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; }
328
				$oTpl->set_var('FLAG_CODE_ICON',' none ');
329
				if( $page['parent'] == 0 )
330
				{
331
					$oTpl->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
332
				}
289 333

  
290
			$template->set_var('FLAG_CODE_ICON',' none ');
291
			if( $page['parent'] == 0 )
292
            {
293
				$template->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
294
			}
295

  
296
			// If the current page cannot be parent, then its children neither
297
			$list_next_level = true;
298
			// Stop users from adding pages with a level of more than the set page level limit
299
			if($page['level']+1 < PAGE_LEVEL_LIMIT)
300
            {
301
				// Get user perms
302
				$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
303
				$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
304

  
305
				$in_group = FALSE;
306
				foreach($admin->get_groups_id() as $cur_gid)
307
                {
308
					if (in_array($cur_gid, $admin_groups))
334
				// If the current page cannot be parent, then its children neither
335
				$list_next_level = true;
336
				// Stop users from adding pages with a level of more than the set page level limit
337
				if($page['level']+1 < PAGE_LEVEL_LIMIT)
338
				{
339
					$can_modify = ($admin->ami_group_member($page['admin_groups']) ||
340
								   $admin->is_group_match($admin->get_user_id(), $page['admin_users']));
341
					$title_prefix = '';
342
					for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
343
					// $space = str_repeat('&nbsp;', 3);  $space.'&lt;'..'&gt;'
344
					$oTpl->set_var(array(
345
											'VALUE' => intval($page['page_code']),
346
											'PAGE_VALUE' => $title_prefix.$page['menu_title'],
347
											'PAGE_CODE' => $title_prefix.$page['page_id']
348
											)
349
									);
350
					if($aCurrentPage['page_code'] == $page['page_code'])
309 351
					{
310
						$in_group = TRUE;
352
						$oTpl->set_var('SELECTED', ' selected="selected"');
353
					} elseif($aCurrentPage['page_code'] == $page['page_code'])
354
					{
355
						$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
356
						$list_next_level=false;
357
					} elseif($can_modify != true)
358
					{
359
						$oTpl->set_var('SELECTED', ' disabled="disabled" class="disabled"');
360
					} else {
361
						$oTpl->set_var('SELECTED', '');
311 362
					}
363
					$oTpl->parse('page_code_list', 'page_code_list_block', true);
312 364
				}
313

  
314
				if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users)))
315
                {
316
					$can_modify = true;
317
				} else {
318
					$can_modify = false;
319
				}
320

  
321
				$title_prefix = '';
322
				for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
323
                // $space = str_repeat('&nbsp;', 3);  $space.'&lt;'..'&gt;'
324
				$template->set_var(array(
325
										'VALUE' => $page['page_code'],
326
                                        'PAGE_VALUE' => $title_prefix.$page['menu_title'],
327
										'PAGE_CODE' => $title_prefix.$page['page_id']
328
										)
329
								);
330
				if($results_array['page_code'] == $page['page_code'])
331
                {
332
					$template->set_var('SELECTED', ' selected="selected"');
333
				} elseif($results_array['page_code'] == $page['page_code'])
334
                {
335
					$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
336
					$list_next_level=false;
337
				} elseif($can_modify != true)
338
                {
339
					$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
340
				} else {
341
					$template->set_var('SELECTED', '');
342
				}
343
				$template->parse('page_code_list', 'page_code_list_block', true);
365
				if ($list_next_level)
366
					page_code_list($page['page_id']);
344 367
			}
345
			if ($list_next_level)
346
				page_code_list($page['page_id']);
347 368
		}
369
	/*-- end recursive function page_code list -----------------------------------------*/
370
		// Insert code_page values from page to modify
371
		$oTpl->set_block('show_page_code_block', 'page_code_list_block', 'page_code_list');
372
		if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
373
			$selected = ($aCurrentPage['parent'] == 0 ? $sSelected : '');
374
			$oTpl->set_var(array(
375
					'VALUE' => 0,
376
					'PAGE_CODE' => $TEXT['NONE'],
377
					'PAGE_VALUE' => '',
378
					'SELECTED' => $selected
379
				)
380
			);
381
			$oTpl->parse('page_code_list', 'page_code_list_block', true);
382
		}
383
		// get pagecode form this page_id
384
		page_code_list(0);
385
		$oTpl->parse('show_page_code', 'show_page_code_block', true);
386
	}else {
387
		$oTpl->set_block('show_page_code', '');
348 388
	}
389
/*-- end multilanguage page_code 20090904 ----------------------------------------------*/
349 390

  
350
	// Insert code_page values from page to modify
351
	$template->set_block('main_block', 'page_code_list_block', 'page_code_list');
352
	if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
353
		if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; }
354
		$template->set_var(array(
355
									'VALUE' => '',
356
									'PAGE_CODE' => $TEXT['NONE'],
357
                                    'PAGE_VALUE' => '',
358
									'SELECTED' => $selected
359
								)
360
							);
361
		$template->parse('page_code_list', 'page_code_list_block', true);
391
/*-- show list of parent pages ---------------------------------------------------------*/
392
	$oTpl->set_block('main_block', 'parent_page_list_block', 'parent_page_list');
393
	if($admin->get_permission('pages_add_l0') == true OR $aCurrentPage['level'] == 0) {
394
		$oTpl->set_var(array(
395
					'ID' => '0',
396
					'TITLE' => $TEXT['NONE'],
397
					'SELECTED' => ($aCurrentPage['parent'] == 0 ? $sSelected : ''),
398
					) );
399
		$oTpl->parse('parent_page_list', 'parent_page_list_block', true);
362 400
	}
363
	// get pagecode form this page_id
364
   	page_code_list(0);
365
}
366
//-- page code -->
401
	parent_list(0);
402
	$oTpl->set_var('DISPLAY_MODIFIED', ($modified_ts == 'Unknown' ? 'hide' : ''));
367 403

  
368
// Parent page list
369
/* $database = new database();  */
370
function parent_list($parent)
371
{
372
	global $admin, $database, $template, $results_array,$field_set;
373

  
374
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ORDER BY `position` ASC';
375
    $get_pages = $database->query($sql);
376

  
377
	while($page = $get_pages->fetchRow())
378
    {
379
		if($admin->page_is_visible($page)==false)
380
        {
381
          continue;
382
        }
383

  
384
		// if parent = 0 set flag_icon
385
		$template->set_var('FLAG_ROOT_ICON',' none ');
386
		if( $page['parent'] == 0  && $field_set)
387
        {
388
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
389
		}
390
		// If the current page cannot be parent, then its children neither
391
		$list_next_level = true;
392
		// Stop users from adding pages with a level of more than the set page level limit
393
		if($page['level']+1 < PAGE_LEVEL_LIMIT)
394
        {
395
			// Get user perms
396
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
397
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
398
			$in_group = FALSE;
399
			foreach($admin->get_groups_id() as $cur_gid)
400
            {
401
				if (in_array($cur_gid, $admin_groups))
402
                {
403
					$in_group = TRUE;
404
/*-- show list of templates ------------------------------------------------------------*/
405
	$oTpl->set_block('main_block', 'template_list_block', 'template_list');
406
	$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
407
	     . 'WHERE `type`=\'template\' AND `function`=\'template\' '
408
	     . 'ORDER BY `name`';
409
	if(($res_templates = $database->query($sql))) {
410
		while($rec_template = $res_templates->fetchRow(MYSQL_ASSOC)) {
411
			// Check if the user has perms to use this template
412
			if($rec_template['directory'] == $aCurrentPage['template'] OR
413
			   $admin->get_permission($rec_template['directory'], 'template'))
414
			{
415
				$oTpl->set_var('VALUE', $rec_template['directory']);
416
				$oTpl->set_var('NAME', $rec_template['name']);
417
				if($rec_template['directory'] == $aCurrentPage['template']) {
418
					$oTpl->set_var('SELECTED', $sSelected);
419
				} else {
420
					$oTpl->set_var('SELECTED', '');
404 421
				}
422
				$oTpl->parse('template_list', 'template_list_block', true);
405 423
			}
406
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users)))
407
            {
408
				$can_modify = true;
409
			} else {
410
				$can_modify = false;
411
			}
412
			// Title -'s prefix
413
			$title_prefix = '';
414
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
415
			$template->set_var(array(
416
								'ID' => $page['page_id'],
417
								'TITLE' => ($title_prefix.$page['menu_title']),
418
								'MENU-TITLE' => ($title_prefix.$page['menu_title']),
419
								'PAGE-TITLE' => ($title_prefix.$page['page_title']),
420
								'FLAG_ICON' => ' none ',
421
								));
422

  
423
			if($results_array['parent'] == $page['page_id'])
424
            {
425
				$template->set_var('SELECTED', ' selected="selected"');
426
			} elseif($results_array['page_id'] == $page['page_id'])
427
            {
428
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
429
				$list_next_level=false;
430
			} elseif($can_modify != true)
431
            {
432
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
433
			} else {
434
				$template->set_var('SELECTED', '');
435
			}
436
			$template->parse('page_list2', 'page_list_block2', true);
437 424
		}
438
		if ($list_next_level)
439
        {
440
          parent_list($page['page_id']);
441
        }
442

  
443 425
	}
444
}
445 426

  
446
$template->set_block('main_block', 'page_list_block2', 'page_list2');
447
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
448
	if($results_array['parent'] == 0)
449
    {
450
		$selected = ' selected="selected"';
451
	} else { 
452
		$selected = '';
427
/*-- show menu select box --------------------------------------------------------------*/
428
	$oTpl->set_block('main_block', 'show_menu_list_block', 'show_menu_list');
429
	if(MULTIPLE_MENUS)
430
	{
431
	/*-- get menusettings from template info file --------------------------------------*/
432
		function getTemplateInfo($sTpl = '') {
433
			if(!$sTpl) { $sTpl = DEFAULT_TEMPLATE; }
434
			$sTplFile = WB_PATH.'/templates/'.$sTpl.'/info.php';
435
			if(is_readable($sTplFile)) { require_once($sTplFile); }
436
			$menu = isset($menu) ? $menu : array();
437
			return $menu;
438
		}
439
		$aMenu = getTemplateInfo($aCurrentPage['template']);
440
		// set menu[1] as default if there's no entry in info.php
441
		$aMenu[1] = (!isset($aMenu[1]) OR ($aMenu[1] == '')) ? $TEXT['MAIN'] : $aMenu[1];
442
		$oTpl->set_block('show_menu_list_block', 'menu_list_block', 'menu_list');
443
		foreach($aMenu as $iIndex => $sMenuName) {
444
			$aVars = array();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff