Changeset 2863 for trunk/bp-xprofile.php
- Timestamp:
- 03/22/2010 11:34:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile.php
r2842 r2863 1 1 <?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 8 2 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-admin.php' ); 9 3 require ( BP_PLUGIN_DIR . '/bp-xprofile/bp-xprofile-classes.php' ); … … 13 7 14 8 /** 15 * xprofile_install()16 *17 * Set up the database tables needed for the xprofile component.18 *19 * @package BuddyPress XProfile20 * @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 table23 */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_delete82 ) VALUES (83 1, 1, 0, 'textbox', '" . get_site_option( 'bp-xprofile-fullname-field-name' ) . "', 1, 084 );";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 /**97 9 * xprofile_setup_globals() 98 10 * … … 106 18 function xprofile_setup_globals() { 107 19 global $bp, $wpdb; 20 21 if ( !defined( 'BP_XPROFILE_SLUG' ) ) 22 define ( 'BP_XPROFILE_SLUG', 'profile' ); 108 23 109 24 /* Assign the base group and fullname field names to constants to use in SQL statements */ … … 155 70 /* Add the administration tab under the "Site Admin" tab for site administrators */ 156 71 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();161 72 } 162 73 add_action( 'admin_menu', 'xprofile_add_admin_menu' );
Note: See TracChangeset
for help on using the changeset viewer.