1 |
1358
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
|
|
* @category admin
|
5 |
|
|
* @package pages
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
|
|
* @copyright 2004-2009, Ryan Djurovich
|
8 |
1373
|
Luisehahne
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
9 |
1358
|
Luisehahne
|
* @link http://www.websitebaker2.org/
|
10 |
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
11 |
|
|
* @platform WebsiteBaker 2.8.x
|
12 |
1373
|
Luisehahne
|
* @requirements PHP 5.2.2 and higher
|
13 |
1358
|
Luisehahne
|
* @version $Id$
|
14 |
|
|
* @filesource $HeadURL$
|
15 |
|
|
* @lastmodified $Date$
|
16 |
|
|
*
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
// Include config file
|
20 |
|
|
require('../../config.php');
|
21 |
|
|
|
22 |
|
|
// Make sure people are allowed to access this page
|
23 |
|
|
if(MANAGE_SECTIONS != 'enabled')
|
24 |
|
|
{
|
25 |
|
|
header('Location: '.ADMIN_URL.'/pages/index.php');
|
26 |
|
|
exit(0);
|
27 |
|
|
}
|
28 |
1402
|
Luisehahne
|
/* */
|
29 |
|
|
$debug = false; // to show position and section_id
|
30 |
|
|
If(!defined('DEBUG')) { define('DEBUG',$debug);}
|
31 |
1475
|
Luisehahne
|
// Include the WB functions file
|
32 |
|
|
require_once(WB_PATH.'/framework/functions.php');
|
33 |
1402
|
Luisehahne
|
// Create new admin object
|
34 |
|
|
require_once(WB_PATH.'/framework/class.admin.php');
|
35 |
1475
|
Luisehahne
|
$admin = new admin('Pages', 'pages_modify', false);
|
36 |
1358
|
Luisehahne
|
|
37 |
1475
|
Luisehahne
|
$action = 'show';
|
38 |
1358
|
Luisehahne
|
// Get page id
|
39 |
1475
|
Luisehahne
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
40 |
|
|
$page_id = intval((isset(${$requestMethod}['page_id'])) ? ${$requestMethod}['page_id'] : 0);
|
41 |
|
|
$action = ($page_id ? 'show' : $action);
|
42 |
|
|
// Get section id if there is one
|
43 |
|
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
44 |
|
|
$section_id = ((isset(${$requestMethod}['section_id'])) ? ${$requestMethod}['section_id'] : 0);
|
45 |
|
|
$action = ($section_id ? 'delete' : $action);
|
46 |
|
|
// Get module if there is one
|
47 |
|
|
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
48 |
|
|
$module = ((isset(${$requestMethod}['module'])) ? ${$requestMethod}['module'] : 0);
|
49 |
|
|
$action = ($module != '' ? 'add' : $action);
|
50 |
|
|
$admin_header = true;
|
51 |
|
|
$backlink = ADMIN_URL.'/pages/sections.php?page_id='.(int)$page_id;
|
52 |
1358
|
Luisehahne
|
|
53 |
1475
|
Luisehahne
|
switch ($action):
|
54 |
|
|
case 'delete' :
|
55 |
1358
|
Luisehahne
|
|
56 |
1475
|
Luisehahne
|
if( ( !($section_id = intval($admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD'])) )) )
|
57 |
|
|
{
|
58 |
|
|
if($admin_header) { $admin->print_header(); }
|
59 |
|
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
|
60 |
|
|
}
|
61 |
1358
|
Luisehahne
|
|
62 |
1475
|
Luisehahne
|
$action = 'show';
|
63 |
|
|
$sql = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
|
64 |
|
|
$sql .= 'WHERE `section_id` ='.$section_id;
|
65 |
|
|
if( ( ($modulname = $database->get_one($sql)) == $module) && ($section_id > 0 ) ) {
|
66 |
|
|
// Include the modules delete file if it exists
|
67 |
|
|
if(file_exists(WB_PATH.'/modules/'.$modulname.'/delete.php'))
|
68 |
|
|
{
|
69 |
|
|
require(WB_PATH.'/modules/'.$modulname.'/delete.php');
|
70 |
|
|
}
|
71 |
|
|
$sql = 'DELETE FROM `'.TABLE_PREFIX.'sections` ';
|
72 |
|
|
$sql .= 'WHERE `section_id` ='.(int)$section_id.' LIMIT 1';
|
73 |
|
|
if( !$database->query($sql) ) {
|
74 |
|
|
if($admin_header) { $admin->print_header(); }
|
75 |
|
|
$admin->print_error($database->get_error(),$backlink);
|
76 |
|
|
} else {
|
77 |
|
|
require_once(WB_PATH.'/framework/class.order.php');
|
78 |
|
|
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
|
79 |
|
|
$order->clean($page_id);
|
80 |
|
|
$format = $TEXT['SECTION'].' %d %s %s '.strtolower( $TEXT['DELETED']);
|
81 |
|
|
$message = sprintf ($format,$section_id,strtoupper($modulname),strtolower($TEXT['SUCCESS']));
|
82 |
|
|
if($admin_header) { $admin->print_header(); }
|
83 |
|
|
$admin_header = false;
|
84 |
|
|
unset($_POST);
|
85 |
|
|
$admin->print_success($message, $backlink );
|
86 |
|
|
}
|
87 |
|
|
} else {
|
88 |
|
|
if($admin_header) { $admin->print_header(); }
|
89 |
|
|
$admin->print_error($module.' '.strtolower($TEXT['NOT_FOUND']),$backlink);
|
90 |
|
|
}
|
91 |
1358
|
Luisehahne
|
|
92 |
1475
|
Luisehahne
|
break;
|
93 |
|
|
case 'add' :
|
94 |
|
|
|
95 |
|
|
if (!$admin->checkFTAN())
|
96 |
|
|
{
|
97 |
|
|
$admin->print_header();
|
98 |
|
|
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
|
99 |
|
|
}
|
100 |
|
|
$action = 'show';
|
101 |
|
|
$module = preg_replace('/\W/', '', $module ); // fix secunia 2010-91-4
|
102 |
|
|
require_once(WB_PATH.'/framework/class.order.php');
|
103 |
|
|
// Get new order
|
104 |
1358
|
Luisehahne
|
$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
|
105 |
1475
|
Luisehahne
|
$position = $order->get_new($page_id);
|
106 |
|
|
// Insert module into DB
|
107 |
|
|
$sql = 'INSERT INTO `'.TABLE_PREFIX.'sections` SET ';
|
108 |
|
|
$sql .= '`page_id` = '.(int)$page_id.', ';
|
109 |
|
|
$sql .= '`module` = \''.$module.'\', ';
|
110 |
|
|
$sql .= '`position` = '.(int)$position.', ';
|
111 |
|
|
$sql .= '`block` = 1';
|
112 |
|
|
if($database->query($sql)) {
|
113 |
|
|
// Get the section id
|
114 |
|
|
$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
|
115 |
|
|
// Include the selected modules add file if it exists
|
116 |
|
|
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php'))
|
117 |
|
|
{
|
118 |
|
|
require(WB_PATH.'/modules/'.$module.'/add.php');
|
119 |
|
|
}
|
120 |
|
|
} elseif ($database->is_error()) {
|
121 |
|
|
if($admin_header) { $admin->print_header(); }
|
122 |
|
|
$admin->print_error($database->get_error());
|
123 |
|
|
}
|
124 |
|
|
break;
|
125 |
|
|
default:
|
126 |
|
|
break;
|
127 |
|
|
endswitch;
|
128 |
1358
|
Luisehahne
|
|
129 |
1475
|
Luisehahne
|
switch ($action):
|
130 |
|
|
default:
|
131 |
1358
|
Luisehahne
|
|
132 |
1475
|
Luisehahne
|
if($admin_header) { $admin->print_header(); }
|
133 |
|
|
// Get perms
|
134 |
|
|
$sql = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
|
135 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id;
|
136 |
|
|
$results = $database->query($sql);
|
137 |
1358
|
Luisehahne
|
|
138 |
1475
|
Luisehahne
|
$results_array = $results->fetchRow();
|
139 |
|
|
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
140 |
|
|
$old_admin_users = explode(',', $results_array['admin_users']);
|
141 |
|
|
$in_old_group = FALSE;
|
142 |
|
|
foreach($admin->get_groups_id() as $cur_gid)
|
143 |
|
|
{
|
144 |
|
|
if (in_array($cur_gid, $old_admin_groups))
|
145 |
|
|
{
|
146 |
|
|
$in_old_group = TRUE;
|
147 |
|
|
}
|
148 |
|
|
}
|
149 |
|
|
if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
|
150 |
|
|
{
|
151 |
|
|
$admin->print_header();
|
152 |
|
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
153 |
|
|
}
|
154 |
1358
|
Luisehahne
|
|
155 |
1475
|
Luisehahne
|
// Get page details
|
156 |
|
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
|
157 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id;
|
158 |
|
|
$results = $database->query($sql);
|
159 |
1358
|
Luisehahne
|
|
160 |
1475
|
Luisehahne
|
if($database->is_error())
|
161 |
|
|
{
|
162 |
|
|
// $admin->print_header();
|
163 |
|
|
$admin->print_error($database->get_error());
|
164 |
|
|
}
|
165 |
|
|
if($results->numRows() == 0)
|
166 |
|
|
{
|
167 |
|
|
// $admin->print_header();
|
168 |
|
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
169 |
|
|
}
|
170 |
|
|
$results_array = $results->fetchRow();
|
171 |
1358
|
Luisehahne
|
|
172 |
1475
|
Luisehahne
|
// Set module permissions
|
173 |
|
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
174 |
1358
|
Luisehahne
|
|
175 |
1475
|
Luisehahne
|
// Unset block var
|
176 |
|
|
unset($block);
|
177 |
|
|
// Include template info file (if it exists)
|
178 |
|
|
if($results_array['template'] != '')
|
179 |
|
|
{
|
180 |
|
|
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
|
181 |
|
|
} else {
|
182 |
|
|
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
|
183 |
|
|
}
|
184 |
|
|
if(file_exists($template_location))
|
185 |
|
|
{
|
186 |
|
|
require($template_location);
|
187 |
|
|
}
|
188 |
|
|
// Check if $menu is set
|
189 |
|
|
if(!isset($block[1]) || $block[1] == '')
|
190 |
|
|
{
|
191 |
|
|
// Make our own menu list
|
192 |
|
|
$block[1] = $TEXT['MAIN'];
|
193 |
|
|
}
|
194 |
1358
|
Luisehahne
|
|
195 |
1475
|
Luisehahne
|
/*-- load css files with jquery --*/
|
196 |
|
|
// include jscalendar-setup
|
197 |
|
|
$jscal_use_time = true; // whether to use a clock, too
|
198 |
|
|
require_once(WB_PATH."/include/jscalendar/wb-setup.php");
|
199 |
1358
|
Luisehahne
|
|
200 |
1475
|
Luisehahne
|
// Setup template object
|
201 |
|
|
$tpl = new Template(THEME_PATH.'/templates');
|
202 |
|
|
$tpl->set_file('page', 'pages_sections.htt');
|
203 |
|
|
$tpl->set_block('page', 'main_block', 'main');
|
204 |
|
|
$tpl->set_block('main_block', 'module_block', 'module_list');
|
205 |
|
|
$tpl->set_block('main_block', 'section_block', 'section_list');
|
206 |
|
|
$tpl->set_block('section_block', 'block_block', 'block_list');
|
207 |
|
|
$tpl->set_block('main_block', 'calendar_block', 'calendar_list');
|
208 |
|
|
$tpl->set_var('FTAN', $admin->getFTAN());
|
209 |
1358
|
Luisehahne
|
|
210 |
1475
|
Luisehahne
|
// set first defaults and messages
|
211 |
|
|
$tpl->set_var(array(
|
212 |
|
|
'PAGE_ID' => $results_array['page_id'],
|
213 |
|
|
// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
|
214 |
|
|
'PAGE_IDKEY' => $results_array['page_id'],
|
215 |
|
|
'TEXT_PAGE' => $TEXT['PAGE'],
|
216 |
|
|
'PAGE_TITLE' => ($results_array['page_title']),
|
217 |
|
|
'MENU_TITLE' => ($results_array['menu_title']),
|
218 |
|
|
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
|
219 |
|
|
'HEADING_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
|
220 |
|
|
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
|
221 |
|
|
'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
|
222 |
|
|
'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
|
223 |
|
|
'TEXT_ID' => 'ID',
|
224 |
|
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
225 |
|
|
'TEXT_BLOCK' => $TEXT['BLOCK'],
|
226 |
|
|
'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
|
227 |
|
|
'TEXT_PUBL_END_DATE' => $TEXT['PUBL_END_DATE'],
|
228 |
|
|
'TEXT_ACTIONS' => $TEXT['ACTIONS'],
|
229 |
|
|
'ADMIN_URL' => ADMIN_URL,
|
230 |
|
|
'WB_URL' => WB_URL,
|
231 |
|
|
'THEME_URL' => THEME_URL
|
232 |
|
|
)
|
233 |
|
|
);
|
234 |
1358
|
Luisehahne
|
|
235 |
1475
|
Luisehahne
|
// Insert variables
|
236 |
|
|
$tpl->set_var(array(
|
237 |
|
|
'PAGE_ID' => $results_array['page_id'],
|
238 |
|
|
// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
|
239 |
|
|
'PAGE_IDKEY' => $results_array['page_id'],
|
240 |
|
|
'VAR_PAGE_TITLE' => $results_array['page_title'],
|
241 |
|
|
'SETTINGS_LINK' => ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'],
|
242 |
|
|
'MODIFY_LINK' => ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id']
|
243 |
|
|
)
|
244 |
|
|
);
|
245 |
1358
|
Luisehahne
|
|
246 |
1475
|
Luisehahne
|
$sql = 'SELECT `section_id`,`module`,`position`,`block`,`publ_start`,`publ_end` ';
|
247 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'sections` ';
|
248 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id.' ';
|
249 |
|
|
$sql .= 'ORDER BY `position` ASC';
|
250 |
|
|
$query_sections = $database->query($sql);
|
251 |
|
|
|
252 |
|
|
if($query_sections->numRows() > 0)
|
253 |
|
|
{
|
254 |
|
|
$num_sections = $query_sections->numRows();
|
255 |
|
|
while($section = $query_sections->fetchRow())
|
256 |
|
|
{
|
257 |
|
|
if(!is_numeric(array_search($section['module'], $module_permissions)))
|
258 |
|
|
{
|
259 |
|
|
// Get the modules real name
|
260 |
|
|
$sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
|
261 |
|
|
$sql .= 'WHERE `directory` = "'.$section['module'].'"';
|
262 |
|
|
if(!$database->get_one($sql) || !file_exists(WB_PATH.'/modules/'.$section['module']))
|
263 |
1358
|
Luisehahne
|
{
|
264 |
1475
|
Luisehahne
|
$edit_page = '<span class="module_disabled">'.$section['module'].'</span>';
|
265 |
|
|
}else
|
266 |
|
|
{
|
267 |
|
|
$edit_page = '';
|
268 |
|
|
}
|
269 |
1518
|
Luisehahne
|
$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? SEC_ANCHOR : '');
|
270 |
1475
|
Luisehahne
|
$edit_page_0 = '<a id="sid'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'];
|
271 |
1518
|
Luisehahne
|
$edit_page_1 = ($sec_anchor!='') ? '#'.$sec_anchor.$section['section_id'].'">' : '">';
|
272 |
|
|
$edit_page_1 .= $section['module'].'</a>';
|
273 |
1475
|
Luisehahne
|
if(SECTION_BLOCKS)
|
274 |
|
|
{
|
275 |
|
|
if($edit_page == '')
|
276 |
|
|
{
|
277 |
|
|
if(defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION)
|
278 |
|
|
{
|
279 |
1518
|
Luisehahne
|
$edit_page = $edit_page_0.'&wysiwyg='.$section['section_id'].$edit_page_1;
|
280 |
1475
|
Luisehahne
|
} else {
|
281 |
1518
|
Luisehahne
|
$edit_page = $edit_page_0.$edit_page_1;
|
282 |
1475
|
Luisehahne
|
}
|
283 |
|
|
}
|
284 |
|
|
$input_attribute = 'input_normal';
|
285 |
|
|
$tpl->set_var(array(
|
286 |
|
|
'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"',
|
287 |
|
|
'NAME_SIZE' => 300,
|
288 |
|
|
'INPUT_ATTRIBUTE' => $input_attribute,
|
289 |
|
|
'VAR_SECTION_ID' => $section['section_id'],
|
290 |
|
|
'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
|
291 |
|
|
// 'VAR_SECTION_IDKEY' => $section['section_id'],
|
292 |
|
|
'VAR_POSITION' => $section['position'],
|
293 |
|
|
'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
|
294 |
|
|
'SELECT' => '',
|
295 |
|
|
'SET_NONE_DISPLAY_OPTION' => ''
|
296 |
|
|
)
|
297 |
|
|
);
|
298 |
|
|
// Add block options to the section_list
|
299 |
|
|
$tpl->clear_var('block_list');
|
300 |
|
|
foreach($block AS $number => $name)
|
301 |
|
|
{
|
302 |
|
|
$tpl->set_var('NAME', htmlentities(strip_tags($name)));
|
303 |
|
|
$tpl->set_var('VALUE', $number);
|
304 |
|
|
$tpl->set_var('SIZE', 1);
|
305 |
|
|
if($section['block'] == $number)
|
306 |
|
|
{
|
307 |
|
|
$tpl->set_var('SELECTED', ' selected="selected"');
|
308 |
|
|
} else {
|
309 |
|
|
$tpl->set_var('SELECTED', '');
|
310 |
|
|
}
|
311 |
|
|
$tpl->parse('block_list', 'block_block', true);
|
312 |
|
|
}
|
313 |
1358
|
Luisehahne
|
} else {
|
314 |
1475
|
Luisehahne
|
if($edit_page == '')
|
315 |
|
|
{
|
316 |
|
|
$edit_page = $edit_page_0.'#wb_'.$edit_page_1;
|
317 |
|
|
}
|
318 |
|
|
$input_attribute = 'input_normal';
|
319 |
|
|
$tpl->set_var(array(
|
320 |
|
|
'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:hidden;"',
|
321 |
|
|
'NAME_SIZE' => 300,
|
322 |
|
|
'INPUT_ATTRIBUTE' => $input_attribute,
|
323 |
|
|
'VAR_SECTION_ID' => $section['section_id'],
|
324 |
|
|
'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
|
325 |
|
|
// 'VAR_SECTION_IDKEY' => $section['section_id'],
|
326 |
|
|
'VAR_POSITION' => $section['position'],
|
327 |
|
|
'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
|
328 |
|
|
'NAME' => htmlentities(strip_tags($block[1])),
|
329 |
|
|
'VALUE' => 1,
|
330 |
|
|
'SET_NONE_DISPLAY_OPTION' => ''
|
331 |
|
|
)
|
332 |
|
|
);
|
333 |
1358
|
Luisehahne
|
}
|
334 |
1475
|
Luisehahne
|
// Insert icon and images
|
335 |
|
|
$tpl->set_var(array(
|
336 |
|
|
'CLOCK_16_PNG' => 'clock_16.png',
|
337 |
|
|
'CLOCK_DEL_16_PNG' => 'clock_del_16.png',
|
338 |
|
|
'DELETE_16_PNG' => 'delete_16.png'
|
339 |
|
|
)
|
340 |
|
|
);
|
341 |
|
|
// set calendar start values
|
342 |
|
|
if($section['publ_start']==0)
|
343 |
|
|
{
|
344 |
|
|
$tpl->set_var('VALUE_PUBL_START', '');
|
345 |
1358
|
Luisehahne
|
} else {
|
346 |
1475
|
Luisehahne
|
$tpl->set_var('VALUE_PUBL_START', date($jscal_format, $section['publ_start']));
|
347 |
1358
|
Luisehahne
|
}
|
348 |
1475
|
Luisehahne
|
// set calendar start values
|
349 |
|
|
if($section['publ_end']==0)
|
350 |
|
|
{
|
351 |
|
|
$tpl->set_var('VALUE_PUBL_END', '');
|
352 |
|
|
} else {
|
353 |
|
|
$tpl->set_var('VALUE_PUBL_END', date($jscal_format, $section['publ_end']));
|
354 |
|
|
}
|
355 |
|
|
// Insert icons up and down
|
356 |
|
|
if($section['position'] != 1 )
|
357 |
|
|
{
|
358 |
|
|
$tpl->set_var(
|
359 |
|
|
'VAR_MOVE_UP_URL',
|
360 |
|
|
'<a href="'.ADMIN_URL.'/pages/move_up.php?page_id='.$page_id.'&section_id='.$section['section_id'].'">
|
361 |
|
|
<img src="'.THEME_URL.'/images/up_16.png" alt="{TEXT_MOVE_UP}" />
|
362 |
|
|
</a>' );
|
363 |
|
|
} else {
|
364 |
|
|
$tpl->set_var(array(
|
365 |
|
|
'VAR_MOVE_UP_URL' => ''
|
366 |
|
|
)
|
367 |
|
|
);
|
368 |
|
|
}
|
369 |
|
|
if($section['position'] != $num_sections ) {
|
370 |
|
|
$tpl->set_var(
|
371 |
|
|
'VAR_MOVE_DOWN_URL',
|
372 |
|
|
'<a href="'.ADMIN_URL.'/pages/move_down.php?page_id='.$page_id.'&section_id='.$section['section_id'].'">
|
373 |
|
|
<img src="'.THEME_URL.'/images/down_16.png" alt="{TEXT_MOVE_DOWN}" />
|
374 |
|
|
</a>' );
|
375 |
|
|
} else {
|
376 |
|
|
$tpl->set_var(array(
|
377 |
|
|
'VAR_MOVE_DOWN_URL' => ''
|
378 |
|
|
)
|
379 |
|
|
);
|
380 |
|
|
}
|
381 |
|
|
} else {
|
382 |
|
|
continue;
|
383 |
1358
|
Luisehahne
|
}
|
384 |
1475
|
Luisehahne
|
|
385 |
|
|
$tpl->set_var(array(
|
386 |
|
|
'DISPLAY_DEBUG' => ' style="visibility="visible;"',
|
387 |
|
|
'TEXT_SID' => 'SID',
|
388 |
|
|
'DEBUG_COLSPAN_SIZE' => 9
|
389 |
|
|
)
|
390 |
|
|
);
|
391 |
|
|
if($debug)
|
392 |
|
|
{
|
393 |
|
|
$tpl->set_var(array(
|
394 |
|
|
'DISPLAY_DEBUG' => ' style="visibility="visible;"',
|
395 |
|
|
'TEXT_PID' => 'PID',
|
396 |
|
|
'TEXT_SID' => 'SID',
|
397 |
|
|
'POSITION' => $section['position']
|
398 |
|
|
)
|
399 |
|
|
);
|
400 |
|
|
} else {
|
401 |
|
|
$tpl->set_var(array(
|
402 |
|
|
'DISPLAY_DEBUG' => ' style="display:none;"',
|
403 |
|
|
'TEXT_PID' => '',
|
404 |
|
|
'POSITION' => ''
|
405 |
|
|
)
|
406 |
|
|
);
|
407 |
1358
|
Luisehahne
|
}
|
408 |
1475
|
Luisehahne
|
$tpl->parse('section_list', 'section_block', true);
|
409 |
1358
|
Luisehahne
|
}
|
410 |
|
|
}
|
411 |
|
|
|
412 |
1475
|
Luisehahne
|
// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp!
|
413 |
|
|
// the loop is simply a copy from above.
|
414 |
|
|
$sql = 'SELECT `section_id`,`module` FROM `'.TABLE_PREFIX.'sections` ';
|
415 |
|
|
$sql .= 'WHERE page_id = '.$page_id.' ';
|
416 |
|
|
$sql .= 'ORDER BY `position` ASC';
|
417 |
|
|
$query_sections = $database->query($sql);
|
418 |
1358
|
Luisehahne
|
|
419 |
1475
|
Luisehahne
|
if($query_sections->numRows() > 0)
|
420 |
|
|
{
|
421 |
|
|
$num_sections = $query_sections->numRows();
|
422 |
|
|
while($section = $query_sections->fetchRow())
|
423 |
|
|
{
|
424 |
|
|
// Get the modules real name
|
425 |
|
|
$sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
|
426 |
|
|
$sql .= 'WHERE `directory` = "'.$section['module'].'"';
|
427 |
|
|
$module_name = $database->get_one($sql);
|
428 |
1358
|
Luisehahne
|
|
429 |
1475
|
Luisehahne
|
if(!is_numeric(array_search($section['module'], $module_permissions)))
|
430 |
|
|
{
|
431 |
|
|
$tpl->set_var(array(
|
432 |
|
|
'jscal_ifformat' => $jscal_ifformat,
|
433 |
|
|
'jscal_firstday' => $jscal_firstday,
|
434 |
|
|
'jscal_today' => $jscal_today,
|
435 |
|
|
'start_date' => 'start_date'.$section['section_id'],
|
436 |
|
|
'end_date' => 'end_date'.$section['section_id'],
|
437 |
|
|
'trigger_start' => 'trigger_start'.$section['section_id'],
|
438 |
|
|
'trigger_end' => 'trigger_stop'.$section['section_id']
|
439 |
|
|
)
|
440 |
|
|
);
|
441 |
|
|
if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
|
442 |
|
|
$tpl->set_var(array(
|
443 |
|
|
'showsTime' => "true",
|
444 |
|
|
'timeFormat' => "24"
|
445 |
|
|
)
|
446 |
|
|
);
|
447 |
|
|
} else {
|
448 |
|
|
$tpl->set_var(array(
|
449 |
|
|
'showsTime' => "false",
|
450 |
|
|
'timeFormat' => "24"
|
451 |
|
|
)
|
452 |
|
|
);
|
453 |
|
|
}
|
454 |
|
|
}
|
455 |
|
|
$tpl->parse('calendar_list', 'calendar_block', true);
|
456 |
1358
|
Luisehahne
|
}
|
457 |
|
|
}
|
458 |
|
|
|
459 |
1475
|
Luisehahne
|
// Work-out if we should show the "Add Section" form
|
460 |
|
|
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
|
461 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id.' AND `module` = "menu_link"';
|
462 |
|
|
$query_sections = $database->query($sql);
|
463 |
|
|
if($query_sections->numRows() == 0)
|
464 |
|
|
{
|
465 |
|
|
// Modules list
|
466 |
|
|
$sql = 'SELECT `name`,`directory`,`type` FROM `'.TABLE_PREFIX.'addons` ';
|
467 |
|
|
$sql .= 'WHERE `type` = "module" AND `function` = "page" AND `directory` != "menu_link" ';
|
468 |
|
|
$sql .= 'ORDER BY `name`';
|
469 |
|
|
$result = $database->query($sql);
|
470 |
|
|
// if(DEBUG && $database->is_error()) { $admin->print_error($database->get_error()); }
|
471 |
1358
|
Luisehahne
|
|
472 |
1475
|
Luisehahne
|
if($result->numRows() > 0)
|
473 |
|
|
{
|
474 |
|
|
while ($module = $result->fetchRow())
|
475 |
|
|
{
|
476 |
|
|
// Check if user is allowed to use this module echo $module['directory'],'<br />';
|
477 |
|
|
if(!is_numeric(array_search($module['directory'], $module_permissions)))
|
478 |
|
|
{
|
479 |
|
|
$tpl->set_var('VALUE', $module['directory']);
|
480 |
|
|
$tpl->set_var('NAME', $module['name']);
|
481 |
|
|
if($module['directory'] == 'wysiwyg')
|
482 |
|
|
{
|
483 |
|
|
$tpl->set_var('SELECTED', ' selected="selected"');
|
484 |
|
|
} else {
|
485 |
|
|
$tpl->set_var('SELECTED', '');
|
486 |
|
|
}
|
487 |
|
|
$tpl->parse('module_list', 'module_block', true);
|
488 |
|
|
} else {
|
489 |
|
|
continue;
|
490 |
|
|
}
|
491 |
1358
|
Luisehahne
|
}
|
492 |
|
|
}
|
493 |
|
|
}
|
494 |
1475
|
Luisehahne
|
// Insert language text and messages
|
495 |
|
|
$tpl->set_var(array(
|
496 |
|
|
'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
|
497 |
1517
|
Luisehahne
|
'TEXT_ARE_YOU_SURE' => $TEXT['ARE_YOU_SURE'],
|
498 |
1475
|
Luisehahne
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
499 |
|
|
'TEXT_ADD' => $TEXT['ADD'],
|
500 |
|
|
'TEXT_SAVE' => $TEXT['SAVE'],
|
501 |
|
|
'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
|
502 |
|
|
'TEXT_CALENDAR' => $TEXT['CALENDAR'],
|
503 |
|
|
'TEXT_DELETE_DATE' => $TEXT['DELETE_DATE'],
|
504 |
|
|
'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
|
505 |
|
|
'TEXT_MOVE_UP' => $TEXT['MOVE_UP'],
|
506 |
|
|
'TEXT_MOVE_DOWN' => $TEXT['MOVE_DOWN']
|
507 |
|
|
)
|
508 |
|
|
);
|
509 |
|
|
$tpl->parse('main', 'main_block', false);
|
510 |
|
|
$tpl->pparse('output', 'page');
|
511 |
|
|
// include the required file for Javascript admin
|
512 |
|
|
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
|
513 |
|
|
{
|
514 |
|
|
include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
|
515 |
|
|
}
|
516 |
|
|
break;
|
517 |
|
|
endswitch;
|
518 |
1358
|
Luisehahne
|
|
519 |
|
|
// Print admin footer
|
520 |
|
|
$admin->print_footer();
|