[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/admin/ -> bp-core-admin-schema.php (source)

   1  <?php
   2  /**
   3   * BuddyPress DB schema.
   4   *
   5   * @package BuddyPress
   6   * @subpackage CoreAdministration
   7   * @since 2.3.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Main installer.
  15   *
  16   * Can be passed an optional array of components to explicitly run installation
  17   * routines on, typically the first time a component is activated in Settings.
  18   *
  19   * @since 1.0.0
  20   *
  21   * @param array|bool $active_components Components to install.
  22   */
  23  function bp_core_install( $active_components = false ) {
  24  
  25      bp_pre_schema_upgrade();
  26  
  27      // If no components passed, get all the active components from the main site.
  28      if ( empty( $active_components ) ) {
  29  
  30          /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
  31          $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
  32      }
  33  
  34      // Install Activity Streams even when inactive (to store last_activity data).
  35      bp_core_install_activity_streams();
  36  
  37      // Install the signups table.
  38      bp_core_maybe_install_signups();
  39  
  40      // Install the invitations table.
  41      bp_core_install_invitations();
  42  
  43      // Install the nonmember opt-outs table.
  44      bp_core_install_nonmember_opt_outs();
  45  
  46      // Notifications.
  47      if ( !empty( $active_components['notifications'] ) ) {
  48          bp_core_install_notifications();
  49      }
  50  
  51      // Friend Connections.
  52      if ( !empty( $active_components['friends'] ) ) {
  53          bp_core_install_friends();
  54      }
  55  
  56      // Extensible Groups.
  57      if ( !empty( $active_components['groups'] ) ) {
  58          bp_core_install_groups();
  59      }
  60  
  61      // Private Messaging.
  62      if ( !empty( $active_components['messages'] ) ) {
  63          bp_core_install_private_messaging();
  64      }
  65  
  66      // Extended Profiles.
  67      if ( !empty( $active_components['xprofile'] ) ) {
  68          bp_core_install_extended_profiles();
  69      }
  70  
  71      // Blog tracking.
  72      if ( !empty( $active_components['blogs'] ) ) {
  73          bp_core_install_blog_tracking();
  74      }
  75  }
  76  
  77  /**
  78   * Install database tables for the Notifications component.
  79   *
  80   * @since 1.0.0
  81   *
  82   */
  83  function bp_core_install_notifications() {
  84      $sql             = array();
  85      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
  86      $bp_prefix       = bp_core_get_table_prefix();
  87  
  88      $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications (
  89                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  90                  user_id bigint(20) NOT NULL,
  91                  item_id bigint(20) NOT NULL,
  92                  secondary_item_id bigint(20),
  93                  component_name varchar(75) NOT NULL,
  94                  component_action varchar(75) NOT NULL,
  95                  date_notified datetime NOT NULL,
  96                  is_new bool NOT NULL DEFAULT 0,
  97                  KEY item_id (item_id),
  98                  KEY secondary_item_id (secondary_item_id),
  99                  KEY user_id (user_id),
 100                  KEY is_new (is_new),
 101                  KEY component_name (component_name),
 102                  KEY component_action (component_action),
 103                  KEY useritem (user_id,is_new)
 104              ) {$charset_collate};";
 105  
 106      $sql[] = "CREATE TABLE {$bp_prefix}bp_notifications_meta (
 107                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 108                  notification_id bigint(20) NOT NULL,
 109                  meta_key varchar(255) DEFAULT NULL,
 110                  meta_value longtext DEFAULT NULL,
 111                  KEY notification_id (notification_id),
 112                  KEY meta_key (meta_key(191))
 113              ) {$charset_collate};";
 114  
 115      dbDelta( $sql );
 116  }
 117  
 118  /**
 119   * Install database tables for the Activity component.
 120   *
 121   * @since 1.0.0
 122   *
 123   */
 124  function bp_core_install_activity_streams() {
 125      $sql             = array();
 126      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 127      $bp_prefix       = bp_core_get_table_prefix();
 128  
 129      $sql[] = "CREATE TABLE {$bp_prefix}bp_activity (
 130                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 131                  user_id bigint(20) NOT NULL,
 132                  component varchar(75) NOT NULL,
 133                  type varchar(75) NOT NULL,
 134                  action text NOT NULL,
 135                  content longtext NOT NULL,
 136                  primary_link text NOT NULL,
 137                  item_id bigint(20) NOT NULL,
 138                  secondary_item_id bigint(20) DEFAULT NULL,
 139                  date_recorded datetime NOT NULL,
 140                  hide_sitewide bool DEFAULT 0,
 141                  mptt_left int(11) NOT NULL DEFAULT 0,
 142                  mptt_right int(11) NOT NULL DEFAULT 0,
 143                  is_spam tinyint(1) NOT NULL DEFAULT 0,
 144                  KEY date_recorded (date_recorded),
 145                  KEY user_id (user_id),
 146                  KEY item_id (item_id),
 147                  KEY secondary_item_id (secondary_item_id),
 148                  KEY component (component),
 149                  KEY type (type),
 150                  KEY mptt_left (mptt_left),
 151                  KEY mptt_right (mptt_right),
 152                  KEY hide_sitewide (hide_sitewide),
 153                  KEY is_spam (is_spam)
 154              ) {$charset_collate};";
 155  
 156      $sql[] = "CREATE TABLE {$bp_prefix}bp_activity_meta (
 157                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 158                  activity_id bigint(20) NOT NULL,
 159                  meta_key varchar(255) DEFAULT NULL,
 160                  meta_value longtext DEFAULT NULL,
 161                  KEY activity_id (activity_id),
 162                  KEY meta_key (meta_key(191))
 163              ) {$charset_collate};";
 164  
 165      dbDelta( $sql );
 166  }
 167  
 168  /**
 169   * Install database tables for the Notifications component.
 170   *
 171   * @since 1.0.0
 172   *
 173   */
 174  function bp_core_install_friends() {
 175      $sql             = array();
 176      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 177      $bp_prefix       = bp_core_get_table_prefix();
 178  
 179      $sql[] = "CREATE TABLE {$bp_prefix}bp_friends (
 180                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 181                  initiator_user_id bigint(20) NOT NULL,
 182                  friend_user_id bigint(20) NOT NULL,
 183                  is_confirmed bool DEFAULT 0,
 184                  is_limited bool DEFAULT 0,
 185                  date_created datetime NOT NULL,
 186                  KEY initiator_user_id (initiator_user_id),
 187                  KEY friend_user_id (friend_user_id)
 188              ) {$charset_collate};";
 189  
 190      dbDelta( $sql );
 191  }
 192  
 193  /**
 194   * Install database tables for the Groups component.
 195   *
 196   * @since 1.0.0
 197   *
 198   */
 199  function bp_core_install_groups() {
 200      $sql             = array();
 201      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 202      $bp_prefix       = bp_core_get_table_prefix();
 203  
 204      $sql[] = "CREATE TABLE {$bp_prefix}bp_groups (
 205                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 206                  creator_id bigint(20) NOT NULL,
 207                  name varchar(100) NOT NULL,
 208                  slug varchar(200) NOT NULL,
 209                  description longtext NOT NULL,
 210                  status varchar(10) NOT NULL DEFAULT 'public',
 211                  parent_id bigint(20) NOT NULL DEFAULT 0,
 212                  enable_forum tinyint(1) NOT NULL DEFAULT '1',
 213                  date_created datetime NOT NULL,
 214                  KEY creator_id (creator_id),
 215                  KEY status (status),
 216                  KEY parent_id (parent_id)
 217              ) {$charset_collate};";
 218  
 219      $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_members (
 220                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 221                  group_id bigint(20) NOT NULL,
 222                  user_id bigint(20) NOT NULL,
 223                  inviter_id bigint(20) NOT NULL,
 224                  is_admin tinyint(1) NOT NULL DEFAULT '0',
 225                  is_mod tinyint(1) NOT NULL DEFAULT '0',
 226                  user_title varchar(100) NOT NULL,
 227                  date_modified datetime NOT NULL,
 228                  comments longtext NOT NULL,
 229                  is_confirmed tinyint(1) NOT NULL DEFAULT '0',
 230                  is_banned tinyint(1) NOT NULL DEFAULT '0',
 231                  invite_sent tinyint(1) NOT NULL DEFAULT '0',
 232                  KEY group_id (group_id),
 233                  KEY is_admin (is_admin),
 234                  KEY is_mod (is_mod),
 235                  KEY user_id (user_id),
 236                  KEY inviter_id (inviter_id),
 237                  KEY is_confirmed (is_confirmed)
 238              ) {$charset_collate};";
 239  
 240      $sql[] = "CREATE TABLE {$bp_prefix}bp_groups_groupmeta (
 241                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 242                  group_id bigint(20) NOT NULL,
 243                  meta_key varchar(255) DEFAULT NULL,
 244                  meta_value longtext DEFAULT NULL,
 245                  KEY group_id (group_id),
 246                  KEY meta_key (meta_key(191))
 247              ) {$charset_collate};";
 248  
 249      dbDelta( $sql );
 250  }
 251  
 252  /**
 253   * Install database tables for the Messages component.
 254   *
 255   * @since 1.0.0
 256   *
 257   */
 258  function bp_core_install_private_messaging() {
 259      $sql             = array();
 260      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 261      $bp_prefix       = bp_core_get_table_prefix();
 262  
 263      $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_messages (
 264                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 265                  thread_id bigint(20) NOT NULL,
 266                  sender_id bigint(20) NOT NULL,
 267                  subject varchar(200) NOT NULL,
 268                  message longtext NOT NULL,
 269                  date_sent datetime NOT NULL,
 270                  KEY sender_id (sender_id),
 271                  KEY thread_id (thread_id)
 272              ) {$charset_collate};";
 273  
 274      $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_recipients (
 275                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 276                  user_id bigint(20) NOT NULL,
 277                  thread_id bigint(20) NOT NULL,
 278                  unread_count int(10) NOT NULL DEFAULT '0',
 279                  sender_only tinyint(1) NOT NULL DEFAULT '0',
 280                  is_deleted tinyint(1) NOT NULL DEFAULT '0',
 281                  KEY user_id (user_id),
 282                  KEY thread_id (thread_id),
 283                  KEY is_deleted (is_deleted),
 284                  KEY sender_only (sender_only),
 285                  KEY unread_count (unread_count)
 286              ) {$charset_collate};";
 287  
 288      $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_notices (
 289                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 290                  subject varchar(200) NOT NULL,
 291                  message longtext NOT NULL,
 292                  date_sent datetime NOT NULL,
 293                  is_active tinyint(1) NOT NULL DEFAULT '0',
 294                  KEY is_active (is_active)
 295              ) {$charset_collate};";
 296  
 297      $sql[] = "CREATE TABLE {$bp_prefix}bp_messages_meta (
 298                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 299                  message_id bigint(20) NOT NULL,
 300                  meta_key varchar(255) DEFAULT NULL,
 301                  meta_value longtext DEFAULT NULL,
 302                  KEY message_id (message_id),
 303                  KEY meta_key (meta_key(191))
 304              ) {$charset_collate};";
 305  
 306      dbDelta( $sql );
 307  }
 308  
 309  /**
 310   * Install database tables for the Profiles component.
 311   *
 312   * @since 1.0.0
 313   *
 314   */
 315  function bp_core_install_extended_profiles() {
 316      global $wpdb;
 317  
 318      $sql             = array();
 319      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 320      $bp_prefix       = bp_core_get_table_prefix();
 321  
 322      // These values should only be updated if they are not already present.
 323      if ( ! bp_get_option( 'bp-xprofile-base-group-name' ) ) {
 324          bp_update_option( 'bp-xprofile-base-group-name', _x( 'General', 'First field-group name', 'buddypress' ) );
 325      }
 326  
 327      if ( ! bp_get_option( 'bp-xprofile-fullname-field-name' ) ) {
 328          bp_update_option( 'bp-xprofile-fullname-field-name', _x( 'Display Name', 'Display name field', 'buddypress' ) );
 329      }
 330  
 331      $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_groups (
 332                  id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
 333                  name varchar(150) NOT NULL,
 334                  description mediumtext NOT NULL,
 335                  group_order bigint(20) NOT NULL DEFAULT '0',
 336                  can_delete tinyint(1) NOT NULL,
 337                  KEY can_delete (can_delete)
 338              ) {$charset_collate};";
 339  
 340      $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_fields (
 341                  id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
 342                  group_id bigint(20) unsigned NOT NULL,
 343                  parent_id bigint(20) unsigned NOT NULL,
 344                  type varchar(150) NOT NULL,
 345                  name varchar(150) NOT NULL,
 346                  description longtext NOT NULL,
 347                  is_required tinyint(1) NOT NULL DEFAULT '0',
 348                  is_default_option tinyint(1) NOT NULL DEFAULT '0',
 349                  field_order bigint(20) NOT NULL DEFAULT '0',
 350                  option_order bigint(20) NOT NULL DEFAULT '0',
 351                  order_by varchar(15) NOT NULL DEFAULT '',
 352                  can_delete tinyint(1) NOT NULL DEFAULT '1',
 353                  KEY group_id (group_id),
 354                  KEY parent_id (parent_id),
 355                  KEY field_order (field_order),
 356                  KEY can_delete (can_delete),
 357                  KEY is_required (is_required)
 358              ) {$charset_collate};";
 359  
 360      $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_data (
 361                  id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
 362                  field_id bigint(20) unsigned NOT NULL,
 363                  user_id bigint(20) unsigned NOT NULL,
 364                  value longtext NOT NULL,
 365                  last_updated datetime NOT NULL,
 366                  KEY field_id (field_id),
 367                  KEY user_id (user_id)
 368              ) {$charset_collate};";
 369  
 370      $sql[] = "CREATE TABLE {$bp_prefix}bp_xprofile_meta (
 371                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 372                  object_id bigint(20) NOT NULL,
 373                  object_type varchar(150) NOT NULL,
 374                  meta_key varchar(255) DEFAULT NULL,
 375                  meta_value longtext DEFAULT NULL,
 376                  KEY object_id (object_id),
 377                  KEY meta_key (meta_key(191))
 378              ) {$charset_collate};";
 379  
 380      dbDelta( $sql );
 381  
 382      // Insert the default group and fields.
 383      $insert_sql = array();
 384  
 385      if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_groups WHERE id = 1" ) ) {
 386          $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_groups ( name, description, can_delete ) VALUES ( " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-base-group-name' ) ) ) . ", '', 0 );";
 387      }
 388  
 389      if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE id = 1" ) ) {
 390          $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_fields ( group_id, parent_id, type, name, description, is_required, can_delete ) VALUES ( 1, 0, 'textbox', " . $wpdb->prepare( '%s', stripslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) . ", '', 1, 0 );";
 391  
 392          // Make sure the custom visibility is disabled for the default field.
 393          if ( ! $wpdb->get_var( "SELECT id FROM {$bp_prefix}bp_xprofile_meta WHERE id = 1" ) ) {
 394              $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'allow_custom_visibility', 'disabled' );";
 395              $insert_sql[] = "INSERT INTO {$bp_prefix}bp_xprofile_meta ( object_id, object_type, meta_key, meta_value ) VALUES ( 1, 'field', 'signup_position', 1 );";
 396          }
 397      }
 398  
 399      dbDelta( $insert_sql );
 400  }
 401  
 402  /**
 403   * Install database tables for the Sites component.
 404   *
 405   * @since 1.0.0
 406   *
 407   */
 408  function bp_core_install_blog_tracking() {
 409      $sql             = array();
 410      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 411      $bp_prefix       = bp_core_get_table_prefix();
 412  
 413      $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs (
 414                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 415                  user_id bigint(20) NOT NULL,
 416                  blog_id bigint(20) NOT NULL,
 417                  KEY user_id (user_id),
 418                  KEY blog_id (blog_id)
 419              ) {$charset_collate};";
 420  
 421      $sql[] = "CREATE TABLE {$bp_prefix}bp_user_blogs_blogmeta (
 422                  id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 423                  blog_id bigint(20) NOT NULL,
 424                  meta_key varchar(255) DEFAULT NULL,
 425                  meta_value longtext DEFAULT NULL,
 426                  KEY blog_id (blog_id),
 427                  KEY meta_key (meta_key(191))
 428              ) {$charset_collate};";
 429  
 430      dbDelta( $sql );
 431  }
 432  
 433  /** Signups *******************************************************************/
 434  
 435  /**
 436   * Install the signups table.
 437   *
 438   * @since 2.0.0
 439   *
 440   * @global $wpdb
 441   */
 442  function bp_core_install_signups() {
 443      global $wpdb;
 444  
 445      // Signups is not there and we need it so let's create it.
 446      require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
 447      require_once( ABSPATH                  . 'wp-admin/includes/upgrade.php'     );
 448  
 449      // Never use bp_core_get_table_prefix() for any global users tables.
 450      $wpdb->signups = $wpdb->base_prefix . 'signups';
 451  
 452      // Use WP's core CREATE TABLE query.
 453      $create_queries = wp_get_db_schema( 'ms_global' );
 454      if ( ! is_array( $create_queries ) ) {
 455          $create_queries = explode( ';', $create_queries );
 456          $create_queries = array_filter( $create_queries );
 457      }
 458  
 459      // Filter out all the queries except wp_signups.
 460      foreach ( $create_queries as $key => $query ) {
 461          if ( preg_match( "|CREATE TABLE ([^ ]*)|", $query, $matches ) ) {
 462              if ( trim( $matches[1], '`' ) !== $wpdb->signups ) {
 463                  unset( $create_queries[ $key ] );
 464              }
 465          }
 466      }
 467  
 468      // Run WordPress's database upgrader.
 469      if ( ! empty( $create_queries ) ) {
 470          dbDelta( $create_queries );
 471      }
 472  }
 473  
 474  /**
 475   * Update the signups table, adding `signup_id` column and drop `domain` index.
 476   *
 477   * This is necessary because WordPress's `pre_schema_upgrade()` function wraps
 478   * table ALTER's in multisite checks, and other plugins may have installed their
 479   * own sign-ups table; Eg: Gravity Forms User Registration Add On.
 480   *
 481   * @since 2.0.1
 482   *
 483   * @see pre_schema_upgrade()
 484   * @link https://core.trac.wordpress.org/ticket/27855 WordPress Trac Ticket
 485   * @link https://buddypress.trac.wordpress.org/ticket/5563 BuddyPress Trac Ticket
 486   *
 487   * @global WPDB $wpdb
 488   */
 489  function bp_core_upgrade_signups() {
 490      global $wpdb;
 491  
 492      // Bail if global tables should not be upgraded.
 493      if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
 494          return;
 495      }
 496  
 497      // Never use bp_core_get_table_prefix() for any global users tables.
 498      $wpdb->signups = $wpdb->base_prefix . 'signups';
 499  
 500      // Attempt to alter the signups table.
 501      $wpdb->query( "ALTER TABLE {$wpdb->signups} ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
 502      $wpdb->query( "ALTER TABLE {$wpdb->signups} DROP INDEX domain" );
 503  }
 504  
 505  /**
 506   * Add default emails.
 507   *
 508   * @since 2.5.0
 509   */
 510  function bp_core_install_emails() {
 511      $defaults = array(
 512          'post_status' => 'publish',
 513          'post_type'   => bp_get_email_post_type(),
 514      );
 515  
 516      $emails       = bp_email_get_schema();
 517      $descriptions = bp_email_get_type_schema( 'description' );
 518  
 519      // Add these emails to the database.
 520      foreach ( $emails as $id => $email ) {
 521  
 522          // Some emails are multisite-only.
 523          if ( ! is_multisite() && isset( $email['args'] ) && ! empty( $email['args']['multisite'] ) ) {
 524              continue;
 525          }
 526  
 527          $post_id = wp_insert_post(
 528              bp_parse_args(
 529                  $email,
 530                  $defaults,
 531                  'install_email_' . $id
 532              )
 533          );
 534  
 535          if ( ! $post_id ) {
 536              continue;
 537          }
 538  
 539          $tt_ids = wp_set_object_terms( $post_id, $id, bp_get_email_tax_type() );
 540          foreach ( $tt_ids as $tt_id ) {
 541              $term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() );
 542              wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array(
 543                  'description' => $descriptions[ $id ],
 544              ) );
 545          }
 546      }
 547  
 548      bp_update_option( 'bp-emails-unsubscribe-salt', base64_encode( wp_generate_password( 64, true, true ) ) );
 549  
 550      /**
 551       * Fires after BuddyPress adds the posts for its emails.
 552       *
 553       * @since 2.5.0
 554       */
 555      do_action( 'bp_core_install_emails' );
 556  }
 557  
 558  /**
 559   * Install database tables for the Invitations API
 560   *
 561   * @since 5.0.0
 562   *
 563   * @uses bp_core_set_charset()
 564   * @uses bp_core_get_table_prefix()
 565   * @uses dbDelta()
 566   */
 567  function bp_core_install_invitations() {
 568      $sql             = array();
 569      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 570      $bp_prefix       = bp_core_get_table_prefix();
 571      $sql[] = "CREATE TABLE {$bp_prefix}bp_invitations (
 572          id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 573          user_id bigint(20) NOT NULL,
 574          inviter_id bigint(20) NOT NULL,
 575          invitee_email varchar(100) DEFAULT NULL,
 576          class varchar(120) NOT NULL,
 577          item_id bigint(20) NOT NULL,
 578          secondary_item_id bigint(20) DEFAULT NULL,
 579          type varchar(12) NOT NULL DEFAULT 'invite',
 580          content longtext DEFAULT '',
 581          date_modified datetime NOT NULL,
 582          invite_sent tinyint(1) NOT NULL DEFAULT '0',
 583          accepted tinyint(1) NOT NULL DEFAULT '0',
 584          KEY user_id (user_id),
 585          KEY inviter_id (inviter_id),
 586          KEY invitee_email (invitee_email),
 587          KEY class (class),
 588          KEY item_id (item_id),
 589          KEY secondary_item_id (secondary_item_id),
 590          KEY type (type),
 591          KEY invite_sent (invite_sent),
 592          KEY accepted (accepted)
 593          ) {$charset_collate};";
 594      dbDelta( $sql );
 595  
 596      /**
 597       * Fires after BuddyPress adds the invitations table.
 598       *
 599       * @since 5.0.0
 600       */
 601      do_action( 'bp_core_install_invitations' );
 602  }
 603  
 604  /**
 605   * Install database tables to store opt-out requests from nonmembers.
 606   *
 607   * @since 8.0.0
 608   *
 609   * @uses bp_core_set_charset()
 610   * @uses bp_core_get_table_prefix()
 611   * @uses dbDelta()
 612   */
 613  function bp_core_install_nonmember_opt_outs() {
 614      $sql             = array();
 615      $charset_collate = $GLOBALS['wpdb']->get_charset_collate();
 616      $bp_prefix       = bp_core_get_table_prefix();
 617      $optouts_class   = new BP_Optout();
 618      $table_name      = $optouts_class->get_table_name();
 619      $sql = "CREATE TABLE {$table_name} (
 620          id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 621          email_address_hash varchar(255) NOT NULL,
 622          user_id bigint(20) NOT NULL,
 623          email_type varchar(255) NOT NULL,
 624          date_modified datetime NOT NULL,
 625          KEY user_id (user_id),
 626          KEY email_type (email_type),
 627          KEY date_modified (date_modified)
 628          ) {$charset_collate};";
 629      dbDelta( $sql );
 630  
 631      /**
 632       * Fires after BuddyPress adds the nonmember opt-outs table.
 633       *
 634       * @since 8.0.0
 635       */
 636      do_action( 'bp_core_install_nonmember_opt_outs' );
 637  }


Generated: Sun Nov 24 01:00:53 2024 Cross-referenced by PHPXref 0.7.1