Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2012 06:50:12 AM (14 years ago)
Author:
johnjamesjacoby
Message:

See #4761:

  • More Credits changes...
  • Update contributor avatars and metadata.
  • Add update/activate redirection helpers.
  • Code improvements to updater.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-update.php

    r6436 r6579  
    1212
    1313/**
    14  * Compare the BuddyPress version to the DB version to determine if updating
    15  *
    16  * @since BuddyPress (1.6)
     14 * If there is no raw DB version, this is the first installation
     15 *
     16 * @since BuddyPress (1.7)
    1717 *
    1818 * @uses get_option()
     
    2020 * @return bool True if update, False if not
    2121 */
     22function bp_is_install() {
     23        return ! bp_get_db_version_raw();
     24}
     25
     26/**
     27 * Compare the BuddyPress version to the DB version to determine if updating
     28 *
     29 * @since BuddyPress (1.6)
     30 *
     31 * @uses get_option()
     32 * @uses bp_get_db_version() To get BuddyPress's database version
     33 * @return bool True if update, False if not
     34 */
    2235function bp_is_update() {
    2336
     
    4255 */
    4356function bp_is_activation( $basename = '' ) {
    44         $bp = buddypress();
    45 
     57        $bp     = buddypress();
    4658        $action = false;
    47         if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) )
     59
     60        if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) ) {
    4861                $action = $_REQUEST['action'];
    49         elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) )
     62        } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) ) {
    5063                $action = $_REQUEST['action2'];
     64        }
    5165
    5266        // Bail if not activating
    53         if ( empty( $action ) || !in_array( $action, array( 'activate', 'activate-selected' ) ) )
    54                 return false;
     67        if ( empty( $action ) || !in_array( $action, array( 'activate', 'activate-selected' ) ) ) {
     68                return false;
     69        }
    5570
    5671        // The plugin(s) being activated
    57         if ( $action == 'activate' )
     72        if ( $action == 'activate' ) {
    5873                $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
    59         else
     74        } else {
    6075                $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
     76        }
    6177
    6278        // Set basename if empty
    63         if ( empty( $basename ) && !empty( $bp->basename ) )
     79        if ( empty( $basename ) && !empty( $bp->basename ) ) {
    6480                $basename = $bp->basename;
     81        }
    6582
    6683        // Bail if no basename
    67         if ( empty( $basename ) )
    68                 return false;
     84        if ( empty( $basename ) ) {
     85                return false;
     86        }
    6987
    7088        // Is BuddyPress being activated?
     
    8199 */
    82100function bp_is_deactivation( $basename = '' ) {
    83         $bp = buddypress();
    84 
     101        $bp     = buddypress();
    85102        $action = false;
    86         if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) )
     103
     104        if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) ) {
    87105                $action = $_REQUEST['action'];
    88         elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) )
     106        } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) ) {
    89107                $action = $_REQUEST['action2'];
     108        }
    90109
    91110        // Bail if not deactivating
    92         if ( empty( $action ) || !in_array( $action, array( 'deactivate', 'deactivate-selected' ) ) )
    93                 return false;
     111        if ( empty( $action ) || !in_array( $action, array( 'deactivate', 'deactivate-selected' ) ) ) {
     112                return false;
     113        }
    94114
    95115        // The plugin(s) being deactivated
    96         if ( $action == 'deactivate' )
     116        if ( 'deactivate' == $action ) {
    97117                $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
    98         else
     118        } else {
    99119                $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
     120        }
    100121
    101122        // Set basename if empty
    102         if ( empty( $basename ) && !empty( $bp->basename ) )
     123        if ( empty( $basename ) && !empty( $bp->basename ) ) {
    103124                $basename = $bp->basename;
     125        }
    104126
    105127        // Bail if no basename
    106         if ( empty( $basename ) )
    107                 return false;
     128        if ( empty( $basename ) ) {
     129                return false;
     130        }
    108131
    109132        // Is bbPress being deactivated?
     
    135158
    136159        // Are we running an outdated version of BuddyPress?
    137         if ( bp_is_update() ) {
    138 
    139                 // Bump the version
    140                 bp_version_bump();
    141 
    142                 // Run the deactivation function to wipe roles, caps, and rewrite rules
    143                 bp_deactivation();
    144 
    145                 // Run the activation function to reset roles, caps, and rewrite rules
    146                 bp_activation();
    147         }
     160        if ( ! bp_is_update() )
     161                return;
     162       
     163        bp_version_updater();
     164}
     165
     166/**
     167 * bbPress's version updater looks at what the current database version is, and
     168 * runs whatever other code is needed.
     169 *
     170 * This is most-often used when the data schema changes, but should also be used
     171 * to correct issues with bbPress meta-data silently on software update.
     172 *
     173 * @since bbPress (r4104)
     174 */
     175function bp_version_updater() {
     176
     177        // Get the raw database version
     178        $raw_db_version = (int) bp_get_db_version_raw();
     179
     180        /** 1.6 Branch ************************************************************/
     181
     182        // 1.6
     183        if ( $raw_db_version < 6067 ) {
     184                // Do nothing
     185        }
     186
     187        /** All done! *************************************************************/
     188
     189        // Bump the version
     190        bp_version_bump();
     191}
     192
     193/**
     194 * Redirect user to BuddyPress's What's New page on activation
     195 *
     196 * @since BuddyPress (1.7)
     197 *
     198 * @internal Used internally to redirect BuddyPress to the about page on activation
     199 *
     200 * @uses set_transient() To drop the activation transient for 30 seconds
     201 *
     202 * @return If bulk activation
     203 */
     204function bp_add_activation_redirect() {
     205
     206        // Bail if activating from network, or bulk
     207        if ( isset( $_GET['activate-multi'] ) )
     208                return;
     209
     210        // Add the transient to redirect
     211    set_transient( '_bp_activation_redirect', true, 30 );
    148212}
    149213
Note: See TracChangeset for help on using the changeset viewer.