Changeset 16
- Timestamp:
- 04/08/2008 12:49:51 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
bp_xprofile.php (modified) (1 diff)
-
bp_xprofile/bp_xprofile.admin.php (modified) (5 diffs)
-
bp_xprofile/bp_xprofile.classes.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp_xprofile.php
r15 r16 73 73 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 74 74 dbDelta($sql); 75 76 75 } 77 76 -
trunk/bp_xprofile/bp_xprofile.admin.php
r1 r16 39 39 } 40 40 } 41 41 else if(isset($_GET['mode']) && isset($_GET['group_id']) && $_GET['mode'] == "edit_group") 42 { 43 if(bp_core_validate($_GET['group_id'])) { 44 xprofile_admin_manage_group($_GET['group_id']); die; 45 } 46 } 42 47 ?> 43 48 <div class="wrap"> … … 66 71 <thead> 67 72 <tr> 68 <th scope="col" colspan="6"><?php echo $groups[$i]->name; ?> <?php if($groups[$i]->can_delete) { ?> [<a href="admin.php?page=xprofile_settings&mode=delete_group&group_id=<?php echo $groups[$i]->id; ?>">x</a>] <?php } ?></th> 69 </tr> 73 <th scope="col" colspan="<?php if($groups[$i]->can_delete) { ?>3<?php } else { ?>5<?php } ?>"><?php echo $groups[$i]->name; ?></th> 74 <?php if($groups[$i]->can_delete) { ?> 75 <th scope="col"><a class="edit" href="admin.php?page=xprofile_settings&mode=edit_group&group_id=<?php echo $groups[$i]->id; ?>">Edit</a></th> 76 <th scope="col"><a class="delete" href="admin.php?page=xprofile_settings&mode=delete_group&group_id=<?php echo $groups[$i]->id; ?>">Delete</a></th> 77 <?php } ?> 78 </tr> 70 79 </thead> 71 80 <tbody id="the-list"> … … 137 146 { 138 147 global $message, $type; 139 148 140 149 $group = new BP_XProfile_Group($group_id); 141 150 … … 212 221 213 222 $field = new BP_XProfile_Field($field_id); 223 $field->group_id = $group_id; 214 224 215 225 if(isset($_POST['saveField'])) … … 217 227 if(BP_XProfile_Field::admin_validate($_POST)) 218 228 { 219 $field->group_id = $group_id;220 229 $field->name = bp_core_clean($_POST['title']); 221 230 $field->desc = bp_core_clean($_POST['description']); -
trunk/bp_xprofile/bp_xprofile.classes.php
r15 r16 61 61 { 62 62 global $wpdb; 63 63 64 64 if($this->id != null) 65 65 { 66 // Update a group. 66 $sql = "UPDATE " . $this->table_name . "_groups 67 SET 68 name = '" . $this->name . "', 69 description = '" . $this->description . "' 70 WHERE id = " . $this->id; 67 71 } 68 72 else … … 70 74 $sql = "INSERT INTO " . $this->table_name . "_groups ( 71 75 name, 72 description 76 description, 77 can_delete 73 78 ) VALUES ( 74 79 '" . $this->name . "', 75 '" . $this->description . "' 80 '" . $this->description . "', 81 1 76 82 )"; 77 83 } … … 94 100 WHERE id = " . $this->id; 95 101 96 if($wpdb->query($sql) === false) { 97 return false; 98 } 99 else { 102 if($wpdb->query($sql) === false) 103 { 104 return false; 105 } 106 else 107 { 100 108 // Now the group is deleted, remove the group's fields. 101 $sql = "DELETE FROM " . $this->table_name . "_fields 102 WHERE group_id = " . $this->id; 103 104 if($wpdb->query($sql) === false) { 105 return false; 106 } 107 else 109 if(BP_XProfile_Field::delete_for_group($this->id)) 108 110 { 109 111 // Now delete all the profile data for the groups fields 110 111 112 for($i=0; $i<count($this->fields); $i++) 112 { 113 $sql = "DELETE FROM " . $this->table_name . "_data 114 WHERE field_id = " . $this->fields[$i]->id; 115 116 $wpdb->query($sql); 113 { 114 BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id); 117 115 } 118 116 } … … 144 142 { 145 143 global $message; 144 145 if($this->id == null) { 146 $title = __('Add Group'); 147 $action = "admin.php?page=xprofile_settings&mode=add_group"; 148 } 149 else { 150 $title = __('Edit Group'); 151 $action = "admin.php?page=xprofile_settings&mode=edit_group&group_id=" . $this->id; 152 } 146 153 147 154 ?> … … 149 156 <div class="wrap"> 150 157 151 <h2><?php _e('Add Group'); ?></h2>158 <h2><?php echo $title; ?></h2> 152 159 153 160 <?php if($message != '') { ?> … … 157 164 <?php } ?> 158 165 159 <form action=" admin.php?page=xprofile_settings&mode=add_group" method="post">166 <form action="<?php echo $action; ?>" method="post"> 160 167 161 168 <fieldset id="titlediv"> … … 167 174 168 175 <p class="submit" style="text-align: left"> 169 <input type="submit" name="saveGroup" value=" Create Group»" />176 <input type="submit" name="saveGroup" value="<?php echo $title; ?> »" /> 170 177 </p> 171 178 … … 302 309 303 310 // delete the data in the DB for this field 304 BP_XProfile_ProfileData::delete_ all($this->id);311 BP_XProfile_ProfileData::delete_for_field($this->id); 305 312 306 313 return true; … … 598 605 function render_admin_form($message = '') 599 606 { 600 if($this->id != null) { 607 if($this->id == null) { 608 $title = __('Add Field'); 609 $action = "admin.php?page=xprofile_settings&group_id=" . $this->group_id . "&mode=add_field"; 610 } 611 else { 612 $title = __('Edit Field'); 613 $action = "admin.php?page=xprofile_settings&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id; 601 614 $options = $this->get_children(); 602 615 } 616 603 617 ?> 604 618 605 619 <div class="wrap"> 606 620 607 <h2><?php _e("Profile Settings") ?> » <?php _e('Add Field')?></h2>621 <h2><?php echo $title; ?></h2> 608 622 609 623 <?php if($message != '') { ?> … … 765 779 return false; 766 780 } 781 782 function delete_for_group($group_id) 783 { 784 global $wpdb, $bp_xprofile_table_name; 785 786 if(bp_core_validate($group_id)) 787 { 788 $sql = "DELETE FROM " . $bp_xprofile_table_name . "_fields 789 WHERE group_id = " . $group_id; 790 791 if($wpdb->get_var($sql) === false) 792 { 793 return false; 794 } 795 796 return true; 797 } 798 799 return false; 800 } 767 801 } 768 802 … … 940 974 } 941 975 942 function delete_ all($field_id)976 function delete_for_field($field_id) 943 977 { 944 978 global $wpdb, $userdata;
Note: See TracChangeset
for help on using the changeset viewer.