}
        } 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 $featured_network, $info_boxes, $networks_data, $section, $perm;
    $obj->perm = $perm;
    switch ($module) {
        default:
            $obj->mode = $section;
            $obj->info_boxes = $info_boxes;
            $obj->networks_data = $networks_data;
        }
        if ($_POST['caption'][$i]) {
            $data[$i]['title'] = $_POST['caption'][$i];
        }
        if (!empty($_FILES['userfile_' . $i]['name'])) {
            $data[$i]['file_name'] = $file;
            Storage::link($file, array("role" => "emblem"));
        } else {
            $data[$i]['file_name'] = $_POST['userimage_' . $i];
        }
    }
    $data = serialize($data);
    $id = 1;
    // stands for the Update for emblum data
    if (!$error) {
        ModuleData::update($data, $id);
        // call the ModuleData to update the data
    }
}
//render the page
$page = new PageRenderer("setup_module", PAGE_MANAGE_EMBLEM, "Manage Emblem", 'container_two_column.tpl', 'header.tpl', PRI, HOMEPAGE, PA::$network_info);
if (!empty($msg)) {
    $msg_tpl = new Template(CURRENT_THEME_FSPATH . "/display_message.tpl");
    $msg_tpl->set('message', $msg);
    $m = $msg_tpl->fetch();
    $page->add_module("middle", "top", $m);
}
$page->html_body_attributes = 'class="no_second_tier network_config"';
$page->add_header_html(js_includes('edit_profile.js'));
$page->add_header_html(js_includes('manage_data.js'));
$css_array = get_network_css();