1 |
|
<?php
|
2 |
|
/**
|
3 |
|
*
|
4 |
|
* @category backend
|
5 |
|
* @package modules
|
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 |
|
// Stop this file being access directly
|
20 |
|
if(!defined('WB_URL')) {
|
21 |
|
header('Location: ../index.php');
|
22 |
|
exit(0);
|
23 |
|
}
|
24 |
|
|
25 |
|
// Get page id
|
26 |
|
if(isset($_GET['page_id']) && is_numeric($_GET['page_id']))
|
27 |
|
{
|
28 |
|
$page_id = $_GET['page_id'];
|
29 |
|
} elseif(isset($_POST['page_id']) && is_numeric($_POST['page_id']))
|
30 |
|
{
|
31 |
|
$page_id = $_POST['page_id'];
|
32 |
|
} else {
|
33 |
|
header("Location: index.php");
|
34 |
|
exit(0);
|
35 |
|
}
|
36 |
|
|
37 |
|
// Get section id if there is one
|
38 |
|
if(isset($_GET['section_id']) && is_numeric($_GET['section_id']))
|
39 |
|
{
|
40 |
|
$section_id = $_GET['section_id'];
|
41 |
|
} elseif(isset($_POST['section_id']) && is_numeric($_POST['section_id']))
|
42 |
|
{
|
43 |
|
$section_id = $_POST['section_id'];
|
44 |
|
} else {
|
45 |
|
// Check if we should redirect the user if there is no section id
|
46 |
|
if (isset($no_section_required))
|
47 |
|
{
|
48 |
|
$section_id = 0;
|
49 |
|
} else {
|
50 |
|
header("Location: $section_required");
|
51 |
|
exit(0);
|
52 |
|
}
|
53 |
|
}
|
54 |
|
|
55 |
|
// Create js back link
|
56 |
|
$js_back = 'javascript: history.go(-1);';
|
57 |
|
|
58 |
|
// Create new admin object
|
59 |
|
include(WB_PATH.'/framework/class.admin.php');
|
60 |
|
// header will be set here, see database->is_error
|
61 |
|
$admin = new admin('Pages', 'pages_modify');
|
62 |
|
|
63 |
|
// Get perms
|
64 |
|
// $database = new database();
|
65 |
|
$sql = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
|
66 |
|
$sql .= 'WHERE `page_id` = '.intval($page_id);
|
67 |
|
|
68 |
|
$res_pages = $database->query($sql);
|
69 |
|
$rec_pages = $res_pages->fetchRow();
|
70 |
|
|
71 |
|
$old_admin_groups = explode(',', str_replace('_', '', $rec_pages['admin_groups']));
|
72 |
|
$old_admin_users = explode(',', str_replace('_', '', $rec_pages['admin_users']));
|
73 |
|
|
74 |
|
$in_group = FALSE;
|
75 |
|
foreach($admin->get_groups_id() as $cur_gid)
|
76 |
|
{
|
77 |
|
if (in_array($cur_gid, $old_admin_groups))
|
78 |
|
{
|
79 |
|
$in_group = TRUE;
|
80 |
|
}
|
81 |
|
}
|
82 |
|
if((!$in_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
|
83 |
|
{
|
84 |
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
85 |
|
}
|
86 |
|
|
87 |
|
// Check whether the section_id belongs to the page_id at all
|
88 |
|
if ($section_id != 0) {
|
89 |
|
$sql = "SELECT `position` FROM `".TABLE_PREFIX."sections` WHERE `page_id` = '$page_id' AND `section_id` = '$section_id'";
|
90 |
|
$res_sec = $database->query($sql);
|
91 |
|
if ($database->is_error())
|
92 |
|
{
|
93 |
|
$admin->print_error($database->get_error());
|
94 |
|
}
|
95 |
|
if ($res_sec->numRows() == 0)
|
96 |
|
{
|
97 |
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
98 |
|
}
|
99 |
|
}
|
100 |
|
|
101 |
|
// Workout if the developer wants to show the info banner
|
102 |
|
if(isset($print_info_banner) && $print_info_banner == true)
|
103 |
|
{
|
104 |
|
// Get page details
|
105 |
|
// $database = new database(); not needed
|
106 |
|
$sql = 'SELECT `page_id`,`page_title`,`modified_by`,`modified_when` FROM `'.TABLE_PREFIX.'pages` ';
|
107 |
|
$sql .= 'WHERE `page_id` = '.intval($page_id);
|
108 |
|
$res_pages = $database->query($sql);
|
109 |
|
if($database->is_error())
|
110 |
|
{
|
111 |
|
// $admin->print_header(); don't know why
|
112 |
|
$admin->print_error($database->get_error());
|
113 |
|
}
|
114 |
|
if($res_pages->numRows() == 0)
|
115 |
|
{
|
116 |
|
// $admin->print_header(); don't know why
|
117 |
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
118 |
|
} else {
|
119 |
|
$rec_pages = $res_pages->fetchRow();
|
120 |
|
}
|
121 |
|
|
122 |
|
// Get display name of person who last modified the page
|
123 |
|
$user = $admin->get_user_details($rec_pages['modified_by']);
|
124 |
|
|
125 |
|
// Convert the unix ts for modified_when to human a readable form
|
126 |
|
if($rec_pages['modified_when'] != 0)
|
127 |
|
{
|
128 |
|
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $rec_pages['modified_when']+TIMEZONE);
|
129 |
|
} else {
|
130 |
|
$modified_ts = 'Unknown';
|
131 |
|
}
|
132 |
|
|
133 |
|
// Include page info script
|
134 |
|
$template = new Template(THEME_PATH.'/templates');
|
135 |
|
$template->set_file('page', 'pages_modify.htt');
|
136 |
|
$template->set_block('page', 'main_block', 'main');
|
137 |
|
$template->set_var(array(
|
138 |
|
'PAGE_ID' => $rec_pages['page_id'],
|
139 |
|
'PAGE_TITLE' => ($rec_pages['page_title']),
|
140 |
|
'MODIFIED_BY' => $user['display_name'],
|
141 |
|
'MODIFIED_BY_USERNAME' => $user['username'],
|
142 |
|
'MODIFIED_WHEN' => $modified_ts,
|
143 |
|
'ADMIN_URL' => ADMIN_URL
|
144 |
|
));
|
145 |
|
|
146 |
|
$template->set_block('main_block', 'show_modify_block', 'show_modify');
|
147 |
|
if($modified_ts == 'Unknown')
|
148 |
|
{
|
149 |
|
$template->set_block('show_modify', '');
|
150 |
|
$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
|
151 |
|
} else {
|
152 |
|
$template->set_var('CLASS_DISPLAY_MODIFIED', '');
|
153 |
|
$template->parse('show_modify', 'show_modify_block', true);
|
154 |
|
}
|
155 |
|
|
156 |
|
$template->set_block('main_block', 'show_section_block', 'show_section');
|
157 |
|
// Work-out if we should show the "manage sections" link
|
158 |
|
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
|
159 |
|
$sql .= 'WHERE `page_id` = '.intval($page_id).' AND `module` = "menu_link"';
|
160 |
|
if( ( $res_sections = $database->query($sql) ) && ($database->is_error() == false ) )
|
161 |
|
{
|
162 |
|
if($res_sections->numRows() > 0)
|
163 |
|
{
|
164 |
|
$template->set_block('show_section', '');
|
165 |
|
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
|
166 |
|
}elseif(MANAGE_SECTIONS == 'enabled')
|
167 |
|
{
|
168 |
|
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
|
169 |
|
$template->parse('show_section', 'show_section_block', true);
|
170 |
|
}else {
|
171 |
|
$template->set_block('show_section', '');
|
172 |
|
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
|
173 |
|
}
|
174 |
|
} else {
|
175 |
|
$admin->print_error($database->get_error());
|
176 |
|
}
|
177 |
|
|
178 |
|
// Insert language TEXT
|
179 |
|
$template->set_var(array(
|
180 |
|
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
|
181 |
|
'TEXT_CHANGE' => $TEXT['CHANGE'],
|
182 |
|
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
|
183 |
|
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
|
184 |
|
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
|
185 |
|
));
|
186 |
|
|
187 |
|
// Parse and print header template
|
188 |
|
$template->parse('main', 'main_block', false);
|
189 |
|
$template->pparse('output', 'page');
|
190 |
|
}
|
191 |
|
|
192 |
|
// Work-out if the developer wants us to update the timestamp for when the page was last modified
|
193 |
|
if(isset($update_when_modified) && $update_when_modified == true)
|
194 |
|
{
|
195 |
|
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` ';
|
196 |
|
$sql .= 'SET `modified_when` = '.time().', ';
|
197 |
|
$sql .= '`modified_by` = '.intval($admin->get_user_id()).' ';
|
198 |
|
$sql .= 'WHERE page_id = '.intval($page_id);
|
199 |
|
$database->query($sql);
|
200 |
|
}
|
201 |
|
|
202 |
|
?>
|
|
1 |
<?php
|
|
2 |
/**
|
|
3 |
*
|
|
4 |
* @category backend
|
|
5 |
* @package modules
|
|
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.9.x
|
|
12 |
* @requirements PHP 5.2.2 and higher
|
|
13 |
* @version $Id$
|
|
14 |
* @filesource $HeadURL$
|
|
15 |
* @lastmodified $Date$
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// Stop this file being access directly
|
|
20 |
if(!defined('WB_URL')) {
|
|
21 |
header('Location: ../index.php');
|
|
22 |
exit(0);
|
|
23 |
}
|
|
24 |
|
|
25 |
// Get page id
|
|
26 |
if(isset($_GET['page_id']) && is_numeric($_GET['page_id']))
|
|
27 |
{
|
|
28 |
$page_id = (int)$_GET['page_id'];
|
|
29 |
} elseif(isset($_POST['page_id']) && is_numeric($_POST['page_id']))
|
|
30 |
{
|
|
31 |
$page_id = (int)$_POST['page_id'];
|
|
32 |
} else {
|
|
33 |
header("Location: index.php");
|
|
34 |
exit(0);
|
|
35 |
}
|
|
36 |
|
|
37 |
// Get section id if there is one
|
|
38 |
if(isset($_GET['section_id']) && is_numeric($_GET['section_id']))
|
|
39 |
{
|
|
40 |
$section_id = (int)$_GET['section_id'];
|
|
41 |
} elseif(isset($_POST['section_id']) && is_numeric($_POST['section_id']))
|
|
42 |
{
|
|
43 |
$section_id = (int)$_POST['section_id'];
|
|
44 |
} else {
|
|
45 |
// Check if we should redirect the user if there is no section id
|
|
46 |
if(!isset($section_required))
|
|
47 |
{
|
|
48 |
$section_id = 0;
|
|
49 |
} else {
|
|
50 |
header("Location: $section_required");
|
|
51 |
exit(0);
|
|
52 |
}
|
|
53 |
}
|
|
54 |
|
|
55 |
// Create js back link
|
|
56 |
$js_back = 'javascript: history.go(-1);';
|
|
57 |
|
|
58 |
// Create new admin object
|
|
59 |
include(WB_PATH.'/framework/class.admin.php');
|
|
60 |
// header will be set here, see database->is_error
|
|
61 |
$admin = new admin('Pages', 'pages_modify');
|
|
62 |
|
|
63 |
// Get perms
|
|
64 |
$sql = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
|
|
65 |
$sql .= 'WHERE `page_id` = '.intval($page_id);
|
|
66 |
$ok = false;
|
|
67 |
if( ($res_pages = $database->query($sql)) )
|
|
68 |
{
|
|
69 |
if( ($rec_pages = $res_pages->fetchRow()) )
|
|
70 |
{
|
|
71 |
if( $admin->ami_group_member($rec_pages['admin_groups']) || $admin->ami_group_member($rec_pages['admin_users']) )
|
|
72 |
{
|
|
73 |
$ok = true;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
}
|
|
77 |
if( !$ok ) { $admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); }
|
|
78 |
|
|
79 |
//$old_admin_groups = explode(',', str_replace('_', '', $rec_pages['admin_groups']));
|
|
80 |
//$old_admin_users = explode(',', str_replace('_', '', $rec_pages['admin_users']));
|
|
81 |
//
|
|
82 |
//$in_group = FALSE;
|
|
83 |
//foreach($admin->get_groups_id() as $cur_gid)
|
|
84 |
//{
|
|
85 |
// if (in_array($cur_gid, $old_admin_groups))
|
|
86 |
// {
|
|
87 |
// $in_group = TRUE;
|
|
88 |
// }
|
|
89 |
//}
|
|
90 |
//if((!$in_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
|
|
91 |
//{
|
|
92 |
// $admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
|
93 |
//}
|
|
94 |
|
|
95 |
// Workout if the developer wants to show the info banner
|
|
96 |
if(isset($print_info_banner) && $print_info_banner == true)
|
|
97 |
{
|
|
98 |
// Get page details
|
|
99 |
$sql = 'SELECT `page_id`,`page_title`,`modified_by`,`modified_when` FROM `'.TABLE_PREFIX.'pages` ';
|
|
100 |
$sql .= 'WHERE `page_id` = '.intval($page_id);
|
|
101 |
$res_pages = $database->query($sql);
|
|
102 |
if($database->is_error())
|
|
103 |
{
|
|
104 |
// $admin->print_header(); don't know why
|
|
105 |
$admin->print_error($database->get_error());
|
|
106 |
}
|
|
107 |
if($res_pages->numRows() == 0)
|
|
108 |
{
|
|
109 |
// $admin->print_header(); don't know why
|
|
110 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
|
111 |
} else {
|
|
112 |
$rec_pages = $res_pages->fetchRow();
|
|
113 |
}
|
|
114 |
|
|
115 |
// Get display name of person who last modified the page
|
|
116 |
$user = $admin->get_user_details($rec_pages['modified_by']);
|
|
117 |
|
|
118 |
// Convert the unix ts for modified_when to human a readable form
|
|
119 |
if($rec_pages['modified_when'] != 0)
|
|
120 |
{
|
|
121 |
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $rec_pages['modified_when']+TIMEZONE);
|
|
122 |
} else {
|
|
123 |
$modified_ts = 'Unknown';
|
|
124 |
}
|
|
125 |
|
|
126 |
// Include page info script
|
|
127 |
$template = new Template(THEME_PATH.'/templates');
|
|
128 |
$template->set_file('page', 'pages_modify.htt');
|
|
129 |
$template->set_block('page', 'main_block', 'main');
|
|
130 |
$template->set_var(array(
|
|
131 |
'PAGE_ID' => $rec_pages['page_id'],
|
|
132 |
'PAGE_TITLE' => ($rec_pages['page_title']),
|
|
133 |
'MODIFIED_BY' => $user['display_name'],
|
|
134 |
'MODIFIED_BY_USERNAME' => $user['username'],
|
|
135 |
'MODIFIED_WHEN' => $modified_ts,
|
|
136 |
'ADMIN_URL' => ADMIN_URL
|
|
137 |
));
|
|
138 |
|
|
139 |
$template->set_block('main_block', 'show_modify_block', 'show_modify');
|
|
140 |
if($modified_ts == 'Unknown')
|
|
141 |
{
|
|
142 |
$template->set_block('show_modify', '');
|
|
143 |
$template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
|
|
144 |
} else {
|
|
145 |
$template->set_var('CLASS_DISPLAY_MODIFIED', '');
|
|
146 |
$template->parse('show_modify', 'show_modify_block', true);
|
|
147 |
}
|
|
148 |
|
|
149 |
$template->set_block('main_block', 'show_section_block', 'show_section');
|
|
150 |
// Work-out if we should show the "manage sections" link
|
|
151 |
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
|
|
152 |
$sql .= 'WHERE `page_id` = '.intval($page_id).' AND `module` = "menu_link"';
|
|
153 |
if( ( $res_sections = $database->query($sql) ) && ($database->is_error() == false ) )
|
|
154 |
{
|
|
155 |
if($res_sections->numRows() > 0)
|
|
156 |
{
|
|
157 |
$template->set_block('show_section', '');
|
|
158 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
|
|
159 |
}elseif(MANAGE_SECTIONS == 'enabled')
|
|
160 |
{
|
|
161 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
|
|
162 |
$template->parse('show_section', 'show_section_block', true);
|
|
163 |
}else {
|
|
164 |
$template->set_block('show_section', '');
|
|
165 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
|
|
166 |
}
|
|
167 |
} else {
|
|
168 |
$admin->print_error($database->get_error());
|
|
169 |
}
|
|
170 |
|
|
171 |
// Insert language TEXT
|
|
172 |
$template->set_var(array(
|
|
173 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
|
|
174 |
'TEXT_CHANGE' => $TEXT['CHANGE'],
|
|
175 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
|
|
176 |
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
|
|
177 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
|
|
178 |
));
|
|
179 |
|
|
180 |
// Parse and print header template
|
|
181 |
$template->parse('main', 'main_block', false);
|
|
182 |
$template->pparse('output', 'page');
|
|
183 |
}
|
|
184 |
|
|
185 |
// Work-out if the developer wants us to update the timestamp for when the page was last modified
|
|
186 |
if(isset($update_when_modified) && $update_when_modified == true)
|
|
187 |
{
|
|
188 |
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` ';
|
|
189 |
$sql .= 'SET `modified_when` = '.time().', ';
|
|
190 |
$sql .= '`modified_by` = '.intval($admin->get_user_id()).' ';
|
|
191 |
$sql .= 'WHERE page_id = '.intval($page_id);
|
|
192 |
$database->query($sql);
|
|
193 |
}
|
|
194 |
|
|
195 |
?>
|
fix known error in drag and drop