Skip to:
Content

BuddyPress.org

Changeset 304


Ignore:
Timestamp:
08/22/2008 04:20:04 AM (17 years ago)
Author:
apeatling
Message:

Brought most core functions under the bp_core_ naming convention
Added extensive function commenting for the core component.
Updated other components to support changes to core function names

Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core.php

    r256 r304  
    11<?php
    22
     3/* Define the protocol to be used, change to https:// if on secure server. */
    34define( 'PROTOCOL', 'http://' );
     5
     6/* Define the current version number for checking if DB tables are up to date. */
    47define( 'BP_CORE_VERSION', '0.2.3' );
    58
     9/* Require all needed files */
    610require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-catchuri.php' );
    711require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-classes.php' );
     
    1216require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-templatetags.php' );
    1317
     18/* If disable blog tab option is set, don't combine blog tabs by skipping blogtab file */
    1419if ( !get_site_option('bp_disable_blog_tab') ) {
    1520    include_once(ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-blogtab.php');
    1621}
    1722
    18 if ( isset($_POST['submit']) && $_POST['save_admin_settings'] ) {
    19     save_admin_settings();
     23/* If admin settings have been posted, redirect to correct function to save settings */
     24if ( isset($_POST['submit']) && $_POST['save_admin_settings'] && is_site_admin() ) {
     25    bp_core_save_admin_settings();
    2026}
    2127
     
    2632 * them in a $bp variable.
    2733 *
    28  * @package BuddyPress
    29  * @uses $current_user A WordPress global containing current user information
    30  * @uses $current_component Which is set up in /bp-core/bp-core-catch-uri.php
    31  * @uses $current_action Which is set up in /bp-core/bp-core-catch-uri.php
    32  * @uses $action_variables Which is set up in /bp-core/bp-core-catch-uri.php
     34 * @package BuddyPress Core Core
     35 * @global $current_user A WordPress global containing current user information
     36 * @global $current_component Which is set up in /bp-core/bp-core-catch-uri.php
     37 * @global $current_action Which is set up in /bp-core/bp-core-catch-uri.php
     38 * @global $action_variables Which is set up in /bp-core/bp-core-catch-uri.php
    3339 * @uses bp_core_get_loggedin_domain() Returns the domain for the logged in user
    3440 * @uses bp_core_get_current_domain() Returns the domain for the current user being viewed
     
    7884        'bp_options_avatar' => '',
    7985       
    80         /* Sets up container for callback messages rendered by bp_render_notice() */
     86        /* Sets up container for callback messages rendered by bp_core_render_notice() */
    8187        'message'           => '',
    8288       
    83         /* Sets up container for callback message type rendered by bp_render_notice() */
     89        /* Sets up container for callback message type rendered by bp_core_render_notice() */
    8490        'message_type'      => '' // error/success
    8591    );
     
    96102 * profile other than that of the current logged in user.
    97103 *
    98  * @package BuddyPress
    99  * @uses $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    100  * @uses bp_is_blog() Checks to see current page is a blog page eg: /blog/ or /archives/2008/09/01/
     104 * @package BuddyPress Core
     105 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     106 * @uses bp_core_is_blog() Checks to see current page is a blog page eg: /blog/ or /archives/2008/09/01/
    101107 * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user
    102108 */
     
    126132        }
    127133    /* If we are on a blog specific page, always set the current component to Blog */
    128     } else if ( bp_is_blog() ) {
     134    } else if ( bp_core_is_blog() ) {
    129135        $bp['current_component'] = 'blog';
    130136    }
     
    146152        } else {
    147153            /* If we are not viewing the logged in user, set up the current users avatar and name */
    148             $bp['bp_options_avatar'] = core_get_avatar( $bp['current_userid'], 1 );
     154            $bp['bp_options_avatar'] = bp_core_get_avatar( $bp['current_userid'], 1 );
    149155            $bp['bp_options_title'] = bp_user_fullname( $bp['current_userid'], false );
    150156        }
     
    159165 * eg: http://andy.domain.com/ or http://domain.com/andy/
    160166 *
    161  * @package BuddyPress
    162  * @uses $current_user WordPress global variable containing current logged in user information
    163  * @uses bp_is_blog() Checks to see current page is a blog page eg: /blog/ or /archives/2008/09/01/
     167 * @package BuddyPress Core
     168 * @global $current_user WordPress global variable containing current logged in user information
     169 * @uses bp_core_is_blog() Checks to see current page is a blog page eg: /blog/ or /archives/2008/09/01/
    164170 * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user
    165171 */
     
    182188 * eg: http://andy.domain.com/ or http://domain.com/andy/
    183189 *
    184  * @package BuddyPress
    185  * @uses $current_blog WordPress global variable containing information for the current blog being viewed.
     190 * @package BuddyPress Core
     191 * @global $current_blog WordPress global variable containing information for the current blog being viewed.
    186192 * @uses get_bloginfo() WordPress function to return the value of a blog setting based on param passed
     193 * @return $current_domain The domain for the user that is currently being viewed.
    187194 */
    188195function bp_core_get_current_domain() {
     
    198205}
    199206
     207/**
     208 * bp_core_get_current_userid()
     209 *
     210 * Returns the user id for the user that is currently being viewed.
     211 * eg: http://andy.domain.com/ or http://domain.com/andy/
     212 *
     213 * @package BuddyPress Core
     214 * @uses bp_core_get_primary_username() Returns the username based on http:// [username] .site.com OR http://site.com/ [username]
     215 * @uses bp_core_get_userid() Returns the user id for the username given.
     216 * @return $current_userid The user id for the user that is currently being viewed.
     217 */
    200218function bp_core_get_current_userid() {
    201219    $siteuser = bp_core_get_primary_username();
     
    205223}
    206224
     225/**
     226 * bp_core_get_primary_username()
     227 *
     228 * Returns the username based on http:// [username] .site.com OR http://site.com/ [username]
     229 *
     230 * @package BuddyPress Core
     231 * @global $current_blog WordPress global containing information and settings for the current blog
     232 * @return $siteuser Username for current blog or user home.
     233 */
    207234function bp_core_get_primary_username() {
    208235    global $current_blog;
     
    218245}
    219246
    220 function start_buffer() {
     247/**
     248 * bp_core_start_buffer()
     249 *
     250 * Start the output buffer to replace content not easily accessible.
     251 *
     252 * @package BuddyPress Core
     253 */
     254function bp_core_start_buffer() {
    221255    ob_start();
    222     add_action( 'dashmenu', 'stop_buffer' );
     256    add_action( 'dashmenu', 'bp_core_stop_buffer' );
    223257}
    224 add_action( 'admin_menu', 'start_buffer' );
    225 
    226 function stop_buffer() {
     258add_action( 'admin_menu', 'bp_core_start_buffer' );
     259
     260/**
     261 * bp_core_stop_buffer()
     262 *
     263 * Stop the output buffer to replace content not easily accessible.
     264 *
     265 * @package BuddyPress Core
     266 */
     267function bp_core_stop_buffer() {
    227268    $contents = ob_get_contents();
    228269    ob_end_clean();
    229     buddypress_blog_switcher( $contents );
    230 }
    231 
    232 function buddypress_blog_switcher( $contents ) {
     270    bp_core__blog_switcher( $contents );
     271}
     272
     273/**
     274 * bp_core_blog_switcher()
     275 *
     276 * Replaces the standard blog switcher included in the WordPress core so that
     277 * BuddyPress specific icons can be used in tabs and the order can be changed.
     278 * An output buffer is used, as the function cannot be overridden or replaced
     279 * any other way.
     280 *
     281 * @package BuddyPress Core
     282 * @param $contents str The contents of the buffer.
     283 * @global $current_user obj WordPress global containing information and settings for the current user
     284 * @global $blog_id int WordPress global containing the current blog id
     285 * @return $siteuser Username for current blog or user home.
     286 */
     287function bp_core_blog_switcher( $contents ) {
    233288    global $current_user, $blog_id; // current blog
    234289   
    235     // This code is duplicated from the MU core so it can
    236     // be modified for BuddyPress.
     290    /* Code duplicated from wp-admin/includes/mu.php */
     291    /* function blogswitch_markup() */
    237292   
    238293    $filter = preg_split( '/\<ul id=\"dashmenu\"\>[\S\s]/', $contents );
     
    323378}
    324379
    325 function add_settings_tab() {
    326     add_submenu_page( 'wpmu-admin.php', "BuddyPress", "BuddyPress", 1, basename(__FILE__), "core_admin_settings" );
    327 }
    328 add_action( 'admin_menu', 'add_settings_tab' );
    329 
    330 
    331 function core_admin_settings() {
     380/**
     381 * bp_core_add_settings_tab()
     382 *
     383 * Adds a new submenu page under the Admin Settings tab for BuddyPress specific settings.
     384 *
     385 * @package BuddyPress Core
     386 * @param $add_submenu_pag str The contents of the buffer.
     387 * @uses add_submenu_page() WordPress function for adding submenu pages to existing admin area menus.
     388 */
     389function bp_core_add_settings_tab() {
     390    add_submenu_page( 'wpmu-admin.php', "BuddyPress", "BuddyPress", 1, basename(__FILE__), "bp_core_admin_settings" );
     391}
     392add_action( 'admin_menu', 'bp_core_add_settings_tab' );
     393
     394/**
     395 * bp_core_admin_settings()
     396 *
     397 * Renders the admin area settings for BuddyPress
     398 *
     399 * @package BuddyPress Core
     400 * @uses get_site_option() Fetches sitemeta based on setting name passed
     401 */
     402function bp_core_admin_settings() {
    332403    if ( get_site_option('bp_disable_blog_tab') ) {
    333404        $blog_tab_checked = ' checked="checked"';
     
    370441}
    371442
    372 function save_admin_settings() {
     443/**
     444 * bp_core_save_admin_settings()
     445 *
     446 * Saves the administration settings once the admin settings form has been posted.
     447 * Checks first to see if the current user is a site administrator.
     448 *
     449 * @package BuddyPress Core
     450 * @param $contents str The contents of the buffer.
     451 * @uses is_site_admin() WordPress function to check if current user has site admin privileges.
     452 * @uses add_site_option() WordPress function to add or update sitemeta based on passed meta name.
     453 */
     454function bp_core_save_admin_settings() {
     455    if ( !is_site_admin() )
     456        return false;
     457
    373458    if ( !isset($_POST['disable_blog_tab']) ) {
    374459        $_POST['disable_blog_tab'] = 0;
     
    434519// }
    435520
     521/**
     522 * bp_core_get_userid()
     523 *
     524 * Returns the user_id for a user based on their username.
     525 *
     526 * @package BuddyPress Core
     527 * @param $username str Username to check.
     528 * @global $wpdb WordPress DB access object.
     529 * @return false on no match
     530 * @return int the user ID of the matched user.
     531 */
    436532function bp_core_get_userid( $username ) {
    437533    global $wpdb;
     534   
    438535    $sql = $wpdb->prepare( "SELECT ID FROM " . $wpdb->base_prefix . "users WHERE user_login = %s", $username );
    439536    return $wpdb->get_var($sql);
    440537}
    441538
     539/**
     540 * bp_core_get_username()
     541 *
     542 * Returns the username for a user based on their user id.
     543 *
     544 * @package BuddyPress Core
     545 * @param $uid int User ID to check.
     546 * @global $userdata WordPress user data for the current logged in user.
     547 * @uses get_userdata() WordPress function to fetch the userdata for a user ID
     548 * @return false on no match
     549 * @return str the username of the matched user.
     550 */
    442551function bp_core_get_username( $uid ) {
    443552    global $userdata;
     
    446555        return 'You';
    447556   
    448     $ud = get_userdata($uid);
     557    if ( !$ud = get_userdata($uid) )
     558        return false;
     559       
    449560    return $ud->user_login;
    450561}
    451562
    452 function bp_core_get_blogdetails( $domain ) {
    453     global $wpdb;
    454     return $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->site WHERE domain = %s", $domain) );
    455 }
    456 
     563/**
     564 * bp_core_get_userurl()
     565 *
     566 * Returns the URL with no HTML markup for a user based on their user id.
     567 *
     568 * @package BuddyPress Core
     569 * @param $uid int User ID to check.
     570 * @global $userdata WordPress user data for the current logged in user.
     571 * @uses get_userdata() WordPress function to fetch the userdata for a user ID
     572 * @return false on no match
     573 * @return str The URL for the user with no HTML formatting.
     574 */
    457575function bp_core_get_userurl( $uid ) {
    458576    global $userdata;
     
    467585    $url = PROTOCOL . $ud->source_domain . '/' . $ud->path;
    468586   
    469     if ( $url == PROTOCOL . '/' )
     587    if ( !$ud )
    470588        return false;
    471589   
     
    473591}
    474592
     593/**
     594 * bp_core_get_user_email()
     595 *
     596 * Returns the email address for the user based on user ID
     597 *
     598 * @package BuddyPress Core
     599 * @param $uid int User ID to check.
     600 * @uses get_userdata() WordPress function to fetch the userdata for a user ID
     601 * @return false on no match
     602 * @return str The email for the matched user.
     603 */
    475604function bp_core_get_user_email( $uid ) {
    476605    $ud = get_userdata($uid);
     
    478607}
    479608
     609/**
     610 * bp_core_get_userlink()
     611 *
     612 * Returns a HTML formatted link for a user with the user's full name as the link text.
     613 * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
     614 * Optional parameters will return just the name, or just the URL, or disable "You" text when
     615 * user matches the logged in user.
     616 *
     617 * [NOTES: This function needs to be cleaned up or split into separate functions]
     618 *
     619 * @package BuddyPress Core
     620 * @param $uid int User ID to check.
     621 * @param $no_anchor bool Disable URL and HTML and just return full name. Default false.
     622 * @param $just_link bool Disable full name and HTML and just return the URL text. Default false.
     623 * @param $no_you bool Disable replacing full name with "You" when logged in user is equal to the current user. Default false.
     624 * @global $userdata WordPress user data for the current logged in user.
     625 * @uses get_userdata() WordPress function to fetch the userdata for a user ID
     626 * @uses bp_user_fullname() Returns the full name for a user based on user ID.
     627 * @return false on no match
     628 * @return str The link text based on passed parameters.
     629 */
    480630function bp_core_get_userlink( $uid, $no_anchor = false, $just_link = false, $no_you = false ) {
    481631    global $userdata;
    482632   
    483633    $ud = get_userdata($uid);
     634   
     635    if ( !$ud )
     636        return false;
    484637
    485638    if ( function_exists('bp_user_fullname') )
     
    505658}
    506659
    507 function bp_core_clean( $dirty ) {
    508     if ( get_magic_quotes_gpc() ) {
    509         $clean = mysql_real_escape_string( stripslashes( $dirty ) );
    510     } else {
    511         $clean = mysql_real_escape_string( $dirty );
    512     }
    513    
    514     return $clean;
    515 }
    516 
    517 function bp_core_truncate( $text, $numb ) {
    518     $text = html_entity_decode( $text, ENT_QUOTES );
    519    
    520     if ( strlen($text) > $numb ) {
    521         $text = substr( $text, 0, $numb );
    522         $text = substr( $text, 0, strrpos( $text, " " ) );
    523         $etc  = " ...";
    524         $text = $text . $etc;
    525     }
    526    
    527     $text = htmlentities( $text, ENT_QUOTES );
    528    
    529     return $text;
    530 }
    531 
    532 function bp_core_validate( $num ) {
    533     if( !is_numeric($num) ) {
    534         return false;
    535     }
    536    
    537     return true;
    538 }
    539 
    540 function bp_format_time( $time, $just_date = false ) {
     660/**
     661 * bp_core_get_user_email()
     662 *
     663 * Returns the email address for the user based on user ID
     664 *
     665 * @package BuddyPress Core
     666 * @param $uid int User ID to check.
     667 * @uses get_userdata() WordPress function to fetch the userdata for a user ID
     668 * @return false on no match
     669 * @return str The email for the matched user.
     670 */
     671function bp_core_format_time( $time, $just_date = false ) {
    541672    $date = date( "F j, Y ", $time );
    542673   
     
    548679}
    549680
    550 function bp_endkey( $array ) {
    551     end( $array );
    552     return key( $array );
    553 }
    554 
    555 function bp_get_homeurl() {
    556     return get_blogaddress_by_id( 0 );
    557 }
    558 
     681/**
     682 * bp_create_excerpt()
     683 *
     684 * Fakes an excerpt on any content. Will not truncate words.
     685 *
     686 * @package BuddyPress Core
     687 * @param $text str The text to create the excerpt from
     688 * @uses $excerpt_length The maximum length in characters of the excerpt.
     689 * @return str The excerpt text
     690 */
    559691function bp_create_excerpt( $text, $excerpt_length = 55 ) { // Fakes an excerpt if needed
    560692    $text = str_replace(']]>', ']]&gt;', $text);
     
    570702}
    571703
     704/**
     705 * bp_is_serialized()
     706 *
     707 * Checks to see if the data passed has been serialized.
     708 *
     709 * @package BuddyPress Core
     710 * @param $data str The data that will be checked
     711 * @return bool false if the data is not serialized
     712 * @return bool true if the data is serialized
     713 */
    572714function bp_is_serialized( $data ) {
    573715   if ( trim($data) == "" ) {
     
    582724}
    583725
     726/**
     727 * bp_upload_dir()
     728 *
     729 * This function will create an upload directory for a new user.
     730 * This is directly copied from WordPress so that the code can be
     731 * accessed on user activation *before* 'upload_path' is placed
     732 * into the options table for the user.
     733 *
     734 * FIX: A fix for this would be to add a hook for 'activate_footer'
     735 * in wp-activate.php
     736 *
     737 * @package BuddyPress Core
     738 * @param $time str? The time so that upload folders can be created for month and day.
     739 * @param $blog_id int The ID of the blog (or user in BP) to create the upload dir for.
     740 * @return array Containing path, url, subdirectory and error message (if applicable).
     741 */
    584742function bp_upload_dir( $time = NULL, $blog_id ) {
    585     // copied from wordpress, need to be able to create a users
    586     // upload dir on activation, before 'upload_path' is
    587     // placed into options table.
    588     // Fix for this would be adding a hook for 'activate_footer'
    589     // in wp-activate.php
    590 
    591743    $siteurl = get_option( 'siteurl' );
    592744    $upload_path = 'wp-content/blogs.dir/' . $blog_id . '/files';
     
    629781}
    630782
    631 function bp_get_page_id($page_title, $output = object) {
     783/**
     784 * bp_get_page_id()
     785 *
     786 * This function will return the ID of a page based on the page title.
     787 *
     788 * @package BuddyPress Core
     789 * @param $page_title str Title of the page
     790 * @global $wpdb WordPress DB access object
     791 * @return int The page ID
     792 * @return bool false on no match.
     793 */
     794function bp_get_page_id($page_title) {
    632795    global $wpdb;
    633    
    634     $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'page'", $page_title);
    635     $page = $wpdb->get_var($sql);
    636    
    637     if ( $page )
    638         return $page;
    639 
    640     return null;
    641 }
    642 
    643 function bp_is_blog() {
    644     global $bp, $wp_query, $cached_page_id;
     796
     797    return $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = 'page'", $page_title) );
     798}
     799
     800/**
     801 * bp_core_is_blog()
     802 *
     803 * Checks to see if the current page is part of the blog.
     804 * Some example blog pages:
     805 *   - Single post, Archives, Categories, Tags, Pages, Blog Home, Search Results ...
     806 *
     807 * @package BuddyPress Core
     808 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     809 * @global $cached_page_id The page id of the current page if cached
     810 * @uses is_tag() WordPress function to check if on tags page
     811 * @uses is_category() WordPress function to check if on category page
     812 * @uses is_day() WordPress function to check if on day page
     813 * @uses is_month() WordPress function to check if on month page
     814 * @uses is_year() WordPress function to check if on year page
     815 * @uses is_paged() WordPress function to check if on page
     816 * @uses is_single() WordPress function to check if on single post page
     817 * @return bool true if
     818 * @return bool false on no match.
     819 */
     820function bp_core_is_blog() {
     821    global $bp, $cached_page_id;
    645822   
    646823    $blog_page_id = bp_get_page_id('Blog');
    647824    if ( is_tag() || is_category() || is_day() || is_month() || is_year() || is_paged() || is_single() )
    648825        return true;
    649     if ( isset($cached_page_id) && ($blog_page_id == $cached_page_id ) )
     826    if ( isset($cached_page_id) && ( $blog_page_id == $cached_page_id ) )
    650827        return true;
    651828    if ( is_page('Blog') )
     
    657834}
    658835
    659 function bp_render_notice( ) {
     836/**
     837 * bp_core_render_notice()
     838 *
     839 * Renders a feedback notice (either error or success message) to the theme template.
     840 * The hook action 'template_notices' is used to call this function, it is not called directly.
     841 * The message and message type are stored in the $bp global, and are set up right before
     842 * the add_action( 'template_notices', 'bp_core_render_notice' ); is called where needed.
     843 *
     844 * @package BuddyPress Core
     845 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     846 */
     847function bp_core_render_notice() {
    660848    global $bp;
    661849
     
    670858}
    671859
    672 function bp_time_since( $older_date, $newer_date = false ) {
     860/**
     861 * bp_core_time_since()
     862 *
     863 * Based on function created by Dunstan Orchard - http://1976design.com
     864 *
     865 * This function will return an English representation of the time elapsed
     866 * since a given date.
     867 * eg: 2 hours and 50 minutes
     868 * eg: 4 days
     869 * eg: 4 weeks and 6 days
     870 *
     871 * @package BuddyPress Core
     872 * @param $older_date int Unix timestamp of date you want to calculate the time since for
     873 * @param $newer_date int Unix timestamp of date to compare older date to. Default false (current time).
     874 * @return str The time since.
     875 */
     876function bp_core_time_since( $older_date, $newer_date = false ) {
    673877    // array of time period chunks
    674878    $chunks = array(
     
    681885    );
    682886
    683     // $newer_date will equal false if we want to know the time elapsed between a date and the current time
    684     // $newer_date will have a value if we want to work out time elapsed between two known dates
     887    /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
     888    /* $newer_date will have a value if we want to work out time elapsed between two known dates */
    685889    $newer_date = ( $newer_date == false ) ? ( time() + ( 60*60*0 ) ) : $newer_date;
    686890
    687     // difference in seconds
     891    /* Difference in seconds */
    688892    $since = $newer_date - $older_date;
    689893
    690     // we only want to output two chunks of time here, eg:
    691     // x years, xx months
    692     // x days, xx hours
    693     // so there's only two bits of calculation below:
    694 
    695     // step one: the first chunk
     894    /**
     895     * We only want to output two chunks of time here, eg:
     896     * x years, xx months
     897     * x days, xx hours
     898     * so there's only two bits of calculation below:
     899     */
     900
     901    /* Step one: the first chunk */
    696902    for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
    697903        $seconds = $chunks[$i][0];
    698904        $name = $chunks[$i][1];
    699905
    700         // finding the biggest chunk (if the chunk fits, break)
     906        /* Finding the biggest chunk (if the chunk fits, break) */
    701907        if ( ( $count = floor($since / $seconds) ) != 0 )
    702908            break;
    703909    }
    704910
    705     // set output var
     911    /* Set output var */
    706912    $output = ( $count == 1 ) ? '1 '. $name : "$count {$name}s";
    707913
    708     // step two: the second chunk
     914    /* Step two: the second chunk */
    709915    if ( $i + 1 < $j ) {
    710916        $seconds2 = $chunks[$i + 1][0];
     
    712918   
    713919        if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
    714             // add to output var
     920            /* Add to output var */
    715921            $output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
    716922        }
     
    720926}
    721927
     928/**
     929 * bp_core_record_activity()
     930 *
     931 * Record user activity to the database. Many functions use a "last active" feature to
     932 * show the length of time since the user was last active.
     933 * This function will update that time as a usermeta setting for the user.
     934 *
     935 * @package BuddyPress Core
     936 * @global $userdata WordPress user data for the current logged in user.
     937 * @uses update_usermeta() WordPress function to update user metadata in the usermeta table.
     938 */
    722939function bp_core_record_activity() {
    723940    global $userdata;
  • trunk/bp-core/bp-core-avatars.php

    r256 r304  
    11<?php
    22/*
    3 Contributor: Beau Lebens - http://www.dentedreality.com.au/
    4 Modified By: Andy Peatling
     3Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/
     4Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
    55*/
    66
     7/* Make sure we have the core WordPress files we need */
    78require_once( ABSPATH . '/wp-admin/includes/image.php' );
    89require_once( ABSPATH . '/wp-admin/includes/file.php' );
    910
     11/* Define settings for avatars. [TODO] This will eventually end up as admin configurable settings */
    1012define( 'CORE_AVATAR_V1_W', 50 );
    1113define( 'CORE_AVATAR_V1_H', 50 );
     
    1618define( 'CORE_DEFAULT_AVATAR', get_option('siteurl') . '/wp-content/mu-plugins/bp-xprofile/images/none.gif' );
    1719
    18 function core_get_avatar( $user, $version = 1, $in_css = false ) {
     20/**
     21 * bp_core_blog_switcher()
     22 *
     23 * Replaces the standard blog switcher included in the WordPress core so that
     24 * BuddyPress specific icons can be used in tabs and the order can be changed.
     25 * An output buffer is used, as the function cannot be overridden or replaced
     26 * any other way.
     27 *
     28 * @package BuddyPress Core
     29 * @param $contents str The contents of the buffer.
     30 * @global $current_user obj WordPress global containing information and settings for the current user
     31 * @global $blog_id int WordPress global containing the current blog id
     32 * @return $siteuser Username for current blog or user home.
     33 */
     34function bp_core_get_avatar( $user, $version = 1, $in_css = false ) {
    1935    if ( !is_int($version) )
    2036        $version = (int) $version;
     
    2339        $version = 1;
    2440   
    25     $str = get_usermeta( $user, "core_avatar_v$version" );
     41    $str = get_usermeta( $user, "bp_core_avatar_v$version" );
    2642   
    2743    if ( strlen($str) ) {
     
    4561// // Override internal "get_avatar()" function to use our own where possible
    4662// // WARNING: Does NOT apply size restrictions
    47 // function core_get_avatar_filter( $avatar, $id_or_email, $size, $default ) {
     63// function bp_core_get_avatar_filter( $avatar, $id_or_email, $size, $default ) {
    4864//  $str = '';
    4965//  $ver = ( $size == 1 || $size == 2 ) ? $size : 1;
     
    5369//     
    5470//  if ( is_numeric($id_or_email) ) {
    55 //      $str = core_get_avatar( $id_or_email, $ver );
     71//      $str = bp_core_get_avatar( $id_or_email, $ver );
    5672//  } elseif ( is_object($id_or_email) ) {
    5773//      if ( !empty($id_or_email->user_id) ) {
    58 //          $str = core_get_avatar( $id_or_email->user_id, $ver );
     74//          $str = bp_core_get_avatar( $id_or_email->user_id, $ver );
    5975//      }
    6076//  }
     
    6278//  return empty($str) ? $avatar : $str;
    6379// }
    64 // add_filter( 'get_avatar', 'core_get_avatar_filter', 10, 4 );
     80// add_filter( 'get_avatar', 'bp_core_get_avatar_filter', 10, 4 );
    6581
    6682
    6783// Main UI Rendering
    68 function core_avatar_admin($message = null, $action = null) {
     84function bp_core_avatar_admin($message = null, $action = null) {
    6985    ?> 
    7086    <?php if ( !isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action']) ) { ?>
     
    86102            $action = get_option('home') . '/wp-admin/admin.php?page=bp-xprofile.php';
    87103       
    88         core_render_avatar_upload_form($action);
    89 
    90         $str = core_get_avatar( get_current_user_id(), 1 );
     104        bp_core_render_avatar_upload_form($action);
     105
     106        $str = bp_core_get_avatar( get_current_user_id(), 1 );
    91107        if ( strlen($str) ) {
    92108            echo '<h3>' . __('This is your current avatar') . '</h3>';
    93             echo '<span class="crop-img avatar">' . core_get_avatar(get_current_user_id(), 1) . '</span>';
    94             echo '<span class="crop-img avatar">' . core_get_avatar(get_current_user_id(), 2) . '</span>';
     109            echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 1) . '</span>';
     110            echo '<span class="crop-img avatar">' . bp_core_get_avatar(get_current_user_id(), 2) . '</span>';
    95111            echo '<a href="' .  get_option('siteurl') . '/wp-admin/admin.php?page=bp-xprofile.php&slick_avatars_action=delete">Delete</a>';
    96112        }
     
    106122        // Confirm that the nonce is valid
    107123        if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars') )
    108             core_ap_die( 'Security error.' );
    109        
    110         if ( !core_check_avatar_upload($_FILES) )
    111             core_ap_die( 'Your upload failed, please try again.' );
    112        
    113         if ( !core_check_avatar_size($_FILES) )
    114             core_ap_die( 'The file you uploaded is too big. Please upload a file under ' . size_format(1024 * CORE_MAX_FILE_SIZE) );
    115 
    116         if ( !core_check_avatar_type($_FILES) )
    117             core_ap_die( 'Please upload only JPG, GIF or PNG photos.' );
     124            bp_core_ap_die( 'Security error.' );
     125       
     126        if ( !bp_core_check_avatar_upload($_FILES) )
     127            bp_core_ap_die( 'Your upload failed, please try again.' );
     128       
     129        if ( !bp_core_check_avatar_size($_FILES) )
     130            bp_core_ap_die( 'The file you uploaded is too big. Please upload a file under ' . size_format(1024 * CORE_MAX_FILE_SIZE) );
     131
     132        if ( !bp_core_check_avatar_type($_FILES) )
     133            bp_core_ap_die( 'Please upload only JPG, GIF or PNG photos.' );
    118134       
    119135        // "Handle" upload into temporary location
    120         if ( !$original = core_handle_avatar_upload($_FILES) )
    121             core_ap_die( 'Upload Failed! Your image is likely too big.' );
    122        
    123         if ( !core_check_avatar_dimensions($original) )
    124             core_ap_die( 'The image you upload must have dimensions of ' . CORE_CROPPING_CANVAS_MAX . " x " . CORE_CROPPING_CANVAS_MAX . " pixels or larger." );
     136        if ( !$original = bp_core_handle_avatar_upload($_FILES) )
     137            bp_core_ap_die( 'Upload Failed! Your image is likely too big.' );
     138       
     139        if ( !bp_core_check_avatar_dimensions($original) )
     140            bp_core_ap_die( 'The image you upload must have dimensions of ' . CORE_CROPPING_CANVAS_MAX . " x " . CORE_CROPPING_CANVAS_MAX . " pixels or larger." );
    125141       
    126142        // Resize down to something we can display on the page
    127         if ( !$canvas = core_resize_avatar($original) )
    128             core_ap_die('Could not create thumbnail.');
     143        if ( !$canvas = bp_core_resize_avatar($original) )
     144            bp_core_ap_die('Could not create thumbnail.');
    129145       
    130146        // Render the cropper UI
     
    132148            $action = get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php';
    133149       
    134         core_render_avatar_cropper($original, $canvas, $action);
     150        bp_core_render_avatar_cropper($original, $canvas, $action);
    135151       
    136152        echo '</div>';
     
    141157        // Confirm that the nonce is valid
    142158        if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'slick_avatars') )
    143             core_ap_die( 'Security error.' );
    144        
    145         if ( !core_check_crop( $_POST['orig'], $_POST['canvas'] ) )
    146             core_ap_die('Error when cropping, please go back and try again');
    147        
    148         if ( !$result = core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] ) )
    149             core_ap_die('Error when saving avatars, please go back and try again.');
     159            bp_core_ap_die( 'Security error.' );
     160       
     161        if ( !bp_core_check_crop( $_POST['orig'], $_POST['canvas'] ) )
     162            bp_core_ap_die('Error when cropping, please go back and try again');
     163       
     164        if ( !$result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] ) )
     165            bp_core_ap_die('Error when saving avatars, please go back and try again.');
    150166       
    151167        // Store details to the DB and we're done
     
    156172        echo '<p>' . __('Your new avatar was successfully created!') . '</p>';
    157173       
    158         core_avatar_save($result);
    159        
    160         echo '<span class="crop-img">' . core_get_avatar( get_current_user_id(), 1 ) . '</span>';
     174        bp_core_avatar_save($result);
     175       
     176        echo '<span class="crop-img">' . bp_core_get_avatar( get_current_user_id(), 1 ) . '</span>';
    161177       
    162178        if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) {
    163             echo '<span class="crop-img">' . core_get_avatar( get_current_user_id(), 2 ) . '</span>';
     179            echo '<span class="crop-img">' . bp_core_get_avatar( get_current_user_id(), 2 ) . '</span>';
    164180        }
    165181       
     
    168184        // Delete an avatar
    169185
    170         core_delete_avatar();
     186        bp_core_delete_avatar();
    171187       
    172188        unset($_GET['slick_avatars_action']);
    173189        $message = __('Avatar successfully removed.');
    174         core_avatar_admin($message);
     190        bp_core_avatar_admin($message);
    175191       
    176192    }
     
    179195}
    180196
    181 function core_check_avatar_upload($file) {
     197function bp_core_check_avatar_upload($file) {
    182198    if ( !isset($file['file']) || $file['file']['size'] == 0 )
    183199        return false;
     
    186202}
    187203
    188 function core_check_avatar_size($file) {
     204function bp_core_check_avatar_size($file) {
    189205    if ( $file['file']['size'] > CORE_MAX_FILE_SIZE )
    190206        return false;
     
    193209}
    194210
    195 function core_check_avatar_type($file) {
     211function bp_core_check_avatar_type($file) {
    196212    if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) )
    197213        return false;
     
    200216}
    201217
    202 function core_handle_avatar_upload($file) {
     218function bp_core_handle_avatar_upload($file) {
    203219    $res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') );
    204220    if ( !in_array('error', array_keys($res) ) ) {
     
    209225}
    210226
    211 function core_check_avatar_dimensions($file) {
     227function bp_core_check_avatar_dimensions($file) {
    212228    $size = getimagesize($file);
    213229   
     
    218234}
    219235
    220 function core_resize_avatar($file, $size = CORE_CROPPING_CANVAS_MAX) {
     236function bp_core_resize_avatar($file, $size = CORE_CROPPING_CANVAS_MAX) {
    221237    $canvas = wp_create_thumbnail( $file, $size);
    222238   
    223     if ( core_thumb_error($canvas) )
     239    if ( bp_core_thumb_error($canvas) )
    224240        return false;
    225241   
     
    227243}
    228244
    229 function core_render_avatar_cropper($original, $new, $action, $user_id = null, $no_form_tag = false) {
     245function bp_core_render_avatar_cropper($original, $new, $action, $user_id = null, $no_form_tag = false) {
    230246    $size = getimagesize($new);
    231247   
     
    319335}
    320336
    321 function core_check_crop( $original, $canvas ) {
     337function bp_core_check_crop( $original, $canvas ) {
    322338    if ( is_file($original) && is_readable($original) && is_file($canvas) && is_readable($canvas) )
    323339        return true;
     
    326342}
    327343
    328 function core_avatar_cropstore( $source, $canvas, $v1_x1, $v1_y1, $v1_w, $v1_h, $v2_x1, $v2_y1, $v2_w, $v2_h, $from_signup = false, $filename = 'avatar', $item_id = null ) {
     344function bp_core_avatar_cropstore( $source, $canvas, $v1_x1, $v1_y1, $v1_w, $v1_h, $v2_x1, $v2_y1, $v2_w, $v2_h, $from_signup = false, $filename = 'avatar', $item_id = null ) {
    329345    $size = getimagesize($source);
    330346    $dims = getimagesize($canvas);
     
    377393}
    378394
    379 function core_avatar_save( $vars, $user_id = false, $upload_dir = false ) {
     395function bp_core_avatar_save( $vars, $user_id = false, $upload_dir = false ) {
    380396    if ( !$user_id )
    381397        $user_id = get_current_user_id();
     
    387403    }
    388404   
    389     $old = get_usermeta( $user_id, 'core_avatar_v1_path' );
     405    $old = get_usermeta( $user_id, 'bp_core_avatar_v1_path' );
    390406    $v1_href = str_replace( array(ABSPATH), array($src), $vars['v1_out'] );
    391     update_usermeta( $user_id, 'core_avatar_v1', $v1_href );
    392     update_usermeta( $user_id, 'core_avatar_v1_path', $vars['v1_out'] );
     407    update_usermeta( $user_id, 'bp_core_avatar_v1', $v1_href );
     408    update_usermeta( $user_id, 'bp_core_avatar_v1_path', $vars['v1_out'] );
    393409    @unlink($old); // Removing old avatar
    394410   
    395411    if ( CORE_AVATAR_V2_W !== false && CORE_AVATAR_V2_H !== false ) {
    396         $old = get_usermeta( $user_id, 'core_avatar_v2_path' );
     412        $old = get_usermeta( $user_id, 'bp_core_avatar_v2_path' );
    397413        $v2_href = str_replace( array(ABSPATH), array($src), $vars['v2_out'] );
    398         update_usermeta( $user_id, 'core_avatar_v2', $v2_href );
    399         update_usermeta( $user_id, 'core_avatar_v2_path', $vars['v2_out'] );
     414        update_usermeta( $user_id, 'bp_core_avatar_v2', $v2_href );
     415        update_usermeta( $user_id, 'bp_core_avatar_v2_path', $vars['v2_out'] );
    400416        @unlink($old); // Removing old avatar
    401417    }
    402418}
    403419
    404 function core_render_avatar_upload_form($action, $no_form_tag = false) {
     420function bp_core_render_avatar_upload_form($action, $no_form_tag = false) {
    405421    if ( !$no_form_tag ) { ?>
    406422    <form method="post" action="<?php echo $action ?>" enctype="multipart/form-data">
     
    418434}
    419435
    420 function core_delete_avatar() {
    421     $old_v1 = get_usermeta( get_current_user_id(), 'core_avatar_v1_path' );
    422     $old_v2 = get_usermeta( get_current_user_id(), 'core_avatar_v2_path' );
    423    
    424     delete_usermeta( get_current_user_id(), 'core_avatar_v1_path' );
    425     delete_usermeta( get_current_user_id(), 'core_avatar_v2_path' );
    426    
    427     delete_usermeta( get_current_user_id(), 'core_avatar_v1' );
    428     delete_usermeta( get_current_user_id(), 'core_avatar_v2' );
     436function bp_core_delete_avatar() {
     437    $old_v1 = get_usermeta( get_current_user_id(), 'bp_core_avatar_v1_path' );
     438    $old_v2 = get_usermeta( get_current_user_id(), 'bp_core_avatar_v2_path' );
     439   
     440    delete_usermeta( get_current_user_id(), 'bp_core_avatar_v1_path' );
     441    delete_usermeta( get_current_user_id(), 'bp_core_avatar_v2_path' );
     442   
     443    delete_usermeta( get_current_user_id(), 'bp_core_avatar_v1' );
     444    delete_usermeta( get_current_user_id(), 'bp_core_avatar_v2' );
    429445   
    430446    // Remove the actual images
     
    433449}
    434450
    435 function core_ap_die( $msg ) {
     451function bp_core_ap_die( $msg ) {
    436452    echo '<p><strong>' . $msg . '</strong></p>';
    437453    echo '<p><a href="' . get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php">' . __('Try Again') . '</a></p>';
     
    440456}
    441457
    442 function core_thumb_error( $str ) {
     458function bp_core_thumb_error( $str ) {
    443459    if ( !is_string($str) ) {
    444460        return false;
     
    448464}
    449465
    450 function core_add_cropper_js() {
     466function bp_core_add_cropper_js() {
    451467    echo '<script type="text/javascript" src="' . get_option('home') . '/wp-includes/js/prototype.js"></script>';
    452468    echo '<script type="text/javascript" src="' . get_option('home') . '/wp-includes/js/scriptaculous/scriptaculous.js"></script>';
  • trunk/bp-core/bp-core-blogtab.php

    r33 r304  
    11<?php
    22
    3 function setup_blog_tab()  {
     3/**
     4 * bp_core_setup_blog_tab()
     5 *
     6 * Combines the "Write", "Manage", and "Comments" admin tabs into one "Blog" tab.
     7 *
     8 * @package BuddyPress Core
     9 * @global $menu WordPress admin navigation array global
     10 * @global $submenu WordPress admin sub navigation array global
     11 * @global $thirdlevel BuddyPress admin third level navigation
     12 * @uses add_menu_page() WordPress function to add a new top level admin navigation tab
     13 */
     14function bp_core_setup_blog_tab()  {
    415    global $menu, $submenu, $thirdlevel;
    516
     17    /* Unset the default secondary level tabs for the top level nav tabs */
    618    unset($submenu['post-new.php']);
    719    unset($submenu['edit.php']);
    820    unset($submenu['edit-comments.php']);
    921
     22    /* Move the top level tabs into the sub menu array */
    1023    $submenu['post-new.php'][20] = $menu[5]; // Write
    1124    $submenu['post-new.php'][25] = $menu[10]; // Manage
    1225    $submenu['post-new.php'][35] = $menu[20]; // Comments
    1326
     27    /* Unset the top level tabs */
    1428    unset($menu[5]); // Write
    1529    unset($menu[10]); // Manage
    1630    unset($menu[20]); // Comments
    1731
     32    /* Add a blog tab to the top level nav */
    1833    add_menu_page( 'Blog', 'Blog', 1, 'post-new.php' );
    1934
     35    /* Move the blog tab so it is the first tab in the top level nav */
    2036    foreach ( $menu as $key => $value ) {
    2137        if ( $menu[$key][0] == 'Blog' ) {
     
    2743    array_pop($menu);
    2844
     45    /* Bump secondary level nav for the old top level tabs down to a new third level navigation */
    2946    if ( strpos( $_SERVER['SCRIPT_NAME'], '/post-new.php' ) ||
    3047         strpos( $_SERVER['SCRIPT_NAME'], '/page-new.php' ) ||
     
    5976   
    6077}
    61 add_action( '_admin_menu', 'setup_blog_tab' );
     78add_action( '_admin_menu', 'bp_core_setup_blog_tab' );
    6279
    63 function alter_blog_tab_positions() {
     80/**
     81 * bp_core_alter_blog_tab_positions()
     82 *
     83 * Keeps a tab highlighted when selected and under the "Blog" tab.
     84 *
     85 * @package BuddyPress Core
     86 * @global $parent_file WordPress global for the name of the file controlling the parent tab
     87 * @global $submenu_file WordPress global for the name of the file controlling the sub parent tab
     88 */
     89function bp_core_alter_blog_tab_positions() {
    6490    global $parent_file, $submenu_file;
    6591   
     
    90116    }
    91117}
    92 add_action('admin_head', 'alter_blog_tab_positions');
     118add_action('admin_head', 'bp_core_alter_blog_tab_positions');
    93119
    94120
  • trunk/bp-core/bp-core-catchuri.php

    r194 r304  
    11<?php
    22/*
    3 Contributor: Chris Taylor - http://www.stillbreathing.co.uk/
    4 Modified By: Andy Peatling
     3Based on contributions from: Chris Taylor - http://www.stillbreathing.co.uk/
     4Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/
    55*/
    66
    7 /*************************************************************
    8   Functions for catching and displaying the right template pages
    9  *************************************************************/
    10 $component_index = 0;
    11 $action_index = 1;
     7/**
     8 * bp_core_set_uri_globals()
     9 *
     10 * Analyzes the URI structure and breaks it down into parts for use in code.
     11 * The idea is that BuddyPress can use complete custom friendly URI's without the
     12 * user having to add new re-write rules.
     13 *
     14 * Future custom components would then be able to use their own custom URI structure.
     15 *
     16 * The URI's are broken down as follows:
     17 *   - VHOST: http:// andy.domain.com / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
     18 *   - NO VHOST: http:// domain.com / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
     19 *
     20 * Example:
     21 *    - http://andy.domain.com/profile/edit/group/5/
     22 *    - $current_component: string 'profile'
     23 *    - $current_action: string 'edit'
     24 *    - $action_variables: array ['group', 5]
     25 *
     26 * @package BuddyPress Core
     27 * @global $menu WordPress admin navigation array global
     28 * @global $submenu WordPress admin sub navigation array global
     29 * @global $thirdlevel BuddyPress admin third level navigation
     30 * @uses add_menu_page() WordPress function to add a new top level admin navigation tab
     31 */
     32function bp_core_set_uri_globals() {
     33    global $current_component, $current_action, $action_variables;
     34   
     35    /* Set the indexes, these are incresed by one if we are not on a VHOST install */
     36    $component_index = 0;
     37    $action_index = 1;
    1238
    13 if ( VHOST == 'no' ) {
    14     $component_index++;
    15     $action_index++;
     39    if ( VHOST == 'no' ) {
     40        $component_index++;
     41        $action_index++;
     42    }
     43
     44    /* Fetch the current URI and explode each part seperated by '/' into an array */
     45    $bp_uri = explode( "/", $_SERVER['REQUEST_URI'] );
     46
     47    /* Take empties off the end */
     48    if ( $bp_uri[count($bp_uri) - 1] == "" )
     49        array_pop( $bp_uri );
     50
     51    /* Take empties off the start */
     52    if ( $bp_uri[0] == "" )
     53        array_shift( $bp_uri );
     54
     55    /* Get total URI segment count */
     56    $bp_uri_count = count( $bp_uri ) - 1;
     57   
     58    /* Set the current component */
     59    $current_component = $bp_uri[$component_index];
     60   
     61    /* Set the current action */
     62    $current_action = $bp_uri[$action_index];
     63
     64    /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
     65    $action_variables = $bp_uri;
     66
     67    /* Remove the username from action variables if this is not a VHOST install */
     68    if ( VHOST == 'no' )
     69        unset($action_variables[0]);
     70
     71    /* Unset the current_component and action from action_variables */
     72    unset($action_variables[$component_index]);
     73    unset($action_variables[$action_index]);
     74   
     75    /* Reset the keys by merging with an empty array */
     76    $action_variables = array_merge( array(), $action_variables );
     77
     78    /* catch 'blog' */
     79    if ( $current_component == 'blog' )
     80        bp_catch_uri( 'blog' );
    1681}
     82add_action( 'wp', 'bp_core_set_uri_globals', 0 );
    1783
    18 $bp_uri = explode( "/", $_SERVER['REQUEST_URI'] );
    19 
    20 if ( $bp_uri[count($bp_uri) - 1] == "" )
    21     array_pop( $bp_uri );
    22    
    23 if ( $bp_uri[0] == "" )
    24     array_shift( $bp_uri );
    25 
    26 $bp_uri_count = count( $bp_uri ) - 1;
    27 $current_component = $bp_uri[$component_index];
    28 $current_action = $bp_uri[$action_index];
    29 
    30 $action_variables = $bp_uri;
    31 
    32 if ( VHOST == 'no' )
    33     unset($action_variables[0]);
    34    
    35 unset($action_variables[$component_index]);
    36 unset($action_variables[$action_index]);
    37 $action_variables = array_merge( array(), $action_variables );
    38 
    39 // catch 'blog'
    40 if ( $current_component == 'blog' )
    41     bp_catch_uri( 'blog' );
    42 
    43 // is the string a guid (lowercase, - instead of spaces, a-z and 0-9 only)
    44 function bp_is_guid( $text ) {
    45     $safe = trim( strtolower( $text ) );
    46     $safe = preg_replace( "/[^-0-9a-zA-Z\s]/", '', $safe );
    47     $safe = preg_replace( "/\s+/", ' ', trim( $safe ) );
    48     $safe = str_replace( "/-+/", "-", $safe );
    49     $safe = str_replace( ' ', '-', $safe );
    50     $safe = preg_replace( "/[-]+/", "-", $safe );
    51    
    52     if ( $safe == '' )
    53         return false;
    54    
    55     return true;
    56 }
    57 
    58 // takes either a single page name or array of page names and
    59 // loads the first template file that can be found
     84/**
     85 * bp_catch_uri()
     86 *
     87 * Takes either a single page name or array of page names and
     88 * loads the first template file that can be found.
     89 *
     90 * @package BuddyPress Core
     91 * @global $bp_path BuddyPress global containing the template file names to use.
     92 * @param $pages Template file names to use.
     93 * @uses add_action() Hooks a function on to a specific action
     94 */
    6095function bp_catch_uri( $pages ) {
    6196    global $bp_path;
     
    6398    $bp_path = $pages;
    6499
    65     add_action( "template_redirect", "bp_do_catch_uri", 10, 1 );
     100    add_action( "template_redirect", "bp_core_do_catch_uri", 10, 1 );
    66101}
    67102
    68 // loads the first template that can be found
    69 function bp_do_catch_uri() {
     103/**
     104 * bp_core_do_catch_uri()
     105 *
     106 * Loads the first template file found based on the $bp_path global.
     107 *
     108 * @package BuddyPress Core
     109 * @global $bp_path BuddyPress global containing the template file names to use.
     110 */
     111function bp_core_do_catch_uri() {
    70112    global $bp_path;
    71113
  • trunk/bp-core/bp-core-classes.php

    r271 r304  
    11<?php
    2 
     2/**
     3 * BP_Core_User class can be used by any component. It will fetch useful
     4 * details for any user when provided with a user_id.
     5 *
     6 * Example:
     7 *    $user = new BP_Core_User( $user_id );
     8 *    $user_avatar = $user->avatar;
     9 *    $user_email = $user->email;
     10 *    $user_status = $user->status;
     11 *    etc.
     12 *
     13 * @package BuddyPress Core
     14 */
    315class BP_Core_User {
    416    var $id;
     
    2537    }
    2638   
     39    /**
     40     * populate()
     41     *
     42     * Populate the instantiated class with data based on the User ID provided.
     43     *
     44     * @package BuddyPress Core
     45     * @global $userdata WordPress user data for the current logged in user.
     46     * @uses bp_core_get_userurl() Returns the URL with no HTML markup for a user based on their user id
     47     * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
     48     * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
     49     * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table
     50     * @uses bp_core_get_avatar() Returns HTML formatted avatar for a user
     51     * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
     52     */
    2753    function populate() {
    2854        global $userdata;
     
    4268           
    4369            if ( strstr( $last_activity, '-' ) ) {
    44                 $this->last_active .= bp_time_since( strtotime(get_usermeta( $this->id, 'last_activity' ) ) );
     70                $this->last_active .= bp_core_time_since( strtotime( get_usermeta( $this->id, 'last_activity' ) ) );
    4571            } else {
    46                 $this->last_active .= bp_time_since( get_usermeta( $this->id, 'last_activity' ) );
     72                $this->last_active .= bp_core_time_since( get_usermeta( $this->id, 'last_activity' ) );
    4773            }
    4874           
     
    5177
    5278        if ( BP_XPROFILE_IS_INSTALLED ) {
    53             $this->avatar = core_get_avatar( $this->id, 1 );
     79            $this->avatar = bp_core_get_avatar( $this->id, 1 );
    5480            $this->profile_last_updated = bp_profile_last_updated_date( $this->id, false );
    5581        }
  • trunk/bp-core/bp-core-cssjs.php

    r251 r304  
    11<?php
    2 function core_add_js() {
     2/**
     3 * bp_core_add_js()
     4 *
     5 * Add the JS required by the core, as well as shared JS used by other components.
     6 * [TODO] This needs to use wp_enqueue_script()
     7 *
     8 * @package BuddyPress Core
     9 * @uses get_option() Selects a site setting from the DB.
     10 */
     11function bp_core_add_js() {
    312    echo '<script type="text/javascript">var ajaxurl = "' . get_option('siteurl') . '/wp-admin/admin-ajax.php";</script>';
    413    echo "<script type='text/javascript' src='" . get_option('siteurl') . "/wp-includes/js/jquery/jquery.js?ver=1.2.3'></script>";
     
    817    echo '<script src="' . get_option('siteurl') . '/wp-content/mu-plugins/bp-core/js/general.js" type="text/javascript"></script>';
    918}
    10 add_action( 'wp_head', 'core_add_js' );
    11 //add_action( 'admin_menu', 'core_add_js' );
     19add_action( 'wp_head', 'bp_core_add_js' );
     20//add_action( 'admin_menu', 'core_add_js' );x
  • trunk/bp-core/bp-core-settingstab.php

    r33 r304  
    11<?php
    2 
    3 function add_blog_settings_tab() {
     2/**
     3 * bp_core_move_blog_settings_tab()
     4 *
     5 * By default all settings are under a "Settings" tab. Most of these are blog related.
     6 * This and the following functions will add a "Blog" option under settings, where blog
     7 * settings can be moved to.
     8 *
     9 * The idea is that other settings for profiles, messages etc will have their own options under
     10 * appropriate headings, rather than being muddled in with blog settings.
     11 *
     12 * @package BuddyPress Core
     13 * @global $submenu WordPress global variable containing all submenu items.
     14 * @global $thirdlevel BuddyPress created global containing nav items at the third level
     15 */
     16function bp_core_move_blog_settings_tab() {
    417    global $submenu, $thirdlevel;
    518   
     
    1124    }
    1225}
    13 add_action( '_admin_menu', 'add_blog_settings_tab' );
     26add_action( '_admin_menu', 'bp_core_move_blog_settings_tab' );
    1427
    15 function move_settings_submenu() {
     28/**
     29 * bp_core_add_settings_submenu()
     30 *
     31 * Function actually adds "Blog" as a submenu action, as well as renaming "Delete Blog" to
     32 * "Delete Account".
     33 *
     34 * @package BuddyPress Core
     35 * @global $submenu WordPress global variable containing all submenu items.
     36 * @global $thirdlevel BuddyPress created global containing nav items at the third level
     37 */
     38function bp_core_add_settings_submenu() {
    1639    global $submenu, $thirdlevel;
    1740   
     
    1942    $submenu['options-general.php'][1][0] = 'Delete Account';
    2043}
    21 add_action( 'admin_menu', 'move_settings_submenu' );
     44add_action( 'admin_menu', 'bp_core_add_settings_submenu' );
    2245
    23 function alter_settings_tab_positions() {
     46/**
     47 * bp_core_alter_settings_tab_positions()
     48 *
     49 * Alter the positioning of settings options, so that the highlighting of tabs
     50 * remains correct.
     51 *
     52 * @package BuddyPress Core
     53 * @global $parent_file WordPress global for the name of the file controlling the parent tab
     54 * @global $submenu_file WordPress global for the name of the file controlling the sub parent tab
     55 */
     56function bp_core_alter_settings_tab_positions() {
    2457    global $parent_file, $submenu_file;
    2558   
     
    4275    }
    4376}
    44 add_action( 'admin_head', 'alter_settings_tab_positions' );
     77add_action( 'admin_head', 'bp_core_alter_settings_tab_positions' );
    4578
    4679?>
  • trunk/bp-core/bp-core-templatetags.php

    r256 r304  
    11<?php
    2 
     2/**
     3 * bp_get_nav()
     4 * TEMPLATE TAG
     5 *
     6 * Uses the $bp['bp_nav'] global to render out the navigation within a BuddyPress install.
     7 * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
     8 *
     9 * This navigation array is the top level navigation, so it contains items such as:
     10 *      [Blog, Profile, Messages, Groups, Friends] ...
     11 *
     12 * The function will also analyze the current component the user is in, to determine whether
     13 * or not to highlight a particular nav item.
     14 *
     15 * It will also compare the current user to the logged in user, if a user profile is being viewed.
     16 * This allows the "Friends" item to be highlighted if the users are friends. This is only if the friends
     17 * component is installed.
     18 *
     19 * @package BuddyPress Core
     20 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     21 * @uses friends_check_friendship() Checks to see if the logged in user is a friend of the currently viewed user.
     22 */
    323function bp_get_nav() {
    424    global $bp;
    5 
     25   
     26    /* Sort the nav by key as the array has been put together in different locations */
    627    ksort($bp['bp_nav']);
    728   
     29    /* Loop through each navigation item */
    830    foreach( $bp['bp_nav'] as $nav_item ) {
     31        /* If the current component matches the nav item id, then add a highlight CSS class. */
    932        if ( $bp['current_component'] == $nav_item['id'] && $bp['current_userid'] == $bp['loggedin_userid'] ) {
    1033            $selected = ' class="current"';
     
    1336        }
    1437       
     38        /* If we are viewing another person (current_userid does not equal loggedin_userid)
     39           then check to see if the two users are friends. if they are, add a highligh CSS class
     40           to the friends nav item if it exists. */
    1541        if ( $bp['current_userid'] != $bp['loggedin_userid'] ) {
    1642            if ( function_exists('friends_check_friendship') ) {
     
    2349        }
    2450       
     51        /* echo out the final list item */
    2552        echo '<li' . $selected . '><a id="' . $nav_item['id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>';
    2653    }
    2754   
     55    /* Always add a log out list item to the end of the navigation */
    2856    echo '<li><a id="wp-logout" href="' . get_option('home') . '/wp-login.php?action=logout">Log Out</a><li>';
    2957}
    3058
     59/**
     60 * bp_get_options_nav()
     61 * TEMPLATE TAG
     62 *
     63 * Uses the $bp['bp_options_nav'] global to render out the sub navigation for the current component.
     64 * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.
     65 *
     66 * This sub navigation array is the secondary level navigation, so for profile it contains:
     67 *      [Public, Edit Profile, Change Avatar]
     68 *
     69 * The function will also analyze the current action for the current component to determine whether
     70 * or not to highlight a particular sub nav item.
     71 *
     72 * @package BuddyPress Core
     73 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     74 * @uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
     75 */
    3176function bp_get_options_nav() {
    3277    global $bp;
    3378
     79    /* Only render this navigation when the logged in user is looking at one of their own pages. */
    3480    if ( $bp['loggedin_userid'] == $bp['current_userid'] ) {
    3581        if ( count( $bp['bp_options_nav'][$bp['current_component']] ) < 1 )
    3682            return false;
    3783   
     84        /* Loop through each navigation item */
    3885        foreach ( $bp['bp_options_nav'][$bp['current_component']] as $slug => $values ) {
    3986            $title = $values['name'];
    4087            $link = $values['link'];
    4188            $id = $values['id'];
    42 
     89           
     90            /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
    4391            if ( $slug == $bp['current_action'] || $slug == $bp['action_variables'][0] || ( $slug == '' && ( $bp['current_component'] == 'blog' && bp_is_blog() ) ) ) {
    4492                $selected = ' class="current"';
     
    4694                $selected = '';
    4795            }
    48        
     96           
     97            /* echo out the final list item */
    4998            echo '<li' . $selected . '><a id="' . $id . '" href="' . $link . '">' . $title . '</a></li>';       
    5099        }
     
    57106}
    58107
     108/**
     109 * bp_get_user_nav()
     110 * TEMPLATE TAG
     111 *
     112 * Uses the $bp['bp_users_nav'] global to render out the user navigation when viewing another user other than
     113 * yourself.
     114 *
     115 * @package BuddyPress Core
     116 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     117 */
    59118function bp_get_user_nav() {
    60119    global $bp;
     
    71130}
    72131
     132/**
     133 * bp_has_options_avatar()
     134 * TEMPLATE TAG
     135 *
     136 * Check to see if there is an options avatar. An options avatar is an avatar for something
     137 * like a group, or a friend. Basically an avatar that appears in the sub nav options bar.
     138 *
     139 * @package BuddyPress Core
     140 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     141 */
    73142function bp_has_options_avatar() {
    74143    global $bp;
     
    80149}
    81150
     151/**
     152 * bp_get_options_avatar()
     153 * TEMPLATE TAG
     154 *
     155 * Gets the avatar for the current sub nav (eg friends avatar or group avatar).
     156 * Does not check if there is one - so always use if ( bp_has_options_avatar() )
     157 *
     158 * @package BuddyPress Core
     159 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     160 */
    82161function bp_get_options_avatar() {
    83162    global $bp;
    84    
    85     if ( $bp['bp_options_avatar'] == '' )
    86         return false;
    87        
     163
    88164    echo $bp['bp_options_avatar'];
    89165}
     
    110186    global $comment;
    111187   
    112     if ( function_exists('core_get_avatar') ) {
    113         echo core_get_avatar( $comment->user_id, 1 );   
     188    if ( function_exists('bp_core_get_avatar') ) {
     189        echo bp_core_get_avatar( $comment->user_id, 1 );   
    114190    } else if ( function_exists('get_avatar') ) {
    115191        get_avatar();
     
    124200}
    125201
     202function bp_format_time( $time, $just_date = false ) {
     203    $date = date( "F j, Y ", $time );
     204   
     205    if ( !$just_date ) {
     206        $date .= __('at') . date( ' g:iA', $time );
     207    }
     208   
     209    return $date;
     210}
     211
     212function bp_is_blog() {
     213    return bp_core_is_blog();
     214}
     215
    126216?>
  • trunk/bp-friends.php

    r295 r304  
    123123            );     
    124124        } else {
    125             $bp['bp_options_avatar'] = core_get_avatar( $bp['current_userid'], 1 );
     125            $bp['bp_options_avatar'] = bp_core_get_avatar( $bp['current_userid'], 1 );
    126126            $bp['bp_options_title'] = bp_user_fullname( $bp['current_userid'], false );
    127127        }
     
    159159                        $bp['message_type'] = 'error';                 
    160160                    }
    161                     add_action( 'template_notices', 'bp_render_notice' );
     161                    add_action( 'template_notices', 'bp_core_render_notice' );
    162162                } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) {
    163163                    if ( BP_Friends_Friendship::reject( $bp['action_variables'][1] ) ) {
     
    168168                        $bp['message_type'] = 'error';             
    169169                    }
    170                     add_action( 'template_notices', 'bp_render_notice' );
     170                    add_action( 'template_notices', 'bp_core_render_notice' );
    171171                }
    172172                bp_catch_uri( 'friends/requests' );
  • trunk/bp-friends/bp-friends-templatetags.php

    r271 r304  
    240240   
    241241    if ( $friends_template->friendship->date_created != "0000-00-00 00:00:00" ) {
    242         echo __('requested') . ' ' . bp_time_since( strtotime( $friends_template->friendship->date_created ) ) . ' ' . __('ago');
     242        echo __('requested') . ' ' . bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) . ' ' . __('ago');
    243243    }
    244244}
  • trunk/bp-groups.php

    r287 r304  
    245245                        $bp['message_type'] = 'error';                 
    246246                    }
    247                     add_action( 'template_notices', 'bp_render_notice' );
     247                    add_action( 'template_notices', 'bp_core_render_notice' );
    248248                } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) {
    249249                    if ( BP_Groups_Member::delete( $bp['loggedin_userid'], $bp['action_variables'][1] ) ) {
     
    254254                        $bp['message_type'] = 'error';             
    255255                    }
    256                     add_action( 'template_notices', 'bp_render_notice' );
     256                    add_action( 'template_notices', 'bp_core_render_notice' );
    257257                }
    258258                bp_catch_uri( 'groups/list-invites' );
     
    286286                            $bp['message_type'] = 'error';
    287287                   
    288                             add_action( 'template_notices', 'bp_render_notice' );
     288                            add_action( 'template_notices', 'bp_core_render_notice' );
    289289                        } else {
    290290                            $create_group_step++;
     
    336336                                    $bp['message_type'] = 'success';
    337337                                   
    338                                     add_action( 'template_notices', 'bp_render_notice' );
     338                                    add_action( 'template_notices', 'bp_core_render_notice' );
    339339                                    bp_catch_uri( 'groups/group-home' );
    340340                                } else {
     
    355355                                    }
    356356
    357                                     add_action( 'template_notices', 'bp_render_notice' );
     357                                    add_action( 'template_notices', 'bp_core_render_notice' );
    358358                                }
    359359                               
     
    370370                                        $bp['message_type'] = 'success';                                   
    371371                                    }
    372                                     add_action( 'template_notices', 'bp_render_notice' );
     372                                    add_action( 'template_notices', 'bp_core_render_notice' );
    373373                                   
    374374                                    $is_single_group = false;
     
    536536        // If this is the group avatar step, load in the JS.
    537537        if ( $create_group_step == '3' )
    538             add_action( 'wp_head', 'core_add_cropper_js' );
     538            add_action( 'wp_head', 'bp_core_add_cropper_js' );
    539539       
    540540        $group = new BP_Groups_Group( $group_id );     
  • trunk/bp-groups/bp-groups-templatetags.php

    r283 r304  
    442442            <?php echo $member->user->avatar ?>
    443443            <h4><?php echo $member->user->user_link ?> <?php if ( $member->user_title ) { ?><?php echo '<span class="small">- ' . $member->user_title . '</span>' ?><?php } ?></h4>
    444             <span class="activity">joined <?php echo bp_time_since( strtotime($member->date_modified) ) ?> ago</span>
     444            <span class="activity">joined <?php echo bp_core_time_since( strtotime($member->date_modified) ) ?> ago</span>
    445445    <?php if ( bp_exists('friends') && function_exists('bp_add_friend_button') ) { ?>
    446446            <div class="action">
  • trunk/bp-messages.php

    r259 r304  
    227227                        if ( !BP_Messages_Thread::delete($thread_id) ) {
    228228                            $bp['message'] = __('There was an error deleting that message.');
    229                             add_action( 'template_notices', 'bp_render_notice' );
     229                            add_action( 'template_notices', 'bp_core_render_notice' );
    230230
    231231                            $bp['current_action'] = 'inbox';
     
    234234                            $bp['message'] = __('Message deleted.');
    235235                            $bp['message_type'] = 'success';
    236                             add_action( 'template_notices', 'bp_render_notice' );
     236                            add_action( 'template_notices', 'bp_core_render_notice' );
    237237
    238238                            $bp['current_action'] = 'inbox';
     
    252252                    if ( !BP_Messages_Thread::delete( explode(',', $thread_ids ) ) ) {
    253253                        $message = __('There was an error deleting messages.');
    254                         add_action( 'template_notices', 'bp_render_notice' );
     254                        add_action( 'template_notices', 'bp_core_render_notice' );
    255255
    256256                        $bp['current_action'] = 'inbox';
     
    259259                        $bp['message'] = __('Messages deleted.');
    260260                        $bp['message_type'] = 'success';
    261                         add_action( 'template_notices', 'bp_render_notice' );
     261                        add_action( 'template_notices', 'bp_core_render_notice' );
    262262
    263263                        $bp['current_action'] = 'inbox';
     
    302302                        }
    303303                    }
    304                     add_action( 'template_notices', 'bp_render_notice' );
     304                    add_action( 'template_notices', 'bp_core_render_notice' );
    305305                    bp_catch_uri( 'messages/notices' );
    306306                }
     
    475475                        <td class="is-read" width="1%"><?php echo $is_read ?></td>
    476476                        <td class="avatar" width="1%">
    477                             <?php if ( function_exists('core_get_avatar') )
    478                                     echo core_get_avatar($thread->last_sender_id, 1);
     477                            <?php if ( function_exists('bp_core_get_avatar') )
     478                                    echo bp_core_get_avatar($thread->last_sender_id, 1);
    479479                            ?>
    480480                        </td>
     
    588588                        $bp['message_type'] = $type;
    589589                       
    590                         bp_render_notice();
     590                        bp_core_render_notice();
    591591                        messages_write_new();
    592592                    } else {
     
    604604                        $bp['message_type'] = $type;
    605605                       
    606                         bp_render_notice();
     606                        bp_core_render_notice();
    607607                        messages_write_new();
    608608                    } else {
     
    623623                    $bp['message_type'] = $type;
    624624                   
    625                     bp_render_notice();
     625                    bp_core_render_notice();
    626626                    messages_write_new();
    627627                } else {
     
    648648   
    649649        if ( $from_template ) {
    650             bp_render_notice();
     650            bp_core_render_notice();
    651651            messages_write_new();
    652652        } else {
     
    729729                    <div class="message-box">
    730730                        <div class="avatar-box">
    731                             <?php if ( function_exists('core_get_avatar') )
    732                                 echo core_get_avatar($message->sender_id, 1);
     731                            <?php if ( function_exists('bp_core_get_avatar') )
     732                                echo bp_core_get_avatar($message->sender_id, 1);
    733733                            ?>
    734734               
     
    747747                            <div id="messagediv">
    748748                                <div class="avatar-box">
    749                                     <?php if ( function_exists('core_get_avatar') )
    750                                         echo core_get_avatar($userdata->ID, 1);
     749                                    <?php if ( function_exists('bp_core_get_avatar') )
     750                                        echo bp_core_get_avatar($userdata->ID, 1);
    751751                                    ?>
    752752                   
  • trunk/bp-messages/bp-messages-ajax.php

    r251 r304  
    1515    if ( $result['status'] ) { ?>
    1616            <div class="avatar-box">
    17                 <?php if ( function_exists('core_get_avatar') )
    18                     echo core_get_avatar($result['reply']->sender_id, 1);
     17                <?php if ( function_exists('bp_core_get_avatar') )
     18                    echo bp_core_get_avatar($result['reply']->sender_id, 1);
    1919                ?>
    2020   
  • trunk/bp-messages/bp-messages-templatetags.php

    r251 r304  
    167167function bp_message_thread_avatar() {
    168168    global $messages_template;
    169     if ( function_exists('core_get_avatar') )
    170         echo core_get_avatar($messages_template->thread->last_sender_id, 1);
     169    if ( function_exists('bp_core_get_avatar') )
     170        echo bp_core_get_avatar($messages_template->thread->last_sender_id, 1);
    171171}
    172172
  • trunk/bp-xprofile.php

    r295 r304  
    146146    add_action( 'admin_head', 'xprofile_add_css' );
    147147    add_action( 'admin_head', 'xprofile_add_js' );
    148     add_action( 'admin_head', 'core_add_cropper_js' );
     148    add_action( 'admin_head', 'bp_core_add_cropper_js' );
    149149}
    150150add_action( 'admin_menu', 'xprofile_admin_setup' );
     
    187187            );
    188188        } else {
    189             $bp['bp_options_avatar'] = core_get_avatar( $bp['current_userid'], 1 );
     189            $bp['bp_options_avatar'] = bp_core_get_avatar( $bp['current_userid'], 1 );
    190190            $bp['bp_options_title'] = bp_user_fullname( $bp['current_userid'], false );
    191191        }
     
    211211            bp_catch_uri( 'profile/edit' );
    212212        } else if ( $bp['current_action'] == 'change-avatar' && $bp['loggedin_userid'] == $bp['current_userid'] ) {
    213             add_action( 'wp_head', 'core_add_cropper_js' );
     213            add_action( 'wp_head', 'bp_core_add_cropper_js' );
    214214            bp_catch_uri( 'profile/change-avatar' );
    215215        } else {
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r251 r304  
    2222
    2323        if ( $id ) {
    24             if ( bp_core_validate($id) ) {
    25                 $this->populate($id);
    26             }
     24            $this->populate($id);
    2725        }
    2826    }
  • trunk/bp-xprofile/bp-xprofile-signup.php

    r295 r304  
    169169                $avatar_error = false;
    170170               
    171                 if ( core_check_avatar_upload($_FILES) ) {
    172                     if ( !core_check_avatar_upload($_FILES) ) {
     171                if ( bp_core_check_avatar_upload($_FILES) ) {
     172                    if ( !bp_core_check_avatar_upload($_FILES) ) {
    173173                        $avatar_error = true;
    174174                        $avatar_error_msg = __('Your avatar upload failed, please try again.');
    175175                    }
    176176
    177                     if ( !core_check_avatar_size($_FILES) ) {
     177                    if ( !bp_core_check_avatar_size($_FILES) ) {
    178178                        $avatar_error = true;
    179179                        $avatar_size = size_format(1024 * XPROFILE_MAX_FILE_SIZE);
     
    181181                    }
    182182
    183                     if ( !core_check_avatar_type($_FILES) ) {
     183                    if ( !bp_core_check_avatar_type($_FILES) ) {
    184184                        $avatar_error = true;
    185185                        $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.');       
     
    187187
    188188                    // "Handle" upload into temporary location
    189                     if ( !$original = core_handle_avatar_upload($_FILES) ) {
     189                    if ( !$original = bp_core_handle_avatar_upload($_FILES) ) {
    190190                        $avatar_error = true;
    191191                        $avatar_error_msg = __('Upload Failed! Your photo dimensions are likely too big.');                     
    192192                    }
    193193
    194                     if ( !core_check_avatar_dimensions($original) ) {
     194                    if ( !bp_core_check_avatar_dimensions($original) ) {
    195195                        $avatar_error = true;
    196196                        $avatar_error_msg = sprintf( __('The image you upload must have dimensions of %d x %d pixels or larger.'), XPROFILE_CROPPING_CANVAS_MAX, XPROFILE_CROPPING_CANVAS_MAX );
    197197                    }
    198198                   
    199                     if ( !$canvas = core_resize_avatar($original) ) {
     199                    if ( !$canvas = bp_core_resize_avatar($original) ) {
    200200                        $avatar_error = true;
    201201                        $avatar_error_msg = __('Could not create thumbnail, try another photo.');
     
    349349        // Render the cropper UI
    350350        $action = PROTOCOL . get_usermeta( $user_id, 'source_domain' ) . '/wp-activate.php?key=' . $_GET['key'] . '&amp;cropped=true';
    351         core_render_avatar_cropper($original, $resized, $action, $user_id);
    352        
    353         //$result = core_avatar_cropstore( $image, $image, $v1_x, $v1_y, XPROFILE_AVATAR_V1_W, XPROFILE_AVATAR_V1_H, $v2_x, $v2_y, XPROFILE_AVATAR_V2_W, XPROFILE_AVATAR_V2_H, true );
    354         //core_avatar_save( $result, $user_id, $upload_dir );
     351        bp_core_render_avatar_cropper($original, $resized, $action, $user_id);
     352       
     353        //$result = bp_core_avatar_cropstore( $image, $image, $v1_x, $v1_y, XPROFILE_AVATAR_V1_W, XPROFILE_AVATAR_V1_H, $v2_x, $v2_y, XPROFILE_AVATAR_V2_W, XPROFILE_AVATAR_V2_H, true );
     354        //bp_core_avatar_save( $result, $user_id, $upload_dir );
    355355    }
    356356   
     
    370370
    371371        if ( $user_id && isset($_POST['orig']) && isset($_POST['canvas']) ) {
    372             core_check_crop( $_POST['orig'], $_POST['canvas'] );
    373             $result = core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] );
    374             core_avatar_save($result, $user_id);
     372            bp_core_check_crop( $_POST['orig'], $_POST['canvas'] );
     373            $result = bp_core_avatar_cropstore( $_POST['orig'], $_POST['canvas'], $_POST['v1_x1'], $_POST['v1_y1'], $_POST['v1_w'], $_POST['v1_h'], $_POST['v2_x1'], $_POST['v2_y1'], $_POST['v2_w'], $_POST['v2_h'] );
     374            bp_core_avatar_save($result, $user_id);
    375375        }
    376376       
     
    410410    }
    411411   
    412     core_add_cropper_js();
     412    bp_core_add_cropper_js();
    413413}
    414414add_action( 'wp_head', 'xprofile_add_jquery' );
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r251 r304  
    214214function bp_the_avatar() {
    215215    global $bp;
    216     echo core_get_avatar( $bp['current_userid'], 2 );
     216    echo bp_core_get_avatar( $bp['current_userid'], 2 );
    217217}
    218218
    219219function bp_the_avatar_thumbnail() {
    220220    global $bp;
    221     echo core_get_avatar( $bp['current_userid'], 1 );
     221    echo bp_core_get_avatar( $bp['current_userid'], 1 );
    222222}
    223223
    224224function bp_loggedinuser_avatar_thumbnail() {
    225225    global $bp;
    226     echo core_get_avatar( $bp['loggedin_userid'], 1 );
     226    echo bp_core_get_avatar( $bp['loggedin_userid'], 1 );
    227227}
    228228
     
    304304    global $bp;
    305305     
    306     core_avatar_admin(null, $bp['loggedin_domain'] . $bp['xprofile']['slug'] . '/change-avatar/');
     306    bp_core_avatar_admin(null, $bp['loggedin_domain'] . $bp['xprofile']['slug'] . '/change-avatar/');
    307307}
    308308
Note: See TracChangeset for help on using the changeset viewer.