Skip to:
Content

BuddyPress.org

Changeset 373 for trunk/bp-core.php


Ignore:
Timestamp:
10/07/2008 07:16:51 AM (18 years ago)
Author:
apeatling
Message:

Bug fixes:

  • Fixed group avatar upload issues
  • Fixed validation on group name/desc/news
  • Fixed support for https://
  • Base support for upcoming home theme and widgets
  • Re-factored JS and CSS inclusion with wp_enqueue_script/styles
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r371 r373  
    11<?php
    2 
    3 /* Define the protocol to be used, change to https:// if on secure server. */
    4 define( 'PROTOCOL', 'http://' );
    5 
    62/* Define the current version number for checking if DB tables are up to date. */
    7 define( 'BP_CORE_VERSION', '0.2.4' );
     3define( 'BP_CORE_VERSION', '0.2.5' );
    84
    95/* Require all needed files */
    10 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-catchuri.php' );
    11 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-classes.php' );
    12 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-cssjs.php' );
    13 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-avatars.php' );
    14 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-templatetags.php' );
    15 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-adminbar.php' );
    16 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/admin-mods/bp-core-remove-blogtabs.php' );
    17 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/admin-mods/bp-core-admin-styles.php' );
    18 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/homebase-creation/bp-core-homebase-functions.php' );
     6require_once( 'bp-core/bp-core-catchuri.php' );
     7require_once( 'bp-core/bp-core-classes.php' );
     8require_once( 'bp-core/bp-core-cssjs.php' );
     9require_once( 'bp-core/bp-core-avatars.php' );
     10require_once( 'bp-core/bp-core-templatetags.php' );
     11require_once( 'bp-core/bp-core-adminbar.php' );
     12require_once( 'bp-core/bp-core-widgets.php' );
     13require_once( 'bp-core/bp-core-ajax.php' );
     14require_once( 'bp-core/admin-mods/bp-core-remove-blogtabs.php' );
     15require_once( 'bp-core/admin-mods/bp-core-admin-styles.php' );
     16require_once( 'bp-core/homebase-creation/bp-core-homebase-functions.php' );
     17
    1918
    2019/**
     
    102101        $bp['is_item_admin'] = bp_is_home();
    103102
     103        $bp['core'] = array(
     104                'image_base' => site_url() . '/wp-content/mu-plugins/bp-core/images',
     105        );
     106
     107
    104108        if ( !$bp['current_component'] )
    105109                $bp['current_component'] = $bp['default_component'];
     
    194198        global $current_blog;
    195199       
    196         if ( VHOST == 'yes' ) {
    197                 $current_domain = PROTOCOL . $current_blog->domain . '/';
    198         } else {
    199                 $current_domain = get_bloginfo('wpurl') . '/';
    200         }
    201        
    202         return $current_domain;
     200        return get_blog_option( $current_blog->blog_id, 'siteurl' ) . '/';
    203201}
    204202
     
    273271 * @return false if no, or true if yes.
    274272 */
    275 function bp_core_user_has_home() {
     273function bp_core_user_has_home( $user_id = false ) {
    276274        global $bp;
    277275
    278         if ( $bp['loggedin_homebase_id'] == '' )
    279                 return false;
    280        
    281         return true;
     276        if ( !$user_id ) {
     277                if ( $bp['loggedin_homebase_id'] == '' )
     278                        return false;
     279
     280                return $bp['loggedin_homebase_id'];
     281        } else {
     282                return get_usermeta( $user_id, 'home_base' );
     283        }
    282284}
    283285
     
    964966        // array of time period chunks
    965967        $chunks = array(
    966         array( 60 * 60 * 24 * 365 , 'year' ),
    967         array( 60 * 60 * 24 * 30 , 'month' ),
    968         array( 60 * 60 * 24 * 7, 'week' ),
    969         array( 60 * 60 * 24 , 'day' ),
    970         array( 60 * 60 , 'hour' ),
    971         array( 60 , 'minute' ),
     968        array( 60 * 60 * 24 * 365 , __('year') ),
     969        array( 60 * 60 * 24 * 30 , __('month') ),
     970        array( 60 * 60 * 24 * 7, __('week') ),
     971        array( 60 * 60 * 24 , __('day') ),
     972        array( 60 * 60 , __('hour') ),
     973        array( 60 , __('minute') ),
     974        array( 1, __('second') )
    972975        );
    973976
     
    10031006                $seconds2 = $chunks[$i + 1][0];
    10041007                $name2 = $chunks[$i + 1][1];
     1008               
     1009                if ( $name2 == __('second') ) return $output;
    10051010       
    10061011                if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
     
    10181023 * Record user activity to the database. Many functions use a "last active" feature to
    10191024 * show the length of time since the user was last active.
    1020  * This function will update that time as a usermeta setting for the user.
     1025 * This function will update that time as a usermeta setting for the user every 5 minutes.
    10211026 *
    10221027 * @package BuddyPress Core
     
    10251030 */
    10261031function bp_core_record_activity() {
    1027         global $userdata;
    1028        
    1029         // Updated last site activity for this user.
    1030         update_usermeta( $userdata->ID, 'last_activity', time() );
    1031 }
    1032 add_action( 'login_head', 'bp_core_record_activity' );
     1032        global $bp;
     1033       
     1034        if ( !is_user_logged_in() )
     1035                return false;
     1036       
     1037        if ( time() >= strtotime('+5 minutes', get_usermeta( $bp['loggedin_userid'], 'last_activity') ) || get_usermeta( $bp['loggedin_userid'], 'last_activity') == '' ) {
     1038                // Updated last site activity for this user.
     1039                update_usermeta( $bp['loggedin_userid'], 'last_activity', time() );
     1040        }
     1041}
     1042add_action( 'wp_head', 'bp_core_record_activity' );
     1043
     1044
     1045/**
     1046 * bp_core_get_last_activity()
     1047 *
     1048 * Formats last activity based on time since date given.
     1049 *
     1050 * @package BuddyPress Core
     1051 * @param last_activity_date The date of last activity.
     1052 * @param $before The text to prepend to the activity time since figure.
     1053 * @param $after The text to append to the activity time since figure.
     1054 * @uses bp_core_time_since() This function will return an English representation of the time elapsed.
     1055 */
     1056function bp_core_get_last_activity( $last_activity_date, $before, $after ) {
     1057        if ( !$last_activity_date || $last_activity_date == '' ) {
     1058                $last_active = __('not recently active');
     1059        } else {
     1060                $last_active = $before;
     1061               
     1062                if ( strstr( $last_activity_date, '-' ) ) {
     1063                        $last_active .= bp_core_time_since( strtotime( $last_activity_date ) );
     1064                } else {
     1065                        $last_active .= bp_core_time_since( $last_activity_date );
     1066                }
     1067               
     1068                $last_active .= $after;
     1069        }
     1070       
     1071        return $last_active;
     1072}
    10331073
    10341074/**
     
    11301170        return $new_nav;
    11311171}
     1172
     1173function bp_core_remove_data( $user_id ) {
     1174        /* When the user is deleted, we must automatically delete their home base blog */
     1175        if ( $home_base_id = bp_core_user_has_home($user_id) )
     1176                wpmu_delete_blog( $home_base_id, true );
     1177       
     1178        /* Remove usermeta */
     1179        delete_usermeta( $user_id, 'home_base' );
     1180        delete_usermeta( $user_id, 'last_activity' );
     1181}
     1182add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 );
     1183add_action( 'delete_user', 'bp_core_remove_data', 1 );
     1184
    11321185?>
Note: See TracChangeset for help on using the changeset viewer.