Changeset 1503
- Timestamp:
- 06/03/2009 10:49:34 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r1482 r1503 1 1 <?php 2 3 2 /* Define the current version number for checking if DB tables are up to date. */ 4 3 define( 'BP_CORE_VERSION', '1.0' ); … … 171 170 add_action( 'plugins_loaded', 'bp_core_setup_root_components', 1 ); 172 171 173 function bp_core_setup_session() { 174 // Start a session for error/success feedback on redirect and for signup functions. 175 @session_start(); 172 function bp_core_setup_cookies() { 173 global $bp_message, $bp_message_type; 176 174 177 175 // Render any error/success feedback on the template 178 if ( $_SESSION['message'] != '' ) 179 add_action( 'template_notices', 'bp_core_render_notice' ); 180 } 181 add_action( 'wp', 'bp_core_setup_session', 3 ); 176 if ( $_COOKIE['bp-message'] == '' || !isset( $_COOKIE['bp-message'] ) ) 177 return false; 178 179 $bp_message = $_COOKIE['bp-message']; 180 $bp_message_type = $_COOKIE['bp-message-type']; 181 add_action( 'template_notices', 'bp_core_render_notice' ); 182 183 setcookie( 'bp-message', false, time() - 1000, COOKIEPATH ); 184 setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH ); 185 } 186 add_action( 'wp', 'bp_core_setup_cookies', 3 ); 182 187 183 188 function bp_core_install() { … … 847 852 if ( !$type ) 848 853 $type = 'success'; 849 850 $_SESSION['message'] = $message;851 $_SESSION['message_type'] = $type;854 855 setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH ); 856 setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH ); 852 857 } 853 858 … … 862 867 */ 863 868 function bp_core_render_notice() { 864 if ( $_ SESSION['message'] ) {865 $type = ( 'success' == $_ SESSION['message_type'] ) ? 'updated' : 'error';869 if ( $_COOKIE['bp-message'] ) { 870 $type = ( 'success' == $_COOKIE['bp-message-type'] ) ? 'updated' : 'error'; 866 871 ?> 867 872 <div id="message" class="<?php echo $type; ?>"> 868 <p><?php echo $_ SESSION['message']; ?></p>873 <p><?php echo $_COOKIE['bp-message']; ?></p> 869 874 </div> 870 <?php 871 unset( $_SESSION['message'] ); 872 unset( $_SESSION['message_type'] ); 873 875 <?php 874 876 do_action( 'bp_core_render_notice' ); 875 877 } -
trunk/bp-groups.php
r1477 r1503 362 362 $completed_to_step = 0; 363 363 364 unset($_SESSION['group_obj_id']);365 unset($_SESSION['completed_to_step']);364 setcookie( 'bp_group_obj_id', false, time() - 1000, COOKIEPATH ); 365 setcookie( 'bp_group_completed_to_step', false, time() - 1000, COOKIEPATH ); 366 366 367 367 $no_instantiate = true; … … 369 369 } 370 370 371 if ( isset($_ SESSION['completed_to_step']) && !$reset_steps ) {372 $completed_to_step = $_ SESSION['completed_to_step'];371 if ( isset($_COOKIE['bp_group_completed_to_step']) && !$reset_steps ) { 372 $completed_to_step = $_COOKIE['bp_group_completed_to_step']; 373 373 } 374 374 375 375 if ( isset( $_POST['save'] ) || isset( $_POST['skip'] ) ) { 376 $group_obj = new BP_Groups_Group( $_ SESSION['group_obj_id'] );377 378 if ( !$group_id = groups_create_group( $create_group_step, $_ SESSION['group_obj_id'] ) ) {376 $group_obj = new BP_Groups_Group( $_COOKIE['bp_group_obj_id'] ); 377 378 if ( !$group_id = groups_create_group( $create_group_step, $_COOKIE['bp_group_obj_id'] ) ) { 379 379 bp_core_add_message( __('There was an error saving group details. Please try again.', 'buddypress'), 'error' ); 380 380 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $create_group_step ); … … 382 382 $create_group_step++; 383 383 $completed_to_step++; 384 $_SESSION['completed_to_step'] = $completed_to_step; 385 $_SESSION['group_obj_id'] = $group_id; 384 385 /* Unset cookie info */ 386 setcookie( 'bp_group_obj_id', false, time() - 1000, COOKIEPATH ); 387 setcookie( 'bp_group_completed_to_step', false, time() - 1000, COOKIEPATH ); 388 389 /* Reset cookie info */ 390 setcookie( 'bp_group_obj_id', $group_id, time()+60*60*24, COOKIEPATH ); 391 setcookie( 'bp_group_completed_to_step', $completed_to_step, time()+60*60*24, COOKIEPATH ); 386 392 } 387 393 … … 390 396 } 391 397 392 if ( isset($_ SESSION['group_obj_id']) && !$group_obj && !$no_instantiate )393 $group_obj = new BP_Groups_Group( $_ SESSION['group_obj_id'] );398 if ( isset($_COOKIE['bp_group_obj_id']) && !$group_obj && !$no_instantiate ) 399 $group_obj = new BP_Groups_Group( $_COOKIE['bp_group_obj_id'] ); 394 400 395 401 bp_core_load_template( apply_filters( 'groups_template_create_group', 'groups/create' ) ); -
trunk/bp-groups/bp-groups-ajax.php
r1486 r1503 22 22 23 23 echo '<li id="uid-' . $user->id . '">'; 24 echo attribute_escape( $user->avatar_thumb );25 echo '<h4>' . attribute_escape( $user->user_link ). '</h4>';24 echo $user->avatar_thumb; 25 echo '<h4>' . $user->user_link . '</h4>'; 26 26 echo '<span class="activity">' . attribute_escape( $user->last_active ) . '</span>'; 27 27 echo '<div class="action"> -
trunk/bp-messages.php
r1460 r1503 501 501 502 502 function messages_add_callback_values( $recipients, $subject, $content ) { 503 $_SESSION['send_to'] = $recipients;504 $_SESSION['subject'] = $subject;505 $_SESSION['content'] = $content;503 setcookie( 'bp_messages_send_to', $recipients, time()+60*60*24, COOKIEPATH ); 504 setcookie( 'bp_messages_subject', $subject, time()+60*60*24, COOKIEPATH ); 505 setcookie( 'bp_messages_content', $content, time()+60*60*24, COOKIEPATH ); 506 506 } 507 507 508 508 function messages_remove_callback_values() { 509 unset($_SESSION['send_to']);510 unset($_SESSION['subject']);511 unset($_SESSION['content']);509 setcookie( 'bp_messages_send_to', false, time()-1000, COOKIEPATH ); 510 setcookie( 'bp_messages_subject', false, time()-1000, COOKIEPATH ); 511 setcookie( 'bp_messages_content', false, time()-1000, COOKIEPATH ); 512 512 } 513 513 -
trunk/bp-messages/bp-messages-templatetags.php
r1473 r1503 284 284 } 285 285 function bp_get_messages_username_value() { 286 if ( isset( $_ SESSION['send_to'] ) ) {287 return apply_filters( 'bp_get_messages_username_value', $_ SESSION['send_to'] );288 } else if ( isset( $_GET['r'] ) && !isset( $_ SESSION['send_to'] ) ) {286 if ( isset( $_COOKIE['bp_messages_send_to'] ) ) { 287 return apply_filters( 'bp_get_messages_username_value', $_COOKIE['bp_messages_send_to'] ); 288 } else if ( isset( $_GET['r'] ) && !isset( $_COOKIE['bp_messages_send_to'] ) ) { 289 289 return apply_filters( 'bp_get_messages_username_value', $_GET['r'] ); 290 290 } … … 295 295 } 296 296 function bp_get_messages_subject_value() { 297 return apply_filters( 'bp_get_messages_subject_value', $_ SESSION['subject'] );297 return apply_filters( 'bp_get_messages_subject_value', $_COOKIE['bp_messages_subject'] ); 298 298 } 299 299 … … 302 302 } 303 303 function bp_get_messages_content_value() { 304 return apply_filters( 'bp_get_messages_content_value', $_ SESSION['content'] );304 return apply_filters( 'bp_get_messages_content_value', $_COOKIE['bp_messages_content'] ); 305 305 } 306 306 -
trunk/bp-xprofile/bp-xprofile-signup.php
r1473 r1503 86 86 87 87 function xprofile_validate_signup_fields( $result ) { 88 global $bp_xprofile_callback, $avatar_error , $avatar_error_msg, $has_errors;88 global $bp_xprofile_callback, $avatar_error_msg; 89 89 global $canvas, $original; 90 90 global $current_site, $active_signup; 91 91 global $wp_upload_error; 92 global $bp_signup_has_errors, $bp_signup_avatar_has_errors; 92 93 93 94 if ( $_POST['stage'] != 'validate-user-signup' ) return $result; 94 95 95 // form has been submitted, let's validate the form96 // using the built in Wordpress functions and our own.97 98 96 extract($result); 99 97 98 if ( $bp_signup_has_errors || $bp_signup_avatar_has_errors ) 99 $errors->add( 'bp_xprofile_errors', '' ); 100 101 return array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); 102 } 103 add_filter( 'wpmu_validate_user_signup', 'xprofile_validate_signup_fields', 10, 1 ); 104 105 function xprofile_add_profile_meta( $meta ) { 106 global $bp, $bp_blog_signup_meta; 107 108 if ( $_POST['stage'] == 'validate-blog-signup' ) { 109 $bp_meta = $bp_blog_signup_meta; 110 } else if ( $_POST['stage'] == 'validate-user-signup' ) { 111 $bp_meta = unserialize( stripslashes( $_COOKIE['bp_xprofile_meta'] ) ); 112 } else { 113 $bp_meta = $meta; 114 } 115 116 return $bp_meta; 117 } 118 add_filter( 'add_signup_meta', 'xprofile_add_profile_meta' ); 119 120 function xprofile_load_signup_meta() { 121 global $bp_signup_has_errors, $bp_signup_avatar_has_errors; 122 global $bp_xprofile_callback, $avatar_error_msg; 123 global $canvas, $original; 124 global $current_site, $active_signup; 125 global $wp_upload_error; 126 127 if ( $_POST['stage'] != 'validate-user-signup' ) return; 128 100 129 $counter = 0; 101 $ has_errors = false;130 $bp_signup_has_errors = false; 102 131 $prev_field_id = -1; 103 132 104 133 // Validate all sign up fields 105 134 $fields = BP_XProfile_Field::get_signup_fields(); 106 135 107 136 if ( $fields ) { 108 137 foreach ( $fields as $field ) { 109 138 110 139 $value = $_POST['field_' . $field->id]; 111 140 112 141 // Need to check if the previous field had 113 142 // the same ID, as to not validate individual … … 133 162 "value" => $value 134 163 ); 135 164 136 165 if ( $field->is_required && empty( $value ) ) { 137 166 $bp_xprofile_callback[$counter]["error_msg"] = sprintf( __( '%s cannot be left blank', 'buddypress' ), $field->name ); 138 $ has_errors = true;167 $bp_signup_has_errors = true; 139 168 } 140 169 … … 167 196 if ( 4 !== $_FILES['file']['error'] ) { 168 197 if ( !$checked_upload = bp_core_check_avatar_upload($_FILES) ) { 169 $ avatar_error= true;198 $bp_signup_avatar_has_errors = true; 170 199 $avatar_error_msg = $uploadErrors[$_FILES['file']['error']]; 171 200 } 172 201 173 202 if ( $checked_upload && !$checked_size = bp_core_check_avatar_size($_FILES) ) { 174 $ avatar_error= true;203 $bp_signup_avatar_has_errors = true; 175 204 $avatar_size = size_format(CORE_MAX_FILE_SIZE); 176 205 $avatar_error_msg = sprintf( __('The file you uploaded is too big. Please upload a file under %s', 'buddypress'), $avatar_size); … … 178 207 179 208 if ( $checked_upload && $checked_size && !$checked_type = bp_core_check_avatar_type($_FILES) ) { 180 $ avatar_error= true;209 $bp_signup_avatar_has_errors = true; 181 210 $avatar_error_msg = __('Please upload only JPG, GIF or PNG photos.', 'buddypress'); 182 211 } … … 184 213 // "Handle" upload into temporary location 185 214 if ( $checked_upload && $checked_size && $checked_type && !$original = bp_core_handle_avatar_upload($_FILES) ) { 186 $ avatar_error= true;215 $bp_signup_avatar_has_errors = true; 187 216 $avatar_error_msg = sprintf( __('Upload Failed! Error was: %s', 'buddypress'), $wp_upload_error ); 188 217 } … … 192 221 } 193 222 } 194 195 if ( !$has_errors && !$avatar_error ) { 223 224 if ( !$bp_signup_has_errors && !$bp_signup_avatar_has_errors ) { 225 /* Destroy and existing cookies */ 226 setcookie( 'bp_xprofile_meta', false, time()-1000, COOKIEPATH ); 227 196 228 $public = (int) $_POST['blog_public']; 197 229 198 230 // put the user profile meta in a session ready to store. 199 231 for ( $i = 0; $i < count($bp_xprofile_callback); $i++ ) { 200 $meta['field_' . $bp_xprofile_callback[$i]['field_id']] .= $bp_xprofile_callback[$i]['value']; 201 } 202 203 $meta['xprofile_field_ids'] = $_POST['xprofile_ids']; 204 $meta['avatar_image_resized'] = $canvas; 205 $meta['avatar_image_original'] = $original; 206 207 $_SESSION['xprofile_meta'] = $meta; 208 } else { 209 $errors->add( 'bp_xprofile_errors', '' ); 210 } 211 212 return array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors); 213 } 214 add_filter( 'wpmu_validate_user_signup', 'xprofile_validate_signup_fields', 10, 1 ); 215 216 217 function xprofile_add_blog_signup_meta( $meta ) { 218 $_SESSION['xprofile_meta']['public'] = (int) $_POST['blog_public']; 219 $_SESSION['xprofile_meta']['lang_id'] = 1; // deprecated 220 $_SESSION['xprofile_meta']['blogname'] = $_POST['blogname']; 221 $_SESSION['xprofile_meta']['blog_title'] = $_POST['blog_title']; 222 223 return $meta; 224 } 225 226 add_filter( 'wpmu_validate_blog_signup', 'xprofile_add_blog_signup_meta' ); 227 228 229 function xprofile_add_profile_meta( $meta ) { 230 global $bp; 231 232 if ( $bp->current_component != $bp->blogs->slug ) 233 return $_SESSION['xprofile_meta']; 234 else 235 return $meta; 236 } 237 add_filter( 'add_signup_meta', 'xprofile_add_profile_meta' ); 232 $bp_meta['field_' . $bp_xprofile_callback[$i]['field_id']] .= $bp_xprofile_callback[$i]['value']; 233 } 234 235 $bp_meta['xprofile_field_ids'] = $_POST['xprofile_ids']; 236 $bp_meta['avatar_image_resized'] = $canvas; 237 $bp_meta['avatar_image_original'] = $original; 238 239 setcookie( 'bp_xprofile_meta', serialize($bp_meta), time()+60*60*24, COOKIEPATH ); 240 } 241 } 242 add_action( 'init', 'xprofile_load_signup_meta' ); 243 244 function xprofile_load_blog_signup_meta() { 245 global $bp_blog_signup_meta; 246 247 if ( $_POST['stage'] != 'validate-blog-signup' ) return; 248 249 $blog_meta = array( 250 'public' => $_POST['blog_public'], 251 'lang_id' => 1, // deprecated 252 'blogname' => $_POST['blogname'], 253 'blog_title' => $_POST['blog_title'] 254 ); 255 256 $bp_meta = unserialize( stripslashes( $_COOKIE['bp_xprofile_meta'] ) ); 257 $bp_blog_signup_meta = array_merge( $bp_meta, $blog_meta ); 258 } 259 add_action( 'init', 'xprofile_load_blog_signup_meta' ); 238 260 239 261 /************************************************************************** … … 265 287 add_action( 'wpmu_activate_user', 'xprofile_on_activate_user', 1, 3 ); 266 288 267 268 289 function xprofile_extract_signup_meta( $user_id, $meta ) { 269 290 // Extract signup meta fields to fill out profile
Note: See TracChangeset
for help on using the changeset viewer.