Revision 1306
Added by Dietmar over 14 years ago
save.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 & section id |
|
27 |
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) { |
|
28 |
header("Location: index.php"); |
|
29 |
exit(0); |
|
30 |
} else { |
|
31 |
$page_id = $_POST['page_id']; |
|
32 |
} |
|
33 |
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) { |
|
34 |
header("Location: index.php"); |
|
35 |
exit(0); |
|
36 |
} else { |
|
37 |
$section_id = $_POST['section_id']; |
|
38 |
} |
|
39 |
|
|
40 |
// Create new admin object |
|
41 |
require('../../config.php'); |
|
42 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
43 |
$admin = new admin('Pages', 'pages_modify'); |
|
44 |
|
|
45 |
// Get perms |
|
46 |
$database = new database(); |
|
47 |
$results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"); |
|
48 |
$results_array = $results->fetchRow(); |
|
49 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
50 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users'])); |
|
51 |
$in_old_group = FALSE; |
|
52 |
foreach($admin->get_groups_id() as $cur_gid){ |
|
53 |
if (in_array($cur_gid, $old_admin_groups)) { |
|
54 |
$in_old_group = TRUE; |
|
55 |
} |
|
56 |
} |
|
57 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) { |
|
58 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
59 |
} |
|
60 |
|
|
61 |
// Get page module |
|
62 |
$database = new database(); |
|
63 |
$query = "SELECT module FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'"; |
|
64 |
$results = $database->query($query); |
|
65 |
if($database->is_error()) { |
|
66 |
$admin->print_error($database->get_error()); |
|
67 |
} |
|
68 |
if($results->numRows() == 0) { |
|
69 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
70 |
} |
|
71 |
$results_array = $results->fetchRow(); |
|
72 |
$module = $results_array['module']; |
|
73 |
|
|
74 |
// Update the pages table |
|
75 |
$now = time(); |
|
76 |
$query = "UPDATE ".TABLE_PREFIX."pages SET modified_when = '$now', modified_by = '".$admin->get_user_id()."' WHERE page_id = '$page_id'"; |
|
77 |
$database->query($query); |
|
78 |
|
|
79 |
// Include the modules saving script if it exists |
|
80 |
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) { |
|
81 |
require(WB_PATH.'/modules/'.$module.'/save.php'); |
|
82 |
} |
|
83 |
|
|
84 |
// Check if there is a db error, otherwise say successful |
|
85 |
if($database->is_error()) { |
|
86 |
$admin->print_error($database->get_error(), $js_back); |
|
87 |
} else { |
|
88 |
$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
89 |
} |
|
90 |
|
|
91 |
// Print admin footer |
|
92 |
$admin->print_footer(); |
|
93 |
|
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category admin |
|
5 |
* @package pages |
|
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 |
// Get page & section id |
|
20 |
if(!isset($_POST['page_id']) OR !is_numeric($_POST['page_id'])) { |
|
21 |
header("Location: index.php"); |
|
22 |
exit(0); |
|
23 |
} else { |
|
24 |
$page_id = intval($_POST['page_id']); |
|
25 |
} |
|
26 |
if(!isset($_POST['section_id']) OR !is_numeric($_POST['section_id'])) { |
|
27 |
header("Location: index.php"); |
|
28 |
exit(0); |
|
29 |
} else { |
|
30 |
$section_id = intval($_POST['section_id']); |
|
31 |
} |
|
32 |
|
|
33 |
// Create new admin object |
|
34 |
require('../../config.php'); |
|
35 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
36 |
$admin = new admin('Pages', 'pages_modify'); |
|
37 |
|
|
38 |
// Get perms |
|
39 |
$sql = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` '; |
|
40 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
41 |
$results = $database->query($sql); |
|
42 |
$results_array = $results->fetchRow(); |
|
43 |
$old_admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
44 |
$old_admin_users = explode(',', str_replace('_', '', $results_array['admin_users'])); |
|
45 |
$in_old_group = FALSE; |
|
46 |
foreach($admin->get_groups_id() as $cur_gid) |
|
47 |
{ |
|
48 |
if (in_array($cur_gid, $old_admin_groups)) |
|
49 |
{ |
|
50 |
$in_old_group = TRUE; |
|
51 |
} |
|
52 |
} |
|
53 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) |
|
54 |
{ |
|
55 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
56 |
} |
|
57 |
// Get page module |
|
58 |
$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` '; |
|
59 |
$sql .= 'WHERE `page_id`='.$page_id.' AND `section_id`='.$section_id; |
|
60 |
$module = $database->get_one($sql); |
|
61 |
if(!$module) |
|
62 |
{ |
|
63 |
$admin->print_error( $database->is_error() ? $database->get_error() : $MESSAGE['PAGES']['NOT_FOUND']); |
|
64 |
} |
|
65 |
//$results = $database->query($sql); |
|
66 |
//if($database->is_error()) { |
|
67 |
// $admin->print_error($database->get_error()); |
|
68 |
//} |
|
69 |
//if($results->numRows() == 0) { |
|
70 |
// $admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
71 |
//} |
|
72 |
//$results_array = $results->fetchRow(); |
|
73 |
//$module = $results_array['module']; |
|
74 |
|
|
75 |
// Update the pages table |
|
76 |
$now = time(); |
|
77 |
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET '; |
|
78 |
$sql .= '`modified_when` = '.$now.', `modified_by` = '.$admin->get_user_id().' '; |
|
79 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
80 |
$database->query($sql); |
|
81 |
|
|
82 |
// Include the modules saving script if it exists |
|
83 |
if(file_exists(WB_PATH.'/modules/'.$module.'/save.php')) |
|
84 |
{ |
|
85 |
include_once(WB_PATH.'/modules/'.$module.'/save.php'); |
|
86 |
} |
|
87 |
// Check if there is a db error, otherwise say successful |
|
88 |
if($database->is_error()) |
|
89 |
{ |
|
90 |
$admin->print_error($database->get_error(), $js_back); |
|
91 |
} else { |
|
92 |
$admin->print_success($MESSAGE['PAGES']['SAVED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
93 |
} |
|
94 |
|
|
95 |
// Print admin footer |
|
96 |
$admin->print_footer(); |
|
97 |
|
|
94 | 98 |
?> |
95 | 99 |
Also available in: Unified diff
rework admin/pages/save.php so that modules can use it
fixed missing global variable in install to work in modules