Skip to:
Content

BuddyPress.org

Changeset 2863 for trunk/bp-groups.php


Ignore:
Timestamp:
03/22/2010 11:34:23 AM (15 years ago)
Author:
apeatling
Message:

Added new install/upgrade wizard. Removed root components and replaced them with actual WordPress pages. Testing on WordPress vhost/novhost and root profile support still to do.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r2842 r2863  
    11<?php
    2 
    3 define ( 'BP_GROUPS_DB_VERSION', '1900' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_GROUPS_SLUG' ) )
    7     define ( 'BP_GROUPS_SLUG', 'groups' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-templatetags.php' );
     
    125require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-filters.php' );
    136
    14 function groups_install() {
    15     global $wpdb, $bp;
    16 
    17     if ( !empty($wpdb->charset) )
    18         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    19 
    20     $sql[] = "CREATE TABLE {$bp->groups->table_name} (
    21             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    22             creator_id bigint(20) NOT NULL,
    23             name varchar(100) NOT NULL,
    24             slug varchar(100) NOT NULL,
    25             description longtext NOT NULL,
    26             status varchar(10) NOT NULL DEFAULT 'public',
    27             enable_forum tinyint(1) NOT NULL DEFAULT '1',
    28             date_created datetime NOT NULL,
    29             KEY creator_id (creator_id),
    30             KEY status (status)
    31            ) {$charset_collate};";
    32 
    33     $sql[] = "CREATE TABLE {$bp->groups->table_name_members} (
    34             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    35             group_id bigint(20) NOT NULL,
    36             user_id bigint(20) NOT NULL,
    37             inviter_id bigint(20) NOT NULL,
    38             is_admin tinyint(1) NOT NULL DEFAULT '0',
    39             is_mod tinyint(1) NOT NULL DEFAULT '0',
    40             user_title varchar(100) NOT NULL,
    41             date_modified datetime NOT NULL,
    42             comments longtext NOT NULL,
    43             is_confirmed tinyint(1) NOT NULL DEFAULT '0',
    44             is_banned tinyint(1) NOT NULL DEFAULT '0',
    45             invite_sent tinyint(1) NOT NULL DEFAULT '0',
    46             KEY group_id (group_id),
    47             KEY is_admin (is_admin),
    48             KEY is_mod (is_mod),
    49             KEY user_id (user_id),
    50             KEY inviter_id (inviter_id),
    51             KEY is_confirmed (is_confirmed)
    52            ) {$charset_collate};";
    53 
    54     $sql[] = "CREATE TABLE {$bp->groups->table_name_groupmeta} (
    55             id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    56             group_id bigint(20) NOT NULL,
    57             meta_key varchar(255) DEFAULT NULL,
    58             meta_value longtext DEFAULT NULL,
    59             KEY group_id (group_id),
    60             KEY meta_key (meta_key)
    61            ) {$charset_collate};";
    62 
    63     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    64     dbDelta($sql);
    65 
    66     do_action( 'groups_install' );
    67 
    68     update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
    69 }
    70 
    717function groups_setup_globals() {
    728    global $bp, $wpdb;
    739
     10    if ( !defined( 'BP_GROUPS_SLUG' ) )
     11        define ( 'BP_GROUPS_SLUG', $bp->pages->groups->slug );
     12
    7413    /* For internal identification */
    7514    $bp->groups->id = 'groups';
     15    $bp->groups->name = $bp->pages->groups->name;
     16    $bp->groups->slug = BP_GROUPS_SLUG;
    7617
    7718    $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
     
    7920    $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
    8021    $bp->groups->format_notification_function = 'groups_format_notifications';
    81     $bp->groups->slug = BP_GROUPS_SLUG;
    8222
    8323    /* Register this in the active components array */
     
    10141add_action( 'bp_setup_globals', 'groups_setup_globals' );
    10242
    103 function groups_setup_root_component() {
    104     /* Register 'groups' as a root component */
    105     bp_core_add_root_component( BP_GROUPS_SLUG );
    106 }
    107 add_action( 'bp_setup_root_components', 'groups_setup_root_component' );
    108 
    109 function groups_check_installed() {
    110     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    111     if ( get_site_option( 'bp-groups-db-version' ) < BP_GROUPS_DB_VERSION )
    112         groups_install();
    113 }
    114 add_action( 'admin_menu', 'groups_check_installed' );
    115 
    11643function groups_setup_nav() {
    11744    global $bp;
     
    14168
    14269    /* Add 'Groups' to the main navigation */
    143     bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
    144 
    145     $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
     70    bp_core_new_nav_item( array( 'name' => sprintf( __( 'Groups <span>(%d)</span>', 'buddypress' ), groups_total_groups_for_user() ), 'slug' => $bp->groups->name, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
     71
     72    $groups_link = $bp->loggedin_user->domain . $bp->groups->name . '/';
    14673
    14774    /* Add the subnav items to the groups nav item */
    148     bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
    149     bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
     75    bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
     76    bp_core_new_subnav_item( array( 'name' => __( 'Invites', 'buddypress' ), 'slug' => 'invites', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->name, 'screen_function' => 'groups_screen_group_invites', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
    15077
    15178    if ( $bp->current_component == $bp->groups->slug ) {
     
    13541281
    13551282            if ( (int)$total_items > 1 ) {
    1356                 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
     1283                return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . $bp->members->slug . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
    13571284            } else {
    13581285                return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
Note: See TracChangeset for help on using the changeset viewer.