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;
}
     // posting the bulletin to the community blog
     if ($_POST['tags']) {
         $tags = explode(',', $_POST['tags']);
         foreach ($tags as $term) {
             $tr = trim($term);
             if ($tr) {
                 $terms[] = $tr;
             }
         }
     }
     try {
         $post_subject = "Network's owner bulletin - " . $_POST['title'];
         $post_message = $_POST['bulletin_body'];
         switch ($type) {
             case 'Suggestion':
                 $res = Suggestion::save_suggestion(0, $from, $post_subject, $post_message, '', $terms, 0, $is_active = ACTIVE, $user->email);
                 break;
             case 'BlogPost':
                 $res = BlogPost::save_blogpost(0, $from, $post_subject, $post_message, '', $terms, 0, $is_active = ACTIVE, $user->email);
                 break;
         }
     } catch (PAException $e) {
         $error_msg .= $e->message;
     }
     if (!empty($res['cid'])) {
         $content_obj = Content::load_content((int) $res['cid']);
         PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj);
     }
 }
 if ($no_reg_user == TRUE) {
     $error_msg .= "No registered member in this network";
             if (isset($contribution_id) && isset($contribution_type)) {
                 $res = Dal::query("INSERT INTO {cc_contributions} (content_id, contribution_id, type, title) VALUES (?, ?, ?, ?)", array(intval($post_saved['cid']), $contribution_id, $contribution_type, $contribution_title));
             }
             if (!isset($query_args['title'])) {
                 $query_args['title'] = $_POST["blog_title"];
             }
             if (!isset($query_args['link'])) {
                 $query_args['link'] = PA::$url . '/content/cid=' . $post_saved['cid'];
             }
             $redirect = $url_parts['scheme'] . '://' . $url_parts['host'];
             $redirect .= isset($url_parts['port']) && $url_parts['port'] != '' && $url_parts['port'] != '80' ? ':' . $url_parts['port'] : '';
             $redirect .= $url_parts['path'] . '?' . http_build_query($query_args);
         }
         break;
     case 'Suggestion':
         $post_saved = Suggestion::save_suggestion(0, PA::$login_uid, $_POST["blog_title"], $_POST["description"], NULL, $terms, $ccid, 1, $display_on_homepage);
         break;
 }
 $permalink_cid = $post_saved['cid'];
 if (PA::is_moderated_content() && PA::$network_info->owner_id != $user->user_id) {
     Network::moderate_network_content(-1, $permalink_cid);
     // -1 for contents; not a part of any collection
     $error_msg = "&err=" . urlencode(MessagesHandler::get_message(1004));
 }
 $login_required_str = null;
 if (PA::is_moderated_content()) {
     $login_required_str = '&login_required=true';
 }
 $content_obj = Content::load_content((int) $permalink_cid);
 PANotify::send("content_posted", PA::$network_info, $user, $content_obj);
 if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {