| 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: sections.php 1289 2010-02-10 15:13:21Z kweitzel $
 | 
  
    | 14 |  * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/trunk/wb/admin/pages/sections.php $
 | 
  
    | 15 |  * @lastmodified    $Date: 2010-02-10 16:13:21 +0100 (Wed, 10 Feb 2010) $
 | 
  
    | 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 | 	header('Location: '.ADMIN_URL.'/pages/index.php');
 | 
  
    | 25 | 	exit(0);
 | 
  
    | 26 | }
 | 
  
    | 27 | 
 | 
  
    | 28 | // Get page id
 | 
  
    | 29 | if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
 | 
  
    | 30 | 	header("Location: index.php");
 | 
  
    | 31 | 	exit(0);
 | 
  
    | 32 | } else {
 | 
  
    | 33 | 	$page_id = $_GET['page_id'];
 | 
  
    | 34 | }
 | 
  
    | 35 | 
 | 
  
    | 36 | $debug = false; // to show position and section_id
 | 
  
    | 37 | 
 | 
  
    | 38 | // Create new admin object
 | 
  
    | 39 | require_once(WB_PATH.'/framework/class.admin.php');
 | 
  
    | 40 | $admin = new admin('Pages', 'pages_modify');
 | 
  
    | 41 | 
 | 
  
    | 42 | // Check if we are supposed to add or delete a section
 | 
  
    | 43 | if(isset($_GET['section_id']) AND is_numeric($_GET['section_id'])) {
 | 
  
    | 44 | 	// Get more information about this section
 | 
  
    | 45 | 	$section_id = $_GET['section_id'];
 | 
  
    | 46 | 	$query_section = $database->query("SELECT module FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id'");
 | 
  
    | 47 | 	if($query_section->numRows() == 0) {
 | 
  
    | 48 | 		$admin->print_error('Section not found');
 | 
  
    | 49 | 	}
 | 
  
    | 50 | 	$section = $query_section->fetchRow();
 | 
  
    | 51 | 	// Include the modules delete file if it exists
 | 
  
    | 52 | 	if(file_exists(WB_PATH.'/modules/'.$section['module'].'/delete.php')) {
 | 
  
    | 53 | 		require(WB_PATH.'/modules/'.$section['module'].'/delete.php');
 | 
  
    | 54 | 	}
 | 
  
    | 55 |     $sql = '';
 | 
  
    | 56 | 	$database->query("DELETE FROM ".TABLE_PREFIX."sections WHERE section_id = '$section_id' LIMIT 1");
 | 
  
    | 57 | 	if($database->is_error()) {
 | 
  
    | 58 | 		$admin->print_error($database->get_error());
 | 
  
    | 59 | 	} else {
 | 
  
    | 60 | 		require(WB_PATH.'/framework/class.order.php');
 | 
  
    | 61 | 		$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
 | 
  
    | 62 | 		$order->clean($page_id);
 | 
  
    | 63 | 		$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/sections.php?page_id='.$page_id);
 | 
  
    | 64 | 		$admin->print_footer();
 | 
  
    | 65 | 		exit();
 | 
  
    | 66 | 	}
 | 
  
    | 67 | } elseif(isset($_POST['module']) AND $_POST['module'] != '') {
 | 
  
    | 68 | 	// Get section info
 | 
  
    | 69 | 	$module = $admin->add_slashes($_POST['module']);
 | 
  
    | 70 | 	// Include the ordering class
 | 
  
    | 71 | 	require(WB_PATH.'/framework/class.order.php');
 | 
  
    | 72 | 	// Get new order
 | 
  
    | 73 | 	$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
 | 
  
    | 74 | 	$position = $order->get_new($page_id);	
 | 
  
    | 75 | 	// Insert module into DB
 | 
  
    | 76 | 	$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,module,position,block) VALUES ('$page_id','$module','$position','1')");
 | 
  
    | 77 | 	// Get the section id
 | 
  
    | 78 | 	$section_id = $database->get_one("SELECT LAST_INSERT_ID()");	
 | 
  
    | 79 | 	// Include the selected modules add file if it exists
 | 
  
    | 80 | 	if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
 | 
  
    | 81 | 		require(WB_PATH.'/modules/'.$module.'/add.php');
 | 
  
    | 82 | 	}
 | 
  
    | 83 | }
 | 
  
    | 84 | 
 | 
  
    | 85 | // Get perms
 | 
  
    | 86 | $database = new database();
 | 
  
    | 87 | $results = $database->query("SELECT admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
 | 
  
    | 88 | $results_array = $results->fetchRow();
 | 
  
    | 89 | $old_admin_groups = explode(',', $results_array['admin_groups']);
 | 
  
    | 90 | $old_admin_users = explode(',', $results_array['admin_users']);
 | 
  
    | 91 | $in_old_group = FALSE;
 | 
  
    | 92 | foreach($admin->get_groups_id() as $cur_gid){
 | 
  
    | 93 | 	if (in_array($cur_gid, $old_admin_groups)) {
 | 
  
    | 94 | 		$in_old_group = TRUE;
 | 
  
    | 95 | 	}
 | 
  
    | 96 | }
 | 
  
    | 97 | if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
 | 
  
    | 98 | 	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
 | 
  
    | 99 | }
 | 
  
    | 100 | 
 | 
  
    | 101 | // Get page details
 | 
  
    | 102 | $database = new database();
 | 
  
    | 103 | $query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
 | 
  
    | 104 | $results = $database->query($query);
 | 
  
    | 105 | if($database->is_error()) {
 | 
  
    | 106 | 	$admin->print_header();
 | 
  
    | 107 | 	$admin->print_error($database->get_error());
 | 
  
    | 108 | }
 | 
  
    | 109 | if($results->numRows() == 0) {
 | 
  
    | 110 | 	$admin->print_header();
 | 
  
    | 111 | 	$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
 | 
  
    | 112 | }
 | 
  
    | 113 | $results_array = $results->fetchRow();
 | 
  
    | 114 | 
 | 
  
    | 115 | // Set module permissions
 | 
  
    | 116 | $module_permissions = $_SESSION['MODULE_PERMISSIONS'];
 | 
  
    | 117 | 
 | 
  
    | 118 | // Unset block var
 | 
  
    | 119 | unset($block);
 | 
  
    | 120 | // Include template info file (if it exists)
 | 
  
    | 121 | if($results_array['template'] != '') {
 | 
  
    | 122 | 	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
 | 
  
    | 123 | } else {
 | 
  
    | 124 | 	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
 | 
  
    | 125 | }
 | 
  
    | 126 | if(file_exists($template_location)) {
 | 
  
    | 127 | 	require($template_location);
 | 
  
    | 128 | }
 | 
  
    | 129 | // Check if $menu is set
 | 
  
    | 130 | if(!isset($block[1]) OR $block[1] == '') {
 | 
  
    | 131 | 	// Make our own menu list
 | 
  
    | 132 | 	$block[1] = $TEXT['MAIN'];
 | 
  
    | 133 | }
 | 
  
    | 134 | 
 | 
  
    | 135 | /*-- load css files with jquery --*/
 | 
  
    | 136 | // include jscalendar-setup
 | 
  
    | 137 | $jscal_use_time = true; // whether to use a clock, too
 | 
  
    | 138 | require_once(WB_PATH."/include/jscalendar/wb-setup.php");
 | 
  
    | 139 | 
 | 
  
    | 140 | // Setup template object
 | 
  
    | 141 | $template = new Template(THEME_PATH.'/templates');
 | 
  
    | 142 | $template->set_file('page', 'pages_sections.htt');
 | 
  
    | 143 | $template->set_block('page', 'main_block', 'main');
 | 
  
    | 144 | $template->set_block('main_block', 'module_block', 'module_list');
 | 
  
    | 145 | $template->set_block('main_block', 'section_block', 'section_list');
 | 
  
    | 146 | $template->set_block('section_block', 'block_block', 'block_list');
 | 
  
    | 147 | $template->set_block('main_block', 'calendar_block', 'calendar_list');
 | 
  
    | 148 | 
 | 
  
    | 149 | // set first defaults and messages
 | 
  
    | 150 | $template->set_var(array(
 | 
  
    | 151 | 				'PAGE_ID' => $results_array['page_id'],
 | 
  
    | 152 | 				'PAGE_TITLE' => ($results_array['page_title']),
 | 
  
    | 153 | 				'MENU_TITLE' => ($results_array['menu_title']),
 | 
  
    | 154 | 				'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
 | 
  
    | 155 | 				'HEADING_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
 | 
  
    | 156 | 				'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
 | 
  
    | 157 | 				'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
 | 
  
    | 158 | 				'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
 | 
  
    | 159 | 				'TEXT_ID' => 'ID',
 | 
  
    | 160 | 				'TEXT_TYPE' => $TEXT['TYPE'],
 | 
  
    | 161 | 				'TEXT_BLOCK' => $TEXT['BLOCK'],
 | 
  
    | 162 | 				'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
 | 
  
    | 163 | 				'TEXT_PUBL_END_DATE' => $TEXT['PUBL_END_DATE'],
 | 
  
    | 164 | 				'TEXT_ACTIONS' => $TEXT['ACTIONS'],
 | 
  
    | 165 | 				'ADMIN_URL' => ADMIN_URL,
 | 
  
    | 166 | 				'WB_URL' => WB_URL,
 | 
  
    | 167 | 				'WB_PATH' => WB_PATH,
 | 
  
    | 168 | 				'THEME_URL' => THEME_URL
 | 
  
    | 169 | 				) 
 | 
  
    | 170 | 			);
 | 
  
    | 171 | 
 | 
  
    | 172 | // Insert variables
 | 
  
    | 173 | $template->set_var(array(
 | 
  
    | 174 | 				'VAR_PAGE_ID' => $results_array['page_id'],
 | 
  
    | 175 | 				'VAR_PAGE_TITLE' => $results_array['page_title'],
 | 
  
    | 176 | 				'SETTINGS_LINK' => ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'],
 | 
  
    | 177 | 				'MODIFY_LINK' => ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id']
 | 
  
    | 178 | 				) 
 | 
  
    | 179 | 			);
 | 
  
    | 180 | 
 | 
  
    | 181 | $query_sections = $database->query("SELECT section_id,module,position,block,publ_start,publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
 | 
  
    | 182 | if($query_sections->numRows() > 0) {
 | 
  
    | 183 | 	$num_sections = $query_sections->numRows();
 | 
  
    | 184 | 	while($section = $query_sections->fetchRow()) {
 | 
  
    | 185 | 		if(!is_numeric(array_search($section['module'], $module_permissions))) {
 | 
  
    | 186 | 			// Get the modules real name
 | 
  
    | 187 | 			$module_name=$database->get_one("SELECT name FROM ".TABLE_PREFIX."addons WHERE directory='".$section['module']."'");
 | 
  
    | 188 | 			$template->set_var(array(
 | 
  
    | 189 | 			) );
 | 
  
    | 190 | 			if(SECTION_BLOCKS) {
 | 
  
    | 191 |                 if(defined('EDIT_ONE_SECTION') and EDIT_ONE_SECTION)
 | 
  
    | 192 |                 {
 | 
  
    | 193 | 				    $edit_page ='<a name="'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'&wysiwyg='.$section['section_id'] .'">'.$module_name.'</a>';
 | 
  
    | 194 |                 }
 | 
  
    | 195 |                 else
 | 
  
    | 196 |                 {
 | 
  
    | 197 | 				    $edit_page ='<a name="'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#wb'.$section['section_id'].'">'.$module_name.'</a>';
 | 
  
    | 198 |                 }
 | 
  
    | 199 | 
 | 
  
    | 200 | 				$input_attribute = 'input_normal';
 | 
  
    | 201 | 				$template->set_var(array(
 | 
  
    | 202 | 						'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"',
 | 
  
    | 203 | 						'NAME_SIZE' => 180,
 | 
  
    | 204 | 						'INPUT_ATTRIBUTE' => $input_attribute,
 | 
  
    | 205 | 						'VAR_SECTION_ID' => $section['section_id'],
 | 
  
    | 206 | 						'VAR_POSITION' => $section['position'],
 | 
  
    | 207 | 						'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
 | 
  
    | 208 | 						'SELECT' => '',
 | 
  
    | 209 | 						'SET_NONE_DISPLAY_OPTION' => ''
 | 
  
    | 210 | 						) 
 | 
  
    | 211 | 					);
 | 
  
    | 212 | 				// Add block options to the section_list
 | 
  
    | 213 | 				$template->clear_var('block_list');
 | 
  
    | 214 | 				foreach($block AS $number => $name) {
 | 
  
    | 215 | 					$template->set_var('NAME', htmlentities(strip_tags($name)));
 | 
  
    | 216 | 					$template->set_var('VALUE', $number);
 | 
  
    | 217 | 					$template->set_var('SIZE', 1);
 | 
  
    | 218 | 					if($section['block'] == $number) {
 | 
  
    | 219 | 						$template->set_var('SELECTED', ' selected="selected"');
 | 
  
    | 220 | 					} else {
 | 
  
    | 221 | 						$template->set_var('SELECTED', '');
 | 
  
    | 222 | 					}
 | 
  
    | 223 | 					$template->parse('block_list', 'block_block', true);
 | 
  
    | 224 | 				}
 | 
  
    | 225 | 			} else {
 | 
  
    | 226 | 				$edit_page ='<a name="'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$section['section_id'].'">'.$module_name.'</a>';
 | 
  
    | 227 | 				$input_attribute = 'input_small';
 | 
  
    | 228 | 				$template->set_var(array(
 | 
  
    | 229 | 						'STYLE_DISPLAY_SECTION_BLOCK' => ' style="display:none;"',
 | 
  
    | 230 | 						'NAME_SIZE' => 270,
 | 
  
    | 231 | 						'INPUT_ATTRIBUTE' => $input_attribute,
 | 
  
    | 232 | 						'VAR_SECTION_ID' => $section['section_id'],
 | 
  
    | 233 | 						'VAR_POSITION' => $section['position'],
 | 
  
    | 234 | 						'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
 | 
  
    | 235 | 						'NAME' => htmlentities(strip_tags($block[1])),
 | 
  
    | 236 | 						'VALUE' => 1,
 | 
  
    | 237 | 						'SET_NONE_DISPLAY_OPTION' => ''
 | 
  
    | 238 | 						) 
 | 
  
    | 239 | 					);
 | 
  
    | 240 | 			}
 | 
  
    | 241 | 			// Insert icon and images
 | 
  
    | 242 | 			$template->set_var(array(
 | 
  
    | 243 | 						'CLOCK_16_PNG' => 'clock_16.png',
 | 
  
    | 244 | 						'CLOCK_DEL_16_PNG' => 'clock_del_16.png',
 | 
  
    | 245 | 						'DELETE_16_PNG' => 'delete_16.png'
 | 
  
    | 246 | 						) 
 | 
  
    | 247 | 					);
 | 
  
    | 248 | 			// set calendar start values
 | 
  
    | 249 | 			if($section['publ_start']==0) {
 | 
  
    | 250 | 				$template->set_var('VALUE_PUBL_START', '');
 | 
  
    | 251 | 			} else {
 | 
  
    | 252 | 				$template->set_var('VALUE_PUBL_START', date($jscal_format, $section['publ_start']));
 | 
  
    | 253 | 			}
 | 
  
    | 254 | 			// set calendar start values
 | 
  
    | 255 | 			if($section['publ_end']==0) {
 | 
  
    | 256 | 				$template->set_var('VALUE_PUBL_END', '');
 | 
  
    | 257 | 			} else {
 | 
  
    | 258 | 				$template->set_var('VALUE_PUBL_END', date($jscal_format, $section['publ_end']));
 | 
  
    | 259 | 			}
 | 
  
    | 260 | 			// Insert icons up and down
 | 
  
    | 261 | 			if($section['position'] != 1 ) {
 | 
  
    | 262 | 				$template->set_var(
 | 
  
    | 263 | 							'VAR_MOVE_UP_URL',
 | 
  
    | 264 | 							'<a href="'.ADMIN_URL.'/pages/move_up.php?page_id='.$page_id.'&section_id='.$section['section_id'].'">
 | 
  
    | 265 | 							<img src="'.THEME_URL.'/images/up_16.png" alt="{TEXT_MOVE_UP}" />
 | 
  
    | 266 | 							</a>' );
 | 
  
    | 267 | 			} else {
 | 
  
    | 268 | 				$template->set_var(array(
 | 
  
    | 269 | 							'VAR_MOVE_UP_URL' => ''
 | 
  
    | 270 | 							) 
 | 
  
    | 271 | 						);
 | 
  
    | 272 | 			}
 | 
  
    | 273 | 			if($section['position'] != $num_sections ) {
 | 
  
    | 274 | 				$template->set_var(
 | 
  
    | 275 | 							'VAR_MOVE_DOWN_URL',
 | 
  
    | 276 | 							'<a href="'.ADMIN_URL.'/pages/move_down.php?page_id='.$page_id.'&section_id='.$section['section_id'].'">
 | 
  
    | 277 | 							<img src="'.THEME_URL.'/images/down_16.png" alt="{TEXT_MOVE_DOWN}" />
 | 
  
    | 278 | 							</a>' );
 | 
  
    | 279 | 			} else {
 | 
  
    | 280 | 				$template->set_var(array(
 | 
  
    | 281 | 							'VAR_MOVE_DOWN_URL' => ''
 | 
  
    | 282 | 							) 
 | 
  
    | 283 | 						);
 | 
  
    | 284 | 			}
 | 
  
    | 285 | 		}
 | 
  
    | 286 | 			$template->set_var(array(
 | 
  
    | 287 | 							'DISPLAY_DEBUG' => ' style="visibility="visible;"',
 | 
  
    | 288 | 							'TEXT_SID' => 'SID',
 | 
  
    | 289 | 							'DEBUG_COLSPAN_SIZE' => 9
 | 
  
    | 290 | 							) 
 | 
  
    | 291 | 						);
 | 
  
    | 292 | 		if($debug) {
 | 
  
    | 293 | 			$template->set_var(array(
 | 
  
    | 294 | 							'DISPLAY_DEBUG' => ' style="visibility="visible;"',
 | 
  
    | 295 | 							'TEXT_PID' => 'PID',
 | 
  
    | 296 | 							'TEXT_SID' => 'SID',
 | 
  
    | 297 | 							'POSITION' => $section['position']
 | 
  
    | 298 | 							) 
 | 
  
    | 299 | 						);
 | 
  
    | 300 | 		} else {
 | 
  
    | 301 | 			$template->set_var(array(
 | 
  
    | 302 | 							'DISPLAY_DEBUG' => ' style="display:none;"',
 | 
  
    | 303 | 							'TEXT_PID' => '',
 | 
  
    | 304 | 							'POSITION' => ''
 | 
  
    | 305 | 							) 
 | 
  
    | 306 | 						);
 | 
  
    | 307 | 		}
 | 
  
    | 308 | 		$template->parse('section_list', 'section_block', true);
 | 
  
    | 309 | 	}
 | 
  
    | 310 | }
 | 
  
    | 311 | 
 | 
  
    | 312 | // now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp!
 | 
  
    | 313 | // the loop is simply a copy from above.
 | 
  
    | 314 | $query_sections = $database->query("SELECT section_id,module FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' ORDER BY position ASC");
 | 
  
    | 315 | if($query_sections->numRows() > 0) {
 | 
  
    | 316 | 	$num_sections = $query_sections->numRows();
 | 
  
    | 317 | 	while($section = $query_sections->fetchRow()) {
 | 
  
    | 318 | 		// Get the modules real name
 | 
  
    | 319 | 		$module_name=$database->get_one("SELECT name FROM ".TABLE_PREFIX."addons WHERE directory='".$section['module']."'");
 | 
  
    | 320 | 		if(!is_numeric(array_search($section['module'], $module_permissions))) {
 | 
  
    | 321 | 			$template->set_var(array(
 | 
  
    | 322 | 						'jscal_ifformat' => $jscal_ifformat,
 | 
  
    | 323 | 						'jscal_firstday' => $jscal_firstday,
 | 
  
    | 324 | 						'jscal_today' => $jscal_today,
 | 
  
    | 325 | 						'start_date' => 'start_date'.$section['section_id'],
 | 
  
    | 326 | 						'end_date' => 'end_date'.$section['section_id'],
 | 
  
    | 327 | 						'trigger_start' => 'trigger_start'.$section['section_id'],
 | 
  
    | 328 | 						'trigger_end' => 'trigger_stop'.$section['section_id']
 | 
  
    | 329 | 						) 
 | 
  
    | 330 | 					);
 | 
  
    | 331 | 			if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
 | 
  
    | 332 | 				$template->set_var(array(
 | 
  
    | 333 | 						'showsTime' => "true",
 | 
  
    | 334 | 						'timeFormat' => "24"
 | 
  
    | 335 | 						) 
 | 
  
    | 336 | 					);
 | 
  
    | 337 | 			}  else {
 | 
  
    | 338 | 				$template->set_var(array(
 | 
  
    | 339 | 						'showsTime' => "false",
 | 
  
    | 340 | 						'timeFormat' => "24"
 | 
  
    | 341 | 						) 
 | 
  
    | 342 | 					);
 | 
  
    | 343 | 			}
 | 
  
    | 344 | 		}
 | 
  
    | 345 | 		$template->parse('calendar_list', 'calendar_block', true);
 | 
  
    | 346 | 	}
 | 
  
    | 347 | }
 | 
  
    | 348 | 
 | 
  
    | 349 | // Work-out if we should show the "Add Section" form
 | 
  
    | 350 | $query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
 | 
  
    | 351 | if($query_sections->numRows() == 0) {
 | 
  
    | 352 | 	// Modules list
 | 
  
    | 353 | 	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' AND directory != 'menu_link' order by name");
 | 
  
    | 354 | 	if($result->numRows() > 0) {
 | 
  
    | 355 | 		while ($module = $result->fetchRow()) {
 | 
  
    | 356 | 			// Check if user is allowed to use this module   echo  $module['directory'],'<br />';
 | 
  
    | 357 | 			if(!is_numeric(array_search($module['directory'], $module_permissions))) {
 | 
  
    | 358 | 				$template->set_var('VALUE', $module['directory']);
 | 
  
    | 359 | 				$template->set_var('NAME', $module['name']);
 | 
  
    | 360 | 				if($module['directory'] == 'wysiwyg') {
 | 
  
    | 361 | 					$template->set_var('SELECTED', ' selected="selected"');
 | 
  
    | 362 | 				} else {
 | 
  
    | 363 | 					$template->set_var('SELECTED', '');
 | 
  
    | 364 | 				}
 | 
  
    | 365 | 				$template->parse('module_list', 'module_block', true);
 | 
  
    | 366 | 			}
 | 
  
    | 367 | 		}
 | 
  
    | 368 | 	}
 | 
  
    | 369 | }
 | 
  
    | 370 | // Insert language text and messages
 | 
  
    | 371 | $template->set_var(array(
 | 
  
    | 372 | 					'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
 | 
  
    | 373 | 					'TEXT_ARE_YOU_SURE' => $TEXT['ARE_YOU_SURE'],
 | 
  
    | 374 | 					'TEXT_TYPE' => $TEXT['TYPE'],
 | 
  
    | 375 | 					'TEXT_ADD' => $TEXT['ADD'],
 | 
  
    | 376 | 					'TEXT_SAVE' =>  $TEXT['SAVE'],
 | 
  
    | 377 | 					'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
 | 
  
    | 378 | 					'TEXT_CALENDAR' => $TEXT['CALENDAR'],
 | 
  
    | 379 | 					'TEXT_DELETE_DATE' => $TEXT['DELETE_DATE'],
 | 
  
    | 380 | 					'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
 | 
  
    | 381 | 					'TEXT_MOVE_UP' => $TEXT['MOVE_UP'],
 | 
  
    | 382 | 					'TEXT_MOVE_DOWN' => $TEXT['MOVE_DOWN']
 | 
  
    | 383 | 					) 
 | 
  
    | 384 | 				);
 | 
  
    | 385 | $template->parse('main', 'main_block', false);
 | 
  
    | 386 | $template->pparse('output', 'page');
 | 
  
    | 387 | 
 | 
  
    | 388 | // Print admin footer
 | 
  
    | 389 | $admin->print_footer();
 | 
  
    | 390 | 
 | 
  
    | 391 | ?>
 |