Project

General

Profile

« Previous | Next » 

Revision 2076

Added by darkviper almost 11 years ago

  1. some fixes in admin/users
  2. some fixes in admin/pages

View differences:

sections.php
35 35
$debug = true; // to show position
36 36
If(!defined('DEBUG')) { define('DEBUG',$debug);}
37 37
// Create new admin object
38
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
38
// if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
39 39
$admin = new admin('Pages', 'pages_view', false);
40

  
41 40
// Include the WB functions file
42 41
if(!function_exists('directory_list')) { require(WB_PATH.'/framework/functions.php'); }
43 42
$mLang = Translate::getinstance();
44 43
$mLang->enableAddon('admin\pages');
45

  
44
$oDb = WbDatabase::getInstance();
46 45
$action = 'show';
47 46
// Get page id
48 47
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
......
64 63
        if($admin->get_permission('pages_delete') == false)
65 64
        {
66 65
			$admin->print_header();
67
			$admin->print_error($module.' '.strtolower($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']),$backlink);
66
			$admin->print_error($module.' '.mb_strtolower($mLang->MESSAGE_PAGES_INSUFFICIENT_PERMISSIONS, 'UTF-8'), $backlink);
68 67
        }
69 68

  
70 69
		if( ( !($section_id = intval($admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD'])) )) )
71 70
		{
72 71
			if($admin_header) { $admin->print_header(); }
73
			$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
72
			$admin->print_error($mlang->MESSAGE_GENERIC_SECURITY_ACCESS,$backlink);
74 73
		}
75 74

  
76 75
		$action = 'show';
77
	    $sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
78
	    $sql .= 'WHERE `section_id` ='.$section_id;
79
        if( ( ($modulname = $database->get_one($sql)) == $module) && ($section_id > 0 ) ) {
76
	    $sql = 'SELECT `module` FROM `'.$oDb->TablePrefix.'sections` '
77
	         . 'WHERE `section_id` ='.$section_id;
78
        if ((($modulname = $oDb->getOne($sql)) == $module) && ($section_id > 0 ) ) {
80 79
			// Include the modules delete file if it exists
81 80
			if(file_exists(WB_PATH.'/modules/'.$modulname.'/delete.php'))
82 81
		    {
83 82
				require(WB_PATH.'/modules/'.$modulname.'/delete.php');
84 83
			}
85
		    $sql  = 'DELETE FROM `'.TABLE_PREFIX.'sections` ';
86
		    $sql .= 'WHERE `section_id` ='.(int)$section_id.' LIMIT 1';
87
			if( !$database->query($sql) ) {
84
		    $sql = 'DELETE FROM `'.$oDb->TablePrefix.'sections` '
85
		         . 'WHERE `section_id` ='.(int)$section_id.' LIMIT 1';
86
			if (!$oDb->doQuery($sql)) {
88 87
				if($admin_header) { $admin->print_header(); }
89
				$admin->print_error($database->get_error(),$backlink);
90
			}  else {
88
				$admin->print_error($oDb->get_error(),$backlink);
89
			} else {
91 90
				require_once(WB_PATH.'/framework/class.order.php');
92
				$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
91
				$order = new order($oDb->TablePrefix.'sections', 'position', 'section_id', 'page_id');
93 92
				$order->clean($page_id);
94
				$format = $mLang->TEXT_SECTION.' %d  %s %s '.strtolower( $mLang->TEXT_DELETED);
95
				$message = sprintf ($format,$section_id,strtoupper($modulname),strtolower($mLang->TEXT_SUCCESS));
93
				$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'));
96 95
				if($admin_header) { $admin->print_header(); }
97 96
				$admin_header = false;
98 97
				unset($_POST);
......
100 99
			}
101 100
        } else {
102 101
			if($admin_header) { $admin->print_header(); }
103
			$admin->print_error($module.' '.strtolower($mLang->TEXT_NOT_FOUND),$backlink);
102
			$admin->print_error($module.' '.mb_strtolower($mLang->TEXT_NOT_FOUND, 'UTF-8'),$backlink);
104 103
        }
105 104

  
106 105
		break;
......
108 107
        if($admin->get_permission('pages_add') == false)
109 108
        {
110 109
			$admin->print_header();
111
			$admin->print_error($module.' '.strtolower($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']),$backlink);
110
			$admin->print_error($module.' '.mb_strtolower($mLang->MESSAGE_PAGES_INSUFFICIENT_PERMISSIONS, 'UTF-8'),$backlink);
112 111
        }
113 112
		if (!$admin->checkFTAN())
114 113
		{
115 114
			$admin->print_header();
116
			$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
115
			$admin->print_error($mLang->MESSAGE_GENERIC_SECURITY_ACCESS,$backlink);
117 116
		}
118 117
		$action = 'show';
119 118
		$module = preg_replace('/\W/', '', $module );  // fix secunia 2010-91-4
120 119
		require_once(WB_PATH.'/framework/class.order.php');
121 120
		// Get new order
122
		$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
121
		$order = new order($oDb->TablePrefix.'sections', 'position', 'section_id', 'page_id');
123 122
		$position = $order->get_new($page_id);
124 123
		// Insert module into DB
125
	    $sql  = 'INSERT INTO `'.TABLE_PREFIX.'sections` SET ';
126
	    $sql .= '`page_id` = '.(int)$page_id.', ';
127
	    $sql .= '`module` = \''.$module.'\', ';
128
	    $sql .= '`position` = '.(int)$position.', ';
129
	    $sql .= '`block` = \'1\', ';
130
        $sql .= '`publ_start` = \'0\',';
131
        $sql .= '`publ_end` = \'0\' ';
124
	    $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\'';
132 131

  
133
        if($database->query($sql)) {
132
        if($oDb->doQuery($sql)) {
134 133
			// Get the section id
135
			$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
134
			$section_id = $oDb->getOne('SELECT LAST_INSERT_ID()');
136 135
			// Include the selected modules add file if it exists
137 136
			if(file_exists(WB_PATH.'/modules/'.$module.'/add.php'))
138 137
		    {
139 138
				require(WB_PATH.'/modules/'.$module.'/add.php');
140 139
			}
141
        } elseif ($database->is_error())  {
140
        } elseif ($oDb->is_error())  {
142 141
			if($admin_header) { $admin->print_header(); }
143
			$admin->print_error($database->get_error());
142
			$admin->print_error($oDb->get_error());
144 143
		}
145 144
		break;
146 145
	default:
......
152 151

  
153 152
		if($admin_header) { $admin->print_header(); }
154 153
		// Get perms
155
		$sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
156
		$sql .= 'WHERE `page_id` = '.$page_id;
157
		$results = $database->query($sql);
158

  
159
		$results_array = $results->fetchRow();
160
		$old_admin_groups = explode(',', $results_array['admin_groups']);
161
		$old_admin_users = explode(',', $results_array['admin_users']);
162
		$in_old_group = FALSE;
163
		foreach($admin->get_groups_id() as $cur_gid)
164
		{
165
			if (in_array($cur_gid, $old_admin_groups))
166
		    {
167
				$in_old_group = TRUE;
168
			}
169
		}
170
		if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
171
		{
154
		$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'])) {
172 160
			$admin->print_header();
173
			$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
174
		}
175

  
161
			$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
//		}
176 178
		// Get page details
177
		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
179
		$sql  = 'SELECT * FROM `'.$oDb->TablePrefix.'pages` ';
178 180
		$sql .= 'WHERE `page_id` = '.$page_id;
179
		$results = $database->query($sql);
181
		$results = $oDb->doQuery($sql);
180 182

  
181
		if($database->is_error())
183
		if($oDb->is_error())
182 184
		{
183 185
			// $admin->print_header();
184
			$admin->print_error($database->get_error());
186
			$admin->print_error($oDb->get_error());
185 187
		}
186 188
		if($results->numRows() == 0)
187 189
		{
188 190
			// $admin->print_header();
189
			$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
191
			$admin->print_error($mLang->MESSAGE_PAGES_NOT_FOUND);
190 192
		}
191 193
		$results_array = $results->fetchRow();
192 194

  
......
215 217
		{
216 218
			require($template_location);
217 219
		}
218
 // check block settings from template/info.php
219
	if(isset($block) && is_array($block) && sizeof($block) > 0) {
220
		if(isset($block[0])) {
221
		throw new AppException('Invalid index 0 for $block[] in '.str_replace(WB_PATH,'',$template_location).'. '
222
		                     . 'The list must start with $block[1]. Please correct it!');
223
		}
224
		foreach($block as $iIndex=>$sBlockTitle) {
225
			if(trim($sBlockTitle) == '' ) {
226
			 $block[$iIndex] = $mLang->TEXT_BLOCK.'_'.$iIndex;
227
			}
228
		}
229
	}else {
230
		// Make our own menu list
231
		$block = array(1, $mLang->TEXT_MAIN);
232
	}
220
    // 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
       }
233 235
		/*-- load css files with jquery --*/
234 236
		// include jscalendar-setup
235 237
		$jscal_use_time = true; // whether to use a clock, too
......
257 259
						'MENU_TITLE' => ($results_array['menu_title']),
258 260
						'TEXT_CURRENT_PAGE' => $mLang->TEXT_CURRENT_PAGE,
259 261
						'TEXT_LAST_MODIFIED' => $mLang->TEXT_LAST_UPDATED_BY,
260
						'HEADING_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
261
						'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
262
						'HEADING_MANAGE_SECTIONS' => $mLang->HEADING_MANAGE_SECTIONS,
263
						'HEADING_MODIFY_PAGE' => $mLang->HEADING_MODIFY_PAGE,
262 264
						'TEXT_CHANGE_SETTINGS' => $mLang->TEXT_CHANGE_SETTINGS,
263 265
						'TEXT_ADD_SECTION' => $mLang->TEXT_ADD_SECTION,
264 266
						'TEXT_SECTION' => $mLang->TEXT_SECTION,
265 267
						'TEXT_ID' => 'ID',
266 268
						'TEXT_TYPE' => $mLang->TEXT_TYPE,
267 269
						'TEXT_BLOCK' => $mLang->TEXT_BLOCK,
268
						'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
270
						'TEXT_PUBL_START_DATE' => $mLang->TEXT_PUBL_START_DATE,
269 271
						'TEXT_PUBL_END_DATE' => $mLang->TEXT_PUBL_END_DATE,
270 272
						'TEXT_ACTIONS' => $mLang->TEXT_ACTIONS,
271 273
						'MODIFIED_BY'          => $user['display_name'],
......
320 322
					);
321 323
// setting trash only if more than one section exists
322 324
		$tpl->set_block('section_block', 'delete_block', 'delete');
323
		if( $bSectionCanDelete = ($database->get_one('SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id))!=1 ) {
325
        $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.'&amp;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>&nbsp;</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.'&amp;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.'&amp;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);
324 477
		}
325 478

  
326
		$sql  = 'SELECT `section_id`,`module`,`position`,`block`,`publ_start`,`publ_end` ';
327
		$sql .= 'FROM `'.TABLE_PREFIX.'sections` ';
328
		$sql .= 'WHERE `page_id` = '.$page_id.' ';
329
		$sql .= 'ORDER BY `position` ASC';
330
		$query_sections = $database->query($sql);
331

  
332
		if($query_sections->numRows() > 0)
333
		{
334
			$num_sections = $query_sections->numRows();
335
			while($section = $query_sections->fetchRow(MYSQL_ASSOC))
336
		    {
337
				if(!is_numeric(array_search($section['module'], $module_permissions)))
338
		        {
339
					// Get the modules real name
340
		            $sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
341
		            $sql .= 'WHERE `directory` = "'.$section['module'].'"';
342
		            if(!$database->get_one($sql) || !file_exists(WB_PATH.'/modules/'.$section['module']))
343
					{
344
						$edit_page = '<span class="module_disabled">'.$section['module'].'</span>';
345
					}else
346
					{
347
						$edit_page = '';
348
					}
349
					$sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec');
350
					$edit_page_0 = '<a id="sid'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'];
351
					$edit_page_1  = ($sSectionIdPrefix!='') ? '#'.$sSectionIdPrefix.$section['section_id'].'">' : '">';
352
					$edit_page_1 .= $section['module'].'</a>';
353
					if(SECTION_BLOCKS)
354
		            {
355
						if($edit_page == '')
356
						{
357
							if(defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION)
358
							{
359
								$edit_page = $edit_page_0.'&amp;wysiwyg='.$section['section_id'].$edit_page_1;
360
							} else {
361
								$edit_page = $edit_page_0.$edit_page_1;
362
							}
363
						}
364
						$input_attribute = 'input_normal';
365
						$tpl->set_var(array(
366
								'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"',
367
								'NAME_SIZE' => 300,
368
								'INPUT_ATTRIBUTE' => $input_attribute,
369
								'VAR_SECTION_ID' => $section['section_id'],
370
								'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
371
								// 'VAR_SECTION_IDKEY' => $section['section_id'],
372
								'VAR_POSITION' => $section['position'],
373
								'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
374
								'SELECT' => '',
375
								'SET_NONE_DISPLAY_OPTION' => ''
376
								)
377
							);
378
						// Add block options to the section_list
379
						$tpl->clear_var('block_list');
380
						foreach($block AS $number => $name)
381
		                {
382
							$tpl->set_var('NAME', htmlentities(strip_tags($name)));
383
							$tpl->set_var('VALUE', $number);
384
							$tpl->set_var('SIZE', 1);
385
							if($section['block'] == $number)
386
		                    {
387
								$tpl->set_var('SELECTED', ' selected="selected"');
388
							} else {
389
								$tpl->set_var('SELECTED', '');
390
							}
391
							$tpl->parse('block_list', 'block_block', true);
392
						}
393
					} else {
394
						if($edit_page == '')
395
						{
396
							$edit_page = $edit_page_0.'#wb_'.$edit_page_1;
397
						}
398
						$input_attribute = 'input_normal';
399
						$tpl->set_var(array(
400
								'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:hidden;"',
401
								'NAME_SIZE' => 300,
402
								'INPUT_ATTRIBUTE' => $input_attribute,
403
								'VAR_SECTION_ID' => $section['section_id'],
404
								'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
405
								// 'VAR_SECTION_IDKEY' => $section['section_id'],
406
								'VAR_POSITION' => $section['position'],
407
								'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
408
								'NAME' => htmlentities(strip_tags($block[1])),
409
								'VALUE' => 1,
410
								'SET_NONE_DISPLAY_OPTION' => '<option>&nbsp;</option>'
411
								)
412
							);
413
					}
414
					// Insert icon and images
415
					$tpl->set_var(array(
416
								'CLOCK_16_PNG' => 'clock_16.png',
417
								'CLOCK_DEL_16_PNG' => 'clock_del_16.png',
418
								'DELETE_16_PNG' => 'delete_16.png'
419
								)
420
							);
421
					// set calendar start values
422
					if($section['publ_start']==0)
423
		            {
424
						$tpl->set_var('VALUE_PUBL_START', '');
425
					} else {
426
						$tpl->set_var('VALUE_PUBL_START', date($jscal_format, $section['publ_start']+TIMEZONE));
427
					}
428
					// set calendar start values
429
					if($section['publ_end']==0)
430
		            {
431
						$tpl->set_var('VALUE_PUBL_END', '');
432
					} else {
433
						$tpl->set_var('VALUE_PUBL_END', date($jscal_format, $section['publ_end']+TIMEZONE));
434
					}
435
					// Insert icons up and down
436
					if($section['position'] != 1 )
437
		            {
438
						$tpl->set_var(
439
									'VAR_MOVE_UP_URL',
440
									'<a href="'.ADMIN_URL.'/pages/move_up.php?page_id='.$page_id.'&amp;section_id='.$section['section_id'].'">
441
									<img src="'.THEME_URL.'/images/up_16.png" alt="{TEXT_MOVE_UP}" />
442
									</a>' );
443
					} else {
444
						$tpl->set_var(array(
445
									'VAR_MOVE_UP_URL' => ''
446
									)
447
								);
448
					}
449
					if($section['position'] != $num_sections ) {
450
						$tpl->set_var(
451
									'VAR_MOVE_DOWN_URL',
452
									'<a href="'.ADMIN_URL.'/pages/move_down.php?page_id='.$page_id.'&amp;section_id='.$section['section_id'].'">
453
									<img src="'.THEME_URL.'/images/down_16.png" alt="{TEXT_MOVE_DOWN}" />
454
									</a>' );
455
					} else {
456
						$tpl->set_var(array(
457
									'VAR_MOVE_DOWN_URL' => ''
458
									)
459
								);
460
					}
461

  
462
				} else {
463
				  continue;
464
				}
465

  
466
					$tpl->set_var(array(
467
									'DISPLAY_DEBUG' => ' style="visibility:visible;"',
468
									'TEXT_SID' => 'SID',
469
									'DEBUG_COLSPAN_SIZE' => 9
470
									)
471
								);
472
				if($debug)
473
		        {
474
					$tpl->set_var(array(
475
									'DISPLAY_DEBUG' => ' style="visibility:visible;"',
476
									'TEXT_PID' => 'PID',
477
									'TEXT_SID' => 'SID',
478
									'POSITION' => $section['position']
479
									)
480
								);
481
				} else {
482
					$tpl->set_var(array(
483
									'DISPLAY_DEBUG' => ' style="display:none;"',
484
									'TEXT_PID' => '',
485
									'POSITION' => ''
486
									)
487
								);
488
				}
489
				if($bSectionCanDelete) {
490
					$tpl->parse('delete', 'delete_block', false);
491
				} else {
492
					$tpl->parse('delete', '', false);
493
				} 
494
				$tpl->parse('section_list', 'section_block', true);
495
			}
496

  
497
		}
498

  
499 479
		// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp!
500 480
		// the loop is simply a copy from above.
501
		$sql  = 'SELECT `section_id`,`module` FROM `'.TABLE_PREFIX.'sections` ';
502
		$sql .= 'WHERE page_id = '.$page_id.' ';
503
		$sql .= 'ORDER BY `position` ASC';
504
		$query_sections = $database->query($sql);
481
		$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);
505 485

  
506
		if($query_sections->numRows() > 0)
507
		{
486
		if ($query_sections->numRows() > 0) {
508 487
			$num_sections = $query_sections->numRows();
509
			while($section = $query_sections->fetchRow())
510
		    {
488
			while ($section = $query_sections->fetchRow()) {
511 489
				// Get the modules real name
512
		        $sql  = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
513
		        $sql .= 'WHERE `directory` = "'.$section['module'].'"';
514
		        $module_name = $database->get_one($sql);
515

  
516
				if(!is_numeric(array_search($section['module'], $module_permissions)))
517
		        {
490
		        $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))) {
518 494
					$tpl->set_var(array(
519 495
								'jscal_ifformat' => $jscal_ifformat,
520 496
								'jscal_firstday' => $jscal_firstday,
......
525 501
								'trigger_end' => 'trigger_stop'.$section['section_id']
526 502
								)
527 503
							);
528
					if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
504
					if (isset($jscal_use_time) && $jscal_use_time==TRUE) {
529 505
						$tpl->set_var(array(
530 506
								'showsTime' => "true",
531 507
								'timeFormat' => "24"
532 508
								)
533 509
							);
534
					}  else {
510
					} else {
535 511
						$tpl->set_var(array(
536 512
								'showsTime' => "false",
537 513
								'timeFormat' => "24"
......
544 520
		}
545 521

  
546 522
		// Work-out if we should show the "Add Section" form
547
		$sql  = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
548
		$sql .= 'WHERE `page_id` = '.$page_id.' AND `module` = "menu_link"';
549
		$query_sections = $database->query($sql);
523
		$sql = 'SELECT `section_id` FROM `'.$oDb->TablePrefix.'sections` '
524
		     . 'WHERE `page_id` = '.$page_id.' AND `module` = "menu_link"';
525
		$query_sections = $oDb->doQuery($sql);
550 526
		$tpl->set_var('TEXT_PLEASE_SELECT', $mLang->TEXT_NONE);
551
		if($query_sections->numRows() == 0)
552
		{
527
		if ($query_sections->numRows() == 0) {
553 528
			$tpl->set_var('TEXT_PLEASE_SELECT', $mLang->TEXT_PLEASE_SELECT);
554 529
			// Modules list
555
		    $sql  = 'SELECT `name`,`directory`,`type` FROM `'.TABLE_PREFIX.'addons` ';
556
		    $sql .= 'WHERE `type` = "module" AND `function` = "page" AND `directory` != "menu_link" ';
557
		    $sql .= 'ORDER BY `name`';
558
		    $result = $database->query($sql);
559
		// if(DEBUG && $database->is_error()) { $admin->print_error($database->get_error()); }
560

  
561
			if($result->numRows() > 0)
562
		    {
563
				while ($module = $result->fetchRow())
564
		        {
530
		    $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()) {
565 537
					// Check if user is allowed to use this module   echo  $module['directory'],'<br />';
566
					if(!is_numeric(array_search($module['directory'], $module_permissions)))
567
		            {
538
					if (!is_numeric(array_search($module['directory'], $module_permissions))) {
568 539
						$tpl->set_var('VALUE', $module['directory']);
569 540
						$tpl->set_var('NAME', $module['name']);
570
						if($module['directory'] == 'wysiwyg')
571
		                {
541
						if ($module['directory'] == 'wysiwyg') {
572 542
							$tpl->set_var('SELECTED', ' selected="selected"');
573 543
						} else {
574 544
							$tpl->set_var('SELECTED', '');
......
582 552
		}
583 553
		// Insert language text and messages
584 554
		$tpl->set_var(array(
585
							'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
555
							'TEXT_MANAGE_SECTIONS' => $mLang->HEADING_MANAGE_SECTIONS,
586 556
							'TEXT_ARE_YOU_SURE' => $mLang->TEXT_ARE_YOU_SURE,
587 557
							'TEXT_TYPE' => $mLang->TEXT_TYPE,
588 558
							'TEXT_ADD' => $mLang->TEXT_ADD,
589 559
							'TEXT_SAVE' =>  $mLang->TEXT_SAVE,
590
							'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
560
							'TEXTLINK_MODIFY_PAGE' => $mLang->HEADING_MODIFY_PAGE,
591 561
							'TEXT_CALENDAR' => $mLang->TEXT_CALENDAR,
592 562
							'TEXT_DELETE_DATE' => $mLang->TEXT_DELETE_DATE,
593 563
							'TEXT_ADD_SECTION' => $mLang->TEXT_ADD_SECTION,
......
598 568
		$tpl->parse('main', 'main_block', false);
599 569
		$tpl->pparse('output', 'page');
600 570
		// include the required file for Javascript admin
601
		if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
602
		{
571
		if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php')) {
603 572
			include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
604 573
		}
605 574
		break;
606 575
endswitch;
607

  
608 576
// Print admin footer
609 577
$admin->print_footer();

Also available in: Unified diff