type == MOTHER_NETWORK_TYPE) { $authorization_required = TRUE; //there is specific task assigned to each page //you can see array of tasks in authorize.inc.php $page_task = 'meta_networks';//meta networks require_once "$path_prefix/web/includes/authorize.inc.php"; $configure_permission = $task_perm;//set from authorize.inc.php } else {//old method for spawned networks $configure_permission = current_user_can('configure_network'); } /********/ $msg = null; $message = array();//array of messages and will be used to display messages. $permission_denied_msg = false; $showcased_networks = 3; //number of showcased networks. $configurable_sections = array('showcased_networks', 'network_of_moment', 'video_tours', 'register_today', 'configure'); $section = 'showcased_networks'; if (!empty($_GET['section'])) { if (!in_array($_GET['section'], $configurable_sections)) { $section = 'showcased_networks'; } else { $section = $_GET['section']; } } $networks_data = array(); $networks_data = ModuleData::get($section); if (($networks_data)) { // data already exists for this module $networks_data = unserialize($networks_data); $action = 'update'; } else { // network operator is saving the data for the first time. $action = 'save'; } if (!empty($_POST)) { if ($section == 'showcased_networks') { for ($counter = 0; $counter < $showcased_networks; $counter++) { if (empty($_POST['network_url'][$counter])) { $message[] = 'Network URL cannot be left empty for showcased network '.($counter + 1); $networks_data[$counter]['network_url'] = null; } else { $networks_data[$counter]['network_url'] = Validation::validate_url($_POST['network_url'][$counter]); } if (!empty($_POST['caption'][$counter])) { $networks_data[$counter]['caption'] = $_POST['caption'][$counter]; } else { $networks_data[$counter]['caption'] = null; } $image_file = 'network_image_'.$counter; if (!empty($_FILES[$image_file]['name'])) { //validating and then uploading the network image. $uploader = new FileUploader; //creating instance of file. $file = $uploader->upload_file($uploaddir,$image_file,true,true,'image'); if( $file == false) { $message[] = ' For showcased network '.($counter + 1).', '.$uploader->error; $networks_data[$counter]['network_image'] = null; } else { $networks_data[$counter]['network_image'] = $file; } } else if (!empty($_POST['current_network_image'][$counter])) { //getting the previously added image from the hidden form field. $networks_data[$counter]['network_image'] = $_POST['current_network_image'][$counter]; } else { //setting the image to null. $networks_data[$counter]['network_image'] = null; } }//end for } else if ($section == 'network_of_moment') { if (empty($_POST['network_caption'])) { $message[] = 'No caption given to network of moment'; } else { $networks_data['network_caption'] = $_POST['network_caption']; } if (empty($_POST['network_url'])) { $message[] = 'Please provide url for network of moment'; } else { $networks_data['network_url'] = Validation::validate_url($_POST['network_url']); } } else if ($section == 'video_tours') { if (empty($_POST['video_url'])) { $message[] = 'No video url provided for video tours'; } else { $networks_data['video_url'] = $_POST['video_url']; } } else if ($section == 'configure') { if (!empty($_POST['show_splash_page']) && $_POST['show_splash_page'] == ACTIVE) { $networks_data['show_splash_page'] = ACTIVE; } else { $networks_data['show_splash_page'] = INACTIVE; } } //code for fields which are common to some sections like description, image if ($section == 'video_tours' || $section == 'register_today' || $section == 'network_of_moment') { if (empty($_POST['description'])) { $message[] = 'No description provided for network of moment'; } else { $networks_data['description'] = $_POST['description']; } $image_file = 'network_image'; if (!empty($_FILES[$image_file]['name'])) { //validating and then uploading the network image. $uploader = new FileUploader; //creating instance of file. $file = $uploader->upload_file($uploaddir,$image_file,true,true,'image'); if( $file == false) { $message[] = ' For network of moment, '.$uploader->error; $networks_data['network_image'] = null; } else { $networks_data['network_image'] = $file; } } else if (!empty($_POST['current_network_image'])) { //getting the previously added image from the hidden form field. $networks_data['network_image'] = $_POST['current_network_image']; } else { //setting the image to null. $networks_data['network_image'] = null; } } $networks_data = serialize($networks_data); if ($action == 'save') { ModuleData::save($networks_data, $section); } else { ModuleData::update($networks_data, $section); } $networks_data = ModuleData::get($section); $networks_data = unserialize($networks_data); //TODO: display the error messages. }//end if function setup_module($column, $module, $obj) { global $permission_denied_msg, $featured_network, $showcased_networks, $networks_data, $section,$perm; if($permission_denied_msg) return 'skip'; $obj->perm = $perm; switch ($module) { default: $obj->mode = $section; $obj->showcased_networks = $showcased_networks; $obj->networks_data = $networks_data; } } $page = new PageRenderer("setup_module", PAGE_CONFIGURE_SPLASH_PAGE, "Configure Splash Page", 'container_two_column.tpl', 'header.tpl', PRI, HOMEPAGE, $network_info); if (count($message)) { $msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl"); $msg_tpl->set('message', $message); $m = $msg_tpl->fetch(); $page->add_module("middle", "top", $m); } $page->html_body_attributes ='class="no_second_tier network_config"'; $css_array = get_network_css(); if (is_array($css_array)) { foreach ($css_array as $key => $value) { $page->add_header_css($value); } } $css_data = inline_css_style(); if (!empty($css_data['newcss']['value'])) { $css_data = ''; $page->add_header_html($css_data); } echo $page->render(); ?>