Changeset 38
- Timestamp:
- 04/18/2008 06:28:48 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 33 added
- 2 edited
-
bp-xprofile.php (modified) (4 diffs)
-
bp-xprofile/bp-xprofile-classes.php (modified) (24 diffs)
-
buddypress-theme (added)
-
buddypress-theme/default (added)
-
buddypress-theme/default/404.php (added)
-
buddypress-theme/default/archive.php (added)
-
buddypress-theme/default/archives.php (added)
-
buddypress-theme/default/attachment.php (added)
-
buddypress-theme/default/blog.php (added)
-
buddypress-theme/default/comments-popup.php (added)
-
buddypress-theme/default/comments.php (added)
-
buddypress-theme/default/footer.php (added)
-
buddypress-theme/default/functions.php (added)
-
buddypress-theme/default/header.php (added)
-
buddypress-theme/default/images (added)
-
buddypress-theme/default/images/audio.jpg (added)
-
buddypress-theme/default/images/bp_logo.gif (added)
-
buddypress-theme/default/images/header-img.php (added)
-
buddypress-theme/default/images/kubrickbg-ltr.jpg (added)
-
buddypress-theme/default/images/kubrickbg-rtl.jpg (added)
-
buddypress-theme/default/images/kubrickbgcolor.jpg (added)
-
buddypress-theme/default/images/kubrickbgwide.jpg (added)
-
buddypress-theme/default/images/kubrickfooter.jpg (added)
-
buddypress-theme/default/images/kubrickheader.jpg (added)
-
buddypress-theme/default/index.php (added)
-
buddypress-theme/default/links.php (added)
-
buddypress-theme/default/page.php (added)
-
buddypress-theme/default/rtl.css (added)
-
buddypress-theme/default/screenshot.png (added)
-
buddypress-theme/default/search.php (added)
-
buddypress-theme/default/searchform.php (added)
-
buddypress-theme/default/sidebar.php (added)
-
buddypress-theme/default/single.php (added)
-
buddypress-theme/default/style.css (added)
-
buddypress-theme/default/tweaked_style.css (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile.php
r37 r38 1 1 <?php 2 2 3 $bp_xprofile_table_name = $wpdb->base_prefix . 'bp_xprofile'; 3 $bp_xprofile_table_name_groups = $wpdb->base_prefix . 'bp_xprofile_groups'; 4 $bp_xprofile_table_name_fields = $wpdb->base_prefix . 'bp_xprofile_fields'; 5 $bp_xprofile_table_name_data = $wpdb->base_prefix . 'bp_xprofile_data'; 6 4 7 $image_base = get_option('siteurl') . '/wp-content/mu-plugins/bp-xprofile/images'; 5 8 $profile_picture_path = trim( get_option('upload_path') ) . '/profilepics'; … … 9 12 include_once( 'bp-xprofile/bp-xprofile-admin.php' ); 10 13 include_once( 'bp-xprofile/bp-xprofile-signup.php' ); 14 include_once( 'bp-xprofile/bp-xprofile-templatetags.php' ); 11 15 include_once( 'bp-xprofile/bp-xprofile-cssjs.php' ); 12 16 … … 177 181 178 182 function xprofile_edit() { 179 global $wpdb, $bp_xprofile_table_name , $userdata;183 global $wpdb, $bp_xprofile_table_name_groups, $userdata; 180 184 181 185 // Dynamic tabs mean that we have to assign the same function to all … … 184 188 $group_name = explode( "_", $_GET['page'] ); 185 189 $group_name = $group_name[1]; // xprofile_XXXX <-- This X bit. 186 $group_id = $wpdb->get_var( "SELECT id FROM " . $bp_xprofile_table_name . "_groups WHERE name = '" . $group_name . "'");190 $group_id = $wpdb->get_var( $wpdb->prepare("SELECT id FROM $bp_xprofile_table_name_groups WHERE name = %s", $group_name) ); 187 191 188 192 $group = new BP_XProfile_Group($group_id); -
trunk/bp-xprofile/bp-xprofile-classes.php
r33 r38 19 19 20 20 var $base_prefix; 21 var $table_name; 21 var $table_name_groups; 22 var $table_name_fields; 22 23 23 24 function bp_xprofile_group( $id = null ) { 24 global $bp_xprofile_table_name ;25 global $bp_xprofile_table_name_groups, $bp_xprofile_table_name_fields; 25 26 26 $this->table_name = $bp_xprofile_table_name; 27 $this->table_name_groups = $bp_xprofile_table_name_groups; 28 $this->table_name_fields = $bp_xprofile_table_name_fields; 27 29 28 30 if ( $id ) { … … 36 38 global $wpdb; 37 39 38 $sql = "SELECT * FROM " . $this->table_name . "_groups 39 WHERE id = " . $id; 40 40 $sql = $wpdb->prepare("SELECT * FROM $this->table_name_groups WHERE id = %d", $id); 41 41 42 if ( $group = $wpdb->get_row($sql) ) { 42 43 $this->id = $group->id; … … 55 56 56 57 if ( $this->id != null ) { 57 $sql = "UPDATE " . $this->table_name . "_groups 58 SET 59 name = '" . $this->name . "', 60 description = '" . $this->description . "' 61 WHERE id = " . $this->id; 62 } else { 63 $sql = "INSERT INTO " . $this->table_name . "_groups ( 64 name, 65 description, 66 can_delete 67 ) VALUES ( 68 '" . $this->name . "', 69 '" . $this->description . "', 70 1 71 )"; 72 } 73 74 if ( $wpdb->query($sql) === false ) { 75 return false; 76 } 58 $sql = $wpdb->prepare("UPDATE $this->table_name_groups SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id); 59 } else { 60 $sql = $wpdb->prepare("INSERT INTO $this->table_name_groups (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description); 61 } 62 63 if ( $wpdb->query($sql) === false ) 64 return false; 77 65 78 66 return true; … … 85 73 return false; 86 74 87 $sql = "DELETE FROM " . $this->table_name . "_groups 88 WHERE id = " . $this->id; 75 $sql = $wpdb->prepare("DELETE FROM $this->table_name_groups WHERE id = %d", $this->id); 89 76 90 77 if ( $wpdb->query($sql) === false) { … … 107 94 108 95 // Get field ids for the current group. 109 $sql = "SELECT id, type FROM " . $this->table_name . "_fields 110 WHERE group_id = " . $this->id . " 111 AND parent_id = 0 112 ORDER BY id"; 96 $sql = $wpdb->prepare("SELECT id, type FROM $this->table_name_fields WHERE group_id = %d AND parent_id = 0 ORDER BY id", $this->id); 113 97 114 98 if(!$fields = $wpdb->get_results($sql)) … … 165 149 166 150 function get_all( $hide_empty = false ) { 167 global $wpdb, $bp_xprofile_table_name ;151 global $wpdb, $bp_xprofile_table_name_groups, $bp_xprofile_table_name_fields; 168 152 169 153 if ( $hide_empty ) { 170 $sql = "SELECT DISTINCT g.* FROM " . $bp_xprofile_table_name . "_groups g 171 INNER JOIN " . $bp_xprofile_table_name . "_fields f 172 ON g.id = f.group_id 173 ORDER BY g.id ASC"; 174 } else { 175 $sql = "SELECT * FROM " . $bp_xprofile_table_name . "_groups 176 ORDER BY id ASC"; 154 $sql = $wpdb->prepare("SELECT DISTINCT g.* FROM $bp_xprofile_table_name_groups g INNER JOIN $bp_xprofile_table_name_fields f ON g.id = f.group_id ORDER BY g.id ASC"); 155 } else { 156 $sql = $wpdb->prepare("SELECT * FROM $bp_xprofile_table_name_groups ORDER BY id ASC"); 177 157 } 178 158 … … 216 196 var $message_type = 'err'; 217 197 218 var $bp_xprofile_table_name; 198 var $table_name_groups; 199 var $table_name_fields; 219 200 220 201 function bp_xprofile_field( $id = null, $user_id = null, $get_data = true ) { 221 global $bp_xprofile_table_name; 222 $this->table_name = $bp_xprofile_table_name; 202 global $bp_xprofile_table_name_groups, $bp_xprofile_table_name_fields; 203 204 $this->table_name_groups = $bp_xprofile_table_name_groups; 205 $this->table_name_fields = $bp_xprofile_table_name_fields; 223 206 224 207 if ( $id ) { 225 $this->populate( $id, $user_id, $get_data);208 $this->populate( $id, $user_id, $get_data ); 226 209 } 227 210 } … … 234 217 } 235 218 236 $sql = "SELECT * FROM " . $this->table_name . "_fields 237 WHERE id = " . $id; 219 $sql = $wpdb->prepare("SELECT * FROM $this->table_name_fields WHERE id = %d", $id); 238 220 239 221 if ( $field = $wpdb->get_row($sql) ) { … … 256 238 global $wpdb; 257 239 258 $sql = "DELETE FROM " . $this->table_name . "_fields 259 WHERE id = " . $this->id . " 260 OR parent_id = " . $this->id; 240 $sql = $wpdb->prepare("DELETE FROM $this->table_name_fields WHERE id = %d OR parent_id = %d", $this->id, $this->id); 261 241 262 242 if ( $wpdb->query($sql) === false ) … … 273 253 274 254 if ( $this->id != null ) { 275 $sql = "UPDATE " . $this->table_name . "_fields 276 SET group_id = " . $this->group_id . ", 277 parent_id = 0, 278 type = '" . $this->type . "', 279 name = '" . $this->name . "', 280 description = '" . $this->desc . "', 281 is_required = " . $this->is_required . " 282 WHERE id = " . $this->id; 283 } else { 284 $sql = "INSERT INTO " . $this->table_name . "_fields 285 (group_id, parent_id, type, name, description, is_required) 286 VALUES 287 (" . $this->group_id . ", 0, '" . $this->type . "', '" . $this->name . "', '" . $this->desc . "', " . $this->is_required . ")"; 255 $sql = $wpdb->prepare("UPDATE $this->table_name_fields SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->desc, $this->is_required, $this->id); 256 } else { 257 $sql = $wpdb->prepare("INSERT INTO $this->table_name_fields (group_id, parent_id, type, name, description, is_required) VALUES (%d, 0, %s, %s, %s, %d)", $this->group_id, $this->type, $this->name, $this->desc, $this->is_required); 288 258 } 289 259 … … 314 284 315 285 for ( $i = 0; $i < count($options); $i++ ) { 316 $option_value = bp_core_clean($options[$i]);286 $option_value = $options[$i]; 317 287 318 288 if ( $option_value != "" ) { 319 289 // don't insert an empty option. 320 $sql = "INSERT INTO " . $this->table_name . "_fields 321 (group_id, parent_id, type, name, description, is_required) 322 VALUES 323 (" . $this->group_id . ", " . $parent_id . ", 'option', '" . $option_value . "', '', 0)"; 290 $sql = $wpdb->prepare("INSERT INTO $this->table_name_fields (group_id, parent_id, type, name, description, is_required) VALUES (%d, %d, 'option', %s, '', 0)", $this->group_id, $parent_id, $option_value); 324 291 325 292 if ( $wpdb->query($sql) === false ) { 326 293 return false; 294 295 // @TODO 327 296 // Need to go back and reverse what has been entered here. 328 297 } … … 493 462 global $wpdb; 494 463 495 $sql = "SELECT * FROM " . $this->table_name . "_fields 496 WHERE parent_id = " . $this->id . " 497 AND group_id = " . $this->group_id; 464 $sql = $wpdb->prepare("SELECT * FROM $this->table_name_fields WHERE parent_id = %d AND group_id = %d", $this->id, $this->group_id); 498 465 499 466 if ( !$children = $wpdb->get_results($sql) ) … … 506 473 global $wpdb; 507 474 508 $sql = "DELETE FROM " . $this->table_name . "_fields 509 WHERE parent_id = " . $this->id; 475 $sql = $wpdb->prepare("DELETE FROM $this->table_name_fields WHERE parent_id = %d", $this->id); 510 476 511 477 $wpdb->query($sql); … … 621 587 622 588 function get_signup_fields() { 623 global $wpdb, $bp_xprofile_table_name; 624 625 $sql = "SELECT f.id 626 FROM " . $bp_xprofile_table_name . "_fields AS f, 627 " . $bp_xprofile_table_name . "_groups AS g 628 WHERE g.name = 'Basic' 629 AND g.id = f.group_id 630 ORDER BY f.id"; 589 global $wpdb, $bp_xprofile_table_name_fields, $bp_xprofile_table_name_groups; 590 591 $sql = $wpdb->prepare("SELECT f.id FROM $bp_xprofile_table_name_fields AS f, $bp_xprofile_table_name_groups AS g WHERE g.name = 'Basic' AND g.id = f.group_id ORDER BY f.id"); 631 592 632 593 if ( !$temp_fields = $wpdb->get_results($sql) ) … … 659 620 660 621 function get_type( $field_id ) { 661 global $wpdb, $bp_xprofile_table_name ;622 global $wpdb, $bp_xprofile_table_name_fields; 662 623 663 624 if ( $field_id ) { 664 $sql = "SELECT type 665 FROM " . $bp_xprofile_table_name . "_fields 666 WHERE id = " . $field_id; 625 $sql = $wpdb->prepare("SELECT type FROM $bp_xprofile_table_name_fields WHERE id = %d", $field_id); 667 626 668 627 if ( !$field_type = $wpdb->get_var($sql) ) … … 676 635 677 636 function delete_for_group( $group_id ) { 678 global $wpdb, $bp_xprofile_table_name ;637 global $wpdb, $bp_xprofile_table_name_fields; 679 638 680 639 if ( $group_id ) { 681 $sql = "DELETE FROM " . $bp_xprofile_table_name . "_fields 682 WHERE group_id = " . $group_id; 640 $sql = $wpdb->prepare("DELETE FROM $bp_xprofile_table_name_fields WHERE group_id = %d", $group_id); 683 641 684 642 if ( $wpdb->get_var($sql) === false ) { … … 700 658 var $value; 701 659 var $last_updated; 702 660 var $table_name_data; 661 var $table_name_fields; 662 703 663 function bp_xprofile_profiledata( $field_id = null, $user_id = null ) { 704 global $bp_xprofile_table_name; 705 706 $this->table_name = $bp_xprofile_table_name; 707 664 global $bp_xprofile_table_name_data, $bp_xprofile_table_name_fields; 665 666 $this->table_name_data = $bp_xprofile_table_name_data; 667 $this->table_name_fields = $bp_xprofile_table_name_fields; 668 708 669 if ( $field_id ) { 709 670 $this->populate( $field_id, $user_id ); … … 717 678 $user_id = $userdata->ID; 718 679 719 $sql = "SELECT * FROM " . $this->table_name . "_data 720 WHERE field_id = " . $field_id . " 721 AND user_id = " . $user_id; 680 $sql = $wpdb->prepare("SELECT * FROM $this->table_name_data WHERE field_id = %d AND user_id = %d", $field_id, $user_id); 722 681 723 682 if ( $profiledata = $wpdb->get_row($sql) ) { … … 734 693 735 694 // check to see if there is data already for the user. 736 737 $sql = "SELECT id FROM " . $this->table_name . "_data 738 WHERE user_id = " . $userdata->ID . " 739 AND field_id = " . $this->field_id; 695 $sql = $wpdb->prepare("SELECT id FROM $this->table_name_data WHERE user_id = %d AND field_id = %d", $userdata->ID, $this->field_id); 740 696 741 697 if ( !$wpdb->get_row($sql) ) … … 749 705 750 706 // check to see if this data is actually for a valid field. 751 $sql = "SELECT id FROM " . $this->table_name . "_fields 752 WHERE id = " . $this->field_id; 707 $sql = $wpdb->prepare("SELECT id FROM $this->table_name_fields WHERE id = %d", $this->field_id); 753 708 754 709 if ( !$wpdb->get_row($sql) ) … … 763 718 if ( $this->is_valid_field() ) { 764 719 if ( $this->exists() && $this->value != '' ) { 765 $sql = "UPDATE " . $this->table_name . "_data 766 SET 767 value = '" . $this->value . "', 768 last_updated = " . $this->last_updated . " 769 WHERE 770 user_id = " . $this->user_id . " 771 AND 772 field_id = " . $this->field_id; 773 720 $sql = $wpdb->prepare("UPDATE $this->table_name_data SET value = %s, last_updated = %d WHERE user_id = %d AND field_id = %d", $this->value, $this->last_updated, $this->user_id, $this->field_id); 774 721 } else if ( $this->exists() and $this->value == '' ) { 775 722 // Data removed, delete the entry. 776 723 $this->delete(); 777 724 } else { 778 $sql = "INSERT INTO " . $this->table_name . "_data ( 779 user_id, 780 field_id, 781 value, 782 last_updated 783 ) 784 VALUES ( 785 " . $this->user_id . ", 786 " . $this->field_id . ", 787 '" . $this->value . "', 788 " . $this->last_updated . " 789 )"; 725 $sql = $wpdb->prepare("INSERT INTO $this->table_name_data (user_id, field_id, value, last_updated) VALUES (%d, %d, %s, %d)", $this->user_id, $this->field_id, $this->value, $this->last_updated); 790 726 } 791 727 … … 802 738 global $wpdb; 803 739 804 $sql = "DELETE FROM " . $this->table_name . "_data 805 WHERE field_id = " . $this->field_id . " 806 AND user_id = " . $this->user_id; 740 $sql = $wpdb->prepare("DELETE FROM $this->table_name_data WHERE field_id = %d AND user_id = %d", $this->field_id, $this->user_id); 807 741 808 742 if ( $wpdb->query($sql) === false ) … … 818 752 819 753 if ( $field_id ) { 820 $sql = "SELECT * FROM " . $this->table_name . "_data 821 WHERE field_id = " . $field_id . " 822 AND user_id = " . $userdata->ID; 754 $sql = $wpdb->prepare("SELECT * FROM $this->table_name_data WHERE field_id = %d AND user_id = %d", $field_id, $userdata->ID); 823 755 824 756 if ( $profileData = $wpdb->get_row($sql) ) { … … 833 765 global $wpdb, $userdata; 834 766 835 $sql = "DELETE FROM " . $this->table_name . "_data 836 WHERE field_id = " . $field_id; 767 $sql = $wpdb->prepare("DELETE FROM $this->table_name_data WHERE field_id = %d", $field_id); 837 768 838 769 if ( $wpdb->query($sql) === false )
Note:
See TracChangeset
for help on using the changeset viewer.