Skip to:
Content

BuddyPress.org

Ticket #2717: dudewheresmycar.patch

File dudewheresmycar.patch, 6.8 KB (added by DJPaul, 15 years ago)
  • bp-core/admin/bp-core-upgrade.php

     
    11<?php
    2 
    32require_once( dirname( dirname( __FILE__ ) ) . '/bp-core-wpabstraction.php' );
    43
    54if ( function_exists( 'register_theme_directory') )
    65        register_theme_directory( WP_PLUGIN_DIR . '/buddypress/bp-themes' );
    76
     7/* Install site options on activation */
     8bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0,  'bp-disable-forum-directory' => 0,  'bp-disable-profile-sync' => 0 ) );
     9
     10/**
     11 * bp_core_activate_site_options()
     12 *
     13 * When switching from single to multisite we need to copy blog options to
     14 * site options.
     15 *
     16 * @package BuddyPress Core
     17 */
     18function bp_core_activate_site_options( $keys = array() ) {
     19        global $bp;
     20
     21        $bp->site_options = bp_core_get_site_options();
     22
     23        if ( !empty( $keys ) && is_array( $keys ) ) {
     24                $errors = false;
     25
     26                foreach ( $keys as $key => $default ) {
     27                        if ( empty( $bp->site_options[ $key ] ) ) {
     28                                $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
     29
     30                                if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
     31                                        $errors = true;
     32                        }
     33                }
     34
     35                if ( empty( $errors ) )
     36                        return true;
     37        }
     38
     39        return false;
     40}
     41
    842class BP_Core_Setup_Wizard {
    943        var $current_step;
    1044        var $steps;
     
    10851119        </style>
    10861120<?php
    10871121}
    1088 
    10891122?>
    1090  No newline at end of file
  • bp-loader.php

     
    7676        do_action( 'bp_loaded' );
    7777}
    7878
     79/**
     80 * bp_core_get_site_options()
     81 *
     82 * BuddyPress uses site options to store configuration settings. Many of these settings are needed
     83 * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
     84 * them all in one go.
     85 *
     86 * @package BuddyPress Core
     87 */
     88function bp_core_get_site_options() {
     89        global $bp, $wpdb;
     90
     91        $options = apply_filters( 'bp_core_site_options', array(
     92                'bp-deactivated-components',
     93                'bp-blogs-first-install',
     94                'bp-disable-blog-forum-comments',
     95                'bp-xprofile-base-group-name',
     96                'bp-xprofile-fullname-field-name',
     97                'bp-disable-profile-sync',
     98                'bp-disable-avatar-uploads',
     99                'bp-disable-account-deletion',
     100                'bp-disable-forum-directory',
     101                'bp-disable-blogforum-comments',
     102                'bb-config-location',
     103                'hide-loggedout-adminbar',
     104
     105                /* Useful WordPress settings used often */
     106                'user-avatar-default',
     107                'tags_blog_id',
     108                'registration',
     109                'fileupload_maxk'
     110        ) );
     111
     112        $meta_keys = "'" . implode( "','", (array)$options ) ."'";
     113
     114        if ( is_multisite() )
     115                $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
     116        else
     117                $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     118
     119        $site_options = array();
     120        if ( !empty( $meta ) ) {
     121                foreach( (array)$meta as $meta_item )
     122                        $site_options[$meta_item->name] = $meta_item->value;
     123        }
     124
     125        return apply_filters( 'bp_core_get_site_options', $site_options );
     126}
     127
    79128/* Activation Function */
    80129function bp_loader_activate() {
     130        global $bp;
     131
    81132        /* Force refresh theme roots. */
    82133        delete_site_transient( 'theme_roots' );
    83134
     
    85136        if ( 'bp-sn-parent' == get_blog_option( BP_ROOT_BLOG, 'template' ) && 'bp-default' == get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) )
    86137                switch_theme( 'bp-default', 'bp-default' );
    87138
    88         /* Install site options on activation */
    89         //TODO: Find where to put this back. Here is no good because bp-core.php isn't loaded on new installation.
    90         //bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0,  'bp-disable-forum-directory' => 0,  'bp-disable-profile-sync' => 0 ) );
    91 
    92139        do_action( 'bp_loader_activate' );
    93140}
    94141register_activation_hook( 'buddypress/bp-loader.php', 'bp_loader_activate' );
  • bp-core.php

     
    15521552}
    15531553
    15541554/**
    1555  * bp_core_get_site_options()
    1556  *
    1557  * BuddyPress uses site options to store configuration settings. Many of these settings are needed
    1558  * at run time. Instead of fetching them all and adding many initial queries to each page load, let's fetch
    1559  * them all in one go.
    1560  *
    1561  * @package BuddyPress Core
    1562  */
    1563 function bp_core_get_site_options() {
    1564         global $bp, $wpdb;
    1565 
    1566         $options = apply_filters( 'bp_core_site_options', array(
    1567                 'bp-deactivated-components',
    1568                 'bp-blogs-first-install',
    1569                 'bp-disable-blog-forum-comments',
    1570                 'bp-xprofile-base-group-name',
    1571                 'bp-xprofile-fullname-field-name',
    1572                 'bp-disable-profile-sync',
    1573                 'bp-disable-avatar-uploads',
    1574                 'bp-disable-account-deletion',
    1575                 'bp-disable-forum-directory',
    1576                 'bp-disable-blogforum-comments',
    1577                 'bb-config-location',
    1578                 'hide-loggedout-adminbar',
    1579 
    1580                 /* Useful WordPress settings used often */
    1581                 'user-avatar-default',
    1582                 'tags_blog_id',
    1583                 'registration',
    1584                 'fileupload_maxk'
    1585         ) );
    1586 
    1587         $meta_keys = "'" . implode( "','", (array)$options ) ."'";
    1588 
    1589         if ( is_multisite() )
    1590                 $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
    1591         else
    1592                 $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
    1593 
    1594         $site_options = array();
    1595         if ( !empty( $meta ) ) {
    1596                 foreach( (array)$meta as $meta_item )
    1597                         $site_options[$meta_item->name] = $meta_item->value;
    1598         }
    1599 
    1600         return apply_filters( 'bp_core_get_site_options', $site_options );
    1601 }
    1602 
    1603 /**
    16041555 * bp_core_redirect()
    16051556 *
    16061557 * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
     
    19941945}
    19951946add_action( 'admin_notices', 'bp_core_activation_notice' );
    19961947
    1997 /**
    1998  * bp_core_activate_site_options()
    1999  *
    2000  * When switching from single to multisite we need to copy blog options to
    2001  * site options.
    2002  *
    2003  * @package BuddyPress Core
    2004  */
    2005 function bp_core_activate_site_options( $keys = array() ) {
    2006         global $bp;
    20071948
    2008         if ( !empty( $keys ) && is_array( $keys ) ) {
    2009                 $errors = false;
    2010 
    2011                 foreach ( $keys as $key => $default ) {
    2012                         if ( empty( $bp->site_options[ $key ] ) ) {
    2013                                 $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
    2014 
    2015                                 if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
    2016                                         $errors = true;
    2017                         }
    2018                 }
    2019 
    2020                 if ( empty( $errors ) )
    2021                         return true;
    2022         }
    2023 
    2024         return false;
    2025 }
    2026 
    20271949/********************************************************************************
    20281950 * Custom Actions
    20291951 *