function widget($args, $instance)
 {
     extract($args);
     $the_title = apply_filters('widget_title', $instance['title'], $instance, $args);
     $fields = isset($instance['fields']) ? $instance['fields'] : array();
     $location_fields = isset($instance['location_fields']) ? $instance['location_fields'] : array();
     $category = isset($instance['category']) ? esc_attr($instance['category']) : 1;
     // set defaults
     $location = isset($instance['location']) ? esc_attr($instance['location']) : 1;
     $categories = isset($instance['categories']) ? esc_attr($instance['categories']) : 'false';
     // are they enabled at all
     $locations = isset($instance['locations']) ? esc_attr($instance['locations']) : 'false';
     $the_form = mc_submit_form($fields, $categories, $locations, $category, $location, $location_fields);
     if (mcs_user_can_submit_events()) {
         echo $before_widget;
         echo $the_title ? $before_title . $the_title . $after_title : '';
         echo $the_form;
         echo $after_widget;
     }
 }
function mcs_submit_form($atts, $content = null)
{
    extract(shortcode_atts(array('fields' => 'end_time,description,event_link,event_recurring,event_image', 'categories' => 1, 'locations' => 'either', 'category' => 1, 'location' => 0, 'location_fields' => 'street,street2,phone,city,state,zip,country,url'), $atts, 'submit_event'));
    $fields = explode(',', $fields);
    $fld = array();
    foreach ($fields as $value) {
        $set = explode('=', $value);
        $value = strtolower(trim($set[0]));
        $fld[$value] = isset($set[1]) ? $set[1] : 'true';
    }
    $location_fields = explode(',', $location_fields);
    $loc = array();
    foreach ($location_fields as $value) {
        $set = explode('=', $value);
        $value = strtolower(trim($set[0]));
        $loc[$value] = isset($set[1]) ? $set[1] : 'true';
    }
    if (mcs_user_can_submit_events()) {
        return mc_submit_form($fld, $categories, $locations, $category, $location, $loc);
    } else {
        return $content;
    }
}