Revision 1289
Added by kweitzel almost 15 years ago
admin.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 |
/* |
|
27 |
|
|
28 |
Admin Wrapper Script |
|
29 |
|
|
30 |
This script allows modules to be written without the need to copy code |
|
31 |
from Website Baker Administration to take advantage of the interface. |
|
32 |
|
|
33 |
*/ |
|
34 |
|
|
35 |
// Stop this file being access directly |
|
36 |
if(!defined('WB_URL')) { |
|
37 |
header('Location: ../index.php'); |
|
38 |
exit(0); |
|
39 |
} |
|
40 |
|
|
41 |
// Get page id |
|
42 |
if(isset($_GET['page_id']) AND is_numeric($_GET['page_id'])) { |
|
43 |
$page_id = $_GET['page_id']; |
|
44 |
} elseif(isset($_POST['page_id']) AND is_numeric($_POST['page_id'])) { |
|
45 |
$page_id = $_POST['page_id']; |
|
46 |
} else { |
|
47 |
header("Location: index.php"); |
|
48 |
exit(0); |
|
49 |
} |
|
50 |
|
|
51 |
// Get section id if there is one |
|
52 |
if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) { |
|
53 |
$section_id = $_GET['section_id']; |
|
54 |
} elseif(isset($_POST['section_id']) AND is_numeric($_POST['section_id'])) { |
|
55 |
$section_id = $_POST['section_id']; |
|
56 |
} else { |
|
57 |
// Check if we should redirect the user if there is no section id |
|
58 |
if(!isset($section_required)) { |
|
59 |
$section_id = 0; |
|
60 |
} else { |
|
61 |
header("Location: $section_required"); |
|
62 |
exit(0); |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
// Create js back link |
|
67 |
$js_back = 'javascript: history.go(-1);'; |
|
68 |
|
|
69 |
// Create new admin object |
|
70 |
require(WB_PATH.'/framework/class.admin.php'); |
|
71 |
$admin = new admin('Pages', 'pages_modify'); |
|
72 |
|
|
73 |
// Get perms |
|
74 |
$database = new database(); |
|
75 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); |
|
76 |
$results_array = $results->fetchRow(); |
|
77 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
78 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users'])); |
|
79 |
|
|
80 |
$in_group = FALSE; |
|
81 |
foreach($admin->get_groups_id() as $cur_gid){ |
|
82 |
if (in_array($cur_gid, $old_admin_groups)) { |
|
83 |
$in_group = TRUE; |
|
84 |
} |
|
85 |
} |
|
86 |
if((!$in_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) { |
|
87 |
echo $admin->get_group_id().$admin->get_user_id(); |
|
88 |
print_r ($old_admin_groups); |
|
89 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
90 |
} |
|
91 |
|
|
92 |
// Workout if the developer wants to show the info banner |
|
93 |
if(isset($print_info_banner) AND $print_info_banner == true) { |
|
94 |
|
|
95 |
// Get page details |
|
96 |
$database = new database(); |
|
97 |
$query = "SELECT page_id,page_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
98 |
$results = $database->query($query); |
|
99 |
if($database->is_error()) { |
|
100 |
$admin->print_header(); |
|
101 |
$admin->print_error($database->get_error()); |
|
102 |
} |
|
103 |
if($results->numRows() == 0) { |
|
104 |
$admin->print_header(); |
|
105 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
106 |
} |
|
107 |
$results_array = $results->fetchRow(); |
|
108 |
|
|
109 |
// Get display name of person who last modified the page |
|
110 |
$user=$admin->get_user_details($results_array['modified_by']); |
|
111 |
|
|
112 |
// Convert the unix ts for modified_when to human a readable form |
|
113 |
if($results_array['modified_when'] != 0) { |
|
114 |
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE); |
|
115 |
} else { |
|
116 |
$modified_ts = 'Unknown'; |
|
117 |
} |
|
118 |
|
|
119 |
// Include page info script |
|
120 |
$template = new Template(THEME_PATH.'/templates'); |
|
121 |
$template->set_file('page', 'pages_modify.htt'); |
|
122 |
$template->set_block('page', 'main_block', 'main'); |
|
123 |
$template->set_var(array( |
|
124 |
'PAGE_ID' => $results_array['page_id'], |
|
125 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
126 |
'MODIFIED_BY' => $user['display_name'], |
|
127 |
'MODIFIED_BY_USERNAME' => $user['username'], |
|
128 |
'MODIFIED_WHEN' => $modified_ts, |
|
129 |
'ADMIN_URL' => ADMIN_URL |
|
130 |
) |
|
131 |
); |
|
132 |
if($modified_ts == 'Unknown') { |
|
133 |
$template->set_var('DISPLAY_MODIFIED', 'hide'); |
|
134 |
} else { |
|
135 |
$template->set_var('DISPLAY_MODIFIED', ''); |
|
136 |
} |
|
137 |
|
|
138 |
// Work-out if we should show the "manage sections" link |
|
139 |
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'"); |
|
140 |
if($query_sections->numRows() > 0) { |
|
141 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none'); |
|
142 |
} elseif(MANAGE_SECTIONS == 'enabled') { |
|
143 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']); |
|
144 |
} else { |
|
145 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none'); |
|
146 |
} |
|
147 |
|
|
148 |
// Insert language TEXT |
|
149 |
$template->set_var(array( |
|
150 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
151 |
'TEXT_CHANGE' => $TEXT['CHANGE'], |
|
152 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
153 |
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'], |
|
154 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'] |
|
155 |
) |
|
156 |
); |
|
157 |
|
|
158 |
// Parse and print header template |
|
159 |
$template->parse('main', 'main_block', false); |
|
160 |
$template->pparse('output', 'page'); |
|
161 |
|
|
162 |
} |
|
163 |
|
|
164 |
// Work-out if the developer wants us to update the timestamp for when the page was last modified |
|
165 |
if(isset($update_when_modified) AND $update_when_modified == true) { |
|
166 |
$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'"); |
|
167 |
} |
|
168 |
|
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category backend |
|
5 |
* @package modules |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2010, 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 4.3.4 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']) AND is_numeric($_GET['page_id'])) { |
|
27 |
$page_id = $_GET['page_id']; |
|
28 |
} elseif(isset($_POST['page_id']) AND is_numeric($_POST['page_id'])) { |
|
29 |
$page_id = $_POST['page_id']; |
|
30 |
} else { |
|
31 |
header("Location: index.php"); |
|
32 |
exit(0); |
|
33 |
} |
|
34 |
|
|
35 |
// Get section id if there is one |
|
36 |
if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) { |
|
37 |
$section_id = $_GET['section_id']; |
|
38 |
} elseif(isset($_POST['section_id']) AND is_numeric($_POST['section_id'])) { |
|
39 |
$section_id = $_POST['section_id']; |
|
40 |
} else { |
|
41 |
// Check if we should redirect the user if there is no section id |
|
42 |
if(!isset($section_required)) { |
|
43 |
$section_id = 0; |
|
44 |
} else { |
|
45 |
header("Location: $section_required"); |
|
46 |
exit(0); |
|
47 |
} |
|
48 |
} |
|
49 |
|
|
50 |
// Create js back link |
|
51 |
$js_back = 'javascript: history.go(-1);'; |
|
52 |
|
|
53 |
// Create new admin object |
|
54 |
require(WB_PATH.'/framework/class.admin.php'); |
|
55 |
$admin = new admin('Pages', 'pages_modify'); |
|
56 |
|
|
57 |
// Get perms |
|
58 |
$database = new database(); |
|
59 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); |
|
60 |
$results_array = $results->fetchRow(); |
|
61 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
62 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users'])); |
|
63 |
|
|
64 |
$in_group = FALSE; |
|
65 |
foreach($admin->get_groups_id() as $cur_gid){ |
|
66 |
if (in_array($cur_gid, $old_admin_groups)) { |
|
67 |
$in_group = TRUE; |
|
68 |
} |
|
69 |
} |
|
70 |
if((!$in_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) { |
|
71 |
echo $admin->get_group_id().$admin->get_user_id(); |
|
72 |
print_r ($old_admin_groups); |
|
73 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
74 |
} |
|
75 |
|
|
76 |
// Workout if the developer wants to show the info banner |
|
77 |
if(isset($print_info_banner) AND $print_info_banner == true) { |
|
78 |
|
|
79 |
// Get page details |
|
80 |
$database = new database(); |
|
81 |
$query = "SELECT page_id,page_title,modified_by,modified_when FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
82 |
$results = $database->query($query); |
|
83 |
if($database->is_error()) { |
|
84 |
$admin->print_header(); |
|
85 |
$admin->print_error($database->get_error()); |
|
86 |
} |
|
87 |
if($results->numRows() == 0) { |
|
88 |
$admin->print_header(); |
|
89 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
90 |
} |
|
91 |
$results_array = $results->fetchRow(); |
|
92 |
|
|
93 |
// Get display name of person who last modified the page |
|
94 |
$user=$admin->get_user_details($results_array['modified_by']); |
|
95 |
|
|
96 |
// Convert the unix ts for modified_when to human a readable form |
|
97 |
if($results_array['modified_when'] != 0) { |
|
98 |
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE); |
|
99 |
} else { |
|
100 |
$modified_ts = 'Unknown'; |
|
101 |
} |
|
102 |
|
|
103 |
// Include page info script |
|
104 |
$template = new Template(THEME_PATH.'/templates'); |
|
105 |
$template->set_file('page', 'pages_modify.htt'); |
|
106 |
$template->set_block('page', 'main_block', 'main'); |
|
107 |
$template->set_var(array( |
|
108 |
'PAGE_ID' => $results_array['page_id'], |
|
109 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
110 |
'MODIFIED_BY' => $user['display_name'], |
|
111 |
'MODIFIED_BY_USERNAME' => $user['username'], |
|
112 |
'MODIFIED_WHEN' => $modified_ts, |
|
113 |
'ADMIN_URL' => ADMIN_URL |
|
114 |
) |
|
115 |
); |
|
116 |
if($modified_ts == 'Unknown') { |
|
117 |
$template->set_var('DISPLAY_MODIFIED', 'hide'); |
|
118 |
} else { |
|
119 |
$template->set_var('DISPLAY_MODIFIED', ''); |
|
120 |
} |
|
121 |
|
|
122 |
// Work-out if we should show the "manage sections" link |
|
123 |
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'"); |
|
124 |
if($query_sections->numRows() > 0) { |
|
125 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none'); |
|
126 |
} elseif(MANAGE_SECTIONS == 'enabled') { |
|
127 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']); |
|
128 |
} else { |
|
129 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none'); |
|
130 |
} |
|
131 |
|
|
132 |
// Insert language TEXT |
|
133 |
$template->set_var(array( |
|
134 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
135 |
'TEXT_CHANGE' => $TEXT['CHANGE'], |
|
136 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
137 |
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'], |
|
138 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'] |
|
139 |
) |
|
140 |
); |
|
141 |
|
|
142 |
// Parse and print header template |
|
143 |
$template->parse('main', 'main_block', false); |
|
144 |
$template->pparse('output', 'page'); |
|
145 |
|
|
146 |
} |
|
147 |
|
|
148 |
// Work-out if the developer wants us to update the timestamp for when the page was last modified |
|
149 |
if(isset($update_when_modified) AND $update_when_modified == true) { |
|
150 |
$database->query("UPDATE ".TABLE_PREFIX."pages SET modified_when = '".time()."', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'"); |
|
151 |
} |
|
152 |
|
|
169 | 153 |
?> |
170 | 154 |
Also available in: Unified diff
Branch 2.8.1 merged back into Trunk