Skip to:
Content

BuddyPress.org

Changeset 2863 for trunk/bp-xprofile.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-xprofile.php

    r2842 r2863  
    11<?php
    2 define ( 'BP_XPROFILE_DB_VERSION', '1950' );
    3 
    4 /* Define the slug for the component */
    5 if ( !defined( 'BP_XPROFILE_SLUG' ) )
    6     define ( 'BP_XPROFILE_SLUG', 'profile' );
    7 
    82require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php' );
    93require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' );
     
    137
    148/**
    15  * xprofile_install()
    16  *
    17  * Set up the database tables needed for the xprofile component.
    18  *
    19  * @package BuddyPress XProfile
    20  * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    21  * @uses dbDelta() Takes SQL statements and compares them to any existing tables and creates/updates them.
    22  * @uses add_site_option() adds a value for a meta_key into the wp_sitemeta table
    23  */
    24 function xprofile_install() {
    25     global $bp, $wpdb;
    26 
    27     if ( !empty($wpdb->charset) )
    28         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    29 
    30     if ( empty( $bp->site_options['bp-xprofile-base-group-name'] ) )
    31         update_site_option( 'bp-xprofile-base-group-name', 'Base' );
    32 
    33     if ( empty( $bp->site_options['bp-xprofile-fullname-field-name'] ) )
    34         update_site_option( 'bp-xprofile-fullname-field-name', 'Name' );
    35 
    36     $sql[] = "CREATE TABLE {$bp->profile->table_name_groups} (
    37               id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    38               name varchar(150) NOT NULL,
    39               description mediumtext NOT NULL,
    40               group_order bigint(20) NOT NULL DEFAULT '0',
    41               can_delete tinyint(1) NOT NULL,
    42               KEY can_delete (can_delete)
    43     ) {$charset_collate};";
    44 
    45     $sql[] = "CREATE TABLE {$bp->profile->table_name_fields} (
    46               id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    47               group_id bigint(20) unsigned NOT NULL,
    48               parent_id bigint(20) unsigned NOT NULL,
    49               type varchar(150) NOT NULL,
    50               name varchar(150) NOT NULL,
    51               description longtext NOT NULL,
    52               is_required tinyint(1) NOT NULL DEFAULT '0',
    53               is_default_option tinyint(1) NOT NULL DEFAULT '0',
    54               field_order bigint(20) NOT NULL DEFAULT '0',
    55               option_order bigint(20) NOT NULL DEFAULT '0',
    56               order_by varchar(15) NOT NULL,
    57               can_delete tinyint(1) NOT NULL DEFAULT '1',
    58               KEY group_id (group_id),
    59               KEY parent_id (parent_id),
    60               KEY field_order (field_order),
    61               KEY can_delete (can_delete),
    62               KEY is_required (is_required)
    63     ) {$charset_collate};";
    64 
    65     $sql[] = "CREATE TABLE {$bp->profile->table_name_data} (
    66               id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
    67               field_id bigint(20) unsigned NOT NULL,
    68               user_id bigint(20) unsigned NOT NULL,
    69               value longtext NOT NULL,
    70               last_updated datetime NOT NULL,
    71               KEY field_id (field_id),
    72               KEY user_id (user_id)
    73     ) {$charset_collate};";
    74 
    75     if ( '' == get_site_option( 'bp-xprofile-db-version' ) ) {
    76         if ( !$wpdb->get_var( "SELECT id FROM {$bp->profile->table_name_groups} WHERE id = 1" ) )
    77             $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );";
    78 
    79         if ( !$wpdb->get_var( "SELECT id FROM {$bp->profile->table_name_fields} WHERE id = 1" ) ) {
    80             $sql[] = "INSERT INTO {$bp->profile->table_name_fields} (
    81                         id, group_id, parent_id, type, name, is_required, can_delete
    82                       ) VALUES (
    83                         1, 1, 0, 'textbox', '" . get_site_option( 'bp-xprofile-fullname-field-name' ) . "', 1, 0
    84                       );";
    85         }
    86     }
    87 
    88     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    89     dbDelta( $sql );
    90 
    91     do_action( 'xprofile_install' );
    92 
    93     update_site_option( 'bp-xprofile-db-version', BP_XPROFILE_DB_VERSION );
    94 }
    95 
    96 /**
    979 * xprofile_setup_globals()
    9810 *
     
    10618function xprofile_setup_globals() {
    10719    global $bp, $wpdb;
     20
     21    if ( !defined( 'BP_XPROFILE_SLUG' ) )
     22        define ( 'BP_XPROFILE_SLUG', 'profile' );
    10823
    10924    /* Assign the base group and fullname field names to constants to use in SQL statements */
     
    15570    /* Add the administration tab under the "Site Admin" tab for site administrators */
    15671    add_submenu_page( 'bp-general-settings', __( 'Profile Field Setup', 'buddypress' ), __( 'Profile Field Setup', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
    157 
    158     /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    159     if ( get_site_option( 'bp-xprofile-db-version' ) < BP_XPROFILE_DB_VERSION )
    160         xprofile_install();
    16172}
    16273add_action( 'admin_menu', 'xprofile_add_admin_menu' );
Note: See TracChangeset for help on using the changeset viewer.