Revision 1358
Added by Dietmar almost 14 years ago
add.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 |
// Create new admin object and print admin header |
|
20 |
require('../../config.php'); |
|
21 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
22 |
$admin = new admin('Pages', 'pages_add'); |
|
23 |
|
|
24 |
if (!$admin->checkFTAN()) |
|
25 |
{ |
|
26 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
27 |
exit(); |
|
28 |
} |
|
29 |
|
|
30 |
// Include the WB functions file |
|
31 |
require_once(WB_PATH.'/framework/functions.php'); |
|
32 |
|
|
33 |
// Get values |
|
34 |
$title = $admin->get_post_escaped('title'); |
|
35 |
$title = htmlspecialchars($title); |
|
36 |
$module = preg_replace("/\W/", "", $admin->get_post('type')); // fix secunia 2010-93-4 |
|
37 |
$parent = (int) $admin->get_post('parent'); // fix secunia 2010-91-2 |
|
38 |
$visibility = $admin->get_post('visibility'); |
|
39 |
if (!in_array($visibility, array('public', 'private', 'registered', 'hidden', 'none'))) $visibility = 'public'; // fix secunia 2010-91-2 |
|
40 |
$admin_groups = $admin->get_post('admin_groups'); |
|
41 |
$viewing_groups = $admin->get_post('viewing_groups'); |
|
42 |
|
|
43 |
// Work-out if we should check for existing page_code |
|
44 |
$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`'; |
|
45 |
$field_sql = $database->query($sql); |
|
46 |
$field_set = $field_sql->numRows(); |
|
47 |
|
|
48 |
// add Admin to admin and viewing-groups |
|
49 |
$admin_groups[] = 1; |
|
50 |
$viewing_groups[] = 1; |
|
51 |
|
|
52 |
if ($parent!=0) { |
|
53 |
if (!$admin->get_page_permission($parent,'admin')) |
|
54 |
{ |
|
55 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
56 |
} |
|
57 |
|
|
58 |
} elseif (!$admin->get_permission('pages_add_l0','system')) |
|
59 |
{ |
|
60 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
61 |
} |
|
62 |
|
|
63 |
// Validate data |
|
64 |
if($title == '' || substr($title,0,1)=='.') |
|
65 |
{ |
|
66 |
$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']); |
|
67 |
} |
|
68 |
|
|
69 |
// Check to see if page created has needed permissions |
|
70 |
if(!in_array(1, $admin->get_groups_id())) |
|
71 |
{ |
|
72 |
$admin_perm_ok = false; |
|
73 |
foreach ($admin_groups as $adm_group) |
|
74 |
{ |
|
75 |
if (in_array($adm_group, $admin->get_groups_id())) |
|
76 |
{ |
|
77 |
$admin_perm_ok = true; |
|
78 |
} |
|
79 |
} |
|
80 |
if ($admin_perm_ok == false) |
|
81 |
{ |
|
82 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
83 |
} |
|
84 |
$admin_perm_ok = false; |
|
85 |
foreach ($viewing_groups as $view_group) |
|
86 |
{ |
|
87 |
if (in_array($view_group, $admin->get_groups_id())) |
|
88 |
{ |
|
89 |
$admin_perm_ok = true; |
|
90 |
} |
|
91 |
} |
|
92 |
if ($admin_perm_ok == false) |
|
93 |
{ |
|
94 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
$admin_groups = preg_replace("/[^\d,]/", "", implode(',', $admin_groups)); |
|
99 |
$viewing_groups = preg_replace("/[^\d,]/", "", implode(',', $viewing_groups)); |
|
100 |
|
|
101 |
// Work-out what the link and page filename should be |
|
102 |
if($parent == '0') |
|
103 |
{ |
|
104 |
$link = '/'.page_filename($title); |
|
105 |
// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php |
|
106 |
if($link == '/index' || $link == '/intro') |
|
107 |
{ |
|
108 |
$link .= '_0'; |
|
109 |
$filename = WB_PATH .PAGES_DIRECTORY .'/' .page_filename($title) .'_0' .PAGE_EXTENSION; |
|
110 |
} else { |
|
111 |
$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($title).PAGE_EXTENSION; |
|
112 |
} |
|
113 |
} else { |
|
114 |
$parent_section = ''; |
|
115 |
$parent_titles = array_reverse(get_parent_titles($parent)); |
|
116 |
foreach($parent_titles AS $parent_title) |
|
117 |
{ |
|
118 |
$parent_section .= page_filename($parent_title).'/'; |
|
119 |
} |
|
120 |
if($parent_section == '/') { $parent_section = ''; } |
|
121 |
$link = '/'.$parent_section.page_filename($title); |
|
122 |
$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($title).PAGE_EXTENSION; |
|
123 |
make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section); |
|
124 |
} |
|
125 |
|
|
126 |
// Check if a page with same page filename exists |
|
127 |
$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'"); |
|
128 |
if($get_same_page->numRows() > 0 OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION) OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/')) |
|
129 |
{ |
|
130 |
$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']); |
|
131 |
} |
|
132 |
|
|
133 |
// Include the ordering class |
|
134 |
require(WB_PATH.'/framework/class.order.php'); |
|
135 |
$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent'); |
|
136 |
// First clean order |
|
137 |
$order->clean($parent); |
|
138 |
// Get new order |
|
139 |
$position = $order->get_new($parent); |
|
140 |
|
|
141 |
// Work-out if the page parent (if selected) has a seperate template or language to the default |
|
142 |
$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'"); |
|
143 |
if($query_parent->numRows() > 0) |
|
144 |
{ |
|
145 |
$fetch_parent = $query_parent->fetchRow(); |
|
146 |
$template = $fetch_parent['template']; |
|
147 |
$language = $fetch_parent['language']; |
|
148 |
} else { |
|
149 |
$template = ''; |
|
150 |
$language = DEFAULT_LANGUAGE; |
|
151 |
} |
|
152 |
|
|
153 |
// Insert page into pages table |
|
154 |
$sql = 'INSERT INTO `'.TABLE_PREFIX.'pages` SET '; |
|
155 |
$sql .= '`parent` = '.$parent.', '; |
|
156 |
$sql .= '`target` = "_top", '; |
|
157 |
$sql .= '`page_title` = "'.$title.'", '; |
|
158 |
$sql .= '`menu_title` = "'.$title.'", '; |
|
159 |
$sql .= '`template` = "'.$template.'", '; |
|
160 |
$sql .= '`visibility` = "'.$visibility.'", '; |
|
161 |
$sql .= '`position` = '.$position.', '; |
|
162 |
$sql .= '`menu` = 1, '; |
|
163 |
$sql .= '`language` = "'.$language.'", '; |
|
164 |
$sql .= '`searching` = 1, '; |
|
165 |
$sql .= '`modified_when` = '.time().', '; |
|
166 |
$sql .= '`modified_by` = '.$admin->get_user_id().', '; |
|
167 |
$sql .= '`admin_groups` = "'.$admin_groups.'", '; |
|
168 |
$sql .= '`viewing_groups` = "'.$viewing_groups.'"'; |
|
169 |
|
|
170 |
$database->query($sql); |
|
171 |
/* |
|
172 |
$query = "INSERT INTO ".TABLE_PREFIX."pages |
|
173 |
(page_title,menu_title,parent,template,target,position,visibility,searching,menu,language,admin_groups,viewing_groups,modified_when,modified_by) VALUES |
|
174 |
('$title','$title','$parent','$template','_top','$position','$visibility','1','1','$language','$admin_groups','$viewing_groups','".time()."','".$admin->get_user_id()."')"; |
|
175 |
$database->query($query); |
|
176 |
*/ |
|
177 |
if($database->is_error()) |
|
178 |
{ |
|
179 |
$admin->print_error($database->get_error()); |
|
180 |
} |
|
181 |
|
|
182 |
// Get the page id |
|
183 |
$page_id = $database->get_one("SELECT LAST_INSERT_ID()"); |
|
184 |
|
|
185 |
// Work out level |
|
186 |
$level = level_count($page_id); |
|
187 |
// Work out root parent |
|
188 |
$root_parent = root_parent($page_id); |
|
189 |
// Work out page trail |
|
190 |
$page_trail = get_page_trail($page_id); |
|
191 |
|
|
192 |
// Update page with new level and link |
|
193 |
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET '; |
|
194 |
$sql .= '`root_parent` = '.$root_parent.', '; |
|
195 |
$sql .= '`level` = '.$level.', '; |
|
196 |
$sql .= '`link` = "'.$link.'", '; |
|
197 |
$sql .= '`page_trail` = "'.$page_trail.'"'; |
|
198 |
$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) |
|
199 |
&& $field_set |
|
200 |
&& ($language == DEFAULT_LANGUAGE) |
|
201 |
&& (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') |
|
202 |
) |
|
203 |
? ', `page_code` = '.(int)$page_id.' ' : ' '; |
|
204 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
205 |
$database->query($sql); |
|
206 |
/* |
|
207 |
$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$link', level = '$level', root_parent = '$root_parent', page_trail = '$page_trail' WHERE page_id = '$page_id'"); |
|
208 |
*/ |
|
209 |
if($database->is_error()) |
|
210 |
{ |
|
211 |
$admin->print_error($database->get_error()); |
|
212 |
} |
|
213 |
// Create a new file in the /pages dir |
|
214 |
create_access_file($filename, $page_id, $level); |
|
215 |
|
|
216 |
// add position 1 to new page |
|
217 |
$position = 1; |
|
218 |
|
|
219 |
// Add new record into the sections table |
|
220 |
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,position,module,block) VALUES ('$page_id','$position', '$module','1')"); |
|
221 |
|
|
222 |
// Get the section id |
|
223 |
$section_id = $database->get_one("SELECT LAST_INSERT_ID()"); |
|
224 |
|
|
225 |
// Include the selected modules add file if it exists |
|
226 |
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) { |
|
227 |
require(WB_PATH.'/modules/'.$module.'/add.php'); |
|
228 |
} |
|
229 |
|
|
230 |
// Check if there is a db error, otherwise say successful |
|
231 |
if($database->is_error()) { |
|
232 |
$admin->print_error($database->get_error()); |
|
233 |
} else { |
|
234 |
$admin->print_success($MESSAGE['PAGES']['ADDED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
235 |
} |
|
236 |
|
|
237 |
// Print admin footer |
|
238 |
$admin->print_footer(); |
|
239 |
|
|
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 |
// Create new admin object and print admin header |
|
20 |
require('../../config.php'); |
|
21 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
22 |
$admin = new admin('Pages', 'pages_add'); |
|
23 |
|
|
24 |
if (!$admin->checkFTAN()) |
|
25 |
{ |
|
26 |
$admin->print_error($MESSAGE['PAGES_NOT_SAVED'],'index.php'); |
|
27 |
exit(); |
|
28 |
} |
|
29 |
|
|
30 |
// Include the WB functions file |
|
31 |
require_once(WB_PATH.'/framework/functions.php'); |
|
32 |
|
|
33 |
// Get values |
|
34 |
$title = $admin->get_post_escaped('title'); |
|
35 |
$title = htmlspecialchars($title); |
|
36 |
$module = $admin->get_post('type'); |
|
37 |
$parent = $admin->get_post('parent'); |
|
38 |
$visibility = $admin->get_post('visibility'); |
|
39 |
$admin_groups = $admin->get_post('admin_groups'); |
|
40 |
$viewing_groups = $admin->get_post('viewing_groups'); |
|
41 |
|
|
42 |
// Work-out if we should check for existing page_code |
|
43 |
$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`'; |
|
44 |
$field_sql = $database->query($sql); |
|
45 |
$field_set = $field_sql->numRows(); |
|
46 |
|
|
47 |
// add Admin to admin and viewing-groups |
|
48 |
$admin_groups[] = 1; |
|
49 |
$viewing_groups[] = 1; |
|
50 |
|
|
51 |
if ($parent!=0) { |
|
52 |
if (!$admin->get_page_permission($parent,'admin')) |
|
53 |
{ |
|
54 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
55 |
} |
|
56 |
|
|
57 |
} elseif (!$admin->get_permission('pages_add_l0','system')) |
|
58 |
{ |
|
59 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
60 |
} |
|
61 |
|
|
62 |
// Validate data |
|
63 |
if($title == '' || substr($title,0,1)=='.') |
|
64 |
{ |
|
65 |
$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']); |
|
66 |
} |
|
67 |
|
|
68 |
// Check to see if page created has needed permissions |
|
69 |
if(!in_array(1, $admin->get_groups_id())) |
|
70 |
{ |
|
71 |
$admin_perm_ok = false; |
|
72 |
foreach ($admin_groups as $adm_group) |
|
73 |
{ |
|
74 |
if (in_array($adm_group, $admin->get_groups_id())) |
|
75 |
{ |
|
76 |
$admin_perm_ok = true; |
|
77 |
} |
|
78 |
} |
|
79 |
if ($admin_perm_ok == false) |
|
80 |
{ |
|
81 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
82 |
} |
|
83 |
$admin_perm_ok = false; |
|
84 |
foreach ($viewing_groups as $view_group) |
|
85 |
{ |
|
86 |
if (in_array($view_group, $admin->get_groups_id())) |
|
87 |
{ |
|
88 |
$admin_perm_ok = true; |
|
89 |
} |
|
90 |
} |
|
91 |
if ($admin_perm_ok == false) |
|
92 |
{ |
|
93 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
$admin_groups = implode(',', $admin_groups); |
|
98 |
$viewing_groups = implode(',', $viewing_groups); |
|
99 |
|
|
100 |
// Work-out what the link and page filename should be |
|
101 |
if($parent == '0') |
|
102 |
{ |
|
103 |
$link = '/'.page_filename($title); |
|
104 |
// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php |
|
105 |
if($link == '/index' || $link == '/intro') |
|
106 |
{ |
|
107 |
$link .= '_0'; |
|
108 |
$filename = WB_PATH .PAGES_DIRECTORY .'/' .page_filename($title) .'_0' .PAGE_EXTENSION; |
|
109 |
} else { |
|
110 |
$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($title).PAGE_EXTENSION; |
|
111 |
} |
|
112 |
} else { |
|
113 |
$parent_section = ''; |
|
114 |
$parent_titles = array_reverse(get_parent_titles($parent)); |
|
115 |
foreach($parent_titles AS $parent_title) |
|
116 |
{ |
|
117 |
$parent_section .= page_filename($parent_title).'/'; |
|
118 |
} |
|
119 |
if($parent_section == '/') { $parent_section = ''; } |
|
120 |
$link = '/'.$parent_section.page_filename($title); |
|
121 |
$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($title).PAGE_EXTENSION; |
|
122 |
make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section); |
|
123 |
} |
|
124 |
|
|
125 |
// Check if a page with same page filename exists |
|
126 |
$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'"); |
|
127 |
if($get_same_page->numRows() > 0 OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION) OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/')) |
|
128 |
{ |
|
129 |
$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']); |
|
130 |
} |
|
131 |
|
|
132 |
// Include the ordering class |
|
133 |
require(WB_PATH.'/framework/class.order.php'); |
|
134 |
$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent'); |
|
135 |
// First clean order |
|
136 |
$order->clean($parent); |
|
137 |
// Get new order |
|
138 |
$position = $order->get_new($parent); |
|
139 |
|
|
140 |
// Work-out if the page parent (if selected) has a seperate template or language to the default |
|
141 |
$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'"); |
|
142 |
if($query_parent->numRows() > 0) |
|
143 |
{ |
|
144 |
$fetch_parent = $query_parent->fetchRow(); |
|
145 |
$template = $fetch_parent['template']; |
|
146 |
$language = $fetch_parent['language']; |
|
147 |
} else { |
|
148 |
$template = ''; |
|
149 |
$language = DEFAULT_LANGUAGE; |
|
150 |
} |
|
151 |
|
|
152 |
// Insert page into pages table |
|
153 |
$sql = 'INSERT INTO `'.TABLE_PREFIX.'pages` SET '; |
|
154 |
$sql .= '`parent` = '.$parent.', '; |
|
155 |
$sql .= '`target` = "_top", '; |
|
156 |
$sql .= '`page_title` = "'.$title.'", '; |
|
157 |
$sql .= '`menu_title` = "'.$title.'", '; |
|
158 |
$sql .= '`template` = "'.$template.'", '; |
|
159 |
$sql .= '`visibility` = "'.$visibility.'", '; |
|
160 |
$sql .= '`position` = '.$position.', '; |
|
161 |
$sql .= '`menu` = 1, '; |
|
162 |
$sql .= '`language` = "'.$language.'", '; |
|
163 |
$sql .= '`searching` = 1, '; |
|
164 |
$sql .= '`modified_when` = '.time().', '; |
|
165 |
$sql .= '`modified_by` = '.$admin->get_user_id().', '; |
|
166 |
$sql .= '`admin_groups` = "'.$admin_groups.'", '; |
|
167 |
$sql .= '`viewing_groups` = "'.$viewing_groups.'"'; |
|
168 |
|
|
169 |
$database->query($sql); |
|
170 |
/* |
|
171 |
$query = "INSERT INTO ".TABLE_PREFIX."pages |
|
172 |
(page_title,menu_title,parent,template,target,position,visibility,searching,menu,language,admin_groups,viewing_groups,modified_when,modified_by) VALUES |
|
173 |
('$title','$title','$parent','$template','_top','$position','$visibility','1','1','$language','$admin_groups','$viewing_groups','".time()."','".$admin->get_user_id()."')"; |
|
174 |
$database->query($query); |
|
175 |
*/ |
|
176 |
if($database->is_error()) |
|
177 |
{ |
|
178 |
$admin->print_error($database->get_error()); |
|
179 |
} |
|
180 |
|
|
181 |
// Get the page id |
|
182 |
$page_id = $database->get_one("SELECT LAST_INSERT_ID()"); |
|
183 |
|
|
184 |
// Work out level |
|
185 |
$level = level_count($page_id); |
|
186 |
// Work out root parent |
|
187 |
$root_parent = root_parent($page_id); |
|
188 |
// Work out page trail |
|
189 |
$page_trail = get_page_trail($page_id); |
|
190 |
|
|
191 |
// Update page with new level and link |
|
192 |
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET '; |
|
193 |
$sql .= '`root_parent` = '.$root_parent.', '; |
|
194 |
$sql .= '`level` = '.$level.', '; |
|
195 |
$sql .= '`link` = "'.$link.'", '; |
|
196 |
$sql .= '`page_trail` = "'.$page_trail.'"'; |
|
197 |
$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) |
|
198 |
&& $field_set |
|
199 |
&& ($language == DEFAULT_LANGUAGE) |
|
200 |
&& (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') |
|
201 |
) |
|
202 |
? ', `page_code` = '.(int)$page_id.' ' : ' '; |
|
203 |
$sql .= 'WHERE `page_id` = '.$page_id; |
|
204 |
$database->query($sql); |
|
205 |
/* |
|
206 |
$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$link', level = '$level', root_parent = '$root_parent', page_trail = '$page_trail' WHERE page_id = '$page_id'"); |
|
207 |
*/ |
|
208 |
if($database->is_error()) |
|
209 |
{ |
|
210 |
$admin->print_error($database->get_error()); |
|
211 |
} |
|
212 |
// Create a new file in the /pages dir |
|
213 |
create_access_file($filename, $page_id, $level); |
|
214 |
|
|
215 |
// add position 1 to new page |
|
216 |
$position = 1; |
|
217 |
|
|
218 |
// Add new record into the sections table |
|
219 |
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,position,module,block) VALUES ('$page_id','$position', '$module','1')"); |
|
220 |
|
|
221 |
// Get the section id |
|
222 |
$section_id = $database->get_one("SELECT LAST_INSERT_ID()"); |
|
223 |
|
|
224 |
// Include the selected modules add file if it exists |
|
225 |
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) { |
|
226 |
require(WB_PATH.'/modules/'.$module.'/add.php'); |
|
227 |
} |
|
228 |
|
|
229 |
// Check if there is a db error, otherwise say successful |
|
230 |
if($database->is_error()) { |
|
231 |
$admin->print_error($database->get_error()); |
|
232 |
} else { |
|
233 |
$admin->print_success($MESSAGE['PAGES']['ADDED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id); |
|
234 |
} |
|
235 |
|
|
236 |
// Print admin footer |
|
237 |
$admin->print_footer(); |
|
238 |
|
|
240 | 239 |
?> |
Also available in: Unified diff
validation fixes in pages backend theme