function route2groups()
{
    global $user, $is_edit;
    $extra = unserialize(PA::$network_info->extra);
    $tags = preg_split('/\\s*,\\s*/', strtolower($_POST['tags']));
    $tags = array_unique($tags);
    $net_owner = new User();
    $net_owner->load((int) PA::$network_info->owner_id);
    $valid_post_types = array('BlogPost', 'Contribution', 'Suggestion');
    $type = isset($_POST) && isset($_POST['blog_type']) && in_array($_POST['blog_type'], $valid_post_types) ? $_POST['blog_type'] : 'BlogPost';
    //find tag entry
    $terms = array();
    foreach ($tags as $term) {
        $tr = trim($term);
        if ($tr) {
            $terms[] = $tr;
        }
    }
    if (!empty($_POST['route_to_pa_home']) && $_POST['route_to_pa_home'] == 1) {
        $display_on_homepage = DISPLAY_ON_HOMEPAGE;
        //its zero
    } else {
        $display_on_homepage = NO_DISPLAY_ON_HOMEPAGE;
        //This will not show up on homepage - flag has opposite values
    }
    if (is_array($_POST['route_targets_group'])) {
        if (in_array(-2, $_POST['route_targets_group'])) {
            //-2 means Select none of group
            // no need to post in any group
        } elseif (in_array(-1, $_POST['route_targets_group'])) {
            //-1 means select all the groups
            // post in all the groups
            $group_array = explode(',', $_POST['Allgroups']);
            foreach ($group_array as $gid) {
                // post to all the groups
                $_group = Group::load_group_by_id((int) $gid);
                $login_required_str = null;
                if ($_group->access_type == ACCESS_PRIVATE) {
                    $login_required_str = '&login_required=true';
                }
                switch ($type) {
                    case 'BlogPost':
                    default:
                        $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Contribution':
                        $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Suggestion':
                        $res = Suggetion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                }
                $permalink_cid = $res['cid'];
                // NOTE: would this notification message be sent for each group ???
                $content_obj = Content::load_content((int) $permalink_cid);
                PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
                // notify network owner (maybe group owner would be better?)
                if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
                    PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
                }
                //-------
                //for rivers of people
                $activity = 'group_post_a_blog';
                $activity_extra['info'] = $user->first_name . 'posted a new blog';
                $activity_extra['blog_name'] = $_POST["blog_title"];
                $activity_extra['blog_id'] = $permalink_cid;
                $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
                $extra = serialize($activity_extra);
                $object = $gid;
                // update status to unverified
                $group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
                if ($group->reg_type == REG_MODERATED) {
                    Network::moderate_network_content((int) $gid, $permalink_cid);
                } else {
                    if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
                        Network::moderate_network_content($gid, $permalink_cid);
                    }
                }
                if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
                    //Write to activity log only when moderation is off
                    Activities::save($user->user_id, $activity, $object, $extra);
                }
            }
        } else {
            // post in selected groups
            foreach ($_POST['route_targets_group'] as $gid) {
                //only send to selected groups
                $_group = Group::load_group_by_id((int) $gid);
                $login_required_str = null;
                if ($_group->access_type == ACCESS_PRIVATE) {
                    $login_required_str = '&login_required=true';
                }
                switch ($type) {
                    case 'BlogPost':
                    default:
                        $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Contribution':
                        $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                    case 'Suggestion':
                        $res = Suggestion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage);
                        break;
                }
                $permalink_cid = $res['cid'];
                $content_obj = Content::load_content((int) $permalink_cid);
                PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
                // notify network owner (maybe group owner would be better?)
                if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
                    PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
                }
                //for rivers of people
                $activity = 'group_post_a_blog';
                $activity_extra['info'] = $user->first_name . 'posted a new blog';
                $activity_extra['blog_name'] = $_POST["blog_title"];
                $activity_extra['blog_id'] = $permalink_cid;
                $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str;
                $extra = serialize($activity_extra);
                $object = $gid;
                // update status to unverified
                $group = ContentCollection::load_collection((int) $gid, PA::$login_uid);
                if ($group->reg_type == REG_MODERATED) {
                    Network::moderate_network_content((int) $gid, $permalink_cid);
                } else {
                    if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) {
                        Network::moderate_network_content($gid, $permalink_cid);
                    }
                }
                if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) {
                    //Write to activity log only when moderation is off
                    Activities::save($user->user_id, $activity, $object, $extra);
                }
            }
        }
    }
    return TRUE;
}
     //its zero
 } else {
     $display_on_homepage = NO_DISPLAY_ON_HOMEPAGE;
     //This will not show up on homepage - flag has opposite values
 }
 $ccid = -1;
 if (!empty(PA::$config->simple['omit_routing'])) {
     $ccid = !empty($_REQUEST['ccid']) ? $_REQUEST['ccid'] : -1;
 }
 switch ($type) {
     case 'BlogPost':
     default:
         $post_saved = BlogPost::save_blogpost(0, PA::$login_uid, $_POST["blog_title"], $_POST["description"], NULL, $terms, $ccid, 1, $display_on_homepage);
         break;
     case 'Contribution':
         $post_saved = Contribution::save_contribution(0, PA::$login_uid, $_POST["blog_title"], $_POST["description"], NULL, $terms, $ccid, 1, $display_on_homepage);
         if ($type == 'Contribution' && $redirect != '') {
             $url_parts = parse_url($redirect);
             parse_str($url_parts['query'], $query_args);
             // save extra information about CC Contributions
             $contribution_id = null;
             $contribution_type = null;
             $contribution_title = null;
             if (isset($query_args['conversation_id'])) {
                 $contribution_type = 'conversation';
                 $contribution_id = $query_args['conversation_id'];
             }
             if (isset($query_args['issue_id'])) {
                 $contribution_type = 'issue';
                 $contribution_id = $query_args['issue_id'];
             }