예제 #1
0
/**
 * groupblog_edit_settings()
 *
 * Save the blog-settings accessible only by the group admin or mod.
 *
 * Since version 1.6, this function has been called directly by
 * BP_Groupblog_Extension::edit_screen_save()
 *
 * @package BP Groupblog
 */
function groupblog_edit_settings()
{
    global $bp, $groupblog_blog_id, $errors, $filtered_results;
    $group_id = isset($_POST['groupblog-group-id']) ? $_POST['groupblog-group-id'] : bp_get_current_group_id();
    if (!bp_groupblog_blog_exists($group_id)) {
        if (isset($_POST['groupblog-enable-blog'])) {
            if ($_POST['groupblog-create-new'] == 'yes') {
                //Create a new blog and assign the blog id to the global $groupblog_blog_id
                if (!bp_groupblog_validate_blog_signup()) {
                    $errors = $filtered_results['errors'];
                    bp_core_add_message($errors);
                    $group_id = '';
                }
            } else {
                if ($_POST['groupblog-create-new'] == 'no') {
                    // They're using an existing blog, so we try to assign that to $groupblog_blog_id
                    if (!($groupblog_blog_id = $_POST['groupblog-blogid'])) {
                        //They forgot to choose a blog, so send them back and make them do it!
                        bp_core_add_message(__('Please choose one of your blogs from the drop-down menu.' . $group_id, 'groupblog'), 'error');
                        if (bp_is_action_variable('step', 0)) {
                            bp_core_redirect(trailingslashit($bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1]));
                        } else {
                            bp_core_redirect(trailingslashit($bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-blog'));
                        }
                    }
                }
            }
        }
    } else {
        // They already have a blog associated with the group, we're just saving other settings
        $groupblog_blog_id = groups_get_groupmeta($bp->groups->current_group->id, 'groupblog_blog_id');
    }
    // Get the necessary settings out of the $_POST global so that we can use them to set up
    // the blog
    $settings = array('groupblog-enable-blog' => '', 'groupblog-silent-add' => '', 'default-administrator' => '', 'default-moderator' => '', 'default-member' => '', 'page_template_layout' => '');
    foreach ($settings as $setting => $val) {
        if (isset($_POST[$setting])) {
            $settings[$setting] = $_POST[$setting];
        }
    }
    if (!groupblog_edit_base_settings($settings['groupblog-enable-blog'], $settings['groupblog-silent-add'], $settings['default-administrator'], $settings['default-moderator'], $settings['default-member'], $settings['page_template_layout'], $group_id, $groupblog_blog_id)) {
        bp_core_add_message(__('There was an error creating your group blog, please try again.', 'groupblog'), 'error');
    } else {
        bp_core_add_message(__('Group details were successfully updated.', 'groupblog'));
    }
    do_action('groupblog_details_edited', $bp->groups->current_group->id);
    //bp_core_redirect( $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/group-blog' );
}
예제 #2
0
<?php

get_header();
?>

	<div id="content">
		<div class="padder">

			<?php 
if (bp_groupblog_blog_exists(bp_get_groupblog_id())) {
    ?>
				<?php 
    if (bp_has_groups('type=single-group&slug=' . bp_get_groupblog_slug())) {
        while (bp_groups()) {
            bp_the_group();
            ?>
				
					<?php 
            locate_template(array('groupblog/group-header.php'), true);
            ?>
					
					<?php 
            do_action('bp_before_blog_single_post');
            ?>
			
					<div class="page" id="blog-single">

						<?php 
            if (bp_group_is_visible()) {
                ?>