<?php
get_header();

locate_template( array( 'leftsidebar.php' ), true );
?>

    <div id="content">
        
        <div id="iron-encabezado-container">
        
            <h2 class="iron-encabezado-seccion">
                <?php echo __('Grupos','buddypress'); ?>
            </h2>
            
            <ul class="iron-encabezado-ul">
                <li class="iron-encabezado-li">
                    <a href="<?php bp_root_domain() ?>/grupos">
                        <?php printf( __( 'Volver al listado', 'buddypress' ) ) ?>
                    </a>
                </li>
            </ul>
        </div>
        
        <div class="padder">
            
            <div id="content-top"></div>
            
            <div id="content-middle">
                
                <div id="content-middle-add">
                
                    <form action="<?php bp_group_creation_form_action() ?>" method="post" id="create-group-form" class="standard-form" enctype="multipart/form-data">
                        
                        <?php do_action( 'bp_before_create_group' ) ?>
                        
                        <div class="item-list-tabs no-ajax" id="group-create-tabs">
                            <ul>
                                <?php bp_group_creation_tabs(); ?>
                            </ul>
                        </div>
                        
                        <?php do_action( 'template_notices' ) ?>
                        
                        <div class="item-body" id="group-create-body">
                            
                            <?php
                            /**
                             * Group creation step 1: Basic group details
                             */
                            
                            if ( bp_is_group_creation_step( 'group-details' ) ) :
                            
                                do_action( 'bp_before_group_details_creation_step' );
                                ?>
                                
                                <label for="group-name"><?php _e('* Nombre del Grupo', 'buddypress') ?> <?php _e( '(requerido)', 'buddypress' )?></label>
                                <input type="text" name="group-name" id="group-name" value="<?php bp_new_group_name() ?>" />
                                
                                <label for="group-desc"><?php _e('* Descripci&oacute;n', 'buddypress') ?> <?php _e( '(requerido)', 'buddypress' )?></label>
                                <textarea name="group-desc" id="group-desc"><?php bp_new_group_description() ?></textarea>
                                
                                <?php
                                do_action( 'bp_after_group_details_creation_step' );
                                /* Deprecated -> */ do_action( 'groups_custom_group_fields_editable' );
                                
                                wp_nonce_field( 'groups_create_save_group-details' );
                                
                            endif;
                            
                            /**
                             * Group creation step 2: Group settings
                             */
                            
                            if ( bp_is_group_creation_step( 'group-settings' ) ) :
                            
                                do_action( 'bp_before_group_settings_creation_step' );
                                
                                if ( function_exists('bp_wire_install') ) :
                                    ?>
                                    <div class="checkbox">
                                        <label><input type="checkbox" name="group-show-wire" id="group-show-wire" value="1"<?php if ( bp_get_new_group_enable_wire() ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable comment wire', 'buddypress') ?></label>
                                    </div>
                                    <?php
                                endif;
                                
                                if ( function_exists('bp_forums_is_installed_correctly') ) :
                                
                                    if ( bp_forums_is_installed_correctly() ) :
                                        ?>
                                        <div class="checkbox">
                                            <label><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1"<?php if ( bp_get_new_group_enable_forum() ) { ?> checked="checked"<?php } ?> /> <?php _e('Enable discussion forum', 'buddypress') ?></label>
                                        </div>
                                        <?php
                                    else :
                                        
                                        if ( is_super_admin() ) :
                                            ?>
                                            <div class="checkbox">
                                                <label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php printf( __('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), bp_get_root_domain() . '/wp-admin/admin.php?page=bb-forums-setup' ) ?></label>
                                            </div>
                                            <?php
                                        endif;
                                    endif;
                                endif;
                            ?>
                            <hr />
                            
                            <h4>
                                <?php _e( 'Opciones de Privacidad', 'buddypress' ); ?>
                            </h4>
                                
                                <div class="radio">
                                    <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == bp_get_new_group_status() || !bp_get_new_group_status() ) { ?> checked="checked"<?php } ?> />
                                        <strong><?php _e( '&Eacute;ste es un grupo p&uacute;blico', 'buddypress' ) ?></strong>
                                        <ul>
                                            <li><?php _e( 'Cualquier usuario puede unirse al grupo.', 'buddypress' ) ?></li>
                                            <li><?php _e( '&Eacute;ste grupo se listar&aacute; en el listado de grupos.', 'buddypress' ) ?></li>
                                        </ul>
                                    </label>
                                    <?php /*
                                    <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == bp_get_new_group_status() ) { ?> checked="checked"<?php } ?> />
                                        <strong><?php _e( '&Eacute;ste es un grupo privado', 'buddypress' ) ?></strong>
                                        <ul>
                                            <li><?php _e( 'Los usuarios necesitar&aacute; solicitar una invitaci&oacute;n y ser aceptados para unirse al grupo.', 'buddypress' ) ?></li>
                                            <li><?php _e( '&Eacute;ste grupo se listar&aacute; en el listado de grupos.', 'buddypress' ) ?></li>
                                        </ul>
                                    </label>
                                    
                                    <label>
                                        <input type="radio" name="group-status" value="hidden"<?php bp_group_show_status_setting( 'hidden' ); ?> />
                                        <strong><?php _e( 'This is a hidden group', 'buddypress' ); ?></strong>
                                        <ul>
                                            <li><?php _e( 'Only users who are invited can join the group.', 'buddypress' ); ?></li>
                                            <li><?php _e( 'This group will not be listed in the groups directory or search results.', 'buddypress' ); ?></li>
                                            <li><?php _e( 'Group content and activity will only be visible to members of the group.', 'buddypress' ); ?></li>
                                        </ul>
                                    </label>
                                */ ?>
                                </div>
                                
                                <?php
                                do_action( 'bp_after_group_settings_creation_step' );
                                
                                wp_nonce_field( 'groups_create_save_group-settings' );
                                
                                endif;
                                
                                /* Group creation step 3: Avatar Uploads */
                                
                                if ( bp_is_group_creation_step( 'group-avatar' ) ) : ?>
            
                                <?php do_action( 'bp_before_group_avatar_creation_step' ); ?>
            
                                <?php if ( bp_get_avatar_admin_step() ) : ?>
            
                                    <div class="left-menu">
                                        <?php bp_new_group_avatar() ?>
                                    </div><!-- .left-menu -->
            
                                    <div class="main-column">
                                        <p><?php _e("Sube una imagen si lo deseas para identificar el grupo.", 'buddypress') ?></p>
            
                                        <p>
                                            <input type="file" name="file" id="file" />
                                            <input type="submit" name="upload" id="upload" value="<?php _e( 'Subir Imagen', 'buddypress' ) ?>" />
                                            <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
                                        </p>
            
                                        <p><?php _e( 'M&aacute;s adelante puedes modificar &eacute;sta imagen.', 'buddypress' ) ?></p>
                                    </div><!-- .main-column -->
            
                                <?php endif; ?>
            
                                <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
            
                                    <h3><?php _e( 'Recortar Avatar', 'buddypress' ) ?></h3>
            
                                    <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar', 'buddypress' ) ?>" />
            
                                    <div id="avatar-crop-pane">
                                        <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Previsualizar', 'buddypress' ) ?>" />
                                    </div>
            
                                    <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Recortar', 'buddypress' ) ?>" />
            
                                    <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
                                    <input type="hidden" name="upload" id="upload" />
                                    <input type="hidden" id="x" name="x" />
                                    <input type="hidden" id="y" name="y" />
                                    <input type="hidden" id="w" name="w" />
                                    <input type="hidden" id="h" name="h" />
            
                                <?php endif; ?>
            
                                <?php do_action( 'bp_after_group_avatar_creation_step' ); ?>
            
                                <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>
            
                            <?php endif; ?>
            
                            <?php /* Group creation step 4: Invite friends to group */ ?>
                            <?php if ( bp_is_group_creation_step( 'group-invites' ) ) : ?>
            
                                <?php do_action( 'bp_before_group_invites_creation_step' ); ?>
            
                                <?php if ( function_exists( 'bp_get_total_friend_count' ) && bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
            <script type="text/javascript">
            var $ = jQuery;
            $(document).ready( function() {
                $('#messages-seleted').click(function(){
                    
                    var inputs   = $('form input:checkbox').length;
                    var friendUl = $('#friend-list li').length;
                    var listFirends = new Array(inputs);
                    var listSending = new Array(friendUl);
                    
                    for ( x=0; x<inputs;) {
                        listFirends[x] = $('form input:checkbox').eq(x).attr('id').replace('f-','');
                        x++;
                    }
                    
                    for (y=0; y<friendUl;) {
                        listSending[y] = $('#friend-list li').eq(y).attr('id').replace('uid-','');
                        y++;
                    }
                    
                    var countInvites = listFirends.diff(listSending).length; 
                    
                    for (inv=0; inv<countInvites;) {
                        var userid = listFirends.diff(listSending);
                        $('#f-'+userid[inv]).attr("checked", true).click().attr("checked", true);
                        inv++;
                    }
                    
                });
                
                Array.prototype.diff = function(a) {
                    return this.filter(function(i) {return !(a.indexOf(i) > -1);});
                };
                
            });
            </script>
                                    <div class="left-menu">
            
                                        <div id="invite-list">
                                            <ul>
                                                <?php bp_new_group_invite_friend_list() ?>
                                            </ul>
            
                                            <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?>
                                        </div>
            <p id="messages-seleted" style="width: 210px;">
                    <?php _e('Invitar a todos mis amigos', 'buddypress'); ?>
                </p>
                                    </div><!-- .left-menu -->
            
                                    <div class="main-column">
            
                                        <div id="message" class="info">
                                            <p><?php _e('Selecciona los amigos que deseas invitar al grupo.', 'buddypress'); ?></p>
                                        </div>
            
                                        <?php /* The ID 'friend-list' is important for AJAX support. */ ?>
                                        <ul id="friend-list" class="item-list">
                                        <?php if ( bp_group_has_invites() ) : ?>
            
                                            <?php while ( bp_group_invites() ) : bp_group_the_invite(); ?>
            
                                                <li id="<?php bp_group_invite_item_id() ?>">
                                                    <?php bp_group_invite_user_avatar() ?>
            
                                                    <h4><?php bp_group_invite_user_link() ?></h4>
                                                    <span class="activity"><?php bp_group_invite_user_last_active() ?></span>
            
                                                    <div class="action">
                                                        <a class="remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
                                                    </div>
                                                </li>
            
                                            <?php endwhile; ?>
            
                                            <?php wp_nonce_field( 'groups_send_invites') ?>
                                        <?php endif; ?>
                                        </ul>
            
                                    </div><!-- .main-column -->
            
                                <?php else : ?>
            
                                    <div id="message" class="info">
                                        <p><?php _e( 'Once you have built up friend connections you will be able to invite others to your group. You can send invites any time in the future by selecting the "Send Invites" option when viewing your new group.', 'buddypress' ); ?></p>
                                    </div>
            
                                <?php endif; ?>
            
                                <?php wp_nonce_field( 'groups_create_save_group-invites' ) ?>
                                <?php do_action( 'bp_after_group_invites_creation_step' ); ?>
            
                            <?php endif; ?>
            
                            <?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?>
            
                            <?php do_action( 'bp_before_group_creation_step_buttons' ); ?>
            
                            <?php if ( 'crop-image' != bp_get_avatar_admin_step() ) : ?>
                                <div class="submit" id="previous-next">
                                    <?php /* Previous Button */ ?>
                                    <?php if ( !bp_is_first_group_creation_step() ) : ?>
                                        <input type="button" value="&larr; <?php _e('Previous Step', 'buddypress') ?>" id="group-creation-previous" name="previous" onclick="location.href='<?php bp_group_creation_previous_link() ?>'" />
                                    <?php endif; ?>
            
                                    <?php /* Next Button */ ?>
                                    <?php if ( !bp_is_last_group_creation_step() && !bp_is_first_group_creation_step() ) : ?>
                                        <input type="submit" value="<?php _e('Next Step', 'buddypress') ?> &rarr;" id="group-creation-next" name="save" />
                                    <?php endif;?>
            
                                    <?php /* Create Button */ ?>
                                    <?php if ( bp_is_first_group_creation_step() ) : ?>
                                        <input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> &rarr;" id="group-creation-create" name="save" />
                                    <?php endif; ?>
            
                                    <?php /* Finish Button */ ?>
                                    <?php if ( bp_is_last_group_creation_step() ) : ?>
                                        <input type="submit" value="<?php _e('Finish', 'buddypress') ?> &rarr;" id="group-creation-finish" name="save" />
                                    <?php endif; ?>
                                </div>
                            <?php endif;?>
            
                            <?php do_action( 'bp_after_group_creation_step_buttons' ); ?>
            
                            <?php /* Don't leave out this hidden field */ ?>
                            <input type="hidden" name="group_id" id="group_id" value="<?php bp_new_group_id() ?>" />
            
                            <?php do_action( 'bp_directory_groups_content' ) ?>
            
                        </div><!-- .item-body -->
            
                        <?php do_action( 'bp_after_create_group' ) ?>
            
                    </form>
        
                </div><!-- content-middle-add -->
                
            </div><!-- content-middle -->
            
            <div id="content-bottom"></div>
            
        </div><!-- .padder -->
    </div><!-- #content -->

<?php
locate_template( array( 'sidebar.php' ), true );

get_footer();
?>