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