Changeset 304
- Timestamp:
- 08/22/2008 04:20:04 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
-
bp-core.php (modified) (29 diffs)
-
bp-core/bp-core-avatars.php (modified) (27 diffs)
-
bp-core/bp-core-blogtab.php (modified) (4 diffs)
-
bp-core/bp-core-catchuri.php (modified) (2 diffs)
-
bp-core/bp-core-classes.php (modified) (4 diffs)
-
bp-core/bp-core-cssjs.php (modified) (2 diffs)
-
bp-core/bp-core-settingstab.php (modified) (4 diffs)
-
bp-core/bp-core-templatetags.php (modified) (9 diffs)
-
bp-friends.php (modified) (3 diffs)
-
bp-friends/bp-friends-templatetags.php (modified) (1 diff)
-
bp-groups.php (modified) (7 diffs)
-
bp-groups/bp-groups-templatetags.php (modified) (1 diff)
-
bp-messages.php (modified) (12 diffs)
-
bp-messages/bp-messages-ajax.php (modified) (1 diff)
-
bp-messages/bp-messages-templatetags.php (modified) (1 diff)
-
bp-xprofile.php (modified) (3 diffs)
-
bp-xprofile/bp-xprofile-classes.php (modified) (1 diff)
-
bp-xprofile/bp-xprofile-signup.php (modified) (6 diffs)
-
bp-xprofile/bp-xprofile-templatetags.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r256 r304 1 1 <?php 2 2 3 /* Define the protocol to be used, change to https:// if on secure server. */ 3 4 define( 'PROTOCOL', 'http://' ); 5 6 /* Define the current version number for checking if DB tables are up to date. */ 4 7 define( 'BP_CORE_VERSION', '0.2.3' ); 5 8 9 /* Require all needed files */ 6 10 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-catchuri.php' ); 7 11 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-classes.php' ); … … 12 16 require_once( ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-templatetags.php' ); 13 17 18 /* If disable blog tab option is set, don't combine blog tabs by skipping blogtab file */ 14 19 if ( !get_site_option('bp_disable_blog_tab') ) { 15 20 include_once(ABSPATH . 'wp-content/mu-plugins/bp-core/bp-core-blogtab.php'); 16 21 } 17 22 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 */ 24 if ( isset($_POST['submit']) && $_POST['save_admin_settings'] && is_site_admin() ) { 25 bp_core_save_admin_settings(); 20 26 } 21 27 … … 26 32 * them in a $bp variable. 27 33 * 28 * @package BuddyPress 29 * @ uses$current_user A WordPress global containing current user information30 * @ uses$current_component Which is set up in /bp-core/bp-core-catch-uri.php31 * @ uses$current_action Which is set up in /bp-core/bp-core-catch-uri.php32 * @ uses$action_variables Which is set up in /bp-core/bp-core-catch-uri.php34 * @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 33 39 * @uses bp_core_get_loggedin_domain() Returns the domain for the logged in user 34 40 * @uses bp_core_get_current_domain() Returns the domain for the current user being viewed … … 78 84 'bp_options_avatar' => '', 79 85 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() */ 81 87 'message' => '', 82 88 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() */ 84 90 'message_type' => '' // error/success 85 91 ); … … 96 102 * profile other than that of the current logged in user. 97 103 * 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/ 101 107 * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user 102 108 */ … … 126 132 } 127 133 /* 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() ) { 129 135 $bp['current_component'] = 'blog'; 130 136 } … … 146 152 } else { 147 153 /* 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 ); 149 155 $bp['bp_options_title'] = bp_user_fullname( $bp['current_userid'], false ); 150 156 } … … 159 165 * eg: http://andy.domain.com/ or http://domain.com/andy/ 160 166 * 161 * @package BuddyPress 162 * @ uses$current_user WordPress global variable containing current logged in user information163 * @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/ 164 170 * @uses bp_is_home() Checks to see if the current user being viewed is the logged in user 165 171 */ … … 182 188 * eg: http://andy.domain.com/ or http://domain.com/andy/ 183 189 * 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. 186 192 * @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. 187 194 */ 188 195 function bp_core_get_current_domain() { … … 198 205 } 199 206 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 */ 200 218 function bp_core_get_current_userid() { 201 219 $siteuser = bp_core_get_primary_username(); … … 205 223 } 206 224 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 */ 207 234 function bp_core_get_primary_username() { 208 235 global $current_blog; … … 218 245 } 219 246 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 */ 254 function bp_core_start_buffer() { 221 255 ob_start(); 222 add_action( 'dashmenu', ' stop_buffer' );256 add_action( 'dashmenu', 'bp_core_stop_buffer' ); 223 257 } 224 add_action( 'admin_menu', 'start_buffer' ); 225 226 function stop_buffer() { 258 add_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 */ 267 function bp_core_stop_buffer() { 227 268 $contents = ob_get_contents(); 228 269 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 */ 287 function bp_core_blog_switcher( $contents ) { 233 288 global $current_user, $blog_id; // current blog 234 289 235 / / This code is duplicated from the MU core so it can236 / / be modified for BuddyPress.290 /* Code duplicated from wp-admin/includes/mu.php */ 291 /* function blogswitch_markup() */ 237 292 238 293 $filter = preg_split( '/\<ul id=\"dashmenu\"\>[\S\s]/', $contents ); … … 323 378 } 324 379 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 */ 389 function bp_core_add_settings_tab() { 390 add_submenu_page( 'wpmu-admin.php', "BuddyPress", "BuddyPress", 1, basename(__FILE__), "bp_core_admin_settings" ); 391 } 392 add_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 */ 402 function bp_core_admin_settings() { 332 403 if ( get_site_option('bp_disable_blog_tab') ) { 333 404 $blog_tab_checked = ' checked="checked"'; … … 370 441 } 371 442 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 */ 454 function bp_core_save_admin_settings() { 455 if ( !is_site_admin() ) 456 return false; 457 373 458 if ( !isset($_POST['disable_blog_tab']) ) { 374 459 $_POST['disable_blog_tab'] = 0; … … 434 519 // } 435 520 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 */ 436 532 function bp_core_get_userid( $username ) { 437 533 global $wpdb; 534 438 535 $sql = $wpdb->prepare( "SELECT ID FROM " . $wpdb->base_prefix . "users WHERE user_login = %s", $username ); 439 536 return $wpdb->get_var($sql); 440 537 } 441 538 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 */ 442 551 function bp_core_get_username( $uid ) { 443 552 global $userdata; … … 446 555 return 'You'; 447 556 448 $ud = get_userdata($uid); 557 if ( !$ud = get_userdata($uid) ) 558 return false; 559 449 560 return $ud->user_login; 450 561 } 451 562 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 */ 457 575 function bp_core_get_userurl( $uid ) { 458 576 global $userdata; … … 467 585 $url = PROTOCOL . $ud->source_domain . '/' . $ud->path; 468 586 469 if ( $url == PROTOCOL . '/')587 if ( !$ud ) 470 588 return false; 471 589 … … 473 591 } 474 592 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 */ 475 604 function bp_core_get_user_email( $uid ) { 476 605 $ud = get_userdata($uid); … … 478 607 } 479 608 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 */ 480 630 function bp_core_get_userlink( $uid, $no_anchor = false, $just_link = false, $no_you = false ) { 481 631 global $userdata; 482 632 483 633 $ud = get_userdata($uid); 634 635 if ( !$ud ) 636 return false; 484 637 485 638 if ( function_exists('bp_user_fullname') ) … … 505 658 } 506 659 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 */ 671 function bp_core_format_time( $time, $just_date = false ) { 541 672 $date = date( "F j, Y ", $time ); 542 673 … … 548 679 } 549 680 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 */ 559 691 function bp_create_excerpt( $text, $excerpt_length = 55 ) { // Fakes an excerpt if needed 560 692 $text = str_replace(']]>', ']]>', $text); … … 570 702 } 571 703 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 */ 572 714 function bp_is_serialized( $data ) { 573 715 if ( trim($data) == "" ) { … … 582 724 } 583 725 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 */ 584 742 function bp_upload_dir( $time = NULL, $blog_id ) { 585 // copied from wordpress, need to be able to create a users586 // upload dir on activation, before 'upload_path' is587 // placed into options table.588 // Fix for this would be adding a hook for 'activate_footer'589 // in wp-activate.php590 591 743 $siteurl = get_option( 'siteurl' ); 592 744 $upload_path = 'wp-content/blogs.dir/' . $blog_id . '/files'; … … 629 781 } 630 782 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 */ 794 function bp_get_page_id($page_title) { 632 795 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 */ 820 function bp_core_is_blog() { 821 global $bp, $cached_page_id; 645 822 646 823 $blog_page_id = bp_get_page_id('Blog'); 647 824 if ( is_tag() || is_category() || is_day() || is_month() || is_year() || is_paged() || is_single() ) 648 825 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 ) ) 650 827 return true; 651 828 if ( is_page('Blog') ) … … 657 834 } 658 835 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 */ 847 function bp_core_render_notice() { 660 848 global $bp; 661 849 … … 670 858 } 671 859 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 */ 876 function bp_core_time_since( $older_date, $newer_date = false ) { 673 877 // array of time period chunks 674 878 $chunks = array( … … 681 885 ); 682 886 683 / / $newer_date will equal false if we want to know the time elapsed between a date and the current time684 / / $newer_date will have a value if we want to work out time elapsed between two known dates887 /* $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 */ 685 889 $newer_date = ( $newer_date == false ) ? ( time() + ( 60*60*0 ) ) : $newer_date; 686 890 687 / / difference in seconds891 /* Difference in seconds */ 688 892 $since = $newer_date - $older_date; 689 893 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 */ 696 902 for ( $i = 0, $j = count($chunks); $i < $j; $i++) { 697 903 $seconds = $chunks[$i][0]; 698 904 $name = $chunks[$i][1]; 699 905 700 / / finding the biggest chunk (if the chunk fits, break)906 /* Finding the biggest chunk (if the chunk fits, break) */ 701 907 if ( ( $count = floor($since / $seconds) ) != 0 ) 702 908 break; 703 909 } 704 910 705 / / set output var911 /* Set output var */ 706 912 $output = ( $count == 1 ) ? '1 '. $name : "$count {$name}s"; 707 913 708 / / step two: the second chunk914 /* Step two: the second chunk */ 709 915 if ( $i + 1 < $j ) { 710 916 $seconds2 = $chunks[$i + 1][0]; … … 712 918 713 919 if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) { 714 / / add to output var920 /* Add to output var */ 715 921 $output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s"; 716 922 } … … 720 926 } 721 927 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 */ 722 939 function bp_core_record_activity() { 723 940 global $userdata; -
trunk/bp-core/bp-core-avatars.php
r256 r304 1 1 <?php 2 2 /* 3 Contributor: Beau Lebens - http://www.dentedreality.com.au/4 Modified By: Andy Peatling3 Based on contributions from: Beau Lebens - http://www.dentedreality.com.au/ 4 Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/ 5 5 */ 6 6 7 /* Make sure we have the core WordPress files we need */ 7 8 require_once( ABSPATH . '/wp-admin/includes/image.php' ); 8 9 require_once( ABSPATH . '/wp-admin/includes/file.php' ); 9 10 11 /* Define settings for avatars. [TODO] This will eventually end up as admin configurable settings */ 10 12 define( 'CORE_AVATAR_V1_W', 50 ); 11 13 define( 'CORE_AVATAR_V1_H', 50 ); … … 16 18 define( 'CORE_DEFAULT_AVATAR', get_option('siteurl') . '/wp-content/mu-plugins/bp-xprofile/images/none.gif' ); 17 19 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 */ 34 function bp_core_get_avatar( $user, $version = 1, $in_css = false ) { 19 35 if ( !is_int($version) ) 20 36 $version = (int) $version; … … 23 39 $version = 1; 24 40 25 $str = get_usermeta( $user, " core_avatar_v$version" );41 $str = get_usermeta( $user, "bp_core_avatar_v$version" ); 26 42 27 43 if ( strlen($str) ) { … … 45 61 // // Override internal "get_avatar()" function to use our own where possible 46 62 // // 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 ) { 48 64 // $str = ''; 49 65 // $ver = ( $size == 1 || $size == 2 ) ? $size : 1; … … 53 69 // 54 70 // 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 ); 56 72 // } elseif ( is_object($id_or_email) ) { 57 73 // 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 ); 59 75 // } 60 76 // } … … 62 78 // return empty($str) ? $avatar : $str; 63 79 // } 64 // add_filter( 'get_avatar', ' core_get_avatar_filter', 10, 4 );80 // add_filter( 'get_avatar', 'bp_core_get_avatar_filter', 10, 4 ); 65 81 66 82 67 83 // Main UI Rendering 68 function core_avatar_admin($message = null, $action = null) {84 function bp_core_avatar_admin($message = null, $action = null) { 69 85 ?> 70 86 <?php if ( !isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action']) ) { ?> … … 86 102 $action = get_option('home') . '/wp-admin/admin.php?page=bp-xprofile.php'; 87 103 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 ); 91 107 if ( strlen($str) ) { 92 108 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>'; 95 111 echo '<a href="' . get_option('siteurl') . '/wp-admin/admin.php?page=bp-xprofile.php&slick_avatars_action=delete">Delete</a>'; 96 112 } … … 106 122 // Confirm that the nonce is valid 107 123 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.' ); 118 134 119 135 // "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." ); 125 141 126 142 // 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.'); 129 145 130 146 // Render the cropper UI … … 132 148 $action = get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php'; 133 149 134 core_render_avatar_cropper($original, $canvas, $action);150 bp_core_render_avatar_cropper($original, $canvas, $action); 135 151 136 152 echo '</div>'; … … 141 157 // Confirm that the nonce is valid 142 158 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.'); 150 166 151 167 // Store details to the DB and we're done … … 156 172 echo '<p>' . __('Your new avatar was successfully created!') . '</p>'; 157 173 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>'; 161 177 162 178 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>'; 164 180 } 165 181 … … 168 184 // Delete an avatar 169 185 170 core_delete_avatar();186 bp_core_delete_avatar(); 171 187 172 188 unset($_GET['slick_avatars_action']); 173 189 $message = __('Avatar successfully removed.'); 174 core_avatar_admin($message);190 bp_core_avatar_admin($message); 175 191 176 192 } … … 179 195 } 180 196 181 function core_check_avatar_upload($file) {197 function bp_core_check_avatar_upload($file) { 182 198 if ( !isset($file['file']) || $file['file']['size'] == 0 ) 183 199 return false; … … 186 202 } 187 203 188 function core_check_avatar_size($file) {204 function bp_core_check_avatar_size($file) { 189 205 if ( $file['file']['size'] > CORE_MAX_FILE_SIZE ) 190 206 return false; … … 193 209 } 194 210 195 function core_check_avatar_type($file) {211 function bp_core_check_avatar_type($file) { 196 212 if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) ) 197 213 return false; … … 200 216 } 201 217 202 function core_handle_avatar_upload($file) {218 function bp_core_handle_avatar_upload($file) { 203 219 $res = wp_handle_upload( $file['file'], array('action'=>'slick_avatars') ); 204 220 if ( !in_array('error', array_keys($res) ) ) { … … 209 225 } 210 226 211 function core_check_avatar_dimensions($file) {227 function bp_core_check_avatar_dimensions($file) { 212 228 $size = getimagesize($file); 213 229 … … 218 234 } 219 235 220 function core_resize_avatar($file, $size = CORE_CROPPING_CANVAS_MAX) {236 function bp_core_resize_avatar($file, $size = CORE_CROPPING_CANVAS_MAX) { 221 237 $canvas = wp_create_thumbnail( $file, $size); 222 238 223 if ( core_thumb_error($canvas) )239 if ( bp_core_thumb_error($canvas) ) 224 240 return false; 225 241 … … 227 243 } 228 244 229 function core_render_avatar_cropper($original, $new, $action, $user_id = null, $no_form_tag = false) {245 function bp_core_render_avatar_cropper($original, $new, $action, $user_id = null, $no_form_tag = false) { 230 246 $size = getimagesize($new); 231 247 … … 319 335 } 320 336 321 function core_check_crop( $original, $canvas ) {337 function bp_core_check_crop( $original, $canvas ) { 322 338 if ( is_file($original) && is_readable($original) && is_file($canvas) && is_readable($canvas) ) 323 339 return true; … … 326 342 } 327 343 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 ) {344 function 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 ) { 329 345 $size = getimagesize($source); 330 346 $dims = getimagesize($canvas); … … 377 393 } 378 394 379 function core_avatar_save( $vars, $user_id = false, $upload_dir = false ) {395 function bp_core_avatar_save( $vars, $user_id = false, $upload_dir = false ) { 380 396 if ( !$user_id ) 381 397 $user_id = get_current_user_id(); … … 387 403 } 388 404 389 $old = get_usermeta( $user_id, ' core_avatar_v1_path' );405 $old = get_usermeta( $user_id, 'bp_core_avatar_v1_path' ); 390 406 $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'] ); 393 409 @unlink($old); // Removing old avatar 394 410 395 411 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' ); 397 413 $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'] ); 400 416 @unlink($old); // Removing old avatar 401 417 } 402 418 } 403 419 404 function core_render_avatar_upload_form($action, $no_form_tag = false) {420 function bp_core_render_avatar_upload_form($action, $no_form_tag = false) { 405 421 if ( !$no_form_tag ) { ?> 406 422 <form method="post" action="<?php echo $action ?>" enctype="multipart/form-data"> … … 418 434 } 419 435 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' );436 function 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' ); 429 445 430 446 // Remove the actual images … … 433 449 } 434 450 435 function core_ap_die( $msg ) {451 function bp_core_ap_die( $msg ) { 436 452 echo '<p><strong>' . $msg . '</strong></p>'; 437 453 echo '<p><a href="' . get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php">' . __('Try Again') . '</a></p>'; … … 440 456 } 441 457 442 function core_thumb_error( $str ) {458 function bp_core_thumb_error( $str ) { 443 459 if ( !is_string($str) ) { 444 460 return false; … … 448 464 } 449 465 450 function core_add_cropper_js() {466 function bp_core_add_cropper_js() { 451 467 echo '<script type="text/javascript" src="' . get_option('home') . '/wp-includes/js/prototype.js"></script>'; 452 468 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 1 1 <?php 2 2 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 */ 14 function bp_core_setup_blog_tab() { 4 15 global $menu, $submenu, $thirdlevel; 5 16 17 /* Unset the default secondary level tabs for the top level nav tabs */ 6 18 unset($submenu['post-new.php']); 7 19 unset($submenu['edit.php']); 8 20 unset($submenu['edit-comments.php']); 9 21 22 /* Move the top level tabs into the sub menu array */ 10 23 $submenu['post-new.php'][20] = $menu[5]; // Write 11 24 $submenu['post-new.php'][25] = $menu[10]; // Manage 12 25 $submenu['post-new.php'][35] = $menu[20]; // Comments 13 26 27 /* Unset the top level tabs */ 14 28 unset($menu[5]); // Write 15 29 unset($menu[10]); // Manage 16 30 unset($menu[20]); // Comments 17 31 32 /* Add a blog tab to the top level nav */ 18 33 add_menu_page( 'Blog', 'Blog', 1, 'post-new.php' ); 19 34 35 /* Move the blog tab so it is the first tab in the top level nav */ 20 36 foreach ( $menu as $key => $value ) { 21 37 if ( $menu[$key][0] == 'Blog' ) { … … 27 43 array_pop($menu); 28 44 45 /* Bump secondary level nav for the old top level tabs down to a new third level navigation */ 29 46 if ( strpos( $_SERVER['SCRIPT_NAME'], '/post-new.php' ) || 30 47 strpos( $_SERVER['SCRIPT_NAME'], '/page-new.php' ) || … … 59 76 60 77 } 61 add_action( '_admin_menu', ' setup_blog_tab' );78 add_action( '_admin_menu', 'bp_core_setup_blog_tab' ); 62 79 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 */ 89 function bp_core_alter_blog_tab_positions() { 64 90 global $parent_file, $submenu_file; 65 91 … … 90 116 } 91 117 } 92 add_action('admin_head', ' alter_blog_tab_positions');118 add_action('admin_head', 'bp_core_alter_blog_tab_positions'); 93 119 94 120 -
trunk/bp-core/bp-core-catchuri.php
r194 r304 1 1 <?php 2 2 /* 3 Contributor: Chris Taylor - http://www.stillbreathing.co.uk/4 Modified By: Andy Peatling3 Based on contributions from: Chris Taylor - http://www.stillbreathing.co.uk/ 4 Modified for BuddyPress by: Andy Peatling - http://apeatling.wordpress.com/ 5 5 */ 6 6 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 */ 32 function 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; 12 38 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' ); 16 81 } 82 add_action( 'wp', 'bp_core_set_uri_globals', 0 ); 17 83 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 */ 60 95 function bp_catch_uri( $pages ) { 61 96 global $bp_path; … … 63 98 $bp_path = $pages; 64 99 65 add_action( "template_redirect", "bp_ do_catch_uri", 10, 1 );100 add_action( "template_redirect", "bp_core_do_catch_uri", 10, 1 ); 66 101 } 67 102 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 */ 111 function bp_core_do_catch_uri() { 70 112 global $bp_path; 71 113 -
trunk/bp-core/bp-core-classes.php
r271 r304 1 1 <?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 */ 3 15 class BP_Core_User { 4 16 var $id; … … 25 37 } 26 38 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 */ 27 53 function populate() { 28 54 global $userdata; … … 42 68 43 69 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' ) ) ); 45 71 } 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' ) ); 47 73 } 48 74 … … 51 77 52 78 if ( BP_XPROFILE_IS_INSTALLED ) { 53 $this->avatar = core_get_avatar( $this->id, 1 );79 $this->avatar = bp_core_get_avatar( $this->id, 1 ); 54 80 $this->profile_last_updated = bp_profile_last_updated_date( $this->id, false ); 55 81 } -
trunk/bp-core/bp-core-cssjs.php
r251 r304 1 1 <?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 */ 11 function bp_core_add_js() { 3 12 echo '<script type="text/javascript">var ajaxurl = "' . get_option('siteurl') . '/wp-admin/admin-ajax.php";</script>'; 4 13 echo "<script type='text/javascript' src='" . get_option('siteurl') . "/wp-includes/js/jquery/jquery.js?ver=1.2.3'></script>"; … … 8 17 echo '<script src="' . get_option('siteurl') . '/wp-content/mu-plugins/bp-core/js/general.js" type="text/javascript"></script>'; 9 18 } 10 add_action( 'wp_head', ' core_add_js' );11 //add_action( 'admin_menu', 'core_add_js' ); 19 add_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 1 1 <?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 */ 16 function bp_core_move_blog_settings_tab() { 4 17 global $submenu, $thirdlevel; 5 18 … … 11 24 } 12 25 } 13 add_action( '_admin_menu', ' add_blog_settings_tab' );26 add_action( '_admin_menu', 'bp_core_move_blog_settings_tab' ); 14 27 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 */ 38 function bp_core_add_settings_submenu() { 16 39 global $submenu, $thirdlevel; 17 40 … … 19 42 $submenu['options-general.php'][1][0] = 'Delete Account'; 20 43 } 21 add_action( 'admin_menu', ' move_settings_submenu' );44 add_action( 'admin_menu', 'bp_core_add_settings_submenu' ); 22 45 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 */ 56 function bp_core_alter_settings_tab_positions() { 24 57 global $parent_file, $submenu_file; 25 58 … … 42 75 } 43 76 } 44 add_action( 'admin_head', ' alter_settings_tab_positions' );77 add_action( 'admin_head', 'bp_core_alter_settings_tab_positions' ); 45 78 46 79 ?> -
trunk/bp-core/bp-core-templatetags.php
r256 r304 1 1 <?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 */ 3 23 function bp_get_nav() { 4 24 global $bp; 5 25 26 /* Sort the nav by key as the array has been put together in different locations */ 6 27 ksort($bp['bp_nav']); 7 28 29 /* Loop through each navigation item */ 8 30 foreach( $bp['bp_nav'] as $nav_item ) { 31 /* If the current component matches the nav item id, then add a highlight CSS class. */ 9 32 if ( $bp['current_component'] == $nav_item['id'] && $bp['current_userid'] == $bp['loggedin_userid'] ) { 10 33 $selected = ' class="current"'; … … 13 36 } 14 37 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. */ 15 41 if ( $bp['current_userid'] != $bp['loggedin_userid'] ) { 16 42 if ( function_exists('friends_check_friendship') ) { … … 23 49 } 24 50 51 /* echo out the final list item */ 25 52 echo '<li' . $selected . '><a id="' . $nav_item['id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>'; 26 53 } 27 54 55 /* Always add a log out list item to the end of the navigation */ 28 56 echo '<li><a id="wp-logout" href="' . get_option('home') . '/wp-login.php?action=logout">Log Out</a><li>'; 29 57 } 30 58 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 */ 31 76 function bp_get_options_nav() { 32 77 global $bp; 33 78 79 /* Only render this navigation when the logged in user is looking at one of their own pages. */ 34 80 if ( $bp['loggedin_userid'] == $bp['current_userid'] ) { 35 81 if ( count( $bp['bp_options_nav'][$bp['current_component']] ) < 1 ) 36 82 return false; 37 83 84 /* Loop through each navigation item */ 38 85 foreach ( $bp['bp_options_nav'][$bp['current_component']] as $slug => $values ) { 39 86 $title = $values['name']; 40 87 $link = $values['link']; 41 88 $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. */ 43 91 if ( $slug == $bp['current_action'] || $slug == $bp['action_variables'][0] || ( $slug == '' && ( $bp['current_component'] == 'blog' && bp_is_blog() ) ) ) { 44 92 $selected = ' class="current"'; … … 46 94 $selected = ''; 47 95 } 48 96 97 /* echo out the final list item */ 49 98 echo '<li' . $selected . '><a id="' . $id . '" href="' . $link . '">' . $title . '</a></li>'; 50 99 } … … 57 106 } 58 107 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 */ 59 118 function bp_get_user_nav() { 60 119 global $bp; … … 71 130 } 72 131 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 */ 73 142 function bp_has_options_avatar() { 74 143 global $bp; … … 80 149 } 81 150 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 */ 82 161 function bp_get_options_avatar() { 83 162 global $bp; 84 85 if ( $bp['bp_options_avatar'] == '' ) 86 return false; 87 163 88 164 echo $bp['bp_options_avatar']; 89 165 } … … 110 186 global $comment; 111 187 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 ); 114 190 } else if ( function_exists('get_avatar') ) { 115 191 get_avatar(); … … 124 200 } 125 201 202 function 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 212 function bp_is_blog() { 213 return bp_core_is_blog(); 214 } 215 126 216 ?> -
trunk/bp-friends.php
r295 r304 123 123 ); 124 124 } 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 ); 126 126 $bp['bp_options_title'] = bp_user_fullname( $bp['current_userid'], false ); 127 127 } … … 159 159 $bp['message_type'] = 'error'; 160 160 } 161 add_action( 'template_notices', 'bp_ render_notice' );161 add_action( 'template_notices', 'bp_core_render_notice' ); 162 162 } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) { 163 163 if ( BP_Friends_Friendship::reject( $bp['action_variables'][1] ) ) { … … 168 168 $bp['message_type'] = 'error'; 169 169 } 170 add_action( 'template_notices', 'bp_ render_notice' );170 add_action( 'template_notices', 'bp_core_render_notice' ); 171 171 } 172 172 bp_catch_uri( 'friends/requests' ); -
trunk/bp-friends/bp-friends-templatetags.php
r271 r304 240 240 241 241 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'); 243 243 } 244 244 } -
trunk/bp-groups.php
r287 r304 245 245 $bp['message_type'] = 'error'; 246 246 } 247 add_action( 'template_notices', 'bp_ render_notice' );247 add_action( 'template_notices', 'bp_core_render_notice' ); 248 248 } else if ( isset($bp['action_variables']) && in_array( 'reject', $bp['action_variables'] ) && is_numeric($bp['action_variables'][1]) ) { 249 249 if ( BP_Groups_Member::delete( $bp['loggedin_userid'], $bp['action_variables'][1] ) ) { … … 254 254 $bp['message_type'] = 'error'; 255 255 } 256 add_action( 'template_notices', 'bp_ render_notice' );256 add_action( 'template_notices', 'bp_core_render_notice' ); 257 257 } 258 258 bp_catch_uri( 'groups/list-invites' ); … … 286 286 $bp['message_type'] = 'error'; 287 287 288 add_action( 'template_notices', 'bp_ render_notice' );288 add_action( 'template_notices', 'bp_core_render_notice' ); 289 289 } else { 290 290 $create_group_step++; … … 336 336 $bp['message_type'] = 'success'; 337 337 338 add_action( 'template_notices', 'bp_ render_notice' );338 add_action( 'template_notices', 'bp_core_render_notice' ); 339 339 bp_catch_uri( 'groups/group-home' ); 340 340 } else { … … 355 355 } 356 356 357 add_action( 'template_notices', 'bp_ render_notice' );357 add_action( 'template_notices', 'bp_core_render_notice' ); 358 358 } 359 359 … … 370 370 $bp['message_type'] = 'success'; 371 371 } 372 add_action( 'template_notices', 'bp_ render_notice' );372 add_action( 'template_notices', 'bp_core_render_notice' ); 373 373 374 374 $is_single_group = false; … … 536 536 // If this is the group avatar step, load in the JS. 537 537 if ( $create_group_step == '3' ) 538 add_action( 'wp_head', ' core_add_cropper_js' );538 add_action( 'wp_head', 'bp_core_add_cropper_js' ); 539 539 540 540 $group = new BP_Groups_Group( $group_id ); -
trunk/bp-groups/bp-groups-templatetags.php
r283 r304 442 442 <?php echo $member->user->avatar ?> 443 443 <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> 445 445 <?php if ( bp_exists('friends') && function_exists('bp_add_friend_button') ) { ?> 446 446 <div class="action"> -
trunk/bp-messages.php
r259 r304 227 227 if ( !BP_Messages_Thread::delete($thread_id) ) { 228 228 $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' ); 230 230 231 231 $bp['current_action'] = 'inbox'; … … 234 234 $bp['message'] = __('Message deleted.'); 235 235 $bp['message_type'] = 'success'; 236 add_action( 'template_notices', 'bp_ render_notice' );236 add_action( 'template_notices', 'bp_core_render_notice' ); 237 237 238 238 $bp['current_action'] = 'inbox'; … … 252 252 if ( !BP_Messages_Thread::delete( explode(',', $thread_ids ) ) ) { 253 253 $message = __('There was an error deleting messages.'); 254 add_action( 'template_notices', 'bp_ render_notice' );254 add_action( 'template_notices', 'bp_core_render_notice' ); 255 255 256 256 $bp['current_action'] = 'inbox'; … … 259 259 $bp['message'] = __('Messages deleted.'); 260 260 $bp['message_type'] = 'success'; 261 add_action( 'template_notices', 'bp_ render_notice' );261 add_action( 'template_notices', 'bp_core_render_notice' ); 262 262 263 263 $bp['current_action'] = 'inbox'; … … 302 302 } 303 303 } 304 add_action( 'template_notices', 'bp_ render_notice' );304 add_action( 'template_notices', 'bp_core_render_notice' ); 305 305 bp_catch_uri( 'messages/notices' ); 306 306 } … … 475 475 <td class="is-read" width="1%"><?php echo $is_read ?></td> 476 476 <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); 479 479 ?> 480 480 </td> … … 588 588 $bp['message_type'] = $type; 589 589 590 bp_ render_notice();590 bp_core_render_notice(); 591 591 messages_write_new(); 592 592 } else { … … 604 604 $bp['message_type'] = $type; 605 605 606 bp_ render_notice();606 bp_core_render_notice(); 607 607 messages_write_new(); 608 608 } else { … … 623 623 $bp['message_type'] = $type; 624 624 625 bp_ render_notice();625 bp_core_render_notice(); 626 626 messages_write_new(); 627 627 } else { … … 648 648 649 649 if ( $from_template ) { 650 bp_ render_notice();650 bp_core_render_notice(); 651 651 messages_write_new(); 652 652 } else { … … 729 729 <div class="message-box"> 730 730 <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); 733 733 ?> 734 734 … … 747 747 <div id="messagediv"> 748 748 <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); 751 751 ?> 752 752 -
trunk/bp-messages/bp-messages-ajax.php
r251 r304 15 15 if ( $result['status'] ) { ?> 16 16 <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); 19 19 ?> 20 20 -
trunk/bp-messages/bp-messages-templatetags.php
r251 r304 167 167 function bp_message_thread_avatar() { 168 168 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); 171 171 } 172 172 -
trunk/bp-xprofile.php
r295 r304 146 146 add_action( 'admin_head', 'xprofile_add_css' ); 147 147 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' ); 149 149 } 150 150 add_action( 'admin_menu', 'xprofile_admin_setup' ); … … 187 187 ); 188 188 } 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 ); 190 190 $bp['bp_options_title'] = bp_user_fullname( $bp['current_userid'], false ); 191 191 } … … 211 211 bp_catch_uri( 'profile/edit' ); 212 212 } 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' ); 214 214 bp_catch_uri( 'profile/change-avatar' ); 215 215 } else { -
trunk/bp-xprofile/bp-xprofile-classes.php
r251 r304 22 22 23 23 if ( $id ) { 24 if ( bp_core_validate($id) ) { 25 $this->populate($id); 26 } 24 $this->populate($id); 27 25 } 28 26 } -
trunk/bp-xprofile/bp-xprofile-signup.php
r295 r304 169 169 $avatar_error = false; 170 170 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) ) { 173 173 $avatar_error = true; 174 174 $avatar_error_msg = __('Your avatar upload failed, please try again.'); 175 175 } 176 176 177 if ( ! core_check_avatar_size($_FILES) ) {177 if ( !bp_core_check_avatar_size($_FILES) ) { 178 178 $avatar_error = true; 179 179 $avatar_size = size_format(1024 * XPROFILE_MAX_FILE_SIZE); … … 181 181 } 182 182 183 if ( ! core_check_avatar_type($_FILES) ) {183 if ( !bp_core_check_avatar_type($_FILES) ) { 184 184 $avatar_error = true; 185 185 $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.'); … … 187 187 188 188 // "Handle" upload into temporary location 189 if ( !$original = core_handle_avatar_upload($_FILES) ) {189 if ( !$original = bp_core_handle_avatar_upload($_FILES) ) { 190 190 $avatar_error = true; 191 191 $avatar_error_msg = __('Upload Failed! Your photo dimensions are likely too big.'); 192 192 } 193 193 194 if ( ! core_check_avatar_dimensions($original) ) {194 if ( !bp_core_check_avatar_dimensions($original) ) { 195 195 $avatar_error = true; 196 196 $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 ); 197 197 } 198 198 199 if ( !$canvas = core_resize_avatar($original) ) {199 if ( !$canvas = bp_core_resize_avatar($original) ) { 200 200 $avatar_error = true; 201 201 $avatar_error_msg = __('Could not create thumbnail, try another photo.'); … … 349 349 // Render the cropper UI 350 350 $action = PROTOCOL . get_usermeta( $user_id, 'source_domain' ) . '/wp-activate.php?key=' . $_GET['key'] . '&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 ); 355 355 } 356 356 … … 370 370 371 371 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); 375 375 } 376 376 … … 410 410 } 411 411 412 core_add_cropper_js();412 bp_core_add_cropper_js(); 413 413 } 414 414 add_action( 'wp_head', 'xprofile_add_jquery' ); -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r251 r304 214 214 function bp_the_avatar() { 215 215 global $bp; 216 echo core_get_avatar( $bp['current_userid'], 2 );216 echo bp_core_get_avatar( $bp['current_userid'], 2 ); 217 217 } 218 218 219 219 function bp_the_avatar_thumbnail() { 220 220 global $bp; 221 echo core_get_avatar( $bp['current_userid'], 1 );221 echo bp_core_get_avatar( $bp['current_userid'], 1 ); 222 222 } 223 223 224 224 function bp_loggedinuser_avatar_thumbnail() { 225 225 global $bp; 226 echo core_get_avatar( $bp['loggedin_userid'], 1 );226 echo bp_core_get_avatar( $bp['loggedin_userid'], 1 ); 227 227 } 228 228 … … 304 304 global $bp; 305 305 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/'); 307 307 } 308 308
Note: See TracChangeset
for help on using the changeset viewer.