Changeset 112
- Timestamp:
- 05/13/2008 11:26:26 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
bp-friends.php (modified) (4 diffs)
-
bp-xprofile/bp-xprofile-ajax.php (modified) (1 diff)
-
bp-xprofile/bp-xprofile-cssjs.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-friends.php
r102 r112 1 1 <?php 2 2 3 $bp_friends_table_name = $wpdb->base_prefix . 'bp_friends'; 4 $bp_friends_image_base = get_option('siteurl') . '/wp-content/mu-plugins/bp-friends/images'; 3 5 define('BP_FRIENDS_VERSION', '0.2'); 6 7 require_once( 'bp-friends/bp-friends-classes.php' ); 8 require_once( 'bp-friends/bp-friends-templatetags.php' ); 9 require_once( 'bp-friends/bp-friends-cssjs.php' ); 4 10 5 11 /************************************************************************** … … 28 34 add_site_option('bp-friends-version', $version); 29 35 } 30 31 36 37 32 38 /************************************************************************** 33 39 friends_add_menu() … … 44 50 add_submenu_page( basename(__FILE__), __("My Friends"), __("My Friends"), 1, basename(__FILE__), "friends_list" ); 45 51 add_submenu_page( basename(__FILE__), __("Friend Finder"), __("Friend Finder"), 1, "friend_finder", "friends_find" ); 46 47 /* Instantiate bp_Friends class to do the real work. */48 $bp_friends = new BP_Friends;49 $bp_friends->bp_friends();50 52 51 53 /* Add the administration tab under the "Site Admin" tab for site administrators */ 52 add_submenu_page( 'wpmu-admin.php', __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_settings" );54 //add_submenu_page( 'wpmu-admin.php', __("Friends"), __("Friends"), 1, basename(__FILE__), "friends_settings" ); 53 55 } 54 56 … … 62 64 63 65 /************************************************************************** 64 messages_write_new(), messages_inbox(), messages_sentbox(), 65 messages_drafts(), messages_add_js(), messages_add_css() 66 67 These are all wrapper functions used in Wordpress hooks to pass through to 68 correct functions within the bp_messages object. Seems the only way 69 Wordpress will handle this. 66 friends_setup() 67 68 Setup CSS, JS and other things needed for the xprofile component. 69 **************************************************************************/ 70 71 function friends_setup() { 72 add_action( 'admin_print_scripts', 'friends_add_css' ); 73 add_action( 'admin_print_scripts', 'friends_add_js' ); 74 } 75 add_action( 'admin_menu', 'friends_setup' ); 76 77 78 /************************************************************************** 79 friends_profile_template() 80 81 Set up access to authordata and then set up template tags for use in 82 templates. 70 83 **************************************************************************/ 71 84 72 function friends_list() { global $bp_friends; $bp_friends->list_friends(); } 73 function friends_find() { global $bp_friends; $bp_friends->find_friends(); } 74 function friends_add_css() { global $bp_friends; $bp_friends->add_css(); } 75 function friends_add_js() { global $bp_friends; $bp_friends->add_js(); } 76 77 /************************************************************************** 78 bp_Friends [Class] 79 80 Where all the magic happens. 81 **************************************************************************/ 82 83 class BP_Friends 85 function friends_template() { 86 global $is_author, $userdata, $authordata, $friends_template; 87 88 $friends_template = new BP_Friends_Template; 89 90 } 91 add_action( 'wp_head', 'friends_template' ); 92 93 94 /************************************************************************** 95 friends_list() 96 97 Creates a nice list of all the current users friends. Gives the user 98 options to filter the list. 99 **************************************************************************/ 100 101 function friends_list() 84 102 { 85 var $wpdb; 86 var $tableName; 87 var $basePrefix; 88 var $userdata; 89 var $imageBase; 90 91 92 /************************************************************************** 93 bp_friends() 94 95 Contructor function. 96 **************************************************************************/ 97 function bp_friends() 103 $bp_friends = new BP_Friends(); 104 $friends = $bp_friends->get_friends(); 105 ?> 106 <div class="wrap"> 107 108 <h2><?php _e("My Friends") ?></h2> 109 110 <?php if(!$friends) { ?> 111 <div id="message" class="error fade"> 112 <p><?php _e("There was an error getting your list of friends, please try again.") ?></p> 113 </div> 114 <?php } else { ?> 115 116 <?php if(count($friends) < 1) { ?> 117 <div id="message" class="updated fade"> 118 <p><?php _e("Looks like you don't have any friends. Why not <a href=\"admin.php?page=friend_finder\" title=\"Friend Finder\">find some</a>?"); ?></p> 119 </div> 120 <?php } else { ?> 121 <ul id="friends-list"> 122 <?php for($i=0; $i<count($friends); $i++) { ?> 123 <li><?php echo '<a href="http://' . $friends[$i][3]->meta_value . '">' . $friends[$i][0]->meta_value . '</a>'; ?></li> 124 125 <?php } ?> 126 </ul> 127 <?php } ?> 128 129 <?php } ?> 130 131 </div> 132 <?php 133 } 134 135 136 /************************************************************************** 137 friends_find() 138 139 Shows the find friend interface, allowing users to search for friends in 140 the system. 141 **************************************************************************/ 142 143 function friends_find($type = "error", $message = "") 144 { 145 if(isset($_POST['searchterm']) && isset($_POST['search'])) 98 146 { 99 global $wpdb, $userdata, $bp_friends_table_name; 100 101 $this->wpdb = &$wpdb; 102 $this->userdata = &$userdata; 103 $this->basePrefix = $wpdb->base_prefix; 104 $this->imageBase = get_option('siteurl') . '/wp-content/mu-plugins/bp_friends/images/'; 105 106 /* Setup CSS and JS */ 107 add_action("admin_print_scripts", "friends_add_css"); 108 add_action("admin_print_scripts", "friends_add_js"); 109 } 110 111 112 /************************************************************************** 113 list_friends() 114 115 Creates a nice list of all the current users friends. Gives the user 116 options to filter the list. 117 **************************************************************************/ 118 119 function list_friends() 120 { 121 $friends = $this->get_friends($this->userdata->ID); 122 ?> 123 <div class="wrap"> 124 125 <h2><?php _e("My Friends") ?></h2> 126 127 <?php if(!$friends) { ?> 128 <div id="message" class="error fade"> 129 <p><?php _e("There was an error getting your list of friends, please try again.") ?></p> 130 </div> 131 <?php } else { ?> 132 133 <?php if(count($friends) < 1) { ?> 134 <div id="message" class="updated fade"> 135 <p><?php _e("Looks like you don't have any friends. Why not <a href=\"admin.php?page=friend_finder\" title=\"Friend Finder\">find some</a>?"); ?></p> 136 </div> 137 <?php } else { ?> 138 <ul id="friends-list"> 139 <?php for($i=0; $i<count($friends); $i++) { ?> 140 <li><?php echo '<a href="http://' . $friends[$i][3]->meta_value . '">' . $friends[$i][0]->meta_value . '</a>'; ?></li> 141 142 <?php } ?> 143 </ul> 144 <?php } ?> 145 146 <?php } ?> 147 148 </div> 149 <?php 150 } 151 152 153 /************************************************************************** 154 find_friends() 155 156 Shows the find friend interface, allowing users to search for friends in 157 the system. 158 **************************************************************************/ 159 160 function find_friends($type = "error", $message = "") 161 { 162 if(isset($_POST['searchterm']) && isset($_POST['search'])) 147 if($_POST['searchterm'] == "") 163 148 { 164 if($_POST['searchterm'] == "") 165 { 166 $message = __("Please make sure you enter something to search for."); 167 } 168 else if(strlen($_POST['searchterm']) < 3) 169 { 170 $message = __("Your search term must be longer than 3 letters otherwise you'll be here for years."); 171 } 172 else { 173 // The search term is okay, let's get it movin' 174 $results = $this->search($_POST['searchterm']); 175 } 149 $message = __("Please make sure you enter something to search for."); 176 150 } 177 178 ?> 179 180 <div class="wrap"> 181 <h2><?php _e('Friend Finder'); ?></h2> 182 183 <?php if($message != '') { ?> 184 <?php if($type == 'error') { $type = "error"; } else { $type = "updated"; } ?> 185 <div id="message" class="<?php echo $type; ?> fade"> 186 <p><?php echo $message; ?></p> 187 </div> 188 <?php } ?> 189 190 <form action="admin.php?page=friend_finder" method="post"> 191 192 <fieldset id="searchtermdiv"> 193 <legend><?php _e("Friends name, username or email address:") ?></legend> 194 <div> 195 <input type="text" name="searchterm" id="searchterm" value="<?php echo $_POST['searchterm'] ?>" /> 196 </div> 197 </fieldset> 198 199 <p> 200 <input type="submit" value="<?php _e("Search") ?> »" name="search" id="search" style="font-weight: bold" /> 201 </p> 202 203 </form> 204 205 <?php if(isset($results)) { ?> 206 <?php if(!$results) { ?> 207 <p>Nothing Found!</p> 208 <?php } else { ?> 209 <ul id="friend_results"> 210 <?php for($i=0; $i<count($results); $i++) { ?> 211 <li><?php echo $results[$i]->display_name; ?></li> 212 <?php } ?> 213 </ul> 214 <?php } ?> 215 <?php } ?> 216 </div> 217 218 <?php 219 } 220 221 222 /************************************************************************** 223 get_friends() 224 225 Get a list of friends for the current user using the current, internal 226 user id. 227 **************************************************************************/ 228 229 function get_friend_list() 230 { 231 return $this->get_friends($this->userdata->ID); 232 } 233 234 235 /************************************************************************** 236 get_friends() 237 238 Get a list of friends for the current user. 239 **************************************************************************/ 240 241 function get_friends($id) 242 { 243 global $bp_friends_table_name; 244 245 if(bp_core_validate($id)) 151 else if(strlen($_POST['searchterm']) < 3) 246 152 { 247 $sql = "SELECT initiator_user_id, friend_user_id 248 FROM " . $bp_friends_table_name . " 249 WHERE initiator_user_id = " . $id . " 250 OR friend_user_id = " . $id . " 251 AND is_confirmed = 1"; 252 253 if(!$friends = $this->wpdb->get_results($sql)) 254 { 255 return false; 256 } 257 258 for($i=0; $i<count($friends); $i++) 259 { 260 if($friends[$i]->initiator_user_id != $id) 261 { 262 $friend_id = $friends[$i]->initiator_user_id; 263 } 264 else 265 { 266 $friend_id = $friends[$i]->friend_user_id; 267 } 268 269 $sql = "SELECT meta_key, meta_value FROM " . $this->basePrefix . "usermeta 270 WHERE user_id = " . $friend_id; 271 272 $friends_details[] = $this->wpdb->get_results($sql); 273 274 } 275 276 return $friends_details; 153 $message = __("Your search term must be longer than 3 letters otherwise you'll be here for years."); 277 154 } 278 155 else { 279 return false; 156 // The search term is okay, let's get it movin' 157 $bp_friends = new BP_Friends(); 158 $results = $bp_friends->search($_POST['searchterm']); 280 159 } 281 160 } 282 283 284 /************************************************************************** 285 search() 286 287 Find a user on the site based on someone entering search terms such as 288 a name, username or email address. 289 **************************************************************************/ 290 291 function search($terms) 292 { 293 $terms = bp_core_clean($terms); 294 295 $sql = "SELECT ID, display_name FROM " . $this->basePrefix . "users 296 WHERE user_login LIKE '%" . $terms . "%' 297 OR user_nicename LIKE '%" . $terms . "%' 298 OR user_email LIKE '%" . $terms . "%' 299 ORDER BY user_nicename ASC"; 300 301 return $this->wpdb->get_results($sql); 302 303 } 304 305 /************************************************************************** 306 callback() 307 308 Callback to specfic functions - this keeps correct tabs selected. 309 **************************************************************************/ 310 311 function callback($message, $type = 'error', $callback) 312 { 313 314 switch($callback) 315 { 316 317 } 318 } 319 320 /************************************************************************** 321 add_js() 322 323 Inserts the TinyMCE Js that's needed for the WYSIWYG message editor. 324 **************************************************************************/ 325 326 function add_js() 327 { 328 if(isset($_GET['page'])) 329 { 330 ?> 331 <?php 332 } 333 } 334 335 336 /************************************************************************** 337 add_css() 338 339 Inserts the CSS needed to style the messages pages. 340 **************************************************************************/ 341 342 function add_css() 343 { 344 ?> 345 <style type="text/css"> 346 .unread td { 347 font-weight: bold; 348 background: #ffffec; 349 } 350 351 #send_message_form fieldset input { 352 width: 98%; 353 font-size: 1.7em; 354 padding: 4px 3px; 355 } 356 357 358 </style> 359 <?php 360 } 361 362 } // End Class 363 364 365 161 366 162 ?> 163 164 <div class="wrap"> 165 <h2><?php _e('Friend Finder'); ?></h2> 166 167 <?php if($message != '') { ?> 168 <?php if($type == 'error') { $type = "error"; } else { $type = "updated"; } ?> 169 <div id="message" class="<?php echo $type; ?> fade"> 170 <p><?php echo $message; ?></p> 171 </div> 172 <?php } ?> 173 174 <form action="admin.php?page=friend_finder" method="post"> 175 176 <fieldset id="searchtermdiv"> 177 <legend><?php _e("Friends name, username or email address:") ?></legend> 178 <div> 179 <input type="text" name="searchterm" id="searchterm" value="<?php echo $_POST['searchterm'] ?>" /> 180 </div> 181 </fieldset> 182 183 <p> 184 <input type="submit" value="<?php _e("Search") ?> »" name="search" id="search" style="font-weight: bold" /> 185 </p> 186 187 </form> 188 189 <?php if(isset($results)) { ?> 190 <?php if(!$results) { ?> 191 <p>Nothing Found!</p> 192 <?php } else { ?> 193 <ul id="friend_results"> 194 <?php for($i=0; $i<count($results); $i++) { ?> 195 <li><?php echo $results[$i]->display_name; ?></li> 196 <?php } ?> 197 </ul> 198 <?php } ?> 199 <?php } ?> 200 </div> 201 202 <?php 203 } 204 205 ?> -
trunk/bp-xprofile/bp-xprofile-ajax.php
r102 r112 1 1 <?php 2 3 2 function xprofile_ajax_reorder_fields() { 4 3 -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r110 r112 1 1 <?php 2 3 function xprofile_add_signup_css() {4 if ( $_SERVER['SCRIPT_NAME'] == '/wp-signup.php' ) {5 ?>6 <style type="text/css">7 8 table#extraFields td label,9 div.radio span,10 div.checkbox span {11 font-weight: bold;12 display: block;13 float: left;14 width: 115px;15 }16 17 table#extraFields td input[type="text"] {18 font-size: 24px;19 width: 280px;20 }21 22 table#extraFields td textarea {23 width: 280px;24 height: 120px;25 }26 27 table#extraFields td select {28 width: 280px;29 }30 31 table#extraFields td div.datefield select {32 width: auto;33 }34 35 table#extraFields td div.radio label,36 table#extraFields td div.checkbox label {37 display: inline;38 font-weight: normal;39 float: none;40 }41 42 table#extraFields td div.radio input,43 table#extraFields td div.checkbox input {44 width: auto;45 }46 47 span.desc {48 margin-left: 115px;49 font-weight: normal;50 }51 52 div.error {53 font-weight: bold;54 margin: 10px 0 10px 113px;55 }56 57 </style>58 <?php59 }60 }61 add_action( 'wp_head', 'xprofile_add_signup_css' );62 63 2 64 3 function xprofile_add_css() { 65 4 global $userdata, $wpdb; 66 5 67 //if ( strpos( $_GET['page'], 'xprofile' ) !== false ) {68 6 ?> 69 7 <style type="text/css"> … … 189 127 } 190 128 191 <?php if ( $wpdb->blogid == $userdata->primary_blog ) { ?>192 /*body.wp-admin #wphead h1 {193 background: url(<?php echo xprofile_get_avatar($userdata->ID, 1, true) ?>) center left no-repeat !important;194 padding: 20px 0 20px 65px;195 margin-left: 18px;196 }*/Å197 <?php } ?>198 199 129 </style> 200 130 <?php 201 131 //} 202 132 } 203 do_action( 'signup_header', 'xprofile_add_css' );204 133 205 134 function xprofile_add_js() {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)