Skip to:
Content

BuddyPress.org

Changeset 2863 for trunk/bp-messages.php


Ignore:
Timestamp:
03/22/2010 11:34:23 AM (16 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-messages.php

    r2761 r2863  
    11<?php
    2 
    3 define ( 'BP_MESSAGES_DB_VERSION', '2000' );
    4 
    5 /* Define the slug for the component */
    6 if ( !defined( 'BP_MESSAGES_SLUG' ) )
    7         define ( 'BP_MESSAGES_SLUG', 'messages' );
    8 
    92require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-classes.php' );
    103require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-cssjs.php' );
     
    125require ( BP_PLUGIN_DIR . '/bp-messages/bp-messages-filters.php' );
    136
    14 function messages_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->messages->table_name_recipients} (
    21                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    22                                 user_id bigint(20) NOT NULL,
    23                                 thread_id bigint(20) NOT NULL,
    24                                 unread_count int(10) NOT NULL DEFAULT '0',
    25                                 sender_only tinyint(1) NOT NULL DEFAULT '0',
    26                                 is_deleted tinyint(1) NOT NULL DEFAULT '0',
    27                             KEY user_id (user_id),
    28                             KEY thread_id (thread_id),
    29                                 KEY is_deleted (is_deleted),
    30                                 KEY sender_only (sender_only),
    31                             KEY unread_count (unread_count)
    32                            ) {$charset_collate};";
    33 
    34         $sql[] = "CREATE TABLE {$bp->messages->table_name_messages} (
    35                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    36                                 thread_id bigint(20) NOT NULL,
    37                                 sender_id bigint(20) NOT NULL,
    38                                 subject varchar(200) NOT NULL,
    39                                 message longtext NOT NULL,
    40                                 date_sent datetime NOT NULL,
    41                             KEY sender_id (sender_id),
    42                             KEY thread_id (thread_id)
    43                            ) {$charset_collate};";
    44 
    45         $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} (
    46                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    47                                 subject varchar(200) NOT NULL,
    48                                 message longtext NOT NULL,
    49                                 date_sent datetime NOT NULL,
    50                                 is_active tinyint(1) NOT NULL DEFAULT '0',
    51                             KEY is_active (is_active)
    52                            ) {$charset_collate};";
    53 
    54         require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    55         dbDelta($sql);
    56 
    57         /* Upgrade and remove the message threads table if it exists */
    58         if ( $wpdb->get_var( "SHOW TABLES LIKE '%{$wpdb->base_prefix}bp_messages_threads%'" ) ) {
    59                 $upgrade = BP_Messages_Thread::upgrade_tables();
    60 
    61                 if ( $upgrade )
    62                         $wpdb->query( "DROP TABLE {$wpdb->base_prefix}bp_messages_threads" );
    63         }
    64 
    65         add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION );
    66 }
    67 
    687function messages_setup_globals() {
    698        global $bp, $wpdb;
     9
     10        if ( !defined( 'BP_MESSAGES_SLUG' ) )
     11                define ( 'BP_MESSAGES_SLUG', 'messages' );
    7012
    7113        /* For internal identification */
     
    8426}
    8527add_action( 'bp_setup_globals', 'messages_setup_globals' );
    86 
    87 function messages_check_installed() {
    88         global $wpdb, $bp;
    89 
    90         if ( !is_site_admin() )
    91                 return false;
    92 
    93         /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    94         if ( get_site_option( 'bp-messages-db-version' ) < BP_MESSAGES_DB_VERSION )
    95                 messages_install();
    96 }
    97 add_action( 'admin_menu', 'messages_check_installed' );
    9828
    9929function messages_setup_nav() {
Note: See TracChangeset for help on using the changeset viewer.