Changeset 167
- Timestamp:
- 06/19/08 17:10:30 (5 months ago)
- Location:
- trunk
- Files:
-
- 7 modified
-
bp-core.php (modified) (2 diffs)
-
bp-core/bp-core-templatetags.php (modified) (1 diff)
-
bp-xprofile.php (modified) (5 diffs)
-
bp-xprofile/bp-xprofile-avatars.php (modified) (6 diffs)
-
bp-xprofile/bp-xprofile-classes.php (modified) (3 diffs)
-
bp-xprofile/bp-xprofile-signup.php (modified) (5 diffs)
-
bp-xprofile/bp-xprofile-templatetags.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r166 r167 15 15 } 16 16 17 function bpcore_setup() { 18 global $current_user, $source_domain, $bp_nav; 19 20 $source_domain = 'http://' . get_usermeta( $current_user->ID, 'source_domain' ) . '/'; 17 function bp_core_setup() { 18 global $current_user, $loggedin_domain, $loggedin_userid; 19 global $current_domain, $current_userid, $bp_nav; 20 21 $loggedin_domain = bp_core_get_loggedin_domain(); 22 $loggedin_userid = $current_user->ID; 23 24 $current_domain = bp_core_get_current_domain(); 25 $current_userid = bp_core_get_current_userid(); 21 26 22 27 $bp_nav[1] = array( 23 28 'id' => 'blog', 24 29 'name' => 'Blog', 25 'link' => $ source_domain . 'blog'30 'link' => $loggedin_domain . 'blog' 26 31 ); 27 32 } 28 add_action( 'wp', 'bpcore_setup' ); 33 add_action( 'wp', 'bp_core_setup' ); 34 35 function bp_core_get_loggedin_domain() { 36 global $current_user; 37 38 if ( VHOST == 'yes' ) { 39 $loggedin_domain = 'http://' . get_usermeta( $current_user->ID, 'source_domain' ) . '/'; 40 } else { 41 $loggedin_domain = 'http://' . get_usermeta( $current_user->ID, 'source_domain' ) . '/' . get_usermeta( $current_user->ID, 'user_login' ) . '/'; 42 } 43 44 return $loggedin_domain; 45 } 46 47 function bp_core_get_current_domain() { 48 global $current_blog; 49 50 if ( VHOST == 'yes' ) { 51 $current_domain = 'http://' . $current_blog->domain . '/'; 52 } else { 53 $current_domain = get_bloginfo('wpurl') . '/'; 54 } 55 56 return $current_domain; 57 } 58 59 function bp_core_get_current_userid() { 60 $siteuser = bp_core_get_primary_username(); 61 $current_userid = bp_core_get_userid($siteuser); 62 63 return $current_userid; 64 } 65 66 function bp_core_get_primary_username() { 67 global $current_blog; 68 69 if ( VHOST == 'yes' ) { 70 $siteuser = explode('.', $current_blog->domain); 71 $siteuser = $siteuser[0]; 72 } else { 73 $siteuser = str_replace('/', '', $current_blog->path); 74 } 75 76 return $siteuser; 77 } 29 78 30 79 function start_buffer() { … … 353 402 } 354 403 355 356 // get the IDs of user blogs in a comma-separated list for use in SQL statements357 function bp_get_blog_ids_of_user( $id, $all = false ) {358 $blogs = get_blogs_of_user( $id, $all );359 $blog_ids = "";360 361 if ( $blogs && count($blogs) > 0 ){362 foreach( $blogs as $blog ) {363 $blog_ids .= $blog->blog_id.",";364 }365 }366 $blog_ids = trim( $blog_ids, "," );367 return $blog_ids;368 }369 370 // return a tick for a checkbox for a true boolean value371 function bp_boolean_ticked($bool) {372 if ( $bool ) {373 return " checked=\"checked\"";374 }375 return "";376 }377 378 // return a tick for a checkbox for a particular value379 function bp_value_ticked( $var, $value ) {380 if ( $var == $value ) {381 return " checked=\"checked\"";382 }383 return "";384 }385 386 // return true for a boolean value from a checkbox387 function bp_boolean( $value = 0 ) {388 if ( $value != "" ) {389 return 1;390 } else {391 return 0;392 }393 }394 395 // return an integer396 function bp_int( $var, $nullToOne=false ) {397 if ( @$var == "" ) {398 if ( $nullToOne ) {399 return 1;400 } else {401 return 0;402 }403 } else {404 return (int)$var;405 }406 }407 408 409 // show a friendly date410 function bp_friendly_date($timestamp) {411 // set the timestamp to now if it hasn't been given412 if ( strlen($timestamp) == 0 )413 $timestamp = time();414 415 // create the date string416 if ( date( "m", $timestamp ) == date("m") && date( "d", $timestamp ) == date("d") - 1 && date( "Y", $timestamp ) == date("Y") ) {417 return "yesterday at " . date( "g:i a", $timestamp );418 } else if ( date( "m", $timestamp ) == date("m") && date( "d", $timestamp ) == date("d") && date( "Y", $timestamp ) == date("Y") ) {419 return "at " . date( "g:i a", $timestamp );420 } else if ( date( "m", $timestamp) == date("m") && date( "d", $timestamp ) > date("d") - 5 && date( "Y", $timestamp ) == date("Y") ) {421 return "on " . date( "l", $timestamp ) . " at " . date( "g:i a", $timestamp );422 } else if ( date( "Y", $timestamp) == date("Y") ) {423 return "on " . date( "F jS", $timestamp );424 } else {425 return "on " . date( "F jS Y", $timestamp );426 }427 }428 429 // search users430 function bp_search_users( $q, $start = 0, $num = 10 ) {431 if ( trim($q) != "" ) {432 global $wpdb;433 global $current_user;434 435 $sql = "SELECT SQL_CALC_FOUND_ROWS id, user_login, display_name, user_nicename436 FROM " . $wpdb->base_prefix . "users437 WHERE (user_nicename like '%" . $wpdb->escape($q) . "%'438 OR user_email like '%" . $wpdb->escape($q) . "%'439 OR display_name like '%" . $wpdb->escape($q) . "%')440 AND (id <> " . $current_user->ID . " and id > 1)441 LIMIT " . $wpdb->escape($start) . ", " . $wpdb->escape($num) . ";";442 443 if ( !$users = $wpdb->get_results($sql) ) {444 return false;445 }446 447 $rows = $wpdb->get_var( "SELECT found_rows() AS found_rows" );448 449 if ( is_array($users) && count($users) > 0 ) {450 for ( $i = 0; $i < count($users); $i++ ) {451 $user = $users[$i];452 $user->siteurl = $user->user_url;453 $user->blogs = "";454 $user->blogs = get_blogs_of_user($user->id);455 $user->rows = $rows;456 }457 return $users;458 } else {459 return false;460 }461 } else {462 return false;463 }464 }465 466 // return a ' if the text ends in an "s", or "'s" otherwise467 function bp_end_with_s( $string ) {468 if ( substr( strtolower($string), - 1 ) == "s" ) {469 return $string . "'";470 } else {471 return $string . "'s";472 }473 }474 475 // pluralise a string476 function bp_plural( $num, $ifone = "", $ifmore = "s" ) {477 if ( bp_int($num) != 1 ) {478 return $ifmore;479 } else {480 return $ifone;481 }482 }483 484 404 function bp_is_serialized( $data ) { 485 405 if ( trim($data) == "" ) { -
trunk/bp-core/bp-core-templatetags.php
r166 r167 2 2 3 3 function bp_get_nav() { 4 global $bp_nav, $current_component ;4 global $bp_nav, $current_component, $current_userid, $loggedin_userid; 5 5 6 6 for ( $i = 0; $i < count($bp_nav); $i++ ) { 7 if ( $current_component == $bp_nav[$i]['id'] ) {7 if ( $current_component == $bp_nav[$i]['id'] && $current_userid == $loggedin_userid ) { 8 8 $selected = ' class="current"'; 9 9 } else { -
trunk/bp-xprofile.php
r166 r167 136 136 137 137 function xprofile_setup_nav() { 138 global $source_domain, $bp_nav, $bp_options_nav, $bp_xprofile_slug; 139 138 global $loggedin_domain, $bp_nav, $bp_options_nav; 139 global $loggedin_userid, $current_userid, $bp_xprofile_slug; 140 140 141 $bp_nav[0] = array( 141 142 'id' => $bp_xprofile_slug, 142 143 'name' => 'Profile', 143 'link' => $ source_domain . $bp_xprofile_slug144 'link' => $loggedin_domain . $bp_xprofile_slug 144 145 ); 145 146 146 $bp_options_nav[$bp_xprofile_slug] = array( 147 '' => array( 148 'name' => __('Publically Viewable'), 149 'link' => $source_domain . $bp_xprofile_slug . '/' ), 150 'edit' => array( 151 'name' => __('Edit Profile'), 152 'link' => $source_domain . $bp_xprofile_slug . '/edit' ), 153 'change-avatar' => array( 154 'name' => __('Change Avatar'), 155 'link' => $source_domain . $bp_xprofile_slug . '/change-avatar' ) 156 ); 147 if ( $loggedin_userid == $current_userid ) { 148 $bp_options_nav[$bp_xprofile_slug] = array( 149 '' => array( 150 'name' => __('Publically Viewable'), 151 'link' => $loggedin_domain . $bp_xprofile_slug . '/' ), 152 'edit' => array( 153 'name' => __('Edit Profile'), 154 'link' => $loggedin_domain . $bp_xprofile_slug . '/edit' ), 155 'change-avatar' => array( 156 'name' => __('Change Avatar'), 157 'link' => $loggedin_domain . $bp_xprofile_slug . '/change-avatar' ) 158 ); 159 } 157 160 } 158 161 add_action( 'wp', 'xprofile_setup_nav' ); … … 166 169 167 170 function xprofile_catch_action() { 168 global $bp_xprofile_slug, $current_component, $current_blog, $current_action; 171 global $bp_xprofile_slug, $current_component, $current_blog; 172 global $loggedin_userid, $current_userid, $current_action; 169 173 170 174 if ( $current_component == $bp_xprofile_slug && $current_blog->blog_id > 1 ) { 171 if ( !$current_action ) 175 if ( !$current_action ) { 172 176 bp_catch_uri( 'profile/index' ); 173 174 if ( $current_action == 'edit' && !$action_variables ) 177 } else if ( $current_action == 'edit' && !$action_variables && $loggedin_userid == $current_userid ) { 175 178 bp_catch_uri( 'profile/edit' ); 176 177 if ( $current_action == 'change-avatar' ) 179 } else if ( $current_action == 'change-avatar' && $loggedin_userid == $current_userid ) { 178 180 bp_catch_uri( 'profile/change-avatar' ); 181 } else { 182 bp_catch_uri( 'profile/index' ); 183 } 179 184 } 180 185 } … … 190 195 191 196 function xprofile_profile_template() { 192 global $current_blog, $profile_template, $coreuser_id; 193 194 if ( VHOST == 'yes' ) { 195 $siteuser = explode('.', $current_blog->domain); 196 $siteuser = $siteuser[0]; 197 } else { 198 $siteuser = str_replace('/', '', $current_blog->path); 199 } 200 201 $coreuser_id = bp_core_get_userid($siteuser); 202 $profile_template = new BP_XProfile_Template($coreuser_id); 197 global $profile_template, $current_userid; 198 199 $profile_template = new BP_XProfile_Template($current_userid); 203 200 } 204 201 add_action( 'wp_head', 'xprofile_profile_template' ); … … 212 209 213 210 function xprofile_edit( $group_id = null, $action = null ) { 214 global $wpdb, $bp_xprofile_table_name_groups, $userdata, $ source_domain;211 global $wpdb, $bp_xprofile_table_name_groups, $userdata, $loggedin_domain; 215 212 216 213 if ( !$group_id ) { … … 225 222 226 223 if ( !$action ) 227 $action = $ source_domain . 'wp-admin/admin.php?page=xprofile_' . $group->name . '&mode=save';224 $action = $loggedin_domain . 'wp-admin/admin.php?page=xprofile_' . $group->name . '&mode=save'; 228 225 ?> 229 226 <div class="wrap"> -
trunk/bp-xprofile/bp-xprofile-avatars.php
r166 r167 67 67 68 68 // Main UI Rendering 69 function xprofile_avatar_admin($message = null ) {69 function xprofile_avatar_admin($message = null, $action = null) { 70 70 ?> 71 71 <?php if ( !isset($_POST['slick_avatars_action']) && !isset($_GET['slick_avatars_action']) ) { ?> … … 84 84 85 85 <?php 86 $action = get_option('home') . '/wp-admin/admin.php?page=bp-xprofile.php'; 86 if ( !$action ) 87 $action = get_option('home') . '/wp-admin/admin.php?page=bp-xprofile.php'; 88 87 89 xprofile_render_avatar_upload_form($action); 88 90 … … 128 130 129 131 // Render the cropper UI 130 $action = get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php'; 132 if ( !$action ) 133 $action = get_option('home') .'/wp-admin/admin.php?page=bp-xprofile.php'; 134 131 135 xprofile_render_avatar_cropper($original, $canvas, $action); 132 136 … … 224 228 } 225 229 226 function xprofile_render_avatar_cropper($original, $new, $action ) {230 function xprofile_render_avatar_cropper($original, $new, $action, $user_id = null) { 227 231 $size = getimagesize($new); 228 232 229 // Get the URL to access the uploaded file 230 $url = get_usermeta( get_current_user_id(), 'source_domain' ); 233 if ( !$user_id ) 234 $user_id = get_current_user_id(); 235 236 if ( VHOST == 'yes' ) { 237 $url = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/'; 238 } else { 239 $url = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/' . get_usermeta( $user_id, 'nickname' ) . '/'; 240 } 241 231 242 $src = str_replace( array(ABSPATH), array($url . '/'), $new ); 232 243 233 244 // Load cropper details 234 245 … … 354 365 if ( !$user_id ) 355 366 $user_id = get_current_user_id(); 367 368 if ( VHOST == 'yes' ) { 369 $src = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/'; 370 } else { 371 $src = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/' . get_usermeta( $user_id, 'nickname' ) . '/'; 372 } 356 373 357 374 $old = get_usermeta( $user_id, 'xprofile_avatar_v1_path' ); 358 $v1_href = str_replace( array(ABSPATH), array( 'http://' . get_usermeta( get_current_user_id(), 'source_domain' ) . '/'), $vars['v1_out'] );375 $v1_href = str_replace( array(ABSPATH), array($src), $vars['v1_out'] ); 359 376 update_usermeta( $user_id, 'xprofile_avatar_v1', $v1_href ); 360 377 update_usermeta( $user_id, 'xprofile_avatar_v1_path', $vars['v1_out'] ); … … 363 380 if ( XPROFILE_AVATAR_V2_W !== false && XPROFILE_AVATAR_V2_H !== false ) { 364 381 $old = get_usermeta( $user_id, 'xprofile_avatar_v2_path' ); 365 $v2_href = str_replace( array(ABSPATH), array( 'http://' . get_usermeta( get_current_user_id(), 'source_domain' ) . '/'), $vars['v2_out'] );382 $v2_href = str_replace( array(ABSPATH), array($src), $vars['v2_out'] ); 366 383 update_usermeta( $user_id, 'xprofile_avatar_v2', $v2_href ); 367 384 update_usermeta( $user_id, 'xprofile_avatar_v2_path', $vars['v2_out'] ); -
trunk/bp-xprofile/bp-xprofile-classes.php
r162 r167 1077 1077 1078 1078 function get_value_byid( $field_id, $user_id = null ) { 1079 global $wpdb, $c oreuser_id, $bp_xprofile_table_name_data;1079 global $wpdb, $current_userid, $bp_xprofile_table_name_data; 1080 1080 1081 1081 if ( !$user_id ) 1082 $user_id = $c oreuser_id;1082 $user_id = $current_userid; 1083 1083 1084 1084 $sql = $wpdb->prepare("SELECT * FROM $bp_xprofile_table_name_data WHERE field_id = %d AND user_id = %d", $field_id, $user_id ); … … 1092 1092 1093 1093 function get_value_byfieldname( $fields, $user_id = null ) { 1094 global $c oreuser_id, $wpdb, $bp_xprofile_table_name_fields, $bp_xprofile_table_name_data;1094 global $current_userid, $wpdb, $bp_xprofile_table_name_fields, $bp_xprofile_table_name_data; 1095 1095 1096 1096 if ( !$fields ) … … 1098 1098 1099 1099 if ( !$user_id ) 1100 $user_id = $c oreuser_id;1100 $user_id = $current_userid; 1101 1101 1102 1102 if ( is_array($fields) ) { -
trunk/bp-xprofile/bp-xprofile-signup.php
r158 r167 291 291 function xprofile_on_activate( $blog_id = null, $user_id = null ) { 292 292 global $wpdb, $profile_picture_path; 293 293 294 294 // Extract signup meta fields to fill out profile 295 295 $field_ids = get_blog_option( $blog_id, 'xprofile_field_ids' ); 296 296 $field_ids = explode( ",", $field_ids ); 297 297 298 298 // Get the new user ID. 299 299 $sql = "SELECT u.ID from " . $wpdb->base_prefix . "users u, … … 302 302 AND um.meta_key = 'primary_blog' 303 303 AND um.meta_value = " . $blog_id; 304 304 305 305 $user_id = $wpdb->get_var($sql); 306 306 … … 326 326 if ( $resized && $original ) { 327 327 $upload_dir = bp_upload_dir(NULL, $blog_id); 328 328 329 329 if ( $upload_dir ) { 330 330 $resized_strip_path = explode( '/', $resized ); … … 349 349 // Render the cropper UI 350 350 $action = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/wp-activate.php?key=' . $_GET['key'] . '&cropped=true'; 351 xprofile_render_avatar_cropper($original, $resized, $action );351 xprofile_render_avatar_cropper($original, $resized, $action, $user_id); 352 352 353 353 //$result = xprofile_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 ); … … 368 368 369 369 $user_id = xprofile_get_user_by_key($_GET['key']); 370 370 371 371 if ( $user_id && isset($_POST['orig']) && isset($_POST['canvas']) ) { 372 echo "test is in here"; 372 373 xprofile_check_crop( $_POST['orig'], $_POST['canvas'] ); 373 374 $result = xprofile_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 375 xprofile_avatar_save($result, $user_id); 375 376 } 376 377 377 378 if ( VHOST == 'yes' ) { 378 header('Location: http://' . $_SERVER['HTTP_HOST']);379 $url = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/'; 379 380 } else { 380 $path = explode( '/', $_SERVER['REQUEST_URI'] ); 381 header( 'Location:' . $path[0] . $path[1] . $path[2] ); 381 $url = 'http://' . get_usermeta( $user_id, 'source_domain' ) . '/' . get_usermeta( $user_id, 'nickname' ); 382 382 } 383 384 header("Location: $url"); 383 385 } 384 386 } -
trunk/bp-xprofile/bp-xprofile-templatetags.php
r166 r167 210 210 211 211 function bp_the_avatar() { 212 global $c oreuser_id;213 echo xprofile_get_avatar( $c oreuser_id, 2 );212 global $current_userid; 213 echo xprofile_get_avatar( $current_userid, 2 ); 214 214 } 215 215 216 216 function bp_the_avatar_thumbnail() { 217 global $c oreuser_id;218 echo xprofile_get_avatar( $c oreuser_id, 1 );217 global $current_userid; 218 echo xprofile_get_avatar( $current_userid, 1 ); 219 219 } 220 220 221 221 function bp_loggedinuser_avatar_thumbnail() { 222 global $ current_user;223 echo xprofile_get_avatar( $ current_user->ID, 1 );222 global $loggedin_userid; 223 echo xprofile_get_avatar( $loggedin_userid, 1 ); 224 224 } 225 225 226 226 function bp_user_fullname($user_id = false) { 227 global $c oreuser_id;227 global $current_userid; 228 228 229 229 if ( !$user_id ) 230 $user_id = $c oreuser_id;230 $user_id = $current_userid; 231 231 232 232 $data = bp_get_field_data( array( 'First Name', 'Last Name' ) ); … … 248 248 249 249 function bp_profile_group_tabs() { 250 global $ source_domain, $bp_xprofile_slug, $group_name;250 global $loggedin_domain, $bp_xprofile_slug, $group_name; 251 251 252 252 $groups = BP_XProfile_Group::get_all(); … … 262 262 } 263 263 264 echo '<li' . $selected . '><a href="' . $ source_domain . $bp_xprofile_slug . '/edit/group/' . $groups[$i]->id . '">' . $groups[$i]->name . '</a></li>';264 echo '<li' . $selected . '><a href="' . $loggedin_domain . $bp_xprofile_slug . '/edit/group/' . $groups[$i]->id . '">' . $groups[$i]->name . '</a></li>'; 265 265 } 266 266 } … … 284 284 285 285 function bp_edit_profile_form() { 286 global $action_variables, $ source_domain, $bp_xprofile_slug;286 global $action_variables, $loggedin_domain, $bp_xprofile_slug; 287 287 288 288 $group_id = $action_variables[1]; … … 291 291 $group_id = 1; // 'Basic' group. 292 292 293 xprofile_edit( $group_id, $source_domain . $bp_xprofile_slug . '/edit/group/' . $group_id . '/?mode=save' ); 294 } 295 296 293 xprofile_edit( $group_id, $loggedin_domain . $bp_xprofile_slug . '/edit/group/' . $group_id . '/?mode=save' ); 294 } 295 296 function bp_avatar_upload_form() { 297 global $loggedin_domain, $bp_xprofile_slug; 298 299 xprofile_avatar_admin(null, $loggedin_domain . $bp_xprofile_slug . '/change-avatar/'); 300 } 297 301 298 302
